首页 > 解决方案 > 禁用规则时,vue-cli linting 抛出驼峰警告

问题描述

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

尽管我在我的.eslintrc.js配置文件中添加了一条规则,并且该规则适用于其他文件,但我文件中的这个特定变量在Welcome.vuelinting 时不断发出警告。

警告:

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并且Game.vuelinting 不会向它们发出警告。

我做错了什么让一个特定的 Vue 文件如此冒犯 linter?!

这是我跑步时npm run servenpm run lint

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

目前我只有welcome.vue的单元测试,它有自己的lint文件,但我已经在其中添加了规则,我仍然收到警告:

测试/单元/eslintrc.js

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

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

解决方案


对于打字稿项目:

.eslintrc.js

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

推荐阅读