簡體   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