如何在eslint-plugin-angular中关闭eslint规则`angular / file-name`

时间:2017-06-04 19:32:18

标签: angularjs webpack eslint

我有这样的配置。

`module.exports = {     "全局":{         "棱角分明":1     },     " env":{         "浏览器":是的,         " commonjs":是的,         " es6":是的     },     扩展:['插件:angular / johnpapa',' eslint:recommended'],

"parserOptions": {
    "sourceType": "module"
},
"plugins": [
    "angular"
],
"rules": {
    "no-console": 0,
    "angular/ng_controller_name": 0,
    "indent": [
        "error",
        "tab"
    ],
    "linebreak-style": [
        "error",
        "unix"
    ],
    "quotes": [
        "error",
        "single"
    ],
    "semi": [
        "error",
        "always"
    ]
}

}; `

我在终端

中收到此警告

Filename must be "callsController.js" angular/file-name

2 个答案:

答案 0 :(得分:4)

angular插件正在运行文件名规则,我默认猜测,因为我在规则列表中没有看到它。您应该能够在eslintrc中使用"angular/file-name":0覆盖此内容。

答案 1 :(得分:2)

规则部分的.eslintrc添加"angular/file-name": 0中,如下所示:

{
    "extends": "eslint:recommended",
    "plugins": ["angular"],
    "env": {
        ...
    },
    "globals": {
        "angular": true,
        "module": true,
        "inject": true
    },
    "rules": {
        "angular/file-name": 0
    }
}