Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/younesaassila/eslint-plugin-curly-quotes
Enforce the use of curly quotes
https://github.com/younesaassila/eslint-plugin-curly-quotes
curly-quotes eslint eslint-plugin eslintconfig quotes smart-quotes
Last synced: 9 days ago
JSON representation
Enforce the use of curly quotes
- Host: GitHub
- URL: https://github.com/younesaassila/eslint-plugin-curly-quotes
- Owner: younesaassila
- License: mit
- Created: 2022-03-24T12:30:53.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-09-19T09:54:42.000Z (about 2 months ago)
- Last Synced: 2024-09-19T09:55:12.457Z (about 2 months ago)
- Topics: curly-quotes, eslint, eslint-plugin, eslintconfig, quotes, smart-quotes
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/eslint-plugin-curly-quotes
- Size: 643 KB
- Stars: 3
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# eslint-plugin-curly-quotes
Enforce the use of curly quotes and apostrophes.
β¨ **Simple** and **customizable** π§ Compatible with JavaScript, TypeScript, **JSX** and **Vue**!
**Fixable:** This rule is automatically fixable using the `--fix` flag on the command line.
> **CAUTION**
>
> The plugin replaces quotes used in query selector or stringified JSON strings when using the `--fix` flag on the command line. To ignore a specific string:
>
> Use tagged template literals:
>
> ```js
> String.raw`{"foo": "bar"}`
> ```
>
> Or disable the rule for the line:
>
> ```js
> const data = '{"foo": "bar"}' // eslint-disable-line curly-quotes/no-straight-quotes
> ```## Installation
Install [ESLint](https://www.npmjs.com/package/eslint):
```sh
npm i --save-dev eslint
```Install [`eslint-plugin-curly-quotes`](https://www.npmjs.com/package/eslint-plugin-curly-quotes):
```sh
npm i --save-dev eslint-plugin-curly-quotes
```## Usage
Add `eslint-plugin-curly-quotes` to the `plugins` section of your `.eslintrc` configuration file:
```json
{
"plugins": ["curly-quotes"]
}
```Then add the `no-straight-quotes` rule to the `rules` section:
```json
{
"rules": {
"curly-quotes/no-straight-quotes": "warn"
}
}
```You may customize the characters used to replace straight quotes:
```json
{
"rules": {
"curly-quotes/no-straight-quotes": [
"warn",
{
"single-opening": "β",
"single-closing": "β", // This character is also used to replace apostrophes.
"double-opening": "β",
"double-closing": "β",
"ignored-jsx-elements": ["script", "style"], // Straight quotes in these JSX elements are ignored.
"ignored-jsx-attributes": ["className"], // Straight quotes in these JSX attributes are ignored.
"ignored-function-calls": ["Error"] // Straight quotes passed as parameters to these functions are ignored.
}
]
}
}
```## Acknowledgements
- Plugin inspired by [`eslint-plugin-prefer-smart-quotes`](https://github.com/totallymoney/eslint-plugin-prefer-smart-quotes)
- Algorithm adapted from [βIdeas for converting straight quotes to curly quotesβ](https://stackoverflow.com/questions/509685/ideas-for-converting-straight-quotes-to-curly-quotes) by [ShreevatsaR](https://stackoverflow.com/users/4958/shreevatsar) on Stack Overflow