admin管理员组文章数量:1310616
I want to specify which files are to be linted in my eslintrc.js, so I've added files: ...
module.exports = {
extends: [
'react-app',
'react-app/jest',
'eslint:remended',
'plugin:@typescript-eslint/remended',
'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 premit runs:
premit: 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".
I want to specify which files are to be linted in my eslintrc.js, so I've added files: ...
module.exports = {
extends: [
'react-app',
'react-app/jest',
'eslint:remended',
'plugin:@typescript-eslint/remended',
'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 premit runs:
premit: 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".
Share
Improve this question
asked Jul 28, 2022 at 14:09
Kevin HamKevin Ham
711 gold badge1 silver badge4 bronze badges
2 Answers
Reset to default 6The top-level rules and config apply to all the matched files according to your mand line options (--ext
etc.)
You only use "files"
inside nested "overrides"
blocks when you want to specify which files the overrides apply to.
See https://eslint/docs/latest/user-guide/configuring/configuration-files#how-do-overrides-work
I have a new version of eslint.config.js
, and I too get the error.
I found an answer on the question: How can i fix "- Unexpected top-level property "files"."
To fix this issue, the “files” property needs to be included in the “overrides” property instead of the top-level property. Below is an example of how to correctly include the “files” property in the “overrides” property:
本文标签:
版权声明:本文标题:javascript - Error: ESLint configuration in .eslintrc.js is invalid: - Unexpected top-level property "files" - 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741795392a2397908.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论