できない.dev

ESLint「TSConfig does not include this file」の原因と直し方

TSConfig does not include this file は、lint 対象が tsconfig の範囲外だと出る。
projectService に切り替えるか、対象を含む tsconfig を指定すれば直る。

公開: 更新:

症状できない · exit 1
npx eslint extra.ts
/tmp/tmp.zQy0vKLHmB/extra.ts
  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): extra.ts

✖ 1 problem (1 error, 0 warnings)
解決後できた · exit 0
npx eslint extra.ts

2026-11-16 に node:20(ESLint 9.39.5 / Node.js 20.20.2) で実際に打って取った出力。検証環境の詳細

要約

型情報を使うルール(typed linting)を有効にすると、Parsing error: ESLint was configured to run on <file> ... however that TSConfig does not include this file が出ることがある。
これは、そのファイルが parserOptions.project で指定した tsconfig の対象範囲に入っていないことが原因である。
最も手軽な解決は、typescript-eslint v8 の projectService に切り替えることだ。

実行例

node:20 環境で上記の手順を動かすと、parserOptions.project の対象外になった extra.ts で、終了コード 1 の Parsing error が発生した。
tsconfig.eslint.json で include を拡張すると、終了コードは 0 になった。

v9.39.5
$ npx eslint extra.ts
/tmp/tmp.zQy0vKLHmB/extra.ts
  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): extra.ts
 
✖ 1 problem (1 error, 0 warnings)
$ echo $?
1
$ npx eslint extra.ts
$ echo $?
0

— 2026-11-16 時点の出力

検証環境Node.js 20.20.2 / npm 10.8.2 / Python 3.11.2 / 2026-11-16 検証(ほか 2 件)
検証日
実行環境
node:20 Debian GNU/Linux 12 (bookworm)
バージョン
  • Node.js 20.20.2
  • npm 10.8.2
  • Python 3.11.2
  • Git 2.39.5
  • ESLint 9.39.5

この記事の「実行例」は、上記の環境で実際にコマンドを実行して得られた出力をそのまま掲載しています。 再現手順はリポジトリの検証スクリプトとして管理し、定期的に再実行して出力を更新しています。

解決策

1. projectService に切り替える(推奨)

typescript-eslint v8 以降は、tsconfig を自動で解決する projectService が推奨である。

// eslint.config.js
import tseslint from 'typescript-eslint'
 
export default tseslint.config({
  languageOptions: {
    parserOptions: {
      projectService: true,
      tsconfigRootDir: import.meta.dirname,
    },
  },
})

Typed Linting のトラブルシューティング(新しいタブで開く) でも、まず projectService を試すことが案内されている。

2. lint 専用の tsconfig を用意する

範囲をきめ細かく制御したいときは、tsconfig.eslint.json を作って対象を広げる。

{
  "extends": "./tsconfig.json",
  "include": ["src", "scripts", "*.config.ts"]
}
parserOptions: {
  project: './tsconfig.eslint.json',
}

3. 型情報が不要なファイルは外す

設定ファイルなど型付きルールが要らないファイルは、files で範囲を分けて型なし設定を当てる。

export default tseslint.config(
  { files: ['**/*.ts'], extends: [...tseslint.configs.recommendedTypeChecked] },
  { files: ['*.config.js'], extends: [tseslint.configs.disableTypeChecked] },
)

対象ファイルだけに型付きルールを当てることで、TSConfig does not include 系のエラーを根本から避けられる。

よくある原因

  1. lint するファイルが include の範囲外にある。
    tsconfig.json の include が src 配下だけなのに、ルートの設定ファイルや scripts/ 配下を lint しようとしている。
  2. project の指す範囲が狭い。
    parserOptions.project に渡した tsconfig が、一部のファイルしかカバーしていない。
  3. プロジェクト外のファイルを lint している。
    eslint.config.js 自身など、ビルド対象に含めない JS / TS を型付きルールで lint している。
  4. モノレポ構成で、ルートと各パッケージの tsconfig の関係が整理されていない。
    そのため、対象から漏れるファイルがある。