eslint-plugin-tachecker
"TA 埋点框架规则检验"
Installation
You'll first need to install ESLint:
$ npm i eslint --save-dev
Next, install eslint-plugin-tachecker
:
$ npm install eslint-plugin-tachecker --save-dev
Note: If you installed ESLint globally (using the -g
flag) then you must also install eslint-plugin-tachecker
globally.
Configuration
You should also specify settings that will be shared across all the plugin rules. (More about eslint shared settings)
"settings": {
"tachecker": {
"pragmas": ["TA", "TAComponents"],
"checkedComponents": ["Modal", {"name": "Switch", "funcName": "onValueChange"}],
"taComponents": []
}
}
key 说明: pragmas
用于指定导入的 TA 组件源文件; checkedComponents
指定需要检测是否有taName属性的组件,数组元素可以是字符串,也可以是对象,如果是字符串则默认处理函数是onPress
;taComponents
指定要检测taName
的 TA 组件,格式和 checkedComponents
相同
Usage
Add tachecker
to the plugins section of your .eslintrc
configuration file. You can omit the eslint-plugin-
prefix:
{
"plugins": [
"tachecker"
]
}
Then configure the rules you want to use under the rules section.
{
"rules": {
"tachecker/exist-taname-checker": 1,
"tachecker/valid-taname-checker": 1,
"tachecker/force-import-ta-component": 1,
"tachecker/ref-checker": 1
}
}
Supported Rule
-
tachecker/exist-taname-checker: Detects whether the component define
taName
property, generating random key when fix it. -
tachecker/valid-taname-checker: Detects whether
taName
is valid. - tachecker/force-import-ta-component: Detects whether use TA Component.
- tachecker/ref-checker: Detects whether use ref property.