From 859d060af1b4876c9293a024ecdef282fa71eb8b Mon Sep 17 00:00:00 2001 From: "Dongmin, Yu" Date: Mon, 23 Mar 2026 19:04:31 +0900 Subject: [PATCH 1/3] linters(dart): upgrade to 3.10.8, add run_from for format/fix, opt-in fix command - Bump known_good_version to 3.10.8 - Remove dartaotruntime shim (unused in current SDK) - Change suggest_if to config_present to avoid false suggestions - Add run_from ${root_or_parent_with(analysis_options.yaml)} to format and fix commands to prevent per-file directory traversal overhead - Set fix to enabled: false (opt-in), keep analyze enabled as the primary diagnostic command, aligning with the pattern used by ruff/sqlfluff/terraform - Update test snapshots accordingly --- linters/dart/plugin.yaml | 16 +++++++--- .../test_data/dart_v3.9.2_basic.check.shot | 31 +++++++------------ ..._v3.9.2_test_data.basic.in.dart.check.shot | 2 +- 3 files changed, 25 insertions(+), 24 deletions(-) diff --git a/linters/dart/plugin.yaml b/linters/dart/plugin.yaml index 65ae285e9..9bc08f557 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 @@ -15,8 +16,8 @@ tools: definitions: - name: dart download: dart - known_good_version: 3.9.2 - shims: [dart, dartaotruntime] + known_good_version: 3.10.8 + shims: [dart] environment: - name: PATH list: ["${tool}/bin"] @@ -28,11 +29,11 @@ lint: - name: dart main_tool: dart files: [dart] - known_good_version: 3.9.2 + 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: @@ -42,20 +43,27 @@ lint: 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() { From 5110d74f6fad6e0c320489b63f2947808c99751b Mon Sep 17 00:00:00 2001 From: "Dongmin, Yu" Date: Mon, 23 Mar 2026 19:27:29 +0900 Subject: [PATCH 2/3] linters(dart): remove shim exposure, flatten to lint-only definition Flattens Dart linter definition Removes the separate, general-purpose tool definition for Dart. This change integrates the Dart download and environment path directly into the linter configuration, consolidating its setup and removing its exposure as a general shimmed tool. It simplifies the configuration by ensuring Dart is defined exclusively within the lint context. --- linters/dart/plugin.yaml | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/linters/dart/plugin.yaml b/linters/dart/plugin.yaml index 9bc08f557..5144d5fde 100644 --- a/linters/dart/plugin.yaml +++ b/linters/dart/plugin.yaml @@ -12,23 +12,14 @@ 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.10.8 - shims: [dart] - environment: - - name: PATH - list: ["${tool}/bin"] lint: files: - name: dart extensions: [dart] definitions: - name: dart - main_tool: dart files: [dart] + download: dart known_good_version: 3.10.8 version_command: parse_regex: "Dart SDK version: ${semver}" @@ -40,6 +31,9 @@ lint: - analysis_options.yaml affects_cache: - pubspec.yaml + environment: + - name: PATH + list: ["${linter}/bin"] commands: - name: format output: rewrite From f422b6b02c759fb525b97f7fe131af3e2c9ef0d5 Mon Sep 17 00:00:00 2001 From: "Dongmin, Yu" Date: Mon, 23 Mar 2026 19:28:11 +0900 Subject: [PATCH 3/3] linters(dart): prefer system dart on PATH, fall back to downloaded SDK Prioritizes system Dart SDK The linter now includes the system's `PATH` when resolving the Dart SDK. This change allows it to prefer a globally installed Dart SDK, providing better integration with existing developer environments, while still falling back to the bundled SDK if a system-wide installation is not present. --- linters/dart/plugin.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linters/dart/plugin.yaml b/linters/dart/plugin.yaml index 5144d5fde..0087b0a4a 100644 --- a/linters/dart/plugin.yaml +++ b/linters/dart/plugin.yaml @@ -33,7 +33,7 @@ lint: - pubspec.yaml environment: - name: PATH - list: ["${linter}/bin"] + list: ["${env.PATH}", "${linter}/bin"] commands: - name: format output: rewrite