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

[Rule idea] Forbid defining unused private members #884

Closed
stof opened this issue Nov 14, 2023 · 1 comment · Fixed by #949
Closed

[Rule idea] Forbid defining unused private members #884

stof opened this issue Nov 14, 2023 · 1 comment · Fixed by #949
Labels
Help wanted 🙋 Help is needed New rule 👌 Ready to be created as a new rule

Comments

@stof
Copy link
Contributor

stof commented Nov 14, 2023

Private members (i.e. functions, mixins, variables and selector placeholders) are not exposed outside the module boundary. so if they are not used inside the module, they are unused.

In Sass, private members have a name that start with either - or _ (for variables, this comes after the $ as the $ is not considered to be part of the name. Same for the % prefix of selector placeholders).

This rule should check for usages in the same file. Projects that are still using @import rather than the module-aware @use and @forward are expected to keep this rule disabled (as all files loaded through @import are loaded inside the same module, which makes it impossible to ensure we see all usages of private members).

@kristerkari kristerkari added Help wanted 🙋 Help is needed New rule 👌 Ready to be created as a new rule labels Dec 8, 2023
@kristerkari
Copy link
Collaborator

Sounds like a good idea!

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.

2 participants