Skip to content

Differences between eslint CLI and vscode linting #3180

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

Open
chelentos opened this issue Apr 22, 2025 · 7 comments
Open

Differences between eslint CLI and vscode linting #3180

chelentos opened this issue Apr 22, 2025 · 7 comments

Comments

@chelentos
Copy link

Hello!

I've upgraded to eslint@9 in my project and have some issues with linting.

Linting of import/order errors is different in CLI/vscode.

What i'm getting in vscode:

Image

what i have in terminal:

Image

Maybe it's caused by several eslint configs or aliases, but i think i'm using all needed settings for this.

I've made repo with reproduction of this problem: https://github.com/chelentos/vscode-eslint-repr

There are vscode settings in README.

Configs for eslint you can find here: https://github.com/gravity-ui/eslint-config
Import/order config: https://github.com/gravity-ui/eslint-config/blob/main/import-order.js

I've already created issue in vscode plugin repo, but maybe you can help me too.

@ljharb
Copy link
Member

ljharb commented Apr 22, 2025

The CLI is the source of truth, so if vscode is different, it's the one that's broken. I will definitely try to take a look when I can, thanks for the repro repo!

@chelentos
Copy link
Author

chelentos commented Apr 22, 2025

@ljharb

The CLI is the source of truth, so if vscode is different, it's the one that's broken

I think yes, but...

It seems to me that vscode linting is more accurate. It's trying to divide external lib and internal alias that looks like external lib.

@JounQin
Copy link
Collaborator

JounQin commented Apr 22, 2025

I didn't read the repro actually, but there could be a chance that resolver doesn't know about correct ESLint cwd from VSCode because there in no such info passed into resolver.

See also #2108

@chelentos
Copy link
Author

chelentos commented Apr 28, 2025

@ljharb @JounQin

FYI

The problem might be in resolving ts aliases not as internal.

I've tried to add this code in config in repro repo:

settings: {
    'import/internal-regex': '^@my-test-package/'
}

and the difference in linting has gone.

Where should I look to make possible fix?

@JounQin
Copy link
Collaborator

JounQin commented Apr 28, 2025

@chelentos You're just by passing the resolving step and mark those packages as internal directly, it's not a fix, just a workaround.

function isInternalRegexMatch(name, settings) {
const internalScope = settings && settings['import/internal-regex'];
return internalScope && new RegExp(internalScope).test(name);
}

The root cause is already described at #2108, and the fix #2519 is alreay there for a long time. @ljharb

@chelentos
Copy link
Author

@JounQin

Could you help me one more time please.

Is there any 100% workaround of this problem now? To not specifying every ts alias as internal regex.

@JounQin
Copy link
Collaborator

JounQin commented Apr 28, 2025

The fix is already there: #2519, no other workarounds.

I'll adopt my our PR into https://github.com/un-ts/eslint-plugin-import-x ASAP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants