Skip to content

typescript-actionテンプレートで作ったGitHub ActionsをFlat Configに対応する

This content is a draft and will not be included in production builds.

公式マイグレーションガイドに従って .eslintrc.json.eslintignoreeslint.config.mjs に移行する。

Terminal window
npx @eslint/migrate-config .eslintrc.json
npm remove @eslint/migrate-config

ただし、このままでは以下のエラーが発生して期待通りに動作しない。

Terminal window
$ npm run lint
ESLint: 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.jsonextends は上から順に適用して、同じ設定項目は後の値で上書きされる。同様に、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,
],
})