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

More permissive import/no-unassigned-import #376

Closed
jamestalmage opened this issue Feb 2, 2019 · 8 comments · Fixed by #430
Closed

More permissive import/no-unassigned-import #376

jamestalmage opened this issue Feb 2, 2019 · 8 comments · Fixed by #430

Comments

@jamestalmage
Copy link
Contributor

jamestalmage commented Feb 2, 2019

Currently, you can't do the following:

require('any-observable/register/zen');

I'm overriding the default rules as follows. I think it would make a sensible default:

{
	"import/no-unassigned-import": [
		"error",
		{
			"allow": [
				"@babel/polyfill",
				"**/register",
				"**/register/**"
			]
		}
	]
}
@sindresorhus
Copy link
Member

Agreed. PR welcome.

@fregante
Copy link
Member

fregante commented Feb 28, 2020

Can/should this feature allow any import of packages that have polyfill in their names? Not just babel's

@sindresorhus
Copy link
Member

@fregante Do you have any examples? The convention, except for Babel, is to use package-name/register, which we now support.

@fregante
Copy link
Member

fregante commented Mar 1, 2020

https://github.com/mozilla/webextension-polyfill

I guess /register is more common for node-native packages than web ones

@sindresorhus
Copy link
Member

PR welcome if you care enough

@fregante
Copy link
Member

fregante commented Mar 3, 2020

I usually disable this rule completely because there are too many exceptions, I just thought Babel's could be made more generic

@sindresorhus
Copy link
Member

What other exceptions have you encountered? I have honestly never encountered any time I needed to manually disable it.

@fregante
Copy link
Member

fregante commented Mar 3, 2020

Refined GitHub loads its features this way, so it’s disabled there. Many of my projects where “features” are self-contained files use unassigned imports. This isn’t something that can be whitelisted, it’s just at odds with the rule’s reasoning (which I assume is “modules shouldn’t have side effects”)

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

Successfully merging a pull request may close this issue.

3 participants