Я пытаюсь добавить объект 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/*"]
}
);
См. документацию здесь.