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

Feature: Allow switch from single quotes to double quotes #2213

Closed
Mattes83 opened this issue Sep 19, 2016 · 11 comments
Closed

Feature: Allow switch from single quotes to double quotes #2213

Mattes83 opened this issue Sep 19, 2016 · 11 comments
Labels
feature Issue that requests a new feature P5 The team acknowledges the request but does not plan to address it, it remains open for discussion

Comments

@Mattes83
Copy link

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.

@Mattes83 Mattes83 changed the title Feature: Switch from single quotes to double quotes Feature: Allow switch from single quotes to double quotes Sep 20, 2016
@filipesilva filipesilva added feature Issue that requests a new feature P5 The team acknowledges the request but does not plan to address it, it remains open for discussion labels Sep 22, 2016
@xtreemrage
Copy link

xtreemrage commented Oct 8, 2016

This would be really nice, in my work environment, we use the follwing:

  • double quotes
  • indent style: space
  • indent size: 4

Would be nice to make this optional.

lkrnac added a commit to lkrnac/janodemp-server that referenced this issue Nov 22, 2016
As angular-cli currently supports only single quotes:
angular/angular-cli#2213
lkrnac added a commit to lkrnac/janodemp that referenced this issue Nov 22, 2016
As angular-cli currently supports only single quotes:
angular/angular-cli#2213
lkrnac added a commit to lkrnac/janodemp that referenced this issue Nov 22, 2016
As angular-cli currently supports only single quotes:
angular/angular-cli#2213
@probert94
Copy link

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.

@delasteve
Copy link
Contributor

With #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.

@probert94
Copy link

probert94 commented Jan 27, 2017

@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

@delasteve
Copy link
Contributor

@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 = "''";

@probert94
Copy link

@delasteve ah thats nice! Thanks a lot. Do you know when this feature will be available in angular-cli?

@delasteve
Copy link
Contributor

It will be available next release. It got merged in yesterday.

@probert94
Copy link

@delasteve Thanks a lot for the information, can't wait for this feature :)

@filipesilva
Copy link
Contributor

Closing as answered (and made possible) by @delasteve. Cheers!

@filipesilva
Copy link
Contributor

This should be available soon-ish via automatically running TS Lint fixers on generators. This is being tracked in #6272.

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature Issue that requests a new feature P5 The team acknowledges the request but does not plan to address it, it remains open for discussion
Projects
None yet
Development

No branches or pull requests

5 participants