简体   繁体   English

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

[英]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.

相关问题 eslintrc 中的 ESLint 配置无效:- 意外的顶级属性“import/no-extraneous-dependencies” - ESLint configuration in .eslintrc is invalid: - Unexpected top-level property “import/no-extraneous-dependencies” 如何获取.eslintrc.js忽略所有无js文件 - How to get .eslintrc.js ignore all none js files ESLint 8.31.0“错误:无法加载在‘.eslintrc.js » eslint-config-standard’中声明的插件‘import’:找不到模块‘array.prototype.flatmap’” - ESLint 8.31.0 "Error: Failed to load plugin 'import' declared in '.eslintrc.js » eslint-config-standard': Cannot find module 'array.prototype.flatmap" .eslintrc.js键,带“-”(破折号) - .eslintrc.js keys with “-” (dash) 是什么导致我的GULP gulpfile.js文件中出现“无效的顶级表达式”错误? - What is causing this “invalid top-level expression” error in my GULP gulpfile.js file? 如何使用 allow: 带有 eslintrc.js 的选项 - How to use allow: options with eslintrc.js React Native 中的“.eslintrc.js”是什么? - What is “.eslintrc.js” in React Native? npm init nuxt-app 结果出现问题“无法加载在‘.eslintrc.js » @nuxtjs/eslint-config’中声明的插件‘unicorn’” - npm init nuxt-app results a problem "Failed to load plugin 'unicorn' declared in '.eslintrc.js » @nuxtjs/eslint-config'" 必须使用import加载ES Module.eslintrc.js - Must use import to load ES Module .eslintrc.js Eslint 报告依赖配置的 eslintrc 配置问题 - Eslint reporting eslintrc configuration problems for dependency configs
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM