带有--Rule选项的ESLint CLI [英] ESLint CLI with --rule option
本文介绍了带有--Rule选项的ESLint CLI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
将ESLint CLI与--rule
选项一起使用时遇到问题。
# This is what I tried
eslint --rule "{no-console: error}" --fix-dry-run .
导致以下错误:
使用选项‘RULE’的值无效-需要类型对象,收到的值为:{no-控制台:.
--rule
选项的正确方式是什么?我已在本地安装了ESLint,并使用npx
运行它。
- Node.js版本14.15.0
- ESLint 7.14.0版
- 操作系统Windows 10
.eslintrc.js
module.exports = {
env: {
browser: true,
es2021: true,
node: true
},
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:vue/vue3-recommended',
'prettier',
'prettier/vue'
],
parser: 'vue-eslint-parser',
parserOptions: {
parser: '@typescript-eslint/parser',
ecmaVersion: 12,
sourceType: 'module'
},
plugins: ['@typescript-eslint'],
rules: {
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-explicit-any': 'off'
}
};
推荐答案
它似乎是npx
和Windows的错误。this issue删除--rule
中的空格可解决问题:
npx eslint --rule "no-console:error" --fix-dry-run .
这篇关于带有--Rule选项的ESLint CLI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文