From 184dfbf81a2ace066c10b372b7ce24eaeea21ede Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Fri, 2 Sep 2022 23:42:39 +0200 Subject: [PATCH 1/7] Upgrade dev dependencies to the latest version --- analysis/pubspec.yaml | 4 ++-- pubspec.yaml | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/analysis/pubspec.yaml b/analysis/pubspec.yaml index e82117548..4e9257b82 100644 --- a/analysis/pubspec.yaml +++ b/analysis/pubspec.yaml @@ -6,7 +6,7 @@ homepage: https://github.com/sass/dart-sass/tree/master/analysis publish_to: none environment: - sdk: ">=2.0.0 <3.0.0" + sdk: ">=2.17.0 <3.0.0" dependencies: - lints: ^1.0.0 + lints: ^2.0.0 diff --git a/pubspec.yaml b/pubspec.yaml index a292405b6..f3ce8dbd5 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -32,15 +32,15 @@ dependencies: http: ^0.13.3 dev_dependencies: - analyzer: ^3.0.0 + analyzer: ^4.7.0 archive: ^3.1.2 cli_pkg: ^2.1.4 crypto: ^3.0.0 dart_style: ^2.0.0 - dartdoc: ^5.0.0 + dartdoc: ^6.0.0 grinder: ^0.9.0 node_preamble: ^2.0.0 - lints: ^1.0.0 + lints: ^2.0.0 pub_api_client: ^2.1.1 pub_semver: ^2.0.0 pubspec_parse: ^1.0.0 From 35cd8a77d9ab2678fbba567b3555d2692eb21d9b Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Sat, 3 Sep 2022 00:13:45 +0200 Subject: [PATCH 2/7] Remove usage of deprecated member --- tool/grind/synchronize.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tool/grind/synchronize.dart b/tool/grind/synchronize.dart index f8b4eb33f..ac0e45fd2 100644 --- a/tool/grind/synchronize.dart +++ b/tool/grind/synchronize.dart @@ -128,7 +128,7 @@ class _Visitor extends RecursiveAstVisitor { } void visitClassDeclaration(ClassDeclaration node) { - if (_sharedClasses.contains(node.name.name)) { + if (_sharedClasses.contains(node.name2.lexeme)) { _skipNode(node); } else { super.visitClassDeclaration(node); @@ -141,7 +141,7 @@ class _Visitor extends RecursiveAstVisitor { } void visitMethodDeclaration(MethodDeclaration node) { - if (_synchronizeName(node.name.name) != node.name.name) { + if (_synchronizeName(node.name2.lexeme) != node.name2.lexeme) { // If the file defines any asynchronous versions of synchronous functions, // remove them. _skipNode(node); From fec9a2aced41282386254addf36db921f646487c Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Sat, 3 Sep 2022 00:15:22 +0200 Subject: [PATCH 3/7] Remove leading underscore on local identifiers --- lib/src/functions/map.dart | 6 +++--- lib/src/value/number.dart | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/src/functions/map.dart b/lib/src/functions/map.dart index e317e2287..f07e1c3b2 100644 --- a/lib/src/functions/map.dart +++ b/lib/src/functions/map.dart @@ -170,7 +170,7 @@ final _hasKey = _function("has-key", r"$map, $key, $keys...", (arguments) { Value _modify(SassMap map, Iterable keys, Value modify(Value old), {bool addNesting = true}) { var keyIterator = keys.iterator; - SassMap _modifyNestedMap(SassMap map) { + SassMap modifyNestedMap(SassMap map) { var mutableMap = Map.of(map.contents); var key = keyIterator.current; @@ -182,11 +182,11 @@ Value _modify(SassMap map, Iterable keys, Value modify(Value old), var nestedMap = mutableMap[key]?.tryMap(); if (nestedMap == null && !addNesting) return SassMap(mutableMap); - mutableMap[key] = _modifyNestedMap(nestedMap ?? const SassMap.empty()); + mutableMap[key] = modifyNestedMap(nestedMap ?? const SassMap.empty()); return SassMap(mutableMap); } - return keyIterator.moveNext() ? _modifyNestedMap(map) : modify(map); + return keyIterator.moveNext() ? modifyNestedMap(map) : modify(map); } /// Merges [map1] and [map2], with values in [map2] taking precedence. diff --git a/lib/src/value/number.dart b/lib/src/value/number.dart index 8caa42041..47d311574 100644 --- a/lib/src/value/number.dart +++ b/lib/src/value/number.dart @@ -593,7 +593,7 @@ abstract class SassNumber extends Value { var otherHasUnits = newNumerators.isNotEmpty || newDenominators.isNotEmpty; if (coerceUnitless && (!hasUnits || !otherHasUnits)) return this.value; - SassScriptException _compatibilityException() { + SassScriptException compatibilityException() { if (other != null) { var message = StringBuffer("$this and"); if (otherName != null) message.write(" \$$otherName:"); @@ -634,7 +634,7 @@ abstract class SassNumber extends Value { if (factor == null) return false; value *= factor; return true; - }, orElse: () => throw _compatibilityException()); + }, orElse: () => throw compatibilityException()); } var oldDenominators = denominatorUnits.toList(); @@ -644,11 +644,11 @@ abstract class SassNumber extends Value { if (factor == null) return false; value /= factor; return true; - }, orElse: () => throw _compatibilityException()); + }, orElse: () => throw compatibilityException()); } if (oldNumerators.isNotEmpty || oldDenominators.isNotEmpty) { - throw _compatibilityException(); + throw compatibilityException(); } return value; From a705445f0d84871e175a5f0b617bd5f9aedb941e Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Sat, 3 Sep 2022 00:17:39 +0200 Subject: [PATCH 4/7] Avoid null check on potentially nullable type parameter --- lib/src/utils.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/utils.dart b/lib/src/utils.dart index a5054298c..20f12fcc6 100644 --- a/lib/src/utils.dart +++ b/lib/src/utils.dart @@ -455,7 +455,7 @@ extension MapExtension on Map { /// [key] to the result. V putOrMerge(K key, V value, V Function(V oldValue, V newValue) merge) => containsKey(key) - ? this[key] = merge(this[key]!, value) + ? this[key] = merge(this[key] as V, value) : this[key] = value; } From 8480259d6ca29bcea85b0c04eb14af274c6bc66b Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Sat, 3 Sep 2022 00:23:35 +0200 Subject: [PATCH 5/7] Avoid using private types in public APIs --- lib/src/callable.dart | 4 ++-- lib/src/callable/async_built_in.dart | 6 +++--- lib/src/callable/built_in.dart | 10 +++++----- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/src/callable.dart b/lib/src/callable.dart index 644877d50..7f8b0c383 100644 --- a/lib/src/callable.dart +++ b/lib/src/callable.dart @@ -10,8 +10,8 @@ import 'exception.dart'; import 'value.dart'; export 'callable/async.dart'; -export 'callable/async_built_in.dart'; -export 'callable/built_in.dart'; +export 'callable/async_built_in.dart' show AsyncBuiltInCallable; +export 'callable/built_in.dart' show BuiltInCallable; export 'callable/plain_css.dart'; export 'callable/user_defined.dart'; diff --git a/lib/src/callable/async_built_in.dart b/lib/src/callable/async_built_in.dart index 6751c0889..ff4513f25 100644 --- a/lib/src/callable/async_built_in.dart +++ b/lib/src/callable/async_built_in.dart @@ -11,7 +11,7 @@ import '../value.dart'; import 'async.dart'; /// An [AsyncBuiltInCallable]'s callback. -typedef _Callback = FutureOr Function(List arguments); +typedef Callback = FutureOr Function(List arguments); /// A callable defined in Dart code. /// @@ -26,7 +26,7 @@ class AsyncBuiltInCallable implements AsyncCallable { final ArgumentDeclaration _arguments; /// The callback to run when executing this callable. - final _Callback _callback; + final Callback _callback; /// Creates a function with a single [arguments] declaration and a single /// [callback]. @@ -76,7 +76,7 @@ class AsyncBuiltInCallable implements AsyncCallable { /// If no exact match is found, finds the closest approximation. Note that this /// doesn't guarantee that [positional] and [names] are valid for the returned /// [ArgumentDeclaration]. - Tuple2 callbackFor( + Tuple2 callbackFor( int positional, Set names) => Tuple2(_arguments, _callback); } diff --git a/lib/src/callable/built_in.dart b/lib/src/callable/built_in.dart index 1b4a2aeb9..8576c5c0c 100644 --- a/lib/src/callable/built_in.dart +++ b/lib/src/callable/built_in.dart @@ -8,7 +8,7 @@ import '../ast/sass.dart'; import '../callable.dart'; import '../value.dart'; -typedef _Callback = Value Function(List arguments); +typedef Callback = Value Function(List arguments); /// A callable defined in Dart code. /// @@ -20,7 +20,7 @@ class BuiltInCallable implements Callable, AsyncBuiltInCallable { final String name; /// The overloads declared for this callable. - final List> _overloads; + final List> _overloads; /// Creates a function with a single [arguments] declaration and a single /// [callback]. @@ -73,7 +73,7 @@ class BuiltInCallable implements Callable, AsyncBuiltInCallable { /// If passed, [url] is the URL of the module in which the function is /// defined. BuiltInCallable.overloadedFunction( - this.name, Map overloads, + this.name, Map overloads, {Object? url}) : _overloads = [ for (var entry in overloads.entries) @@ -91,9 +91,9 @@ class BuiltInCallable implements Callable, AsyncBuiltInCallable { /// If no exact match is found, finds the closest approximation. Note that this /// doesn't guarantee that [positional] and [names] are valid for the returned /// [ArgumentDeclaration]. - Tuple2 callbackFor( + Tuple2 callbackFor( int positional, Set names) { - Tuple2? fuzzyMatch; + Tuple2? fuzzyMatch; int? minMismatchDistance; for (var overload in _overloads) { From 19ef66f510b3b006eb233b5dd1782f720a97a182 Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Sat, 3 Sep 2022 01:40:07 +0200 Subject: [PATCH 6/7] Remove useless ignore rules Those rules are not part of lints/recommended, but were not cleaned when migrating from pedantic. --- analysis/lib/analysis_options.yaml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/analysis/lib/analysis_options.yaml b/analysis/lib/analysis_options.yaml index 63c08dc2b..5a65db81b 100644 --- a/analysis/lib/analysis_options.yaml +++ b/analysis/lib/analysis_options.yaml @@ -11,16 +11,12 @@ analyzer: # These are necessary for matching the JS API. avoid_types_as_parameter_names: ignore - # This has tons of false positives for StreamSubscription.close(). - unawaited_futures: ignore - # These are style preferences rather than potential semantic issues. While # we're not intrinsically opposed to adopting them for consistency with the # Dart ecosystem, there aren't currently any automated tools to help us # migrate to and remain consistent with these style rules, so achieving # consistency isn't worth the engineering time we'd spend getting there. annotate_overrides: ignore - prefer_single_quotes: ignore use_function_type_syntax_for_parameters: ignore include: package:lints/recommended.yaml From ba2971c61aed524e2982d89c50a74495cf229b1f Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Sat, 3 Sep 2022 01:41:51 +0200 Subject: [PATCH 7/7] Disable the prefer_interpolation_to_compose_strings rule --- analysis/lib/analysis_options.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/analysis/lib/analysis_options.yaml b/analysis/lib/analysis_options.yaml index 5a65db81b..4ab629352 100644 --- a/analysis/lib/analysis_options.yaml +++ b/analysis/lib/analysis_options.yaml @@ -18,5 +18,6 @@ analyzer: # consistency isn't worth the engineering time we'd spend getting there. annotate_overrides: ignore use_function_type_syntax_for_parameters: ignore + prefer_interpolation_to_compose_strings: ignore include: package:lints/recommended.yaml