javascript - 使用覆盖在 ESLint 配置中设置文件扩展名
问题描述
我试图通过overrides
在配置中设置而不是需要使用--ext
命令行标志来指定 ESLint 应该检查的文件扩展名。文档说:
默认情况下,ESLint 会检查
*.js
文件以及与overrides
配置条目匹配的文件。
for的文档overrides
说,glob 模式files
可以遵循 "src/*.js"
or"**/*.js"
并且这些是相对于您的 ESLint 配置文件的基本目录的。这些选项都不适用于我使 ESLint 进程文件超出默认值*.js
(在我的情况下*.jsx
)。
这是我运行 ESLint 时的输出--ext
:
scott@dev /home/scott/project (main)
$ npx eslint --ext .js,.jsx ./src
/home/scott/project/src/file.jsx
1:1 warning Unexpected console statement no-console
✖ 1 problem (0 errors, 1 warning)
正如预期的那样,它会产生一个警告。但是没有--ext
,ESLint 不会产生任何输出。
目录结构:
/home/scott/project/
.eslintrc.js
src/
file.jsx
.eslintrc.js
:
const rules = {
// ...
};
module.exports = {
// ...
overrides: [
{
files: [ "*.jsx" ], // also doesn't work with "src/**/*.jsx", "**/*.jsx"
rules: rules
}
],
rules: rules
};
我需要做什么?
解决方案
推荐阅读
- arrays - 将 2 个范围组合成一个数组并过滤
- python - 为什么我们可以为 OrderedDict 的对象创建属性,但不能为 Dict 创建属性?
- javascript - 代码无法识别 ColumnDataSource 是什么
- synology - 通过命令行获取 gofile.me - Synology
- reactjs - GraphQL Apollo 错误请求
- machine-learning - PyTorch tensor.to(device) 用于字典列表
- php - laravel 中的更改顺序
- c# - C# 发送电子邮件错误。如何用这种方式发送电子邮件?
- java - 我应该如何插入由 JPA 组合键组成的表中?
- javascript - 我想做的拆分将是 Enter (discord.js)