1.0.0 • Published 5 years ago

@antstudiocz/eslint-plugin-ant-rules v1.0.0

Weekly downloads
5
License
-
Repository
-
Last release
5 years ago

eslint-plugin-ant-rules

Internal ANT eslint rules

Installation

You'll first need to install ESLint:

$ npm install eslint --save-dev

Next, install eslint-plugin-ant-rules:

$ npm install @antstudiocz/eslint-plugin-ant-rules --save-dev

Usage

Add ant-rules to the plugins section of your package.json or .eslintrc configuration file. You can omit the eslint-plugin- prefix:

{
    "plugins": [
        "ant-rules"
    ]
}

Then configure the rules you want to use under the rules section.

rule output option:

  • 0 = disable output
  • 1 = danger only
  • 2 = error

Config object: define danger function. - not required

TRUE = validation FALSE = no validation

{
    "rules": {
        "ant-rules/rule-name": [
         	1,
         	{
         		"innerHTML" : true,
         		"outerHTML" : true,
         		"write"     : true,
         		"writeln"   : true,
         		"src"       : true,
         		"open"      : true
         	}
         ]
    }
}

Function list:

  • innerHTML
  • outerHTML
  • write
  • writeln
  • src
  • open

How to add new rules

make sure you have install Yeoman globally:

$ npm i -g yo

then install generator-eslint:

$ npm i -g generator-eslint

with this tool you can ease create new rule or new plugin for eslint - https://github.com/eslint/generator-eslint

If you want to create a new ESLint rule, make sure you're in the top-level (eg. front/js/eslint-plugin-ant-rules) directory of an ESLint repo clone or an ESLint plugin and type:

$ yo eslint:rule

You'll be prompted for some information and then it will generate the files necessary for a new rule, including the source file, a test file, and a documentation file. After that remove unnecessary code in rule and if is possible rewrite it into ES6