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

Add a lint for an explicit namespace that's the same as the default #445

Closed
nex3 opened this issue Jan 21, 2020 · 2 comments · Fixed by #848
Closed

Add a lint for an explicit namespace that's the same as the default #445

nex3 opened this issue Jan 21, 2020 · 2 comments · Fixed by #848
Labels
Help wanted 🙋 Help is needed New rule 👌 Ready to be created as a new rule

Comments

@nex3
Copy link
Contributor

nex3 commented Jan 21, 2020

If a user writes something like @use "foo" as foo, the as foo is totally redundant since it's the same as the default namespace that the @use rule would provide on its own. It would be nice to have a lint for this case.

@kristerkari kristerkari added New rule 👌 Ready to be created as a new rule Help wanted 🙋 Help is needed labels Jan 28, 2020
@airyboy
Copy link

airyboy commented Apr 8, 2020

Any ideas for the name of this rule?
at-use-no-redundant-alias?

@thibaudcolas
Copy link
Contributor

Based on the Sass @use documentation and the Sass Module System spec, I think a good name would be at-use-no-redundant-namespace. I quite like "alias" too, but the as-clause is not described with that term anywhere in the official documentation.


It took me a few months of occasional @use usage to discover that there was in fact a default namespace, extracted from the last component of the import URL. I’d almost be tempted to ask for the opposite rule (or a true/false at-use-redundant-namespace) to mandate the redundancy –  I find this automatic default very un-intuitive since the import path otherwise looks like any other string.

It might just be a matter of getting used to / seeing it used more / having better syntax highlighting that highlights the last component of the path as an identifier – but for now, I’d rather do:

@use "src/corners" as corners;
@use "sass:math" as math;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Help wanted 🙋 Help is needed New rule 👌 Ready to be created as a new rule
Development

Successfully merging a pull request may close this issue.

4 participants