Skip to content

feat: Added rule to enforce quotes type#475

Merged
gajus merged 4 commits intogajus:masterfrom
angiebeepboop:quotes
Apr 12, 2021
Merged

feat: Added rule to enforce quotes type#475
gajus merged 4 commits intogajus:masterfrom
angiebeepboop:quotes

Conversation

@angiebeepboop
Copy link
Copy Markdown
Contributor

closes #473
Added new rule quotes that enforces consistent quote types around strings.

Options: double (default) or single

Double (default):

// Correct
type Y = {foo: "bar"};
type T = { test: "hello" | "world" }

// Incorrect
type N = { foo: 'bar' };
type T = { test: "hello" | 'world' }

Single:

// Correct
type Y = {foo: 'bar'};
type T = { test: 'hello' | 'world' }

// Incorrect
type N = { foo: 'bar' };
type T = { test: "hello" | 'world' }

@gajus

Comment thread src/rules/quotes.js Outdated
fixer.replaceTextRange([node.range[1] - 1, node.range[1]], '"'),
];
},
message: 'Strings must use double quote.',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should name these as String literals not just Strings

@mrtnzlml
Copy link
Copy Markdown
Contributor

mrtnzlml commented Apr 9, 2021

@angelica-bocanegra It might be a good idea to add this rule here as well: https://github.com/prettier/eslint-config-prettier (https://github.com/prettier/eslint-config-prettier/blob/96efee3dc6d37f9a89d6facb04359a73409cb1e6/index.js#L111-L120) to disable it for Prettier users.

Comment thread README.md

* `"double"` (default) requires double quotes around strings.
* `"single"` requires single quotes around strings.
* `"double"` (default) requires double quotes around string literals.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm I wonder why is default double? Guess same as regular quotes rule?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep keeping it standard

@gajus gajus merged commit 8008f78 into gajus:master Apr 12, 2021
@gajus
Copy link
Copy Markdown
Owner

gajus commented Apr 12, 2021

🎉 This PR is included in version 5.7.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flowtype quotes rule

4 participants