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

feat: Added rule to enforce quotes type #475

Merged
merged 4 commits into from
Apr 12, 2021

Conversation

angelica-bocanegra
Copy link
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

fixer.replaceTextRange([node.range[1] - 1, node.range[1]], '"'),
];
},
message: 'Strings must use double quote.',
Copy link
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
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.


<a name="eslint-plugin-flowtype-rules-quotes-options-3"></a>
#### Options

The rule has string options of:

* `"double"` (default) requires double quotes around strings.
* `"single"` requires single quotes around strings.
* `"double"` (default) requires double quotes around string literals.
Copy link
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
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
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