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

Local config seems to be ignored 🤷 #1831

Open
RobinKnipe opened this issue Apr 16, 2024 · 3 comments
Open

Local config seems to be ignored 🤷 #1831

RobinKnipe opened this issue Apr 16, 2024 · 3 comments
Labels
info-needed Issue requires more information from poster

Comments

@RobinKnipe
Copy link

RobinKnipe commented Apr 16, 2024

Running any combination of eslint through via the terminal works as expected, picking up the project config correctly, but the vscode extension just moans about:

Parsing error: ESLint was configured to run on `src/services/user.service.ts` using `parserOptions.project`: <tsconfigRootDir>/tsconfig.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/linting/troubleshooting#i-get-errors-telling-me-eslint-was-configured-to-run--however-that-tsconfig-does-not--none-of-those-tsconfigs-include-this-file

This same error appears at the beginning of the every project file, regardless of location, and so no actual linting takes place. I've tried various ways to force the extension to pick up the project config, but sadly nothing has worked. I would expect the extension to simply honour the project config files without further customisation, but instead the extension just seems to ignore all configuration (whether set in project files or VSCode settings).

Config files

//./.eslintrc.js
module.exports = {
  extends: '@loopback/eslint-config',
  parserOptions: {
    project: './tsconfig.json',
  },
};
//./tsconfig.json
{
  "$schema": "http://json.schemastore.org/tsconfig",
  "extends": "@loopback/build/config/tsconfig.common.json",
  "compilerOptions": {
    "typeRoots": ["./src/typing", "./node_modules/@types"],
    "rootDir": "src",
    "outDir": "dist",
    "experimentalDecorators": true
  },
  "exclude": ["./src/typing", "./node_modules/@types"],
  "include": ["src"]
}

Even trying to add overrides in the VSCode settings don't seem to have any effect:

//./.vscode/settings.json
{
  "eslint.options": {"overrideConfigFile": ".eslintrc.js"},
  "eslint.runtime": "./node_modules/.bin/lb-eslint",
  "eslint.debug": true,
  "eslint.nodePath": "/usr/local/bin/node"
}

ESLint output:

[Info  - 11:27:39] ESLint server is starting.
[Info  - 11:27:39] ESLint server running in node v18.18.2
[Info  - 11:27:39] ESLint server is running.
[Info  - 11:27:39] ESLint library loaded from: ./node_modules/eslint/lib/api.js
[Error - 11:27:40] Server process exited with code 0.

Note: no debug output, wrong node version, etc.

Expected result (from terminal)

$ npx eslint src

...

./src/services/user.service.ts
   21:8   error  Import name `_` must match one of the following formats: camelCase  @typescript-eslint/naming-convention
  185:15  error  'user.id' is assigned to itself                                     no-self-assign

✖ 10 problems (10 errors, 0 warnings)
@dbaeumer
Copy link
Member

Can you please provide me with a GitHub repository I can clone with a minimal setup that demos what you are seeing. Otherwise it is hard to tell since something like this can happen due to many things

@dbaeumer dbaeumer added the info-needed Issue requires more information from poster label Apr 17, 2024
@sahilanguralla
Copy link

sahilanguralla commented May 15, 2024

I am seeing the same issue. I am not sure from where it is picking this node version specifically. I don't have it installed on my system. I tried using eslint.nodePath to hardcode the version to v20.11.1 but it didn't respect the configuration. I tried creating a new react app using npx create-react-app and it still behaves the same

ESLint debug output:

[Info - 6:46:48 PM] ESLint server is starting.
[Info - 6:46:49 PM] ESLint server running in node v18.18.2
[Info - 6:46:49 PM] ESLint server is running.
[Error - 8:31:24 AM] Server process exited with code 0.
[Info - 6:46:50 PM] ESLint library loaded from: /Users/sahil/repos/test-app/node_modules/eslint/lib/api.js

.vscode/settings.json:

{
"eslint.nodePath": "/Users/sahil/.nvm/versions/node/v20.11.1/bin/node"
}

@dbaeumer
Copy link
Member

@sahilanguralla it uses the node version that comes with VS Code. If you want to use a custom node version you need to set eslint.runtime. The nodePath value points to pathes to load node modules from.

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

3 participants