Skip to content

Find correct linter instance also in case of multiple folders in workspace #97

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

Merged
merged 3 commits into from
Apr 23, 2021

Conversation

CherryDT
Copy link
Contributor

@CherryDT CherryDT commented Mar 7, 2021

This fixes #96

@CherryDT
Copy link
Contributor Author

CherryDT commented Mar 7, 2021

I think the tests failed because of #94 and not anything I did...

throw new Error('Could not find ESLint Linter in require cache');
}
// there may be more than one instance in case of multiple folders in the workspace
// try to find the one that's inside the same node_modules directory as this plugin
// if not found for some reason, assume it's the last one in the array
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you elaborate why you pick the last one in the array as fallback? The previous behavior was picking the first, maybe we should keep this as fallback behavior.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's because the extension will be loaded only when needed, i.e. when a Svelte file has to be linted for the first time. This also applies to ESLint itself though, so the chances are high that in the case like I had, where I first opened a JS file from the server project (loading the ESLint instance in the server directory and no Svelte plugin instance) and only afterwards a Svelte file from the frontend project (loading the second ESLint instance in the frontend directory and this time also the Svelte plugin instance), the right ESLint that belongs to the project in question will be loaded more recently.

Of course this still won't work if the order happens to be something like JS file in frontend in another directory where eslintrc doesn't specify the Svelte plugin -> JS file in server -> Svelte file. But this is less likely in my opinion. What do you think?

@CherryDT
Copy link
Contributor Author

CherryDT commented Apr 22, 2021

@dummdidumm Hi, is there any update on this? I have addressed your comments.

Copy link
Member

@dummdidumm dummdidumm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Conduitry looks good to me. If for you, too, could you merge?

@Conduitry Conduitry merged commit a2b28c4 into sveltejs:master Apr 23, 2021
@Conduitry
Copy link
Member

This has been released in 3.2.0. Thank you!

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

Successfully merging this pull request may close these issues.

Configuration is ignored when workspace has multiple folders and a file from a folder without this plugin is linted first
3 participants