繁体   English   中英

错误:.eslintrc.js 中的 ESLint 配置无效:-意外的顶级属性“文件”

[英]Error: ESLint configuration in .eslintrc.js is invalid: - Unexpected top-level property "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',
  },
};

但是当我的预提交运行时出现以下错误:

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".

根据您的命令行选项( --ext等),顶级规则和配置适用于所有匹配的文件

当您想要指定覆盖适用于哪些文件时,您只能在嵌套的"overrides"块中使用"files"

请参阅https://eslint.org/docs/latest/user-guide/configuring/configuration-files#how-do-overrides-work

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM