Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parsing error: ESLint was configured to run on X However, that TSConfig does not include this file (when project opened from symlinked folder) #1972

Open
fohrloop opened this issue Jan 17, 2025 · 4 comments
Labels
info-needed Issue requires more information from poster

Comments

@fohrloop
Copy link

I'm in the process of setting up my very first JS/TS project. I was getting and error like this in VSCode from the eslint plugin:

Parsing error: ESLint was configured to run on `/testproj/repo/frontend/app/foo.ts` using `parserOptions.project`: <tsconfigRootDir>/tsconfig.node.json
However, that TSConfig does not include this file. Either:
- Change ESLint's list of included files to not include this file
- Change that TSConfig to include this file
- Create a new TSConfig that includes this file and include it in your parserOptions.project
See the typescript-eslint docs for more info: https://typescript-eslint.io/troubleshooting/typed-linting#i-get-errors-telling-me-eslint-was-configured-to-run--however-that-tsconfig-does-not--none-of-those-tsconfigs-include-this-fileeslint

I was trying to reproduce the issue with minimal example, and this is what I got. The reason seems to be somehow related to the fact that the project was opened from a location that is a symlink to another folder.

Steps to reproduce

1 Create the repo

Create a project folder with a "repo" folder (that would contain your git repo) somewhere. In this example, I'm using

/home/USERNAME/projects/testproj/repo

Create a /frontend directory to the repo, and add the following files:

eslint.config.js
import eslint from '@eslint/js';
import globals from 'globals';
import tseslint from 'typescript-eslint';

export default tseslint.config({
  files: ['**/*.{ts,tsx}'],

  extends: [
    eslint.configs.recommended,
    ...tseslint.configs.strictTypeChecked,
    ...tseslint.configs.stylisticTypeChecked,
  ],

  languageOptions: {
    ecmaVersion: 'latest',
    globals: globals.browser,
    parserOptions: {
      project: ['./tsconfig.node.json'],
      tsconfigRootDir: import.meta.dirname,
    },
  },

});
tsconfig.node.json
{
  "include": [
    "app/**/*",
  ],
  "compilerOptions": {
    "composite": true,
    "lib": ["DOM", "DOM.Iterable", "ES2022"],
    "types": ["vite/client"],
    "target": "ES2022",
    "module": "ES2022",
    "moduleResolution": "bundler",
    "jsx": "react-jsx",
    "isolatedModules": true,
    "moduleDetection": "force",
    "noEmit": true,
    "baseUrl": ".",
    "rootDirs": [".", "./.react-router/types"],
    "paths": {
      "~/*": ["./app/*"]
    },
  }
}
package.json
{
  "name": "testproj",
  "version": "1.0.0",
  "author": "",
  "type": "module",
  "license": "MIT",
  "description": "",
  "devDependencies": {
    "@eslint/js": "^9.18.0",
    "@types/eslint__js": "^8.42.3",
    "eslint": "^9.18.0",
    "globals": "^15.14.0",
    "typescript": "^5.7.3",
    "typescript-eslint": "^8.20.0"
  }
}
app/foo.ts
import { something } from 'somewhere';

Install the package. The repo folder should have following contents:

📁 repo/
└─📁 frontend/
  ├─📄 pnpm-lock.yaml
  ├─📄 eslint.config.js
  ├─📄 package.json
  ├─📁 app/
  │ └─📄 foo.ts
  ├─📁 node_modules/
  └─📄 tsconfig.node.json

2 Create a symbolic link to the repo folder

❯ cd /
❯ sudo mkdir testproj
❯ sudo chown USERNAME /testproj
❯ cd testproj/
❯ ln -s /home/USERNAME/projects/testproj/repo/ repo

3 Open the project with VS Code with original and symlinked locations

When opening original folder (/home/USERNAME/projects/testproj/repo) in VS Code:

  • You'll see some as expected but no ESLint Parsing error

Image

When opening symlinked folder (/testproj/repo ) in VS Code:

  • You'll see the unexpected Parsing error: ESLint was configured to run on X However, that TSConfig does not include this file . (this is the problem)
  • If you have a larger project, the same error will be visible on the first word of every .ts/.tsx file in the project.

Image

Version info

  • VsCode extension Identifier: dbaeumer.vscode-eslint
  • VsCode extension Version: 3.0.10

from ESList Output:

[Info  - 2:49:42 PM] ESLint server is starting.
[Info  - 2:49:42 PM] ESLint server running in node v20.18.1
[Info  - 2:49:42 PM] ESLint server is running.
[Info  - 2:49:43 PM] Server process exited successfully
[Info  - 2:49:43 PM] ESLint library loaded from: /home/USERNAME/projects/testproj/repo/frontend/node_modules/.pnpm/[email protected]/node_modules/eslint/lib/api.js
@dbaeumer
Copy link
Member

Thanks for the issue report.

Does the validation happen correctly when you use eslint in the terminal. The error you are seeing indicates that this is a general ESLint setup problem independent of the VSCode extension.

If validation happens correctly in the terminal can you please provide me with a GitHub repository I can clone that demos what you are experiencing.

@dbaeumer dbaeumer added the info-needed Issue requires more information from poster label Jan 20, 2025
@fohrloop
Copy link
Author

When opening the original folder, and running in the "frontend" folder in VS Code terminal, I get (as expected):

repo/frontend on  main [?] is 📦 v1.0.0 via  v22.11.0 
❯ pwd
/home/fohrloop/projects/testproj/repo/frontend

repo/frontend on  main [?] is 📦 v1.0.0 via  v22.11.0 
❯ pnpm eslint .

/home/fohrloop/projects/testproj/repo/frontend/app/foo.ts
  0:1   error  This rule requires the `strictNullChecks` compiler option to be turned on to function correctly  @typescript-eslint/no-unnecessary-condition
  0:1   error  This rule requires the `strictNullChecks` compiler option to be turned on to function correctly  @typescript-eslint/prefer-nullish-coalescing
  1:10  error  'something' is defined but never used                                                            @typescript-eslint/no-unused-vars

✖ 3 problems (3 errors, 0 warnings)

When opening the symlinked folder, and running in the "frontend" folder in VS Code terminal, I get:

repo/frontend on  main [?] is 📦 v1.0.0 via  v22.11.0 took 2s 
❯ pwd
/testproj/repo/frontend

repo/frontend on  main [?] is 📦 v1.0.0 via  v22.11.0 
❯ pnpm eslint .

/home/fohrloop/projects/testproj/repo/frontend/app/foo.ts
  0:1   error  This rule requires the `strictNullChecks` compiler option to be turned on to function correctly  @typescript-eslint/no-unnecessary-condition
  0:1   error  This rule requires the `strictNullChecks` compiler option to be turned on to function correctly  @typescript-eslint/prefer-nullish-coalescing
  1:10  error  'something' is defined but never used                                                            @typescript-eslint/no-unused-vars

✖ 3 problems (3 errors, 0 warnings)

So, exactly the same output in command line, but different behavior in the editor.

I've created a repo with the example reproducing the issue: fohrloop/vscode-eslint-issue-1972.

@dbaeumer
Copy link
Member

Thanks for the repository!

Can you provide me with some steps I should following on the reproducing example.

@fohrloop
Copy link
Author

Sure! I wrote some steps already on the issue itself (under Steps to reproduce). Basically

Setup

  • Clone the repo. I had the original folder inside home folder, so I would create /home/USERNAME/projects/testproj/repo and clone the repo there for maximal reproducibility. (Should have a file called /home/USERNAME/projects/testproj/repo/frontend/app/foo.ts after this)
  • Install the project with npm / pnpm or a similar tool (e.g. pnpm install inside the repo folder)
  • Create a symbolic link to the repo folder as instructed above. For maximal reproducibility, I would use the same folder as in the issue (/testproj)

Reproducing the issue

  • Open VS Code and open the testproj folder from the symlinked folder (so: open /testproj)
  • Open the repo/frontend/app/foo.ts in VS Code from the left side panel to see the contents
  • After ESLint runs (after few seconds), the import text is underlined with red squiggly line. Hover over it to see the error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
info-needed Issue requires more information from poster
Projects
None yet
Development

No branches or pull requests

2 participants