I think it would be useful to be able to configure if single quotes or double quotes are used in files generated by the cli.
This could e.g. be configured in angular-cli.json.
This would be really nice, in my work environment, we use the follwing:
Would be nice to make this optional.
I usually work with java, so I am used to use double quotes.
Also I usually use tabs instead of spaces, but most IDEs support a Tab-to-Space conversion, so thats not a big problem.
However I haven't seen a Single-to-Double-Quote conversion until now and I guess it is pretty complex to implement one...
So having an option to use double quotes instead of single quotes in all CLI-generated files would be really great.
With https://github.com/angular/angular-cli/pull/4248 you should be able to change the tslint.json quotemark rule from
"quotemark": [
true,
"single"
],
to
"quotemark": [
true,
"double"
],
and then do ng lint --fix.
I don't think this feature is necessary, as it will be more effort than it's worth, especially now that there will be (hopefully) a quick fix. Granted, all new files will also give you lint errors since they will use single quotes, but doing a quick ng lint --fix I don't think is too unreasonable.
@delasteve Thanks for this suggestion, I did not know about that tslint feature.
But is it able to handle literals inside strings like:
alert("Say 'Hello'");
or will it replace them to?
Thanks
@Springrbua, the linter will change single quotes to double quotes. It will keep the inside quotes the same.
Example 1: Double quotes inside single quotes
const foo = '""';
ng lint --fix (tslint ran with --fix under the hood)
const foo = "\"\"";
Example 2: Single quotes inside double quotes
const foo = "''";
ng lint --fix (tslint ran with --fix under the hood)
const foo = "''";
@delasteve ah thats nice! Thanks a lot. Do you know when this feature will be available in angular-cli?
It will be available next release. It got merged in yesterday.
@delasteve Thanks a lot for the information, can't wait for this feature :)
Closing as answered (and made possible) by @delasteve. Cheers!
This should be available soon-ish via automatically running TS Lint fixers on generators. This is being tracked in #6272.
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
_This action has been performed automatically by a bot._
Most helpful comment
With https://github.com/angular/angular-cli/pull/4248 you should be able to change the
tslint.jsonquotemarkrule fromto
and then do
ng lint --fix.I don't think this feature is necessary, as it will be more effort than it's worth, especially now that there will be (hopefully) a quick fix. Granted, all new files will also give you lint errors since they will use single quotes, but doing a quick
ng lint --fixI don't think is too unreasonable.