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

New rule: at-if-no-null #344

Merged
merged 9 commits into from Aug 26, 2019

Conversation

rambleraptor
Copy link
Contributor

@rambleraptor rambleraptor commented Jul 12, 2019

The sass/linter project had a rule to check for using == null or != null inside @if statements.

This rule replicates that.

@rambleraptor
Copy link
Contributor Author

@nex3

src/rules/at-if-no-null/README.md Outdated Show resolved Hide resolved
}`,
description: "does not use the == null format"
}
],
Copy link
Collaborator

Choose a reason for hiding this comment

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

There could be some more tests with calculations and other conditions inside @if to make sure that there are no false positives/negatives.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nex3 any ideas on good tests or language constructs that users might be using in these if/else statements?

Copy link
Contributor

@nex3 nex3 Jul 26, 2019

Choose a reason for hiding this comment

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

When I'm looking for realistic examples, I often look through big open-source corpuses like https://github.com/angular/components/tree/master/src/material or https://github.com/carbon-design-system/carbon/tree/master/packages.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great idea! I didn't know of any large Sass codebases.

I grepped through carbon-design and came across a common pattern (if $x != null and expr). I made adjustments to the rule for that pattern.

src/rules/at-if-no-null/index.js Outdated Show resolved Hide resolved
@kristerkari kristerkari merged commit 859438c into stylelint-scss:master Aug 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants