禁用规则时,vue-cli linting投掷驼峰警告

时间:2019-06-07 05:27:13

标签: vue.js eslint vue-cli-3 eslint-config-airbnb

我正在使用vue-cli构建一个应用程序,并使用airbnb规则进行测试。

尽管我向我的.eslintrc.js配置文件中添加了一条规则,并且该规则适用于其他文件,但我的Welcome.vue文件中的此特定变量在掉毛时始终会发出警告。

警告:

warning: Identifier 'tables_count' is not in camel case (camelcase) at src\components\Welcome.vue:49:33:
47 |         enableAll: function enableAll() {
48 |             const tables_count = this.tables.length;
49 |             for (let i = 0; i < tables_count; i += 1) {
   |                                 ^
50 |                 this.tables[i].enabled = true;
51 |             }
52 |         },

完整的.eslintrc.js文件:

module.exports = {
    root: true,
    env: {
        node: true,
    },
    extends: [
        'plugin:vue/essential',
        '@vue/airbnb',
    ],
    rules: {
        'no-console': process.env.NODE_ENV === 'production' ? 'error' :     'off',
        'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
        indent: ['error', 4],
        camelcase: ['warn', { properties: 'never' }],
    },
    parserOptions: {
        parser: 'babel-eslint',
    },
};

我的应用程序的结构如下:

  • App.vue
    • Welcome.vue
    • Game.vue

App.vueGame.vue的变量都得分不足,并且棉絮不会向它们发出警告。

  • App.vue:this.show_welcome = true;
  • Game.vue:this.current_answer = '';

我怎么做才能使一个特定的Vue文件严重侵犯短绒呢?!

这是我运行npm run servenpm run lint的时候

注意:我以为我已经解决了,但还是没有...

目前,我仅对welcome.vue进行单元测试,它具有它自己的lint文件,但是我在其中添加了规则,但仍然收到警告:

tests / unit / eslintrc.js

module.exports = {
    env: {
        jest: true,
    },
    rules: {
        camelcase: ['warn', { properties: 'never' }],
    },
};

2 个答案:

答案 0 :(得分:0)

如果您不希望eslint检查变量大小写,只需在camelcase: 'off'中用.eslintrc.js将其关闭。

答案 1 :(得分:0)

对于打字稿项目:

.eslintrc.js

{
  rules: {
    '@typescript-eslint/camelcase': 'off'
  }
}