Skip to content

Commit 37534aa

Browse files
authored
Merge pull request #903 from sass/fix-lints
Fix new pedantic lints
2 parents 8270dc1 + 2755a81 commit 37534aa

21 files changed

+109
-68
lines changed

analysis/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
This package provides a shared set of analysis options for use by Sass team
2+
packages. To use it, add it as a Git dependency to your `pubspec.yaml`:
3+
4+
```yaml
5+
dev_dependencies:
6+
sass_analysis:
7+
git: {url: git://github.com/sass/dart-sass.git, path: analysis}
8+
```
9+
10+
and include it in your `analysis_options.yaml`:
11+
12+
```yaml
13+
include: package:sass_analysis/analysis_options.yaml
14+
```

analysis/lib/analysis_options.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
analyzer:
2+
strong-mode:
3+
implicit-casts: false
4+
language:
5+
strict-inference: true
6+
strict-raw-types: true
7+
errors:
8+
missing_js_lib_annotation: ignore
9+
deprecated_member_use_from_same_package: ignore
10+
11+
# These are necessary for matching the JS API.
12+
avoid_types_as_parameter_names: ignore
13+
14+
# This has tons of false positives for StreamSubscription.close().
15+
unawaited_futures: ignore
16+
17+
# These are style preferences rather than potential semantic issues. While
18+
# we're not intrinsically opposed to adopting them for consistency with the
19+
# Dart ecosystem, there aren't currently any automated tools to help us
20+
# migrate to and remain consistent with these style rules, so achieving
21+
# consistency isn't worth the engineering time we'd spend getting there.
22+
annotate_overrides: ignore
23+
prefer_single_quotes: ignore
24+
use_function_type_syntax_for_parameters: ignore
25+
26+
include: package:pedantic/analysis_options.yaml

analysis/pubspec.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: sass_analysis
2+
version: 0.0.0
3+
description: Shared analysis options for Sass team packages.
4+
author: Sass Team
5+
homepage: https://github.com/sass/dart-sass/tree/master/analysis
6+
7+
publish_to: none
8+
9+
environment:
10+
sdk: ">=2.0.0 <3.0.0"
11+
12+
dependencies:
13+
pedantic: ^1.0.0

analysis_options.yaml

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,6 @@
1-
analyzer:
2-
strong-mode:
3-
implicit-casts: false
4-
language:
5-
strict-inference: true
6-
strict-raw-types: true
7-
errors:
8-
missing_js_lib_annotation: ignore
9-
deprecated_member_use_from_same_package: ignore
10-
11-
# These are necessary for matching the JS API.
12-
avoid_types_as_parameter_names: ignore
13-
14-
# This has tons of false positives for StreamSubscription.close().
15-
unawaited_futures: ignore
16-
17-
include: package:pedantic/analysis_options.yaml
1+
# We could depend on sass_analysis with a path dependency and include
2+
# package:sass_analysis/analysis_options.yaml, but path dependencies don't play
3+
# nicely with the logic we use to determine whether generated files are
4+
# out-of-date (because they cause "pub run" to modify the lockfile before it
5+
# runs the executable).
6+
include: analysis/lib/analysis_options.yaml

lib/src/ast/css/media_query.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class CssMediaQuery {
8181
} else {
8282
return MediaQueryMergeResult.unrepresentable;
8383
}
84-
} else if (this.matchesAllTypes || other.matchesAllTypes) {
84+
} else if (matchesAllTypes || other.matchesAllTypes) {
8585
return MediaQueryMergeResult.unrepresentable;
8686
}
8787

@@ -116,7 +116,7 @@ class CssMediaQuery {
116116
// Otherwise, there's no way to represent the intersection.
117117
return MediaQueryMergeResult.unrepresentable;
118118
}
119-
} else if (this.matchesAllTypes) {
119+
} else if (matchesAllTypes) {
120120
modifier = theirModifier;
121121
// Omit the type if either input query did, since that indicates that they
122122
// aren't targeting a browser that requires "all and".

lib/src/ast/selector/list.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ class SelectorList extends Selector {
169169
return null;
170170
}
171171

172-
Iterable<SimpleSelector> resolvedMembers = containsSelectorPseudo
172+
var resolvedMembers = containsSelectorPseudo
173173
? compound.components.map((simple) {
174174
if (simple is PseudoSelector) {
175175
if (simple.selector == null) return simple;

lib/src/ast/selector/pseudo.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ class PseudoSelector extends SimpleSelector {
135135
if (simple is PseudoSelector && simple.isElement) {
136136
// A given compound selector may only contain one pseudo element. If
137137
// [compound] has a different one than [this], unification fails.
138-
if (this.isElement) return null;
138+
if (isElement) return null;
139139

140140
// Otherwise, this is a pseudo selector and should come before pseduo
141141
// elements.

lib/src/callable/built_in.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,5 @@ class BuiltInCallable implements Callable, AsyncBuiltInCallable {
8585
}
8686

8787
/// Returns a copy of this callable with the given [name].
88-
BuiltInCallable withName(String name) =>
89-
BuiltInCallable._(name, this._overloads);
88+
BuiltInCallable withName(String name) => BuiltInCallable._(name, _overloads);
9089
}

lib/src/executable/options.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ class ExecutableOptions {
243243
var stdin = _options['stdin'] as bool;
244244
if (_options.rest.isEmpty && !stdin) _fail("Compile Sass to CSS.");
245245

246-
var directories = Set<String>();
246+
var directories = <String>{};
247247
var colonArgs = false;
248248
var positionalArgs = false;
249249
for (var argument in _options.rest) {
@@ -314,7 +314,7 @@ class ExecutableOptions {
314314
// Track [seen] separately from `sourcesToDestinations.keys` because we want
315315
// to report errors for sources as users entered them, rather than after
316316
// directories have been resolved.
317-
var seen = Set<String>();
317+
var seen = <String>{};
318318
var sourcesToDestinations = p.PathMap<String>();
319319
var sourceDirectoriesToDestinations = p.PathMap<String>();
320320
for (var argument in _options.rest) {

lib/src/executable/watch.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ class _Watcher {
224224
///
225225
/// Returns whether all recompilations succeeded.
226226
Future<bool> _recompileDownstream(Iterable<StylesheetNode> nodes) async {
227-
var seen = Set<StylesheetNode>();
227+
var seen = <StylesheetNode>{};
228228
var toRecompile = Queue.of(nodes);
229229

230230
var allSucceeded = true;

0 commit comments

Comments
 (0)