Skip to content
This repository was archived by the owner on Nov 20, 2024. It is now read-only.

Commit de31be5

Browse files
committed
wip
1 parent 540cc75 commit de31be5

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

lib/src/rules/unnecessary_parenthesis.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,10 @@ class _Visitor extends SimpleAstVisitor<void> {
8888
@override
8989
void visitParenthesizedPattern(ParenthesizedPattern node) {
9090
//https://github.com/dart-lang/linter/issues/4062
91-
// var parent = node.parent;
92-
// if (parent is DartPattern && parent.precedence < node.precedence) {
93-
// rule.reportLint(node);
94-
// }
91+
var parent = node.parent;
92+
if (parent is DartPattern && parent.precedence < node.pattern.precedence) {
93+
rule.reportLint(node);
94+
}
9595
}
9696

9797
@override

test/rules/unnecessary_parenthesis_test.dart

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,26 +36,27 @@ void f(int i) {
3636
}
3737

3838
///https://github.com/dart-lang/linter/issues/4062
39-
@FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/51426')
39+
//@FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/51426')
40+
@soloTest
4041
test_parenthesized_listPattern() async {
4142
await assertDiagnostics(r'''
42-
void f(Object x) {
43-
if (x case [(<3), 12]) return;
43+
void f(List<int> l) {
44+
if (l case [(<3), 12]) return;
4445
}
4546
''', [
4647
lint(41, 11),
4748
]);
4849
}
4950

50-
///https://github.com/dart-lang/linter/issues/4062
51-
@FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/51426')
51+
@soloTest
5252
test_parenthesized_relationalPattern() async {
5353
await assertDiagnostics(r'''
54-
void f(int x) {
55-
if (x case (<3) || (>5)) return;
54+
void f(List<int> l) {
55+
if (l case [(<3) || (>5)]) return;
5656
}
5757
''', [
58-
lint(41, 11),
58+
lint(36, 4),
59+
lint(44, 4),
5960
]);
6061
}
6162
}

0 commit comments

Comments
 (0)