linters(dart): remove dart shim, bump to 3.10.8#1114
linters(dart): remove dart shim, bump to 3.10.8#1114AndrewDongminYoo wants to merge 3 commits intotrunk-io:mainfrom
Conversation
… 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
Remove tools.definitions block entirely to prevent trunk from exposing a dart shim in .trunk/tools/, which could shadow the project-local dart binary (Flutter SDK). Move download and environment into lint.definitions directly, following the same pattern as clippy and gofmt.
Reorder environment PATH to ["${env.PATH}", "${linter}/bin"] so that a
project-local dart binary (e.g. managed by Flutter) is used when available.
Falls back to trunk's downloaded SDK when no system dart exists. Same
pattern as buf, trivy, and clippy.
|
Hi @TylerJang27 👋 I wanted to follow up on #1098, which you kindly reviewed and merged back in October. After using the dart plugin in production, I discovered a critical issue with my original implementation: the I've submitted #1114 to address this and other edge cases that emerged from real-world usage: Key fixes:
Testing: I apologize for not catching these issues during the initial PR. |
Summary
known_good_versionto Dart 3.10.8 and wirerun_fromforformat/fixcommands to prevent per-file directory traversal overheadfixto opt-in (enabled: false), keepanalyzeas the default diagnostic command aligning with the pattern used byruff,sqlfluff, andterraformtools.definitionsentirely and flattendownload/environmentintolint.definitions, eliminating thedartshim in.trunk/tools/to prevent it from shadowing the project-local Flutter/Dart SDK binary (same structure asclippyandgofmt)environment.PATHto["${env.PATH}", "${linter}/bin"]so that a project-local dart (e.g. managed by Flutter) is preferred when available, with trunk's downloaded SDK as fallbackChanges in detail
known_good_version3.9.2 → 3.10.8Bumps the default Dart SDK version trunk downloads for linting.
This version is used as a fallback when no system dart is available on PATH (see the PATH reorder section below).
suggest_if: files_present→config_presentAvoids auto-suggesting the dart linter in projects that have
.dartfiles but noanalysis_options.yaml.Reduces noise for projects that don't actively use the Dart analyzer.
run_fromonformatandfixdart formatanddart fixare slow when trunk moves into each file's directory individually.Setting
run_from: ${root_or_parent_with(analysis_options.yaml)}batches execution from the project root (or nearest ancestor withanalysis_options.yaml), matching how the Dart toolchain expects to be invoked.fix→enabled: falseanalyzeis the only command that produces diagnostic output.Other linters in this repo (
ruff,sqlfluff,terraform) follow the same convention: the diagnostic command stays enabled by default, and mutating commands likefixare opt-in.Reversing this would mean users who enable the dart linter receive no lint diagnostics at all.
Remove
tools.definitions/ shimWhen
tools.definitionsdeclaresshims: [dart], trunk exposes adartbinary under.trunk/tools/.If
.trunk/toolsis on PATH (as trunk adds it), this silently shadows the project's own dart binary (typically managed by Flutter).clippyandgofmtavoid this by placingdownloaddirectly insidelint.definitionswith no separate tool block.This PR applies the same pattern.
Prefer system dart on PATH
Previously
environment.PATHwas set to["${linter}/bin"], which meant trunk's downloaded dart was the only binary available when running lint commands.This PR changes it to
["${env.PATH}", "${linter}/bin"]: the system PATH is checked first, so a Flutter-managed dart binary is used when present.Trunk's downloaded SDK remains as a fallback for environments without one (e.g. bare CI).
The same pattern is used by
buf,trivy, andclippyin this repo.Test plan
dartlinter enables and runsanalyzeby defaultdart formatexecutes without per-file directory errorsdart fixdoes not run unless explicitly enabled (trunk check enable dart→ verify nofixaction in output)dartbinary appears under.trunk/tools/after enabling the linterdartbinary is not overridden on PATH