Skip to content

Commit

Permalink
Avoid-late ignored_types tests
Browse files Browse the repository at this point in the history
  • Loading branch information
maxxlab committed Nov 17, 2023
1 parent 8167c07 commit 2037550
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lib/lints/avoid_late_keyword/avoid_late_keyword_rule.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class AvoidLateKeywordRule extends SolidLintRule<AvoidLateKeywordParameters> {
final hasInitializer = node.initializer != null;
return !hasInitializer;
}

bool _hasIgnoredType(VariableDeclaration node) {
final ignoredTypes = config.parameters.ignoredTypes.toSet();
if (ignoredTypes.isEmpty) return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ custom_lint:
rules:
- avoid_late_keyword:
allow_initialized: false
ignored_types:
- Animation
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// ignore_for_file: prefer_const_declarations, unused_local_variable, prefer_match_file_name
// ignore_for_file: avoid_global_state

import 'package:flutter/material.dart';

/// Check "late" keyword fail
///
/// `avoid_late_keyword`
Expand All @@ -22,7 +20,7 @@ class AvoidLateKeyword {
void test() {
/// expect_lint: avoid_late_keyword
late final ColorTween colorTween;

late final AnimationController controller2;

/// expect_lint: avoid_late_keyword
Expand All @@ -32,3 +30,9 @@ class AvoidLateKeyword {
late String field4;
}
}

abstract class Animation {}

class AnimationController implements Animation {}

class ColorTween {}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ environment:
sdk: '>=3.0.0 <4.0.0'

dependencies:
flutter:
sdk: flutter

dev_dependencies:
solid_lints:
Expand Down
8 changes: 4 additions & 4 deletions lint_test/avoid_late_keyword_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ class AvoidLateKeyword {

late final SubAnimationController controller2;

/// expect_lint: avoid_late_keyword
late final NotAllowed na;

late final field1 = 'string';

/// expect_lint: avoid_late_keyword
/// expect_lint: avoid_late_keyword
late String field2;

/// expect_lint: avoid_late_keyword
late final NotAllowed na;

void test() {
late final ColorTween colorTween;

Expand Down

0 comments on commit 2037550

Please sign in to comment.