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

Replace *-whitelist/*-blacklist/*-requirelist rules with *-allowed-list/*-disallowed-list/*-required-list rules #4845

Merged
merged 5 commits into from Jul 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/maintainer-guide/issues.md
Expand Up @@ -34,10 +34,10 @@ Rename the title into a consistent format.
You should:

- lead with the [CHANGELOG group names](pull-requests.md), but in the present tense:
- "Remove y", e.g. "Remove unit-blacklist"
- "Remove y", e.g. "Remove unit-disallowed-list"
- "Deprecate x in y", e.g. "Deprecate resolvedNested option in selector-class-pattern"
- "Add y", e.g. "Add unit-blacklist"
- "Add x to y", e.g. "Add ignoreProperties: [] to property-blacklist"
- "Add y", e.g. "Add unit-disallowed-list"
- "Add x to y", e.g. "Add ignoreProperties: [] to property-disallowed-list"
- "Fix false positives/negatives for x in y", e.g. "Fix false positives for Less mixins in color-no-hex"
- use `*` if the issue applies to a group of rules, e.g. "Fix false negatives for SCSS variables in selector-\*-pattern"

Expand Down
2 changes: 1 addition & 1 deletion docs/maintainer-guide/pull-requests.md
Expand Up @@ -29,5 +29,5 @@ When merging a PR, you should:
2. Prefix the item with either: "Removed", "Changed", "Deprecated", "Added", or "Fixed".
3. Order the item within the group by the widest-reaching first to the smallest, and then alphabetically by rule name.
4. Suffix the item with the relevant pull request number, using the complete GitHub URL so that it works on [the website](https://stylelint.io/CHANGELOG/).
5. If applicable, lead the item with the name of the rule, e.g. "Fixed: `unit-blacklist` false positives for SCSS nested properties".
5. If applicable, lead the item with the name of the rule, e.g. "Fixed: `unit-disallowed-list` false positives for SCSS nested properties".
3. Post this update as a comment to the pull request.
4 changes: 2 additions & 2 deletions docs/user-guide/configure.md
Expand Up @@ -61,7 +61,7 @@ You can add any number of keys in the object. For example, you can:

- turn off `block-no-empty`
- turn on `comment-empty-line-before` with a primary and secondary option
- turn on `max-empty-lines` and `unit-whitelist` with primary options
- turn on `max-empty-lines` and `unit-allowed-list` with primary options

```json
{
Expand All @@ -74,7 +74,7 @@ You can add any number of keys in the object. For example, you can:
}
],
"max-empty-lines": 2,
"unit-whitelist": ["em", "rem", "%", "s"]
"unit-allowed-list": ["em", "rem", "%", "s"]
}
}
```
Expand Down
2 changes: 1 addition & 1 deletion docs/user-guide/get-started.md
Expand Up @@ -43,7 +43,7 @@ To further customize your stylelint configuration, you can adapt your:
- [shared configs](configure.md#extends)
- [plugins](configure.md#plugins)

We recommend you add [rules that limit language features](rules/list.md#limit-language-features) to your configuration, e.g. [`unit-whitelist`](../../lib/rules/unit-whitelist/README.md), [`selector-class-pattern`](../../lib/rules/selector-class-pattern/README.md) and [`selector-max-id`](../../lib/rules/selector-max-id/README.md). These are powerful rules that you can use to enforce non-stylistic consistency in your code.
We recommend you add [rules that limit language features](rules/list.md#limit-language-features) to your configuration, e.g. [`unit-allowed-list`](../../lib/rules/unit-allowed-list/README.md), [`selector-class-pattern`](../../lib/rules/selector-class-pattern/README.md) and [`selector-max-id`](../../lib/rules/selector-max-id/README.md). These are powerful rules that you can use to enforce non-stylistic consistency in your code.

### Your usage

Expand Down
28 changes: 14 additions & 14 deletions docs/user-guide/rules/combine.md
Expand Up @@ -275,33 +275,33 @@ You can do that with:
}
```

## `*-whitelist`, `*-blacklist`, `color-named` and applicable `*-no-*` rules
## `*-allowed-list`, `*-disallowed-list`, `color-named` and applicable `*-no-*` rules

These rules work together to (dis)allow language features and constructs.

There are `*-whitelist` and `*-blacklist` rules that target the constructs of the CSS language: at-rules, functions, declarations (i.e. property-value pairs), properties and units. These rules (dis)allow any language features that make use of these constructs (e.g. `@media`, `rgb()`). However, there are features not caught by these `*-whitelist` and `*-blacklist` rules (or are, but would require complex regex to configure). There are individual rules, usually a `*-no-*` rule (e.g. `color-no-hex` and `selector-no-id`), to disallow each of these features.
There are `*-allowed-list` and `*-disallowed-list` rules that target the constructs of the CSS language: at-rules, functions, declarations (i.e. property-value pairs), properties and units. These rules (dis)allow any language features that make use of these constructs (e.g. `@media`, `rgb()`). However, there are features not caught by these `*-allowed-list` and `*-disallowed-list` rules (or are, but would require complex regex to configure). There are individual rules, usually a `*-no-*` rule (e.g. `color-no-hex` and `selector-no-id`), to disallow each of these features.

Say you want to disallow the `@debug` language extension. You can do that using either the `at-rule-blacklist` or `at-rule-whitelist` rules because the `@debug` language extension uses the at-rule construct e.g.
Say you want to disallow the `@debug` language extension. You can do that using either the `at-rule-disallowed-list` or `at-rule-allowed-list` rules because the `@debug` language extension uses the at-rule construct e.g.

```json
{
"at-rule-blacklist": ["debug"]
"at-rule-disallowed-list": ["debug"]
}
```

Say you want to, for whatever reason, disallow the whole at-rule construct. You can do that using:

```json
{
"at-rule-whitelist": []
"at-rule-allowed-list": []
}
```

Say you want to disallow the value `none` for the `border` properties. You can do that using either the `declaration-property-value-blacklist` or `declaration-property-value-whitelist` e.g.
Say you want to disallow the value `none` for the `border` properties. You can do that using either the `declaration-property-value-disallowed-list` or `declaration-property-value-allowed-list` e.g.

```json
{
"declaration-property-value-blacklist": [
"declaration-property-value-disallowed-list": [
{
"/^border/": ["none"]
}
Expand All @@ -311,7 +311,7 @@ Say you want to disallow the value `none` for the `border` properties. You can d

## `color-*` and `function-*` rules

Most `<color>` values are _functions_. As such, they can be (dis)allowed using either the `function-blacklist` or `function-whitelist` rules. Two other color representations aren't functions: named colors and hex colors. There are two specific rules that (dis)allow these: `color-named` and `color-no-hex`, respectively.
Most `<color>` values are _functions_. As such, they can be (dis)allowed using either the `function-allowed-list` or `function-disallowed-list` rules. Two other color representations aren't functions: named colors and hex colors. There are two specific rules that (dis)allow these: `color-named` and `color-no-hex`, respectively.

Say you want to enforce using a named color _if one exists for your chosen color_ and use `hwb` color if one does not, e.g.:

Expand All @@ -323,23 +323,23 @@ a {
}
```

If you're taking a whitelisting approach, you can do that with:
If you're taking an allow approach, you can do that with:

```json
{
"color-named": "always-where-possible",
"color-no-hex": true,
"function-whitelist": ["hwb"]
"function-allowed-list": ["hwb"]
}
```

Or, if you're taking a blacklisting approach:
Or, if you're taking a disallow approach:

```json
{
"color-named": "always-where-possible",
"color-no-hex": true,
"function-blacklist": ["/^rgb/", "/^hsl/", "gray"]
"function-disallowed-list": ["/^rgb/", "/^hsl/", "gray"]
}
```

Expand All @@ -349,12 +349,12 @@ This approach scales to when language extensions (that use the two built-in exte
{
"color-named": "never",
"color-no-hex": true,
"function-whitelist": ["my-color"]
"function-allowed-list": ["my-color"]
}
```

## Manage conflicts

Each rule stands alone, so sometimes it's possible to configure rules such that they conflict with one another. For example, you could turn on two conflicting blacklist and whitelist rules, e.g. `unit-blacklist` and `unit-whitelist`.
Each rule stands alone, so sometimes it's possible to configure rules such that they conflict with one another. For example, you could turn on two conflicting allow and disallow list rules, e.g. `unit-allowed-list` and `unit-disallowed-list`.

It's your responsibility as the configuration author to resolve these conflicts.
54 changes: 27 additions & 27 deletions docs/user-guide/rules/list.md
Expand Up @@ -101,11 +101,11 @@ Grouped first by the following categories and then by the [_thing_](http://apps.

### Function

- [`function-blacklist`](../../../lib/rules/function-blacklist/README.md): Specify a blacklist of disallowed functions.
- [`function-allowed-list`](../../../lib/rules/function-allowed-list/README.md): Specify a list of allowed functions.
- [`function-disallowed-list`](../../../lib/rules/function-disallowed-list/README.md): Specify a list of disallowed functions.
- [`function-url-no-scheme-relative`](../../../lib/rules/function-url-no-scheme-relative/README.md): Disallow scheme-relative urls.
- [`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-allowed-list`](../../../lib/rules/function-url-scheme-allowed-list/README.md): Specify a list of allowed URL schemes.
- [`function-url-scheme-disallowed-list`](../../../lib/rules/function-url-scheme-disallowed-list/README.md): Specify a list of disallowed URL schemes.

### Keyframes

Expand All @@ -121,8 +121,8 @@ Grouped first by the following categories and then by the [_thing_](http://apps.

### Unit

- [`unit-blacklist`](../../../lib/rules/unit-blacklist/README.md): Specify a blacklist of disallowed units.
- [`unit-whitelist`](../../../lib/rules/unit-whitelist/README.md): Specify a whitelist of allowed units.
- [`unit-allowed-list`](../../../lib/rules/unit-allowed-list/README.md): Specify a list of allowed units.
- [`unit-disallowed-list`](../../../lib/rules/unit-disallowed-list/README.md): Specify a list of disallowed units.

### Shorthand property

Expand All @@ -138,30 +138,30 @@ Grouped first by the following categories and then by the [_thing_](http://apps.

### Property

- [`property-blacklist`](../../../lib/rules/property-blacklist/README.md): Specify a blacklist of disallowed properties.
- [`property-allowed-list`](../../../lib/rules/property-allowed-list/README.md): Specify a list of allowed properties.
- [`property-disallowed-list`](../../../lib/rules/property-disallowed-list/README.md): Specify a list of disallowed properties.
- [`property-no-vendor-prefix`](../../../lib/rules/property-no-vendor-prefix/README.md): Disallow vendor prefixes for properties.
- [`property-whitelist`](../../../lib/rules/property-whitelist/README.md): Specify a whitelist of allowed properties.

### Declaration

- [`declaration-block-no-redundant-longhand-properties`](../../../lib/rules/declaration-block-no-redundant-longhand-properties/README.md): Disallow longhand properties that can be combined into one shorthand property.
- [`declaration-no-important`](../../../lib/rules/declaration-no-important/README.md): Disallow `!important` within declarations.
- [`declaration-property-unit-blacklist`](../../../lib/rules/declaration-property-unit-blacklist/README.md): Specify a blacklist of disallowed property and unit pairs within declarations.
- [`declaration-property-unit-whitelist`](../../../lib/rules/declaration-property-unit-whitelist/README.md): Specify a whitelist of allowed property and unit pairs within declarations.
- [`declaration-property-value-blacklist`](../../../lib/rules/declaration-property-value-blacklist/README.md): Specify a blacklist of disallowed property and value pairs within declarations.
- [`declaration-property-value-whitelist`](../../../lib/rules/declaration-property-value-whitelist/README.md): Specify a whitelist of allowed property and value pairs within declarations.
- [`declaration-property-unit-allowed-list`](../../../lib/rules/declaration-property-unit-allowed-list/README.md): Specify a list of allowed property and unit pairs within declarations.
- [`declaration-property-unit-disallowed-list`](../../../lib/rules/declaration-property-unit-disallowed-list/README.md): Specify a list of disallowed property and unit pairs within declarations.
- [`declaration-property-value-allowed-list`](../../../lib/rules/declaration-property-value-allowed-list/README.md): Specify a list of allowed property and value pairs within declarations.
- [`declaration-property-value-disallowed-list`](../../../lib/rules/declaration-property-value-disallowed-list/README.md): Specify a list of disallowed property and value pairs within declarations.

### Declaration block

- [`declaration-block-single-line-max-declarations`](../../../lib/rules/declaration-block-single-line-max-declarations/README.md): Limit the number of declarations within a single-line declaration block.

### Selector

- [`selector-attribute-operator-blacklist`](../../../lib/rules/selector-attribute-operator-blacklist/README.md): Specify a blacklist of disallowed attribute operators.
- [`selector-attribute-operator-whitelist`](../../../lib/rules/selector-attribute-operator-whitelist/README.md): Specify a whitelist of allowed attribute operators.
- [`selector-attribute-operator-allowed-list`](../../../lib/rules/selector-attribute-operator-allowed-list/README.md): Specify a list of allowed attribute operators.
- [`selector-attribute-operator-disallowed-list`](../../../lib/rules/selector-attribute-operator-disallowed-list/README.md): Specify a list of disallowed attribute operators.
- [`selector-class-pattern`](../../../lib/rules/selector-class-pattern/README.md): Specify a pattern for class selectors.
- [`selector-combinator-blacklist`](../../../lib/rules/selector-combinator-blacklist/README.md): Specify a blacklist of disallowed combinators.
- [`selector-combinator-whitelist`](../../../lib/rules/selector-combinator-whitelist/README.md): Specify a whitelist of allowed combinators.
- [`selector-combinator-allowed-list`](../../../lib/rules/selector-combinator-allowed-list/README.md): Specify a list of allowed combinators.
- [`selector-combinator-disallowed-list`](../../../lib/rules/selector-combinator-disallowed-list/README.md): Specify a list of disallowed combinators.
- [`selector-id-pattern`](../../../lib/rules/selector-id-pattern/README.md): Specify a pattern for ID selectors.
- [`selector-max-attribute`](../../../lib/rules/selector-max-attribute/README.md): Limit the number of attribute selectors in a selector.
- [`selector-max-class`](../../../lib/rules/selector-max-class/README.md): Limit the number of classes in a selector.
Expand All @@ -176,33 +176,33 @@ Grouped first by the following categories and then by the [_thing_](http://apps.
- [`selector-nested-pattern`](../../../lib/rules/selector-nested-pattern/README.md): Specify a pattern for the selectors of rules nested within rules.
- [`selector-no-qualifying-type`](../../../lib/rules/selector-no-qualifying-type/README.md): Disallow qualifying a selector by type.
- [`selector-no-vendor-prefix`](../../../lib/rules/selector-no-vendor-prefix/README.md): Disallow vendor prefixes for selectors.
- [`selector-pseudo-class-blacklist`](../../../lib/rules/selector-pseudo-class-blacklist/README.md): Specify a blacklist of disallowed pseudo-class selectors.
- [`selector-pseudo-class-whitelist`](../../../lib/rules/selector-pseudo-class-whitelist/README.md): Specify a whitelist of allowed pseudo-class selectors.
- [`selector-pseudo-element-blacklist`](../../../lib/rules/selector-pseudo-element-blacklist/README.md): Specify a blacklist of disallowed pseudo-element selectors.
- [`selector-pseudo-class-allowed-list`](../../../lib/rules/selector-pseudo-class-allowed-list/README.md): Specify a list of allowed pseudo-class selectors.
- [`selector-pseudo-class-disallowed-list`](../../../lib/rules/selector-pseudo-class-disallowed-list/README.md): Specify a list of disallowed pseudo-class selectors.
- [`selector-pseudo-element-allowed-list`](../../../lib/rules/selector-pseudo-element-allowed-list/README.md): Specify a list of allowed pseudo-element selectors.
- [`selector-pseudo-element-colon-notation`](../../../lib/rules/selector-pseudo-element-colon-notation/README.md): Specify single or double colon notation for applicable pseudo-elements (Autofixable).
- [`selector-pseudo-element-whitelist`](../../../lib/rules/selector-pseudo-element-whitelist/README.md): Specify a whitelist of allowed pseudo-element selectors.
- [`selector-pseudo-element-disallowed-list`](../../../lib/rules/selector-pseudo-element-disallowed-list/README.md): Specify a list of disallowed pseudo-element selectors.

### Media feature

- [`media-feature-name-blacklist`](../../../lib/rules/media-feature-name-blacklist/README.md): Specify a blacklist of disallowed media feature names.
- [`media-feature-name-allowed-list`](../../../lib/rules/media-feature-name-allowed-list/README.md): Specify a list of allowed media feature names.
- [`media-feature-name-disallowed-list`](../../../lib/rules/media-feature-name-disallowed-list/README.md): Specify a list of disallowed media feature names.
- [`media-feature-name-no-vendor-prefix`](../../../lib/rules/media-feature-name-no-vendor-prefix/README.md): Disallow vendor prefixes for media feature names.
- [`media-feature-name-value-whitelist`](../../../lib/rules/media-feature-name-value-whitelist/README.md): Specify a whitelist of allowed media feature name and value pairs.
- [`media-feature-name-whitelist`](../../../lib/rules/media-feature-name-whitelist/README.md): Specify a whitelist of allowed media feature names.
- [`media-feature-name-value-allowed-list`](../../../lib/rules/media-feature-name-value-allowed-list/README.md): Specify a list of allowed media feature name and value pairs.

### Custom media

- [`custom-media-pattern`](../../../lib/rules/custom-media-pattern/README.md): Specify a pattern for custom media query names.

### At-rule

- [`at-rule-blacklist`](../../../lib/rules/at-rule-blacklist/README.md): Specify a blacklist of disallowed at-rules.
- [`at-rule-allowed-list`](../../../lib/rules/at-rule-allowed-list/README.md): Specify a list of allowed at-rules.
- [`at-rule-disallowed-list`](../../../lib/rules/at-rule-disallowed-list/README.md): Specify a list of disallowed at-rules.
- [`at-rule-no-vendor-prefix`](../../../lib/rules/at-rule-no-vendor-prefix/README.md): Disallow vendor prefixes for at-rules.
- [`at-rule-property-requirelist`](../../../lib/rules/at-rule-property-requirelist/README.md): Specify a requirelist of properties for an at-rule.
- [`at-rule-whitelist`](../../../lib/rules/at-rule-whitelist/README.md): Specify a whitelist of allowed at-rules.
- [`at-rule-property-required-list`](../../../lib/rules/at-rule-property-required-list/README.md): Specify a list of required properties for an at-rule.

### Comment

- [`comment-word-blacklist`](../../../lib/rules/comment-word-blacklist/README.md): Specify a blacklist of disallowed words within comments.
- [`comment-word-disallowed-list`](../../../lib/rules/comment-word-disallowed-list/README.md): Specify a list of disallowed words within comments.

### General / Sheet

Expand Down
4 changes: 2 additions & 2 deletions docs/user-guide/rules/regex.md
Expand Up @@ -2,8 +2,8 @@

The following classes of rules support regex:

- `*-blacklist`
- `*-whitelist`
- `*-allowed-list`
- `*-disallowed-list`
- `*-pattern`

As does the `ignore*` secondary options.
Expand Down
Binary file modified example.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.