Dart-code: Support automatically fixing all incorrect types of quotes

Created on 19 Apr 2020  ·  4Comments  ·  Source: Dart-Code/Dart-Code

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.

duplicate

Most helpful comment

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.

All 4 comments

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

Apply all

Was this page helpful?
0 / 5 - 0 ratings

Related issues

e200 picture e200  ·  3Comments

ghost picture ghost  ·  5Comments

rgb1380 picture rgb1380  ·  3Comments

shamrin picture shamrin  ·  5Comments

FeimiSzy picture FeimiSzy  ·  4Comments