eslint-plugin-anker
v0.0.5
Published
eslint-custom-anker
Downloads
3
Maintainers
Readme
eslint-plugin-anker
eslint-custom-anker
Installation
You'll first need to install ESLint:
npm i eslint --save-dev
Next, install eslint-plugin-anker
:
npm install eslint-plugin-anker --save-dev
Usage
Add anker
to the plugins section of your .eslintrc
configuration file. You can omit the eslint-plugin-
prefix:
{
"plugins": [
"anker"
]
}
Then configure the rules you want to use under the rules section.
{
"rules": {
"anker/necessary-optional-chaining": 2
}
}
Rules
1. Necessary Optional Chaining (necessary-optional-chaining
)
"?." 语法的强制性使用。
Rule Details
获取对象value时,必须使用 "?." 来避免key值不存在导致的报错。
Examples of incorrect code for this rule:
var a = A?.a
var b = A?.B?.b
var c = A?.[0]?.c
Examples of correct code for this rule:
var a = A.a
var b = A.B.b
var c = A[0].c