Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.31.0 (cherry-pick release) #3865

Merged
merged 3 commits into from
Nov 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 1.31.0

- updated `prefer_equal_for_default_values` to not report for SDKs `>=2.19`,
where this lint is now an analyzer diagnostic.

# 1.30.0

- new lint: `enable_null_safety`
Expand Down
25 changes: 2 additions & 23 deletions lib/src/rules/prefer_equal_for_default_values.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
// 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.

import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/ast/token.dart';
import 'package:analyzer/dart/ast/visitor.dart';

import '../analyzer.dart';

const _desc = r'Use `=` to separate a named parameter from its default value.';
Expand Down Expand Up @@ -42,23 +38,6 @@ class PreferEqualForDefaultValues extends LintRule {
@override
LintCode get lintCode => code;

@override
void registerNodeProcessors(
NodeLintRegistry registry, LinterContext context) {
var visitor = _Visitor(this);
registry.addDefaultFormalParameter(this, visitor);
}
}

class _Visitor extends SimpleAstVisitor<void> {
final LintRule rule;

_Visitor(this.rule);

@override
void visitDefaultFormalParameter(DefaultFormalParameter node) {
if (node.isNamed && node.separator?.type == TokenType.COLON) {
rule.reportLintForToken(node.separator);
}
}
// As of 2.19, this is a warning so we don't want to double-report and so
// we don't register any processors.
}
2 changes: 1 addition & 1 deletion lib/src/version.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
// BSD-style license that can be found in the LICENSE file.

/// Package version. Synchronized w/ pubspec.yaml.
const String version = '1.30.0';
const String version = '1.31.0';
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: linter
version: 1.30.0
version: 1.31.0

description: >-
The implementation of the lint rules supported by the analyzer framework.
Expand Down
7 changes: 3 additions & 4 deletions test/rules/prefer_equal_for_default_values_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ class PreferEqualForDefaultValuesTest extends LintRuleTest {
String get lintRule => 'prefer_equal_for_default_values';

test_super() async {
await assertDiagnostics(r'''
// As of 2.19, this is a warning and the lint is a no-op.
await assertNoDiagnostics(r'''
class A {
String? a;
A({this.a});
Expand All @@ -27,8 +28,6 @@ class A {
class B extends A {
B({super.a : ''});
}
''', [
lint(74, 1),
]);
''');
}
}
4 changes: 3 additions & 1 deletion test_data/rules/prefer_equal_for_default_values.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

// test w/ `dart test -N prefer_equal_for_default_values`

f1({a: 1}) => null; // LINT
// As of 2.19, this is a warning and the lint is a no-op.

f1({a: 1}) => null; // OK
f2({a = 1}) => null; // OK
f3([a = 1]) => null; // OK
f4([a]) => null; // OK