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

Named code blocks confuse relative import paths #1415

Closed
Conduitry opened this issue Jul 14, 2019 · 10 comments
Closed

Named code blocks confuse relative import paths #1415

Conduitry opened this issue Jul 14, 2019 · 10 comments

Comments

@Conduitry
Copy link

Hey there! I'm the author of a processor plugin that produces named code blocks, which are confusing this plugin, because the new virtual path for the js files is now one additional layer down.

I'm not sure whether this plugin is something that was considered when named code blocks were added in ESLint 6, or whose responsibility it's going to be to fix this. I'll gladly make changes to my plugin if that's what it takes, but right now I don't know what those would be.

Thanks!

See also:

@ljharb
Copy link
Member

ljharb commented Jul 14, 2019

What are named code blocks? Is it a JavaScript feature I’m unaware of?

@Conduitry
Copy link
Author

It's a new feature with processors in ESLint 6 - https://eslint.org/docs/user-guide/configuring#specifying-processor

@ljharb
Copy link
Member

ljharb commented Jul 14, 2019

So these are nonexistent virtual files that are different from the only previous instance of these, which is “stdin” - looks like this is something eslint v6 has forced every plugin to potentially handle - since my assumption is that a plugin’s visitors get called on this code block as if it was a normal file.

One option is to bail out early on every cross-file rule; but a better one would be to treat them like normal files. A PR to fix this, with test cases, would be appreciated.

@Conduitry
Copy link
Author

I'm not sure how a plugin would be able to distinguish between a virtual named block file, and a file that's inside a folder whose name simply contains a .. Should it just check whether the current 'file' actually exists in the filesystem? Is that something that would happen here?

@ljharb
Copy link
Member

ljharb commented Jul 14, 2019

eslint itself may provide that information in the file’s context; I’m not sure yet.

@Conduitry
Copy link
Author

I don't believe the necessary information is currently available. Opened eslint/eslint#11989

@Conduitry
Copy link
Author

Can this be closed now? It sounds like #2160 should have addressed this.

@ljharb
Copy link
Member

ljharb commented Sep 9, 2021

I think you're right.

@ljharb ljharb closed this as completed Sep 9, 2021
@divStar
Copy link

divStar commented Sep 17, 2022

Excuse me for asking, but do the restrictions (especially the ones for eslint-import-plugin) from https://github.com/sveltejs/eslint-plugin-svelte3/blob/master/OTHER_PLUGINS.md#eslint-plugin-import still apply? I ask, because import/no-unresolved still throws errors where I wouldn't expect any (because the application actually works and uses the imports successfully).

@ljharb
Copy link
Member

ljharb commented Sep 17, 2022

If not, please file a new issue - note you may need a svelte-specific import resolver.

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