我正在尝试将
ignores
对象添加到 typescript-eslint 配置
我想这可以解决问题:
import eslint from "@eslint/js";
import tseslint from "typescript-eslint";
export default tseslint.config(
eslint.configs.recommended,
...tseslint.configs.recommended,
).push({
ignores: ["build/*"]
});
但是,当运行
npx eslint .
时,它会产生以下错误:
Oops! Something went wrong! :(
ESLint: 8.57.0
TypeError: All arguments must be objects.
at ObjectSchema.merge (/Users/oleersoy/Github/fs-typescript-starter/node_modules/@humanwhocodes/object-schema/src/object-schema.js:234:19)
at /Users/oleersoy/Github/fs-typescript-starter/node_modules/@humanwhocodes/config-array/api.js:935:42
at Array.reduce (<anonymous>)
at FlatConfigArray.getConfig (/Users/oleersoy/Github/fs-typescript-starter/node_modules/@humanwhocodes/config-array/api.js:934:39)
at FlatConfigArray.isFileIgnored (/Users/oleersoy/Github/fs-typescript-starter/node_modules/@humanwhocodes/config-array/api.js:962:15)
at /Users/oleersoy/Github/fs-typescript-starter/node_modules/eslint/lib/eslint/eslint-helpers.js:312:49
at Array.reduce (<anonymous>)
at entryFilter (/Users/oleersoy/Github/fs-typescript-starter/node_modules/eslint/lib/eslint/eslint-helpers.js:299:28)
at Object.isAppliedFilter (/Users/oleersoy/Github/fs-typescript-starter/node_modules/@nodelib/fs.walk/out/readers/common.js:12:31)
at AsyncReader._handleEntry (/Users/oleersoy/Github/fs-typescript-starter/node_modules/@nodelib/fs.walk/out/readers/async.js:86:20)
我们应该如何扩展配置来添加
ignores
?
config
期望有对象; push
作用于数组。
只需添加附加规则对象即可:
import eslint from "@eslint/js";
import tseslint from "typescript-eslint";
export default tseslint.config(
eslint.configs.recommended,
...tseslint.configs.recommended,
{
ignores: ["build/*"]
}
);
请参阅此处了解文档。