vue.js - 禁用规则时,vue-cli linting 抛出驼峰警告
问题描述
我正在使用 vue-cli 构建一个应用程序,使用 airbnb 规则进行 lint。
尽管我在我的.eslintrc.js
配置文件中添加了一条规则,并且该规则适用于其他文件,但我文件中的这个特定变量在Welcome.vue
linting 时不断发出警告。
警告:
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',
},
};
我的应用程序的结构如下:
- 应用程序.vue
- 欢迎.vue
- 游戏.vue
两者都有分数低于标准的变量,App.vue
并且Game.vue
linting 不会向它们发出警告。
- 应用程序.vue:
this.show_welcome = true;
- 游戏.vue:
this.current_answer = '';
我做错了什么让一个特定的 Vue 文件如此冒犯 linter?!
这是我跑步时npm run serve
或npm run lint
注意:我以为我已经解决了,但仍然没有......
目前我只有welcome.vue的单元测试,它有自己的lint文件,但我已经在其中添加了规则,我仍然收到警告:
测试/单元/eslintrc.js
module.exports = {
env: {
jest: true,
},
rules: {
camelcase: ['warn', { properties: 'never' }],
},
};
解决方案
对于打字稿项目:
.eslintrc.js
{
rules: {
'@typescript-eslint/camelcase': 'off'
}
}
推荐阅读
- foreach - UML 序列图是否有 forEach 构造的约定
- android - 我们如何改变在android画中画模式下添加的drawable的颜色
- flutter - 有没有一种方法可以帮助键盘正确聚焦在 textformfield 上
- javascript - 上传多个图像不会添加到 FormData
- html - 如何修复响应大小的砌体
- powershell - PowerShell 中的 Web 客户端请求期间发生异常。如何修复它?
- javascript - 如何使用 SweetAlert2 在 PHP 中进行删除确认框?
- ios - 为什么 iOS 中点击手势识别器的界面构建器操作不触发?
- java - 如何使用递归找到数组的最后一个元素?
- batch-file - 为什么来自用户的输入值在批处理文件中的代码中不起作用?