0.2.1 • Published 3 years ago
eslint-plugin-contextual-quotes v0.2.1
Contextual Quotes
Enforce the use of specific quotes based on the content of the string.
'for empty strings and strings of only a single character"for regular strings`for strings that use string interpolation
Installation
You'll first need to install ESLint:
$ npm i eslint --save-devNext, install eslint-plugin-contextual-quotes:
$ npm install eslint-plugin-contextual-quotes --save-devNote: If you have installed ESLint globally then you must also install this globally.
Usage
Add contextual-quotes to the plugins section of your configuration file.
// .eslintrc
{
"plugins": [
"contextual-quotes"
],
...
}Then setup the actual rule under rules in the same configuration file.
// .eslintrc
{
...
"rules": {
...
"contextual-quotes/contextual-quotes": "error"
}
}Options
"applyFix": "never"Whether to apply fixes"never"Only give suggestions"always"Always give a fix along with the suggestions
"expressionBlockEscapes": ["\\"]What strings should be allowed to escape${}in regular strings. The first string in the list is used for the corresponding suggestion"emoijAsSingleCharacter": "never"Whether to treat emoijs and other special characters as a single character (allow to be wrapped in just')"never"Count string length in utf-16 units"always"Count string length in visual characters
// .eslintrc
{
...
"rules": {
...
"contextual-quotes/contextual-quotes": ["error", {
"applyFix": "always",
"expressionBlockEscapes": ["custom_escape", "\\"],
"emoijAsSingleCharacter": "always"
}]
}
}