eslint-plugin-gtjsutils
v0.2.0-alpha.0
Published
检查函数名、变量名在utils包中是否存在,并给出提示和修复
Downloads
2
Maintainers
Readme
eslint-plugin-utilssuggest
这是一个在eslint中给出js-utils建议的插件,
安装
需要先安装 ESLint:
npm i eslint --save-dev
再安装 eslint-plugin-gtjsutils
:
npm install eslint-plugin-gtjsutils --save-dev
使用
在 .eslintrc
的plugin
中增加gtjsutils
配置, 可以省略 eslint-plugin-
"plugins": [
"gtjsutils"
],
接下来需要配置规则:
functionNames
是可以校验的函数名,contsants
是可以检验的常量名
插件内部内置了functionNames
和contsants
,可以不传递functionNames
和contsants
,但传递后将以传递的数组作为检验的依据
{
"rules": {
"gtjsutils/suggest": [
"warn",
{
"functionNames": [
"urlReplaceState", "toParamUrl", "replaceUrl", "parseUrlByKey",
"parseUrl", "hrefUrl", "getOriginPath", "getCurrentEnv", "updateWebviewCache",
"updateVisibilityWindowData", "unSaveDataWrapper", "sourceInit", "saveDataWrapper",
"onpageshowListner", "notifyPage", "loginByH5", "goToUserLogin", "getSourceParams",
"closeWindow", "advanceSetChildLeadsId", "addSourceToUrl", "bridgeCallLogger",
"bridgeCallbackLogger", "asyncCallNative", "callNative", "getCommonUserInfo", "gtJsBridge",
"judgeIsGaoTuApp", "registerCallback", "shareImageToCircle", "shareImageToFriend",
"shareImageToSave", "shareUrlToWechat", "showAlbum"
],
"contsants": [
"isAndroid", "isDouYin", "isGaotuApp",
"isIOS", "isNoah", "isWechat", "isWeibo",
"isDouyinVersionOk", "isInBrowser"
]
}
]
}
}