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
Replace *-whitelist/*-blacklist/*-requirelist rules with *-allowed-list/*-disallowed-list/*-required-list rules #4845
Conversation
@kevindew Thank you for getting the ball rolling with this.
Excellent. Regardless of the final route we decide on, we'll need to go about it this way.
I've made some suggestions about the implementation route and renaming over in the issue. |
This applies a full rename across the repository to reflect that the term "blacklist" is controversial in the tech community and that using the term "disallowed-list" is more explicit in it's purpose.
28e1a31
to
cbdf5de
Compare
Thanks, the clarity in your suggestions was super helpful. I've now amended this in line with them, do let me know if I've misinterpreted any. I wasn't too sure of what testing approach, if any, to take with the aliased rules and put this together where I might benefit from some pointers to precedence if it's not sufficiently consistent with this codebase. I also wasn't sure if this risks being a BC break given that violations for a whitelist rule will be returned under a new rule name. For example, a unit-whitelist violation will be raised as a unit-allowed-list violation. I expect you'll know better than me if that is considered part of the API. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kevindew Thanks for putting all the legwork into this one. It's looking great.
I've requested:
- some very minor nitpicks
- the regeneration of the example.png screenshot
I wasn't too sure of what testing approach,
Tests look great.
I also wasn't sure if this risks being a BC break given that violations for a whitelist rule will be returned under a new rule name.
I think we're good. The only place outside of a config where the rule names are used is within the checkAgainstRule
plugin utility. It would be great if we could add a test ensuring the renamed rule is in the warning when an alias is used.
docs/user-guide/rules/list.md
Outdated
- [`function-url-scheme-blacklist`](../../../lib/rules/function-url-scheme-blacklist/README.md): Specify a blacklist of disallowed URL schemes. | ||
- [`function-url-scheme-whitelist`](../../../lib/rules/function-url-scheme-whitelist/README.md): Specify a whitelist of allowed URL schemes. | ||
- [`function-whitelist`](../../../lib/rules/function-whitelist/README.md): Specify a whitelist of allowed functions. | ||
- [`function-url-scheme-disallowed-list`](../../../lib/rules/function-url-scheme-disallowed-list/README.md): Specify a list of disallowed URL schemes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's alphabetize this and the next line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops, nice spot 👍
lib/__tests__/integration.test.js
Outdated
@@ -141,6 +143,19 @@ it('Scss integration test', () => { | |||
}); | |||
}); | |||
|
|||
it('Rule aliasing integration test', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it('Rule aliasing integration test', () => { | |
it('rule aliasing integration test', () => { |
Let's use a lower case here to be consistent with the majority of other descriptions (the capitalised "Scss..." description above is more an exception than the norm).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, done
|
||
const messages = ruleMessages(ruleName, { | ||
expected: (property, atRule) => `Expected property "${property}" for at-rule "${atRule}"`, | ||
}); | ||
|
||
function rule(primary) { | ||
function rule(list) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for making this consistent.
@@ -12,16 +12,16 @@ const ruleMessages = require('../../utils/ruleMessages'); | |||
const validateOptions = require('../../utils/validateOptions'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file shifts from whitelist to disallowed list, and vice-versa for its twin. However, the logic also shifts in both rules, so things work out in the end.
I think we can roll with it, rather than try to unpick it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This just seems to be GitHub becoming confused when merging the diffs of multiple commits. In the individual commits this rule doesn't shift.For example:
rename lib/rules/{declaration-property-unit-blacklist => declaration-property-unit-disallowed-list}/README.md (91%)
rename lib/rules/{declaration-property-unit-blacklist => declaration-property-unit-disallowed-list}/__tests__/index.js (100%)
rename lib/rules/{declaration-property-unit-blacklist => declaration-property-unit-disallowed-list}/index.js (85%)
and
rename lib/rules/{declaration-property-unit-whitelist => declaration-property-unit-allowed-list}/README.md (92%)
rename lib/rules/{declaration-property-unit-whitelist => declaration-property-unit-allowed-list}/__tests__/index.js (100%)
rename lib/rules/{declaration-property-unit-whitelist => declaration-property-unit-allowed-list}/index.js (85%)
@@ -1,6 +1,6 @@ | |||
# selector-pseudo-element-blacklist |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A blacklist to allowed list shift, but the examples shifted too. As with the rule shift above, I think we're good to roll with this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same GitHub session, looks good in commit history.
scripts/visual-config.json
Outdated
@@ -1,7 +1,7 @@ | |||
{ | |||
"rules": { | |||
"color-no-invalid-hex": true, | |||
"declaration-property-unit-blacklist": { "margin": ["px"] }, | |||
"declaration-property-unit-disallowed-list": { "margin": ["px"] }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"declaration-property-unit-disallowed-list": { "margin": ["px"] }, | |
"unit-disallowed-list": ["px"], |
Let's:
- change this to the shorter
unit-disallowed-list
- run
cd scripts && ./visual.sh
- screenshot the "Normal" terminal output
- optimise the resultant
.png
- replace https://github.com/stylelint/stylelint/blob/master/example.png with it
It's shown in the README and project homepage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, I've added this in 8e8aa2c
This applies a full rename across the repository to reflect that the term "whitelist" is controversial in the tech community and that using the term "allowed-list" is more explicit in it's purpose.
This is to make this rule consistent in naming with the other list based rule names (*-allowed-list and *-disallowed-list).
Previously *-whitelist, *-blacklist and *-requirelist rules were renamed to a consistent naming pattern of *-allowed-list, *-disallowed-list and *-required-list respectively. This commit adds aliases so that the old rules can continue to operate; this allows backwards compatibility to be maintained. A consequence of this is that violations for the previously named rules will show up with the new name. A developer may also get some confusing results if they happen to have the same rule defined with both names and different options.
This replaces the declaration-property-unit-disallowed-list rule with the shorter unit-disallowed-unit one to create a simpler example image.
cbdf5de
to
8e8aa2c
Compare
I've added that in 96acce6 with: stylelint/lib/utils/__tests__/checkAgainstRule.test.js Lines 64 to 82 in 96acce6
Let me know if you'd like any amends to it (I don't have much of an understanding of the code this part is testing) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent, thank you! It all looks good to me now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ran your fork locally and looked through the code, everything looks good to me! This is a large change, thank you for all the work! LGTM!
Would like to loop in a more experienced member on the @stylelint/core team, since this is a pretty big change.
Also, have we made the PR to the stylelint.io website to add redirects for the renamed rules and/or a quick writeup explaining what we did? We'll need to do that before releasing, right?
(and update configs: https://github.com/stylelint/stylelint-config-standard
https://github.com/stylelint/stylelint-config-recommended )
Great stuff, yup this needs at least a changelog entry for this repo. Would that be where the write-up goes or somewhere else? I’ve not opened any other PRs in other repos but I’ll look into sorting that out now this is on the way in. |
At least in the
Sounds good! I can help you with some of the low-hanging but tedious fruit like the config updating! |
Not yet. It's the only thing remaining to do.
@malsf21 Excellent. If you've time, would you mind rustling up a pull request for the redirects? I've created an issue for it: stylelint/stylelint.io#158
We'll add a changelog entry just after merging. We'll tweet the release too. |
Changelog:
|
# By Richard Hallows (4) and others # Via GitHub * master: Create codeql analysis workflow (#4850) Update CHANGELOG.md Add support for descriptions in stylelint command comments (#4848) Update CHANGELOG.md Add *-allowed-list/*-disallowed-list/*-required-list names for *-whitelist/*-blacklist/*-requirelist rules (#4845) Update CHANGELOG.md Add syntax object acceptance to customSyntax option (#4839) Bump typescript from 3.9.5 to 3.9.6 (#4853) Add ignoreComments[] to comment-empty-line-before (#4841) Bump autoprefixer from 9.8.0 to 9.8.2 (#4838)
Resolves #4844
This PR serves as a potential implementation route to achieve the re-naming change raised in issue #4844, where I expect there is still to be a reasonable amount of discussion on the issue. It has been reworked following @jeddy3 suggestion on an implementation route.
It takes an approach of renaming all
*-blacklist
,*-requirelist
and*-whitelist
rules to*-disallowed-list
,*-required-list
and*-allowed-list
which creates a consistent*-list
pattern for naming list based rules. There have then been aliases created so that the previously named rules remain operational.