npm.io
1.0.2 • Published 2 years ago

eslint-plugin-ascii-x

Licence
ISC
Version
1.0.2
Deps
0
Size
6 kB
Vulns
0
Weekly
0
Stars
1

ASCII fiXer (eslint-plugin-ascii-x)

NPM Version ESLint Version Node Current

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

Keywords