[ddc] Remove more diffs with pkg/js_ast

- Remove lint ignores and cleanup violations when they are either
  in code that doesn't exist in or are already fixed in the pkg/js_ast
  version.
- Migrate the builder_test.dart (the small test file).

Issue: https://github.com/dart-lang/sdk/issues/46617
Change-Id: I1083235de93f028e5f338180b97308f52a45f17f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239363
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
diff --git a/pkg/dev_compiler/lib/src/js_ast/builder.dart b/pkg/dev_compiler/lib/src/js_ast/builder.dart
index 6ba6a81..5f0c23e 100644
--- a/pkg/dev_compiler/lib/src/js_ast/builder.dart
+++ b/pkg/dev_compiler/lib/src/js_ast/builder.dart
@@ -2,14 +2,11 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// ignore_for_file: always_declare_return_types
 // ignore_for_file: library_prefixes
 // ignore_for_file: non_constant_identifier_names
 // ignore_for_file: omit_local_variable_types
-// ignore_for_file: prefer_collection_literals
 // ignore_for_file: prefer_single_quotes
 // ignore_for_file: unnecessary_brace_in_string_interps
-// ignore_for_file: unnecessary_new
 
 /// Utilities for building JS ASTs at runtime. Contains a builder class and a
 /// parser that parses part of the language.
@@ -325,7 +322,7 @@
       return string(value, quote);
     }
 
-    var sb = new StringBuffer();
+    var sb = StringBuffer();
 
     for (int rune in value.runes) {
       final escape = _irregularEscape(rune, quote);
@@ -398,7 +395,7 @@
   LiteralNumber number(num value) => LiteralNumber('$value');
 
   LiteralNumber uint64(int value) {
-    BigInt uint64Value = new BigInt.from(value).toUnsigned(64);
+    BigInt uint64Value = BigInt.from(value).toUnsigned(64);
     return LiteralNumber('$uint64Value');
   }
 
@@ -640,7 +637,7 @@
     '/': 5,
     '%': 5
   };
-  static final UNARY_OPERATORS = [
+  static final UNARY_OPERATORS = {
     '++',
     '--',
     '+',
@@ -651,12 +648,12 @@
     'void',
     'delete',
     'await'
-  ].toSet();
+  };
 
   static final ARROW_TOKEN = '=>';
   static final ELLIPSIS_TOKEN = '...';
 
-  static final OPERATORS_THAT_LOOK_LIKE_IDENTIFIERS = [
+  static final OPERATORS_THAT_LOOK_LIKE_IDENTIFIERS = {
     'typeof',
     'void',
     'delete',
@@ -664,7 +661,7 @@
     'instanceof',
     'await',
     'extends'
-  ].toSet();
+  };
 
   static int category(int code) {
     if (code >= CATEGORIES.length) return OTHER;
diff --git a/pkg/dev_compiler/lib/src/js_ast/js_ast.dart b/pkg/dev_compiler/lib/src/js_ast/js_ast.dart
index d059a14..7fc3091 100644
--- a/pkg/dev_compiler/lib/src/js_ast/js_ast.dart
+++ b/pkg/dev_compiler/lib/src/js_ast/js_ast.dart
@@ -2,13 +2,9 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
-// ignore_for_file: directives_ordering
-
 library js_ast;
 
-export 'nodes.dart';
 export 'builder.dart';
+export 'nodes.dart';
 export 'printer.dart';
 export 'template.dart';
diff --git a/pkg/dev_compiler/lib/src/js_ast/nodes.dart b/pkg/dev_compiler/lib/src/js_ast/nodes.dart
index cb6c11d..9d29e05 100644
--- a/pkg/dev_compiler/lib/src/js_ast/nodes.dart
+++ b/pkg/dev_compiler/lib/src/js_ast/nodes.dart
@@ -3,10 +3,7 @@
 // BSD-style license that can be found in the LICENSE file.
 
 // ignore_for_file: always_declare_return_types
-// ignore_for_file: always_require_non_null_named_parameters
 // ignore_for_file: omit_local_variable_types
-// ignore_for_file: prefer_final_fields
-// ignore_for_file: prefer_initializing_formals
 // ignore_for_file: prefer_single_quotes
 // ignore_for_file: unnecessary_this
 
@@ -1124,9 +1121,7 @@
 
 class SimpleBindingPattern extends BindingPattern {
   final Identifier name;
-  SimpleBindingPattern(Identifier name)
-      : name = name,
-        super([DestructuredVariable(name: name)]);
+  SimpleBindingPattern(this.name) : super([DestructuredVariable(name: name)]);
 
   @override
   T accept<T>(NodeVisitor<T> visitor) =>
@@ -1406,7 +1401,7 @@
       throw ArgumentError.value(name, "name", "not a valid identifier");
     }
   }
-  static RegExp _identifierRE = RegExp(r'^[A-Za-z_$][A-Za-z_$0-9]*$');
+  static final RegExp _identifierRE = RegExp(r'^[A-Za-z_$][A-Za-z_$0-9]*$');
 
   @override
   bool shadows(Set<String> names) => names.contains(name);
diff --git a/pkg/dev_compiler/lib/src/js_ast/printer.dart b/pkg/dev_compiler/lib/src/js_ast/printer.dart
index adddaae..7a97ad3 100644
--- a/pkg/dev_compiler/lib/src/js_ast/printer.dart
+++ b/pkg/dev_compiler/lib/src/js_ast/printer.dart
@@ -5,13 +5,10 @@
 // ignore_for_file: always_declare_return_types
 // ignore_for_file: library_prefixes
 // ignore_for_file: omit_local_variable_types
-// ignore_for_file: prefer_collection_literals
-// ignore_for_file: prefer_final_fields
 // ignore_for_file: prefer_initializing_formals
 // ignore_for_file: prefer_interpolation_to_compose_strings
 // ignore_for_file: prefer_is_not_empty
 // ignore_for_file: prefer_single_quotes
-// ignore_for_file: unnecessary_const
 // ignore_for_file: use_function_type_syntax_for_parameters
 
 library js_ast.printer;
@@ -89,7 +86,7 @@
   // The current indentation level.
   int _indentLevel = 0;
   // A cache of all indentation strings used so far.
-  List<String> _indentList = <String>[""];
+  final List<String> _indentList = [""];
 
   /// Whether the next call to [indent] should just be a no-op.
   bool _skipNextIndent = false;
@@ -610,15 +607,15 @@
 
     out(")");
     switch (fun.asyncModifier) {
-      case const AsyncModifier.sync():
+      case AsyncModifier.sync():
         break;
-      case const AsyncModifier.async():
+      case AsyncModifier.async():
         out(' async');
         break;
-      case const AsyncModifier.syncStar():
+      case AsyncModifier.syncStar():
         out(' sync*');
         break;
-      case const AsyncModifier.asyncStar():
+      case AsyncModifier.asyncStar():
         out(' async*');
         break;
     }
@@ -1452,8 +1449,8 @@
 
   VarCollector()
       : nested = false,
-        vars = Set<String>(),
-        params = Set<String>();
+        vars = {},
+        params = {};
 
   void forEachVar(void fn(String v)) => vars.forEach(fn);
   void forEachParam(void fn(String p)) => params.forEach(fn);
@@ -1632,7 +1629,7 @@
   void enterScope(Node node) {
     var vars = VarCollector();
     node.accept(vars);
-    maps.add(Map<String, String>());
+    maps.add({});
     variableNumberStack.add(variableNumber);
     parameterNumberStack.add(parameterNumber);
     vars.forEachVar(declareVariable);
diff --git a/pkg/dev_compiler/lib/src/js_ast/template.dart b/pkg/dev_compiler/lib/src/js_ast/template.dart
index 9ceb51f..22d76d7 100644
--- a/pkg/dev_compiler/lib/src/js_ast/template.dart
+++ b/pkg/dev_compiler/lib/src/js_ast/template.dart
@@ -3,20 +3,17 @@
 // BSD-style license that can be found in the LICENSE file.
 
 // ignore_for_file: always_declare_return_types
-// ignore_for_file: avoid_returning_null_for_void
 // ignore_for_file: omit_local_variable_types
-// ignore_for_file: prefer_collection_literals
 // ignore_for_file: prefer_generic_function_type_aliases
 // ignore_for_file: prefer_single_quotes
-// ignore_for_file: unnecessary_this
 
 library js_ast.template;
 
 import 'nodes.dart';
 
 class TemplateManager {
-  Map<String, Template> expressionTemplates = Map<String, Template>();
-  Map<String, Template> statementTemplates = Map<String, Template>();
+  Map<String, Template> expressionTemplates = {};
+  Map<String, Template> statementTemplates = {};
 
   TemplateManager();
 
@@ -817,13 +814,13 @@
   @override
   Instantiator<ArrayBindingPattern> visitArrayBindingPattern(
       ArrayBindingPattern node) {
-    List<Instantiator> makeVars = node.variables.map(this.visit).toList();
+    List<Instantiator> makeVars = node.variables.map(visit).toList();
     return (a) => ArrayBindingPattern(splayNodes(makeVars, a));
   }
 
   @override
   Instantiator visitObjectBindingPattern(ObjectBindingPattern node) {
-    List<Instantiator> makeVars = node.variables.map(this.visit).toList();
+    List<Instantiator> makeVars = node.variables.map(visit).toList();
     return (a) => ObjectBindingPattern(splayNodes(makeVars, a));
   }
 
@@ -835,8 +832,8 @@
 /// InterpolatedNodeAnalysis determines which AST trees contain
 /// [InterpolatedNode]s, and the names of the named interpolated nodes.
 class InterpolatedNodeAnalysis extends BaseVisitorVoid {
-  final Set<Node> containsInterpolatedNode = Set<Node>();
-  final Set<String> holeNames = Set<String>();
+  final Set<Node> containsInterpolatedNode = {};
+  final Set<String> holeNames = {};
   int count = 0;
 
   InterpolatedNodeAnalysis();
@@ -853,7 +850,6 @@
     int before = count;
     node.visitChildren(this);
     if (count != before) containsInterpolatedNode.add(node);
-    return null;
   }
 
   @override
diff --git a/pkg/dev_compiler/test/js/builder_test.dart b/pkg/dev_compiler/test/js/builder_test.dart
index acfb55c..9a1ac18 100644
--- a/pkg/dev_compiler/test/js/builder_test.dart
+++ b/pkg/dev_compiler/test/js/builder_test.dart
@@ -1,5 +1,3 @@
-// @dart = 2.9
-
 import 'package:dev_compiler/src/js_ast/js_ast.dart';
 import 'package:test/test.dart';