Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support automatically fixing all incorrect types of quotes #2367

Closed
gleich opened this issue Apr 19, 2020 · 4 comments
Closed

Support automatically fixing all incorrect types of quotes #2367

gleich opened this issue Apr 19, 2020 · 4 comments

Comments

@gleich
Copy link

gleich commented Apr 19, 2020

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.

@DanTup
Copy link
Member

DanTup commented Apr 19, 2020

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!

@gleich
Copy link
Author

gleich commented Apr 19, 2020

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?

@DanTup
Copy link
Member

DanTup commented Apr 19, 2020

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:

dart-lang/sdk#37228

This could allow us to run fixes on-save, which is probably the ideal solution here.

@DanTup DanTup added blocked on dart / flutter Requires a change in Dart or Flutter to progress in editor Relates to code editing or language features is enhancement labels Apr 23, 2020
@DanTup DanTup added this to the Backlog milestone Apr 23, 2020
@DanTup DanTup changed the title Option to enforce quote style Support automatically fixing all incorrect types of quotes Nov 18, 2020
@DanTup DanTup modified the milestones: Backlog, On Deck Nov 18, 2020
@DanTup
Copy link
Member

DanTup commented Dec 8, 2020

This was done as part of #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

@DanTup DanTup added duplicate and removed blocked on dart / flutter Requires a change in Dart or Flutter to progress in editor Relates to code editing or language features is enhancement labels Dec 8, 2020
@DanTup DanTup removed this from the On Deck milestone Dec 8, 2020
@DanTup DanTup closed this as completed Dec 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants