typescript-actionテンプレートで作ったGitHub ActionsをFlat Configに対応する
This content is a draft and will not be included in production builds.
公式マイグレーションガイドに従って .eslintrc.json と .eslintignore を eslint.config.mjs に移行する。
npx @eslint/migrate-config .eslintrc.jsonnpm remove @eslint/migrate-configただし、このままでは以下のエラーが発生して期待通りに動作しない。
$ npm run lintESLint: 9.16.0
Error: Key "rules": Key "filenames/match-regex": Value ["^[a-z0-9-]+(.[a-z0-9-]+)?$"] should NOT have more than 0 items..eslintrc.json の extends は上から順に適用して、同じ設定項目は後の値で上書きされる。同様に、eslint.config.js のConfig Objectも上から順にマージしていき、同じ設定項目があれば後勝ちとなる。
最終的にこうなった。
export default tseslint.config({ ignores: ["**/dist/", "**/lib/", "**/node_modules/", "**/jest.config.js"], extends: [ eslint.configs.recommended, ...tseslint.configs.recommended, github.getFlatConfigs().recommended, github.getFlatConfigs().typescript, ],})