[英]Error: ESLint configuration in .eslintrc.js is invalid: - Unexpected top-level property "files"
I want to specify which files are to be linted in my eslintrc.js, so I've added files: ...我想在我的 eslintrc.js 中指定要检查哪些文件,所以我添加了文件:...
module.exports = {
extends: [
'react-app',
'react-app/jest',
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'prettier',
],
files: ['*.ts', '*.jsx', '*.ts', '*.tsx'],
parser: '@typescript-eslint/parser',
parserOptions: {
project: './tsconfig.json',
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 'latest',
sourceType: 'module',
},
rules: {
'testing-library/no-node-access': 'off',
},
};
But getting the following error when my precommit runs:但是当我的预提交运行时出现以下错误:
precommit: BABEL_ENV=development eslint src --ext .js,.jsx,.ts,.tsx --fix'*.ts', '*.tsx'
Error: ESLint configuration in .eslintrc.js is invalid:
- Unexpected top-level property "files".
The top-level rules and config apply to all the matched files according to your command line options ( --ext
etc.)根据您的命令行选项(
--ext
等),顶级规则和配置适用于所有匹配的文件
You only use "files"
inside nested "overrides"
blocks when you want to specify which files the overrides apply to.当您想要指定覆盖适用于哪些文件时,您只能在嵌套的
"overrides"
块中使用"files"
。
See https://eslint.org/docs/latest/user-guide/configuring/configuration-files#how-do-overrides-work请参阅https://eslint.org/docs/latest/user-guide/configuring/configuration-files#how-do-overrides-work
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.