In some other languages like javascript and typescript, you can enforce the type of quote used for strings. It would be great if the dart extension has this feature.
This can be done with Dart's lints 🙂
https://dart-lang.github.io/linter/lints/prefer_single_quotes.html
https://dart-lang.github.io/linter/lints/prefer_double_quotes.html
You can enable lints in the analysis_options.yaml file and will see violations in the editor/Problems list (as well as often get lightbulb fixes for them).
Let me know if you have any issues getting these working!
Would be really great if could be added to the analysis_options.yaml
file automatically or replace it when formatted. Does this extension use dartfmt
to format the file? If so should I make an issue there?
Does this extension use
dartfmt
to format the file? If so should I make an issue there?
It does, though I'm not sure if dartfmt
is likely to apply fixes for lints. There is another tool, dartfix
, but it's not integrated into VS Code and I'm not sure from its readme if it's only for fixes for new language features.
There is an open issue in the SDK to support applying multiple fixes to a file at once:
https://github.com/dart-lang/sdk/issues/37228
This could allow us to run fixes on-save, which is probably the ideal solution here.
This was done as part of https://github.com/Dart-Code/Dart-Code/issues/2926. It requires using the LSP Preview (which wll become default soon) and having a new enough SDK (it's not currently available in stable, but is in the dev builds and will make its way to stable in the future).
https://dartcode.org/releases/v3-17/#lsp-apply-all-fixes
Most helpful comment
It does, though I'm not sure if
dartfmt
is likely to apply fixes for lints. There is another tool,dartfix
, but it's not integrated into VS Code and I'm not sure from its readme if it's only for fixes for new language features.There is an open issue in the SDK to support applying multiple fixes to a file at once:
https://github.com/dart-lang/sdk/issues/37228
This could allow us to run fixes on-save, which is probably the ideal solution here.