使用覆盖在 ESLint 配置中设置文件扩展名

Sco*_*tin 5 javascript eslint

我正在尝试通过overrides在配置中设置来指定 ESLint 应检查的文件扩展名,而不是需要使用--ext命令行标志。该文件说:

\n
\n

默认情况下,ESLint 会检查文件以及与配置条目*.js匹配的文件。overrides

\n
\n

的文档overrides说glob 模式files可以沿着 "src/*.js"or的行"**/*.js",并且这些与 ESLint 配置文件的基本目录相关。这些选项都不能让我使 ESLint 进程文件超出默认值*.js(在我的例子中*.jsx)。

\n

这是我运行 ESLint 时的输出--ext

\n
scott@dev /home/scott/project (main)\n$ npx eslint --ext .js,.jsx ./src\n\n/home/scott/project/src/file.jsx\n  1:1  warning  Unexpected console statement  no-console\n\n\xe2\x9c\x96 1 problem (0 errors, 1 warning)\n
Run Code Online (Sandbox Code Playgroud)\n

正如预期的那样,它会产生警告。但如果没有--ext,ESLint 不会产生任何输出。

\n

目录结构:

\n
/home/scott/project/\n  .eslintrc.js\n  src/\n      file.jsx\n
Run Code Online (Sandbox Code Playgroud)\n

.eslintrc.js

\n
scott@dev /home/scott/project (main)\n$ npx eslint --ext .js,.jsx ./src\n\n/home/scott/project/src/file.jsx\n  1:1  warning  Unexpected console statement  no-console\n\n\xe2\x9c\x96 1 problem (0 errors, 1 warning)\n
Run Code Online (Sandbox Code Playgroud)\n

我需要做什么?

\n