我正在使用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
和Game.vue
的变量都得分不足,并且棉絮不会向它们发出警告。
this.show_welcome = true;
this.current_answer = '';
我怎么做才能使一个特定的Vue文件严重侵犯短绒呢?!
这是我运行npm run serve
或npm run lint
的时候
注意:我以为我已经解决了,但还是没有...
目前,我仅对welcome.vue进行单元测试,它具有它自己的lint文件,但是我在其中添加了规则,但仍然收到警告:
tests / unit / eslintrc.js
module.exports = {
env: {
jest: true,
},
rules: {
camelcase: ['warn', { properties: 'never' }],
},
};
答案 0 :(得分:0)
如果您不希望eslint检查变量大小写,只需在camelcase: 'off'
中用.eslintrc.js
将其关闭。
答案 1 :(得分:0)
对于打字稿项目:
.eslintrc.js
{
rules: {
'@typescript-eslint/camelcase': 'off'
}
}