eslintでdistやlibを除外したければ個別に書く
setup-plan9port をアップデートしているとき、以下の警告に遭遇した。
$ npm run lint
/home/lufia/src/setup-plan9port/dist/index.js 0:0 error Parsing error: "parserOptions.project" has been provided for @typescript-eslint/parser.The file was not found in any of the provided project(s): dist/index.jsこれは eslint が出力しているもので、エラーの内容はともかく dist/index.js といった成果物ディレクトリ以下のファイルがlintの対象となっているのがおかしい。
このとき、 eslint.config.mjs は以下のような設定になっていた。
export default tseslint.config({ ignores: ["**/dist", "**/node_modules"], extends: [ eslint.configs.recommended, ...tseslint.configs.recommended, ],})typescript-actionテンプレートで作ったGitHub ActionsをFlat Configに対応するときにも眺めたが、ignores に /dist が含まれるのでうまく無視されるものだと思っていた。しかし実際は、ルールごとに ignores が適用されるので、すべてのルールで無視したい場合は個別のエントリとして書く必要があるらしい。
なので最終的には分離させた。
export default tseslint.config({ ignores: ["**/dist", "**/node_modules"],},{ extends: [ eslint.configs.recommended, ...tseslint.configs.recommended, ],})