1.0.0 • Published 6 years ago
eslint-plugin-dmp v1.0.0
eslint-plugin-dmp
eslint-plugin-dmp
说明
魔改eslint
下的no-restricted-imports
与no-restricted-modules
两个规则,增加scoped
字段限定这两个规则的生效范围并支持多个配置项
示例
const noRestrictedConfig = [
//示例:项目下的src文件夹下禁止引用echarts、vue-echarts、lodash等第三方模块,src/modules下的文件除外
{
paths: ["echarts", "vue-echarts", "lodash"],
scoped: ["src/*", "!src/modules"]
},
//示例:项目下src/modules文件夹的文件禁止引用src/api文件夹的文件,src/api/index除外
{
patterns: ["src/api/*", "!src/api/index"],
scoped: ["src/modules/*"]
}
];
module.exports = {
plugins: ["dmp"],
rules: {
"no-console": "off",
"no-debugger": "off",
"dmp/no-restricted-imports": ["error"].concat(noRestrictedConfig),
"dmp/no-restricted-modules": ["error"].concat(noRestrictedConfig)
}
};
Installation
You'll first need to install ESLint:
$ npm i eslint --save-dev
Next, install eslint-plugin-dmp
:
$ npm install eslint-plugin-dmp --save-dev
Note: If you installed ESLint globally (using the -g
flag) then you must also install eslint-plugin-dmp
globally.
Usage
Add dmp
to the plugins section of your .eslintrc
configuration file. You can omit the eslint-plugin-
prefix:
{
"plugins": ["dmp"]
}
Then configure the rules you want to use under the rules section.
{
"rules": {
"dmp/rule-name": 2
}
}
Supported Rules
- Fill in provided rules here
1.0.0
6 years ago