diff --git a/linters/dart/plugin.yaml b/linters/dart/plugin.yaml index 65ae285e9..0087b0a4a 100644 --- a/linters/dart/plugin.yaml +++ b/linters/dart/plugin.yaml @@ -1,6 +1,7 @@ version: 0.1 downloads: - name: dart + # https://dart.dev/get-dart/archive downloads: - os: linux: linux @@ -11,51 +12,52 @@ downloads: arm_64: arm64 url: https://storage.googleapis.com/dart-archive/channels/stable/release/${version}/sdk/dartsdk-${os}-${cpu}-release.zip strip_components: 1 -tools: - definitions: - - name: dart - download: dart - known_good_version: 3.9.2 - shims: [dart, dartaotruntime] - environment: - - name: PATH - list: ["${tool}/bin"] lint: files: - name: dart extensions: [dart] definitions: - name: dart - main_tool: dart files: [dart] - known_good_version: 3.9.2 + download: dart + known_good_version: 3.10.8 version_command: parse_regex: "Dart SDK version: ${semver}" run: dart --version - suggest_if: files_present + suggest_if: config_present description: Lints and formats dart code issue_url_format: https://dart.dev/tools/linter-rules/{} direct_configs: - analysis_options.yaml affects_cache: - pubspec.yaml + environment: + - name: PATH + list: ["${env.PATH}", "${linter}/bin"] commands: - name: format output: rewrite + # By default, trunk linters attempt to move to each file's directory to format it, + # but this slows down Dart formatters and increases the occurrence of errors. + run_from: ${root_or_parent_with(analysis_options.yaml)} run: dart format ${target} batch: true in_place: true formatter: true success_codes: [0] + - name: fix # Some analyze results are autofixable, others are not. output: rewrite + run_from: ${root_or_parent_with(analysis_options.yaml)} run: dart fix --apply ${target} batch: true fix_prompt: Quick fix available fix_verb: fix in_place: true success_codes: [0] + enabled: false + - name: analyze output: regex # The output only includes the filename so in order to use a relative path we need to run from parent. diff --git a/linters/dart/test_data/dart_v3.9.2_basic.check.shot b/linters/dart/test_data/dart_v3.9.2_basic.check.shot index ea9669421..9f84d2cc6 100644 --- a/linters/dart/test_data/dart_v3.9.2_basic.check.shot +++ b/linters/dart/test_data/dart_v3.9.2_basic.check.shot @@ -3,6 +3,18 @@ exports[`Testing linter dart test basic 1`] = ` { "issues": [ + { + "code": "use_super_parameters", + "column": "3", + "file": "test_data/basic.in.dart", + "issueClass": "ISSUE_CLASS_EXISTING", + "issueUrl": "https://dart.dev/tools/linter-rules/use_super_parameters", + "level": "LEVEL_LOW", + "line": "12", + "linter": "dart", + "message": "Parameters ''x' and 'y'' could be super parameters. Trying converting ''x' and 'y'' to super parameters.", + "targetType": "dart", + }, { "code": "undefined_identifier", "column": "10", @@ -60,25 +72,6 @@ exports[`Testing linter dart test basic 1`] = ` "upstream": true, "verb": "TRUNK_VERB_CHECK", }, - { - "command": "fix", - "fileGroupName": "dart", - "linter": "dart", - "paths": [ - "test_data/basic.in.dart", - ], - "verb": "TRUNK_VERB_CHECK", - }, - { - "command": "fix", - "fileGroupName": "dart", - "linter": "dart", - "paths": [ - "test_data/basic.in.dart", - ], - "upstream": true, - "verb": "TRUNK_VERB_CHECK", - }, { "command": "format", "fileGroupName": "dart", diff --git a/linters/dart/test_data/dart_v3.9.2_test_data.basic.in.dart.check.shot b/linters/dart/test_data/dart_v3.9.2_test_data.basic.in.dart.check.shot index b4a65c3a0..638a8ff57 100644 --- a/linters/dart/test_data/dart_v3.9.2_test_data.basic.in.dart.check.shot +++ b/linters/dart/test_data/dart_v3.9.2_test_data.basic.in.dart.check.shot @@ -12,7 +12,7 @@ class Vector2d { class Vector3d extends Vector2d { final double z; - Vector3d(super.x, super.y, this.z); + Vector3d(final double x, final double y, this.z) : super(x, y); } void main() {