eslint-plugin-ascii-x
v1.0.2
Published
ESLint plugin to escape or delete non-ASCII characters, using autofixes
Downloads
7
Maintainers
Readme
ASCII fiXer (eslint-plugin-ascii-x
)
ESLint plugin to delete or escape non-ASCII characters, using autofixes
Example using rule (ascii-x/ascii
)
Example of original code:
/** foo 🅱ar */
console.log("¡Hello World!🏳️🌈");
let a = 2; // 🦊Answer
console.log(`🔢1+1=${a}`);
Example of corrected code:
/** foo ar */
console.log("\xA1Hello World!\u{1F3F3}\uFE0F\u200D\u{1F308}");
const a = 2; // Answer
console.log(`\u{1F522}1+1=${a}`);
Installation
You'll first need to install ESLint:
npm i eslint --save-dev
Next, install eslint-plugin-ascii-x
:
npm install eslint-plugin-ascii-x --save-dev
Usage
Add ascii-x
to the plugins section of your .eslintrc
configuration file. You can omit the eslint-plugin-
prefix:
{
"plugins": [
"ascii-x"
]
}
Then configure the rule.
{
"rules": {
"ascii-x/ascii": "error"
}
}
Rules
🔧 Automatically fixable by the --fix
CLI option.
| Name | Description | 🔧 | | :--------------------------- | :------------ | :- | | ascii | Enforce ASCII | 🔧 |
Planned Features
- Separate rules for comments and strings
- Whitelist characters
- Suggest other replacements (e.g. left/right quotes)
Acknowledgements
Inspired by eslint-plugin-only-ascii, eslint-plugin-ascii, and eslint-plugin-escape
Inspired by VSCode's "Non Basic ASCII" setting