diff --git a/docs/maintainer-guide/issues.md b/docs/maintainer-guide/issues.md index 92d469133d..523385308f 100644 --- a/docs/maintainer-guide/issues.md +++ b/docs/maintainer-guide/issues.md @@ -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" diff --git a/docs/maintainer-guide/pull-requests.md b/docs/maintainer-guide/pull-requests.md index 1dbca62a3f..53b7677dea 100644 --- a/docs/maintainer-guide/pull-requests.md +++ b/docs/maintainer-guide/pull-requests.md @@ -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. diff --git a/docs/user-guide/configure.md b/docs/user-guide/configure.md index 5f6327c32d..38afea37d6 100644 --- a/docs/user-guide/configure.md +++ b/docs/user-guide/configure.md @@ -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 { @@ -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"] } } ``` diff --git a/docs/user-guide/get-started.md b/docs/user-guide/get-started.md index d7bca64ff5..bec1d23fea 100644 --- a/docs/user-guide/get-started.md +++ b/docs/user-guide/get-started.md @@ -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 diff --git a/docs/user-guide/rules/combine.md b/docs/user-guide/rules/combine.md index cd4cbbd9d6..9f3daf4b3b 100644 --- a/docs/user-guide/rules/combine.md +++ b/docs/user-guide/rules/combine.md @@ -275,17 +275,17 @@ 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"] } ``` @@ -293,15 +293,15 @@ Say you want to, for whatever reason, disallow the whole at-rule construct. You ```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"] } @@ -311,7 +311,7 @@ Say you want to disallow the value `none` for the `border` properties. You can d ## `color-*` and `function-*` rules -Most `` 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 `` 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.: @@ -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"] } ``` @@ -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. diff --git a/docs/user-guide/rules/list.md b/docs/user-guide/rules/list.md index 781ebf0141..2fb3483afa 100644 --- a/docs/user-guide/rules/list.md +++ b/docs/user-guide/rules/list.md @@ -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 @@ -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 @@ -138,18 +138,18 @@ 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 @@ -157,11 +157,11 @@ Grouped first by the following categories and then by the [_thing_](http://apps. ### 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. @@ -176,18 +176,18 @@ 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 @@ -195,14 +195,14 @@ Grouped first by the following categories and then by the [_thing_](http://apps. ### 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 diff --git a/docs/user-guide/rules/regex.md b/docs/user-guide/rules/regex.md index 9dc553f445..db64e0f48d 100644 --- a/docs/user-guide/rules/regex.md +++ b/docs/user-guide/rules/regex.md @@ -2,8 +2,8 @@ The following classes of rules support regex: -- `*-blacklist` -- `*-whitelist` +- `*-allowed-list` +- `*-disallowed-list` - `*-pattern` As does the `ignore*` secondary options. diff --git a/example.png b/example.png index 3bec5258a8..34e7b84a90 100644 Binary files a/example.png and b/example.png differ diff --git a/lib/__tests__/aliasedRules.test.js b/lib/__tests__/aliasedRules.test.js new file mode 100644 index 0000000000..50a2eecaa4 --- /dev/null +++ b/lib/__tests__/aliasedRules.test.js @@ -0,0 +1,41 @@ +'use strict'; + +const rules = require('../rules'); + +const whitelistAndBlacklistRulePrefixes = [ + 'at-rule', + 'declaration-property-unit', + 'declaration-property-value', + 'function', + 'function-url-scheme', + 'media-feature-name', + 'property', + 'selector-attribute-operator', + 'selector-combinator', + 'selector-pseudo-class', + 'selector-pseudo-element', + 'unit', +]; + +const whitelistRulePrefixes = whitelistAndBlacklistRulePrefixes.concat([ + 'media-feature-name-value', +]); + +whitelistRulePrefixes.forEach((prefix) => { + it(`aliases ${prefix}-whitelist to ${prefix}-allowed-list`, () => + expect(rules[`${prefix}-whitelist`].ruleName).toEqual(`${prefix}-allowed-list`)); +}); + +const blacklistRulePrefixes = whitelistAndBlacklistRulePrefixes.concat(['comment-word']); + +blacklistRulePrefixes.forEach((prefix) => { + it(`aliases ${prefix}-blacklist to ${prefix}-disallowed-list`, () => + expect(rules[`${prefix}-blacklist`].ruleName).toEqual(`${prefix}-disallowed-list`)); +}); + +const requirelistRulePrefixes = ['at-rule-property']; + +requirelistRulePrefixes.forEach((prefix) => { + it(`aliases ${prefix}-requirelist to ${prefix}-required-list`, () => + expect(rules[`${prefix}-requirelist`].ruleName).toEqual(`${prefix}-required-list`)); +}); diff --git a/lib/__tests__/fixtures/config-no-pixels.json b/lib/__tests__/fixtures/config-no-pixels.json index 8cff6f62ff..b39672f4fe 100644 --- a/lib/__tests__/fixtures/config-no-pixels.json +++ b/lib/__tests__/fixtures/config-no-pixels.json @@ -1,5 +1,5 @@ { "rules": { - "unit-blacklist": ["px"] + "unit-disallowed-list": ["px"] } } diff --git a/lib/__tests__/integration.test.js b/lib/__tests__/integration.test.js index 4c1bc27e06..df73623bf7 100644 --- a/lib/__tests__/integration.test.js +++ b/lib/__tests__/integration.test.js @@ -10,7 +10,7 @@ const stylelint = require('..'); const config = { rules: { 'block-opening-brace-newline-after': 'always', - 'declaration-property-unit-blacklist': { + 'declaration-property-unit-disallowed-list': { width: ['px', 'em'], }, 'color-no-invalid-hex': [ @@ -20,8 +20,8 @@ const config = { message: 'You made a mistake', }, ], - 'function-blacklist': ['calc'], - 'function-whitelist': null, + 'function-allowed-list': null, + 'function-disallowed-list': ['calc'], 'no-duplicate-selectors': true, }, }; @@ -72,12 +72,14 @@ describe('integration test expecting warnings', () => { expect(error.severity).toBe('error'); }); - it('declaration-property-unit-blacklist - object primary option', () => { - const error = result.messages.find((msg) => msg.rule === 'declaration-property-unit-blacklist'); + it('declaration-property-unit-disallowed-list - object primary option', () => { + const error = result.messages.find( + (msg) => msg.rule === 'declaration-property-unit-disallowed-list', + ); expect(error).toBeTruthy(); expect(error.text).toBe( - 'Unexpected unit "px" for property "width" (declaration-property-unit-blacklist)', + 'Unexpected unit "px" for property "width" (declaration-property-unit-disallowed-list)', ); expect(error.severity).toBe('error'); }); @@ -92,11 +94,11 @@ describe('integration test expecting warnings', () => { }); }); - it('function-blacklist - array primary option', () => { - const error = result.messages.find((msg) => msg.rule === 'function-blacklist'); + it('function-disallowed-list - array primary option', () => { + const error = result.messages.find((msg) => msg.rule === 'function-disallowed-list'); expect(error).toBeTruthy(); - expect(error.text).toBe('Unexpected function "calc" (function-blacklist)'); + expect(error.text).toBe('Unexpected function "calc" (function-disallowed-list)'); expect(error.severity).toBe('error'); }); }); @@ -141,6 +143,19 @@ it('Scss integration test', () => { }); }); +it('rule aliasing integration test', () => { + return postcss() + .use(stylelint({ rules: { 'unit-blacklist': ['px'] } })) + .process('a { top: 10px; }', { from: undefined }) + .then((result) => { + const error = result.messages[0]; + + expect(error).toBeTruthy(); + expect(error.rule).toBe('unit-disallowed-list'); + expect(error.text).toBe('Unexpected unit "px" (unit-disallowed-list)'); + }); +}); + describe('integration test null option', () => { let results; @@ -150,7 +165,7 @@ describe('integration test null option', () => { config: { extends: [path.join(__dirname, 'fixtures/config-no-pixels')], rules: { - 'unit-blacklist': null, + 'unit-disallowed-list': null, }, }, code: 'a { top: 10px; }', @@ -176,7 +191,7 @@ describe('integration test [null] option', () => { config: { extends: [path.join(__dirname, 'fixtures/config-no-pixels')], rules: { - 'unit-blacklist': [null], + 'unit-disallowed-list': [null], }, }, code: 'a { top: 10px; }', diff --git a/lib/__tests__/normalizeRuleSettings-integration.test.js b/lib/__tests__/normalizeRuleSettings-integration.test.js index fd21524090..07fc097307 100644 --- a/lib/__tests__/normalizeRuleSettings-integration.test.js +++ b/lib/__tests__/normalizeRuleSettings-integration.test.js @@ -8,11 +8,11 @@ it('[normalized rule settings] primary option array', () => { code: 'a:focus {}', config: { rules: { - 'selector-pseudo-class-blacklist': ['focus'], + 'selector-pseudo-class-disallowed-list': ['focus'], }, }, }).then((linted) => { - expect(linted.results[0].warnings[0].rule).toBe('selector-pseudo-class-blacklist'); + expect(linted.results[0].warnings[0].rule).toBe('selector-pseudo-class-disallowed-list'); }); }); @@ -21,11 +21,11 @@ it('[normalized rule settings] primary option array in array', () => { code: 'a:focus {}', config: { rules: { - 'selector-pseudo-class-blacklist': [['focus']], + 'selector-pseudo-class-disallowed-list': [['focus']], }, }, }).then((linted) => { - expect(linted.results[0].warnings[0].rule).toBe('selector-pseudo-class-blacklist'); + expect(linted.results[0].warnings[0].rule).toBe('selector-pseudo-class-disallowed-list'); }); }); @@ -63,7 +63,7 @@ it('[normalized rule settings] array primary, primary option null', () => { config: { extends: [path.join(__dirname, 'fixtures/config-no-pixels.json')], rules: { - 'unit-blacklist': null, + 'unit-disallowed-list': null, }, }, }).then((linted) => { @@ -77,7 +77,7 @@ it('[normalized rule settings] array primary, primary option null in array', () config: { extends: [path.join(__dirname, 'fixtures/config-no-pixels.json')], rules: { - 'unit-blacklist': [null], + 'unit-disallowed-list': [null], }, }, }).then((linted) => { diff --git a/lib/__tests__/normalizeRuleSettings.test.js b/lib/__tests__/normalizeRuleSettings.test.js index fda9bb309e..6f57e77aa4 100644 --- a/lib/__tests__/normalizeRuleSettings.test.js +++ b/lib/__tests__/normalizeRuleSettings.test.js @@ -85,14 +85,14 @@ describe('rules whose primary option CAN BE an array', () => { }); it('solo primary option array is nested within an array', () => { - const actual = normalizeRuleSettings(['calc', 'rgba'], 'function-whitelist', true); + const actual = normalizeRuleSettings(['calc', 'rgba'], 'function-allowed-list', true); const expected = [['calc', 'rgba']]; expect(actual).toEqual(expected); }); it('primary option array in an array', () => { - const actual = normalizeRuleSettings([['calc', 'rgba']], 'function-whitelist', true); + const actual = normalizeRuleSettings([['calc', 'rgba']], 'function-allowed-list', true); const expected = [['calc', 'rgba']]; expect(actual).toEqual(expected); @@ -101,7 +101,7 @@ describe('rules whose primary option CAN BE an array', () => { it('nested primary option array returns same', () => { const actual = normalizeRuleSettings( [['calc', 'rgba'], { severity: 'warning' }], - 'function-whitelist', + 'function-allowed-list', true, ); const expected = [['calc', 'rgba'], { severity: 'warning' }]; diff --git a/lib/__tests__/reportUnknownRuleNames.test.js b/lib/__tests__/reportUnknownRuleNames.test.js index e2f58f53c3..2902da6ced 100644 --- a/lib/__tests__/reportUnknownRuleNames.test.js +++ b/lib/__tests__/reportUnknownRuleNames.test.js @@ -6,7 +6,7 @@ it('test case (1)', () => { const config = { rules: { 'color-hex-cas': ['upper'], - 'function-whitelst': ['scale'], + 'function-allowed-lst': ['scale'], }, }; @@ -26,8 +26,8 @@ it('test case (1)', () => { line: 1, column: 1, severity: 'error', - rule: 'function-whitelst', - text: 'Unknown rule function-whitelst. Did you mean function-whitelist?', + rule: 'function-allowed-lst', + text: 'Unknown rule function-allowed-lst. Did you mean function-allowed-list?', }); }); }); @@ -36,7 +36,7 @@ it('test case (2)', () => { const config = { rules: { 'color-hex-case': ['upper'], - 'function-whitelst': ['rgb'], + 'function-allowed-lst': ['rgb'], }, }; @@ -49,8 +49,8 @@ it('test case (2)', () => { line: 1, column: 1, severity: 'error', - rule: 'function-whitelst', - text: 'Unknown rule function-whitelst. Did you mean function-whitelist?', + rule: 'function-allowed-lst', + text: 'Unknown rule function-allowed-lst. Did you mean function-allowed-list?', }); expect(linted.results[0].warnings).toContainEqual( expect.objectContaining({ diff --git a/lib/rules/at-rule-whitelist/README.md b/lib/rules/at-rule-allowed-list/README.md similarity index 86% rename from lib/rules/at-rule-whitelist/README.md rename to lib/rules/at-rule-allowed-list/README.md index 0aecbdda5e..8755baf322 100644 --- a/lib/rules/at-rule-whitelist/README.md +++ b/lib/rules/at-rule-allowed-list/README.md @@ -1,6 +1,6 @@ -# at-rule-whitelist +# at-rule-allowed-list -Specify a whitelist of allowed at-rules. +Specify a list of allowed at-rules. ```css @@ -9,6 +9,8 @@ Specify a whitelist of allowed at-rules. * At-rules like this */ ``` +This rule was previously called, and is aliased as, `at-rule-whitelist`. + ## Options `array|string`: `["array", "of", "unprefixed", "at-rules"]|"at-rule"` diff --git a/lib/rules/at-rule-whitelist/__tests__/index.js b/lib/rules/at-rule-allowed-list/__tests__/index.js similarity index 68% rename from lib/rules/at-rule-whitelist/__tests__/index.js rename to lib/rules/at-rule-allowed-list/__tests__/index.js index ecf9d692a1..2873e4b816 100644 --- a/lib/rules/at-rule-whitelist/__tests__/index.js +++ b/lib/rules/at-rule-allowed-list/__tests__/index.js @@ -14,7 +14,7 @@ testRule({ }, { code: 'a { @extend %placeholder; }', - description: '@rule from a whitelist, is a Sass directive.', + description: '@rule from an allowed list, is a Sass directive.', }, { code: ` @@ -23,7 +23,7 @@ testRule({ %placeholder; } `, - description: '@rule from a whitelist; newline after its name.', + description: '@rule from an allowed list; newline after its name.', }, { code: ` @@ -32,7 +32,7 @@ testRule({ to { top: 20px; } } `, - description: '@rule from a whitelist; independent rule.', + description: '@rule from an allowed list; independent rule.', }, { code: ` @@ -41,7 +41,7 @@ testRule({ to { top: 20px; } } `, - description: '@rule from a whitelist; independent rule; messed case.', + description: '@rule from an allowed list; independent rule; messed case.', }, { code: ` @@ -50,7 +50,7 @@ testRule({ to { top: 20px; } } `, - description: '@rule from a whitelist; independent rule; has vendor prefix.', + description: '@rule from an allowed list; independent rule; has vendor prefix.', }, { code: ` @@ -59,7 +59,7 @@ testRule({ to { top: 20px; } } `, - description: '@rule from a whitelist; independent rule; has vendor prefix.', + description: '@rule from an allowed list; independent rule; has vendor prefix.', }, ], @@ -71,7 +71,7 @@ testRule({ line: 2, columt: 7, message: messages.rejected('mixin'), - description: '@rule not from a whitelist; independent rule.', + description: '@rule not from an allowed list; independent rule.', }, ], }); @@ -90,7 +90,7 @@ testRule({ to { top: 20px; } } `, - description: '@rule from a whitelist; independent rule.', + description: '@rule from an allowed list; independent rule.', }, { code: ` @@ -99,7 +99,7 @@ testRule({ to { top: 20px; } } `, - description: '@rule from a whitelist; independent rule; messed case.', + description: '@rule from an allowed list; independent rule; messed case.', }, { code: ` @@ -108,7 +108,7 @@ testRule({ to { top: 20px; } } `, - description: '@rule from a whitelist; independent rule; has vendor prefix.', + description: '@rule from an allowed list; independent rule; has vendor prefix.', }, { code: ` @@ -117,7 +117,7 @@ testRule({ to { top: 20px; } } `, - description: '@rule from a whitelist; independent rule; has vendor prefix.', + description: '@rule from an allowed list; independent rule; has vendor prefix.', }, ], @@ -129,21 +129,21 @@ testRule({ message: messages.rejected('mixin'), line: 2, column: 7, - description: '@rule not from a whitelist.', + description: '@rule not from an allowed list.', }, { code: "@import 'path/to/file.css';", message: messages.rejected('import'), line: 1, column: 1, - description: '@rule not from a whitelist.', + description: '@rule not from an allowed list.', }, { code: '@media screen and (max-witdh: 1000px) {}', message: messages.rejected('media'), line: 1, column: 1, - description: '@rule not from a whitelist.', + description: '@rule not from an allowed list.', }, ], }); diff --git a/lib/rules/at-rule-whitelist/index.js b/lib/rules/at-rule-allowed-list/index.js similarity index 82% rename from lib/rules/at-rule-whitelist/index.js rename to lib/rules/at-rule-allowed-list/index.js index 14312e593d..65f950d34c 100644 --- a/lib/rules/at-rule-whitelist/index.js +++ b/lib/rules/at-rule-allowed-list/index.js @@ -9,19 +9,19 @@ const report = require('../../utils/report'); const ruleMessages = require('../../utils/ruleMessages'); const validateOptions = require('../../utils/validateOptions'); -const ruleName = 'at-rule-whitelist'; +const ruleName = 'at-rule-allowed-list'; const messages = ruleMessages(ruleName, { rejected: (name) => `Unexpected at-rule "${name}"`, }); -function rule(whitelistInput) { +function rule(listInput) { // To allow for just a string as a parameter (not only arrays of strings) - const whitelist = [].concat(whitelistInput); + const list = [].concat(listInput); return (root, result) => { const validOptions = validateOptions(result, ruleName, { - actual: whitelist, + actual: list, possible: [_.isString], }); @@ -36,7 +36,7 @@ function rule(whitelistInput) { return; } - if (whitelist.includes(postcss.vendor.unprefixed(name).toLowerCase())) { + if (list.includes(postcss.vendor.unprefixed(name).toLowerCase())) { return; } diff --git a/lib/rules/at-rule-blacklist/README.md b/lib/rules/at-rule-disallowed-list/README.md similarity index 82% rename from lib/rules/at-rule-blacklist/README.md rename to lib/rules/at-rule-disallowed-list/README.md index 0e50126c8f..0baefb6134 100644 --- a/lib/rules/at-rule-blacklist/README.md +++ b/lib/rules/at-rule-disallowed-list/README.md @@ -1,6 +1,6 @@ -# at-rule-blacklist +# at-rule-disallowed-list -Specify a blacklist of disallowed at-rules. +Specify a list of disallowed at-rules. ```css @@ -9,6 +9,8 @@ Specify a blacklist of disallowed at-rules. * At-rules like this */ ``` +This rule was previously called, and is aliased as, `at-rule-blacklist`. + ## Options `array|string`: `["array", "of", "unprefixed", "at-rules"]|"at-rule"` diff --git a/lib/rules/at-rule-blacklist/__tests__/index.js b/lib/rules/at-rule-disallowed-list/__tests__/index.js similarity index 73% rename from lib/rules/at-rule-blacklist/__tests__/index.js rename to lib/rules/at-rule-disallowed-list/__tests__/index.js index 9149826faa..44c2be5a20 100644 --- a/lib/rules/at-rule-blacklist/__tests__/index.js +++ b/lib/rules/at-rule-disallowed-list/__tests__/index.js @@ -14,7 +14,7 @@ testRule({ }, { code: '@mixin name ($p) {}', - description: '@rule not from a blacklist.', + description: '@rule not from a disallowed list.', }, ], @@ -24,7 +24,7 @@ testRule({ message: messages.rejected('extend'), line: 1, column: 5, - description: '@rule from a blacklist, is a Sass directive.', + description: '@rule from a disallowed list, is a Sass directive.', }, { code: ` @@ -36,7 +36,7 @@ testRule({ message: messages.rejected('extend'), line: 3, column: 9, - description: '@rule from a blacklist; newline after its name.', + description: '@rule from a disallowed list; newline after its name.', }, { code: ` @@ -47,7 +47,7 @@ testRule({ `, message: messages.rejected('keyframes'), line: 2, - description: '@rule from a blacklist; independent rule.', + description: '@rule from a disallowed list; independent rule.', }, { code: ` @@ -59,7 +59,7 @@ testRule({ message: messages.rejected('Keyframes'), line: 2, column: 7, - description: '@rule from a blacklist; independent rule; messed case.', + description: '@rule from a disallowed list; independent rule; messed case.', }, { code: ` @@ -71,7 +71,7 @@ testRule({ message: messages.rejected('-moz-keyframes'), line: 2, column: 7, - description: '@rule from a blacklist; independent rule; has vendor prefix.', + description: '@rule from a disallowed list; independent rule; has vendor prefix.', }, { code: ` @@ -83,7 +83,7 @@ testRule({ message: messages.rejected('-WEBKET-KEYFRAMES'), line: 2, column: 7, - description: '@rule from a blacklist; independent rule; has vendor prefix.', + description: '@rule from a disallowed list; independent rule; has vendor prefix.', }, ], }); @@ -100,7 +100,7 @@ testRule({ }, { code: '@mixin name ($p) {}', - description: '@rule not from a blacklist.', + description: '@rule not from a disallowed list.', }, ], @@ -115,7 +115,7 @@ testRule({ message: messages.rejected('keyframes'), line: 2, column: 7, - description: '@rule from a blacklist; independent rule.', + description: '@rule from a disallowed list; independent rule.', }, { code: ` @@ -127,7 +127,7 @@ testRule({ message: messages.rejected('Keyframes'), line: 2, column: 7, - description: '@rule from a blacklist; independent rule; messed case.', + description: '@rule from a disallowed list; independent rule; messed case.', }, { code: ` @@ -139,7 +139,7 @@ testRule({ message: messages.rejected('-moz-keyframes'), line: 2, column: 7, - description: '@rule from a blacklist; independent rule; has vendor prefix.', + description: '@rule from a disallowed list; independent rule; has vendor prefix.', }, { code: ` @@ -151,7 +151,7 @@ testRule({ message: messages.rejected('-WEBKET-KEYFRAMES'), line: 2, column: 7, - description: '@rule from a blacklist; independent rule; has vendor prefix.', + description: '@rule from a disallowed list; independent rule; has vendor prefix.', }, ], }); diff --git a/lib/rules/at-rule-blacklist/index.js b/lib/rules/at-rule-disallowed-list/index.js similarity index 82% rename from lib/rules/at-rule-blacklist/index.js rename to lib/rules/at-rule-disallowed-list/index.js index 2ec5a514d2..f593ecdb29 100644 --- a/lib/rules/at-rule-blacklist/index.js +++ b/lib/rules/at-rule-disallowed-list/index.js @@ -9,19 +9,19 @@ const report = require('../../utils/report'); const ruleMessages = require('../../utils/ruleMessages'); const validateOptions = require('../../utils/validateOptions'); -const ruleName = 'at-rule-blacklist'; +const ruleName = 'at-rule-disallowed-list'; const messages = ruleMessages(ruleName, { rejected: (name) => `Unexpected at-rule "${name}"`, }); -function rule(blacklistInput) { +function rule(listInput) { // To allow for just a string as a parameter (not only arrays of strings) - const blacklist = [].concat(blacklistInput); + const list = [].concat(listInput); return (root, result) => { const validOptions = validateOptions(result, ruleName, { - actual: blacklist, + actual: list, possible: [_.isString], }); @@ -36,7 +36,7 @@ function rule(blacklistInput) { return; } - if (!blacklist.includes(postcss.vendor.unprefixed(name).toLowerCase())) { + if (!list.includes(postcss.vendor.unprefixed(name).toLowerCase())) { return; } diff --git a/lib/rules/at-rule-property-requirelist/README.md b/lib/rules/at-rule-property-required-list/README.md similarity index 84% rename from lib/rules/at-rule-property-requirelist/README.md rename to lib/rules/at-rule-property-required-list/README.md index bdd6d4b0af..002bf1b02c 100644 --- a/lib/rules/at-rule-property-requirelist/README.md +++ b/lib/rules/at-rule-property-required-list/README.md @@ -1,6 +1,6 @@ -# at-rule-property-requirelist +# at-rule-property-required-list -Specify a requirelist of properties for an at-rule. +Specify a list of required properties for an at-rule. ```css @@ -9,6 +9,8 @@ Specify a requirelist of properties for an at-rule. * At-rule and required property names */ ``` +This rule was previously called, and is aliased as, `at-rule-requirelist`. + ## Options `object`: `{ "at-rule-name": ["array", "of", "properties"] }` diff --git a/lib/rules/at-rule-property-requirelist/__tests__/index.js b/lib/rules/at-rule-property-required-list/__tests__/index.js similarity index 100% rename from lib/rules/at-rule-property-requirelist/__tests__/index.js rename to lib/rules/at-rule-property-required-list/__tests__/index.js diff --git a/lib/rules/at-rule-property-requirelist/index.js b/lib/rules/at-rule-property-required-list/index.js similarity index 87% rename from lib/rules/at-rule-property-requirelist/index.js rename to lib/rules/at-rule-property-required-list/index.js index da3aa097f2..e6f0fbe04b 100644 --- a/lib/rules/at-rule-property-requirelist/index.js +++ b/lib/rules/at-rule-property-required-list/index.js @@ -8,16 +8,16 @@ const report = require('../../utils/report'); const ruleMessages = require('../../utils/ruleMessages'); const validateOptions = require('../../utils/validateOptions'); -const ruleName = 'at-rule-property-requirelist'; +const ruleName = 'at-rule-property-required-list'; const messages = ruleMessages(ruleName, { expected: (property, atRule) => `Expected property "${property}" for at-rule "${atRule}"`, }); -function rule(primary) { +function rule(list) { return (root, result) => { const validOptions = validateOptions(result, ruleName, { - actual: primary, + actual: list, possible: [_.isObject], }); @@ -33,11 +33,11 @@ function rule(primary) { const { name, nodes } = atRule; const atRuleName = name.toLowerCase(); - if (!primary[atRuleName]) { + if (!list[atRuleName]) { return; } - primary[atRuleName].forEach((property) => { + list[atRuleName].forEach((property) => { const propertyName = property.toLowerCase(); const hasProperty = nodes.find( diff --git a/lib/rules/comment-word-blacklist/README.md b/lib/rules/comment-word-disallowed-list/README.md similarity index 82% rename from lib/rules/comment-word-blacklist/README.md rename to lib/rules/comment-word-disallowed-list/README.md index d2a24d61f5..5578dc894a 100644 --- a/lib/rules/comment-word-blacklist/README.md +++ b/lib/rules/comment-word-disallowed-list/README.md @@ -1,6 +1,6 @@ -# comment-word-blacklist +# comment-word-disallowed-list -Specify a blacklist of disallowed words within comments. +Specify a list of disallowed words within comments. ```css @@ -9,6 +9,8 @@ Specify a blacklist of disallowed words within comments. * These three words */ ``` +This rule was previously called, and is aliased as, `comment-word-blacklist`. + **Caveat:** Comments within _selector and value lists_ are currently ignored. ## Options diff --git a/lib/rules/comment-word-blacklist/__tests__/index.js b/lib/rules/comment-word-disallowed-list/__tests__/index.js similarity index 100% rename from lib/rules/comment-word-blacklist/__tests__/index.js rename to lib/rules/comment-word-disallowed-list/__tests__/index.js diff --git a/lib/rules/comment-word-blacklist/index.js b/lib/rules/comment-word-disallowed-list/index.js similarity index 86% rename from lib/rules/comment-word-blacklist/index.js rename to lib/rules/comment-word-disallowed-list/index.js index 1294faa913..fab060c50a 100644 --- a/lib/rules/comment-word-blacklist/index.js +++ b/lib/rules/comment-word-disallowed-list/index.js @@ -9,16 +9,16 @@ const report = require('../../utils/report'); const ruleMessages = require('../../utils/ruleMessages'); const validateOptions = require('../../utils/validateOptions'); -const ruleName = 'comment-word-blacklist'; +const ruleName = 'comment-word-disallowed-list'; const messages = ruleMessages(ruleName, { rejected: (pattern) => `Unexpected word matching pattern "${pattern}"`, }); -function rule(blacklist) { +function rule(list) { return (root, result) => { const validOptions = validateOptions(result, ruleName, { - actual: blacklist, + actual: list, possible: [_.isString, _.isRegExp], }); @@ -36,7 +36,7 @@ function rule(blacklist) { return; } - const matchesWord = matchesStringOrRegExp(text, blacklist) || containsString(text, blacklist); + const matchesWord = matchesStringOrRegExp(text, list) || containsString(text, list); if (!matchesWord) { return; diff --git a/lib/rules/declaration-property-unit-whitelist/README.md b/lib/rules/declaration-property-unit-allowed-list/README.md similarity index 87% rename from lib/rules/declaration-property-unit-whitelist/README.md rename to lib/rules/declaration-property-unit-allowed-list/README.md index 2b2372bfbe..8ff7d6d235 100644 --- a/lib/rules/declaration-property-unit-whitelist/README.md +++ b/lib/rules/declaration-property-unit-allowed-list/README.md @@ -1,6 +1,6 @@ -# declaration-property-unit-whitelist +# declaration-property-unit-allowed-list -Specify a whitelist of allowed property and unit pairs within declarations. +Specify a list of allowed property and unit pairs within declarations. ```css @@ -9,6 +9,8 @@ a { width: 100px; } * These properties and these units */ ``` +This rule was previously called, and is aliased as, `declaration-property-unit-whitelist`. + ## Options `object`: `{ "unprefixed-property-name": ["array", "of", "units"] }` diff --git a/lib/rules/declaration-property-unit-whitelist/__tests__/index.js b/lib/rules/declaration-property-unit-allowed-list/__tests__/index.js similarity index 100% rename from lib/rules/declaration-property-unit-whitelist/__tests__/index.js rename to lib/rules/declaration-property-unit-allowed-list/__tests__/index.js diff --git a/lib/rules/declaration-property-unit-blacklist/index.js b/lib/rules/declaration-property-unit-allowed-list/index.js similarity index 85% rename from lib/rules/declaration-property-unit-blacklist/index.js rename to lib/rules/declaration-property-unit-allowed-list/index.js index d32a002c6c..f57ad17b66 100644 --- a/lib/rules/declaration-property-unit-blacklist/index.js +++ b/lib/rules/declaration-property-unit-allowed-list/index.js @@ -12,16 +12,16 @@ const ruleMessages = require('../../utils/ruleMessages'); const validateOptions = require('../../utils/validateOptions'); const valueParser = require('postcss-value-parser'); -const ruleName = 'declaration-property-unit-blacklist'; +const ruleName = 'declaration-property-unit-allowed-list'; const messages = ruleMessages(ruleName, { rejected: (property, unit) => `Unexpected unit "${unit}" for property "${property}"`, }); -function rule(blacklist) { +function rule(list) { return (root, result) => { const validOptions = validateOptions(result, ruleName, { - actual: blacklist, + actual: list, possible: [_.isObject], }); @@ -35,11 +35,11 @@ function rule(blacklist) { const unprefixedProp = postcss.vendor.unprefixed(prop); - const propBlacklist = _.find(blacklist, (list, propIdentifier) => + const propList = _.find(list, (units, propIdentifier) => matchesStringOrRegExp(unprefixedProp, propIdentifier), ); - if (!propBlacklist) { + if (!propList) { return; } @@ -55,7 +55,7 @@ function rule(blacklist) { const unit = getUnitFromValueNode(node); - if (!unit || (unit && !propBlacklist.includes(unit.toLowerCase()))) { + if (!unit || (unit && propList.indexOf(unit.toLowerCase())) !== -1) { return; } diff --git a/lib/rules/declaration-property-unit-blacklist/README.md b/lib/rules/declaration-property-unit-disallowed-list/README.md similarity index 86% rename from lib/rules/declaration-property-unit-blacklist/README.md rename to lib/rules/declaration-property-unit-disallowed-list/README.md index dba13d35b5..50d0cc81f0 100644 --- a/lib/rules/declaration-property-unit-blacklist/README.md +++ b/lib/rules/declaration-property-unit-disallowed-list/README.md @@ -1,6 +1,6 @@ -# declaration-property-unit-blacklist +# declaration-property-unit-disallowed-list -Specify a blacklist of disallowed property and unit pairs within declarations. +Specify a list of disallowed property and unit pairs within declarations. ```css @@ -9,6 +9,8 @@ a { width: 100px; } * These properties and these units */ ``` +This rule was previously called, and is aliased as, `declaration-property-unit-blacklist`. + ## Options `object`: `{ "unprefixed-property-name": ["array", "of", "units"] }` diff --git a/lib/rules/declaration-property-unit-blacklist/__tests__/index.js b/lib/rules/declaration-property-unit-disallowed-list/__tests__/index.js similarity index 100% rename from lib/rules/declaration-property-unit-blacklist/__tests__/index.js rename to lib/rules/declaration-property-unit-disallowed-list/__tests__/index.js diff --git a/lib/rules/declaration-property-unit-whitelist/index.js b/lib/rules/declaration-property-unit-disallowed-list/index.js similarity index 85% rename from lib/rules/declaration-property-unit-whitelist/index.js rename to lib/rules/declaration-property-unit-disallowed-list/index.js index 0b32365544..e4924d7be5 100644 --- a/lib/rules/declaration-property-unit-whitelist/index.js +++ b/lib/rules/declaration-property-unit-disallowed-list/index.js @@ -12,16 +12,16 @@ const ruleMessages = require('../../utils/ruleMessages'); const validateOptions = require('../../utils/validateOptions'); const valueParser = require('postcss-value-parser'); -const ruleName = 'declaration-property-unit-whitelist'; +const ruleName = 'declaration-property-unit-disallowed-list'; const messages = ruleMessages(ruleName, { rejected: (property, unit) => `Unexpected unit "${unit}" for property "${property}"`, }); -function rule(whitelist) { +function rule(list) { return (root, result) => { const validOptions = validateOptions(result, ruleName, { - actual: whitelist, + actual: list, possible: [_.isObject], }); @@ -35,11 +35,11 @@ function rule(whitelist) { const unprefixedProp = postcss.vendor.unprefixed(prop); - const propWhitelist = _.find(whitelist, (list, propIdentifier) => + const propList = _.find(list, (units, propIdentifier) => matchesStringOrRegExp(unprefixedProp, propIdentifier), ); - if (!propWhitelist) { + if (!propList) { return; } @@ -55,7 +55,7 @@ function rule(whitelist) { const unit = getUnitFromValueNode(node); - if (!unit || (unit && propWhitelist.indexOf(unit.toLowerCase())) !== -1) { + if (!unit || (unit && !propList.includes(unit.toLowerCase()))) { return; } diff --git a/lib/rules/declaration-property-value-whitelist/README.md b/lib/rules/declaration-property-value-allowed-list/README.md similarity index 83% rename from lib/rules/declaration-property-value-whitelist/README.md rename to lib/rules/declaration-property-value-allowed-list/README.md index fc387e139f..32ff898097 100644 --- a/lib/rules/declaration-property-value-whitelist/README.md +++ b/lib/rules/declaration-property-value-allowed-list/README.md @@ -1,6 +1,6 @@ -# declaration-property-value-whitelist +# declaration-property-value-allowed-list -Specify a whitelist of allowed property and value pairs within declarations. +Specify a list of allowed property and value pairs within declarations. ```css @@ -9,11 +9,13 @@ a { text-transform: uppercase; } * These properties and these values */ ``` +This rule was previously called, and is aliased as, `declaration-property-value-whitelist`. + ## Options `object`: `{ "unprefixed-property-name": ["array", "of", "values"], "unprefixed-property-name": ["/regex/", "non-regex"] }` -If a property name is found in the object, only its whitelisted property values are allowed. This rule complains about all non-matching values. (If the property name is not included in the object, anything goes.) +If a property name is found in the object, only the listed property values are allowed. This rule complains about all non-matching values. (If the property name is not included in the object, anything goes.) If a property name is surrounded with `"/"` (e.g. `"/^animation/"`), it is interpreted as a regular expression. This allows, for example, easy targeting of shorthands: `/^animation/` will match `animation`, `animation-duration`, `animation-timing-function`, etc. diff --git a/lib/rules/declaration-property-value-whitelist/__tests__/index.js b/lib/rules/declaration-property-value-allowed-list/__tests__/index.js similarity index 100% rename from lib/rules/declaration-property-value-whitelist/__tests__/index.js rename to lib/rules/declaration-property-value-allowed-list/__tests__/index.js diff --git a/lib/rules/declaration-property-value-whitelist/index.js b/lib/rules/declaration-property-value-allowed-list/index.js similarity index 80% rename from lib/rules/declaration-property-value-whitelist/index.js rename to lib/rules/declaration-property-value-allowed-list/index.js index c7b0dd53cd..227bad0f83 100644 --- a/lib/rules/declaration-property-value-whitelist/index.js +++ b/lib/rules/declaration-property-value-allowed-list/index.js @@ -9,16 +9,16 @@ const report = require('../../utils/report'); const ruleMessages = require('../../utils/ruleMessages'); const validateOptions = require('../../utils/validateOptions'); -const ruleName = 'declaration-property-value-whitelist'; +const ruleName = 'declaration-property-value-allowed-list'; const messages = ruleMessages(ruleName, { rejected: (property, value) => `Unexpected value "${value}" for property "${property}"`, }); -function rule(whitelist) { +function rule(list) { return (root, result) => { const validOptions = validateOptions(result, ruleName, { - actual: whitelist, + actual: list, possible: [_.isObject], }); @@ -31,15 +31,15 @@ function rule(whitelist) { const value = decl.value; const unprefixedProp = postcss.vendor.unprefixed(prop); - const propWhitelist = _.find(whitelist, (list, propIdentifier) => + const propList = _.find(list, (values, propIdentifier) => matchesStringOrRegExp(unprefixedProp, propIdentifier), ); - if (_.isEmpty(propWhitelist)) { + if (_.isEmpty(propList)) { return; } - if (matchesStringOrRegExp(value, propWhitelist)) { + if (matchesStringOrRegExp(value, propList)) { return; } diff --git a/lib/rules/declaration-property-value-blacklist/README.md b/lib/rules/declaration-property-value-disallowed-list/README.md similarity index 91% rename from lib/rules/declaration-property-value-blacklist/README.md rename to lib/rules/declaration-property-value-disallowed-list/README.md index 737890a5ac..ea583a2f9f 100644 --- a/lib/rules/declaration-property-value-blacklist/README.md +++ b/lib/rules/declaration-property-value-disallowed-list/README.md @@ -1,6 +1,6 @@ -# declaration-property-value-blacklist +# declaration-property-value-disallowed-list -Specify a blacklist of disallowed property and value pairs within declarations. +Specify a list of disallowed property and value pairs within declarations. ```css @@ -9,6 +9,8 @@ a { text-transform: uppercase; } * These properties and these values */ ``` +This rule was previously called, and is aliased as, `declaration-property-value-blacklist`. + ## Options `object`: `{ "unprefixed-property-name": ["array", "of", "values"], "unprefixed-property-name": ["/regex/", "non-regex", /regex/] }` diff --git a/lib/rules/declaration-property-value-blacklist/__tests__/index.js b/lib/rules/declaration-property-value-disallowed-list/__tests__/index.js similarity index 100% rename from lib/rules/declaration-property-value-blacklist/__tests__/index.js rename to lib/rules/declaration-property-value-disallowed-list/__tests__/index.js diff --git a/lib/rules/declaration-property-value-blacklist/index.js b/lib/rules/declaration-property-value-disallowed-list/index.js similarity index 80% rename from lib/rules/declaration-property-value-blacklist/index.js rename to lib/rules/declaration-property-value-disallowed-list/index.js index acfb25f040..21f3b7f0c9 100644 --- a/lib/rules/declaration-property-value-blacklist/index.js +++ b/lib/rules/declaration-property-value-disallowed-list/index.js @@ -9,16 +9,16 @@ const report = require('../../utils/report'); const ruleMessages = require('../../utils/ruleMessages'); const validateOptions = require('../../utils/validateOptions'); -const ruleName = 'declaration-property-value-blacklist'; +const ruleName = 'declaration-property-value-disallowed-list'; const messages = ruleMessages(ruleName, { rejected: (property, value) => `Unexpected value "${value}" for property "${property}"`, }); -function rule(blacklist) { +function rule(list) { return (root, result) => { const validOptions = validateOptions(result, ruleName, { - actual: blacklist, + actual: list, possible: [_.isObject], }); @@ -31,15 +31,15 @@ function rule(blacklist) { const value = decl.value; const unprefixedProp = postcss.vendor.unprefixed(prop); - const propBlacklist = _.find(blacklist, (list, propIdentifier) => + const propList = _.find(list, (values, propIdentifier) => matchesStringOrRegExp(unprefixedProp, propIdentifier), ); - if (_.isEmpty(propBlacklist)) { + if (_.isEmpty(propList)) { return; } - if (!matchesStringOrRegExp(value, propBlacklist)) { + if (!matchesStringOrRegExp(value, propList)) { return; } diff --git a/lib/rules/function-whitelist/README.md b/lib/rules/function-allowed-list/README.md similarity index 88% rename from lib/rules/function-whitelist/README.md rename to lib/rules/function-allowed-list/README.md index 46e7a26a7e..e8229a835a 100644 --- a/lib/rules/function-whitelist/README.md +++ b/lib/rules/function-allowed-list/README.md @@ -1,6 +1,6 @@ -# function-whitelist +# function-allowed-list -Specify a whitelist of allowed functions. +Specify a list of allowed functions. ```css @@ -9,6 +9,8 @@ a { transform: scale(1); } * This function */ ``` +This rule was previously called, and is aliased as, `function-whitelist`. + ## Options `array|string`: `["array", "of", "unprefixed", /functions/ or "regex"]|"function"|"/regex/"` diff --git a/lib/rules/function-whitelist/__tests__/index.js b/lib/rules/function-allowed-list/__tests__/index.js similarity index 100% rename from lib/rules/function-whitelist/__tests__/index.js rename to lib/rules/function-allowed-list/__tests__/index.js diff --git a/lib/rules/function-whitelist/index.js b/lib/rules/function-allowed-list/index.js similarity index 90% rename from lib/rules/function-whitelist/index.js rename to lib/rules/function-allowed-list/index.js index e04559bcae..d162557a56 100644 --- a/lib/rules/function-whitelist/index.js +++ b/lib/rules/function-allowed-list/index.js @@ -12,18 +12,18 @@ const ruleMessages = require('../../utils/ruleMessages'); const validateOptions = require('../../utils/validateOptions'); const valueParser = require('postcss-value-parser'); -const ruleName = 'function-whitelist'; +const ruleName = 'function-allowed-list'; const messages = ruleMessages(ruleName, { rejected: (name) => `Unexpected function "${name}"`, }); -function rule(whitelistInput) { - const whitelist = [].concat(whitelistInput); +function rule(listInput) { + const list = [].concat(listInput); return (root, result) => { const validOptions = validateOptions(result, ruleName, { - actual: whitelist, + actual: list, possible: [_.isString, _.isRegExp], }); @@ -43,7 +43,7 @@ function rule(whitelistInput) { return; } - if (matchesStringOrRegExp(postcss.vendor.unprefixed(node.value), whitelist)) { + if (matchesStringOrRegExp(postcss.vendor.unprefixed(node.value), list)) { return; } diff --git a/lib/rules/function-blacklist/README.md b/lib/rules/function-disallowed-list/README.md similarity index 84% rename from lib/rules/function-blacklist/README.md rename to lib/rules/function-disallowed-list/README.md index 8ef17de5bf..8f622db3ae 100644 --- a/lib/rules/function-blacklist/README.md +++ b/lib/rules/function-disallowed-list/README.md @@ -1,6 +1,6 @@ -# function-blacklist +# function-disallowed-list -Specify a blacklist of disallowed functions. +Specify a list of disallowed functions. ```css @@ -9,6 +9,8 @@ a { transform: scale(1); } * This function */ ``` +This rule was previously called, and is aliased as, `function-blacklist`. + ## Options `array|string`: `["array", "of", "unprefixed", /functions/ or "regex"]|"function"|"/regex/"` diff --git a/lib/rules/function-blacklist/__tests__/index.js b/lib/rules/function-disallowed-list/__tests__/index.js similarity index 100% rename from lib/rules/function-blacklist/__tests__/index.js rename to lib/rules/function-disallowed-list/__tests__/index.js diff --git a/lib/rules/function-blacklist/index.js b/lib/rules/function-disallowed-list/index.js similarity index 92% rename from lib/rules/function-blacklist/index.js rename to lib/rules/function-disallowed-list/index.js index f92e1b3ac9..5f30bb862a 100644 --- a/lib/rules/function-blacklist/index.js +++ b/lib/rules/function-disallowed-list/index.js @@ -12,16 +12,16 @@ const ruleMessages = require('../../utils/ruleMessages'); const validateOptions = require('../../utils/validateOptions'); const valueParser = require('postcss-value-parser'); -const ruleName = 'function-blacklist'; +const ruleName = 'function-disallowed-list'; const messages = ruleMessages(ruleName, { rejected: (name) => `Unexpected function "${name}"`, }); -function rule(blacklist) { +function rule(list) { return (root, result) => { const validOptions = validateOptions(result, ruleName, { - actual: blacklist, + actual: list, possible: [_.isString, _.isRegExp], }); @@ -41,7 +41,7 @@ function rule(blacklist) { return; } - if (!matchesStringOrRegExp(postcss.vendor.unprefixed(node.value), blacklist)) { + if (!matchesStringOrRegExp(postcss.vendor.unprefixed(node.value), list)) { return; } diff --git a/lib/rules/function-url-scheme-whitelist/README.md b/lib/rules/function-url-scheme-allowed-list/README.md similarity index 91% rename from lib/rules/function-url-scheme-whitelist/README.md rename to lib/rules/function-url-scheme-allowed-list/README.md index 4476de88cf..8a2d49154c 100644 --- a/lib/rules/function-url-scheme-whitelist/README.md +++ b/lib/rules/function-url-scheme-allowed-list/README.md @@ -1,6 +1,6 @@ -# function-url-scheme-whitelist +# function-url-scheme-allowed-list -Specify a whitelist of allowed URL schemes. +Specify a list of allowed URL schemes. ```css @@ -9,6 +9,8 @@ a { background-image: url('http://www.example.com/file.jpg'); } * This URL scheme */ ``` +This rule was previously called, and is aliased as, `function-url-scheme-whitelist`. + A [URL scheme](https://url.spec.whatwg.org/#syntax-url-scheme) consists of alphanumeric, `+`, `-`, and `.` characters. It can appear at the start of a URL and is followed by `:`. This rule ignores: diff --git a/lib/rules/function-url-scheme-whitelist/__tests__/index.js b/lib/rules/function-url-scheme-allowed-list/__tests__/index.js similarity index 100% rename from lib/rules/function-url-scheme-whitelist/__tests__/index.js rename to lib/rules/function-url-scheme-allowed-list/__tests__/index.js diff --git a/lib/rules/function-url-scheme-whitelist/index.js b/lib/rules/function-url-scheme-allowed-list/index.js similarity index 90% rename from lib/rules/function-url-scheme-whitelist/index.js rename to lib/rules/function-url-scheme-allowed-list/index.js index d8d100e55c..224cba8baa 100644 --- a/lib/rules/function-url-scheme-whitelist/index.js +++ b/lib/rules/function-url-scheme-allowed-list/index.js @@ -11,16 +11,16 @@ const report = require('../../utils/report'); const ruleMessages = require('../../utils/ruleMessages'); const validateOptions = require('../../utils/validateOptions'); -const ruleName = 'function-url-scheme-whitelist'; +const ruleName = 'function-url-scheme-allowed-list'; const messages = ruleMessages(ruleName, { rejected: (scheme) => `Unexpected URL scheme "${scheme}:"`, }); -function rule(whitelist) { +function rule(list) { return (root, result) => { const validOptions = validateOptions(result, ruleName, { - actual: whitelist, + actual: list, possible: [_.isString, _.isRegExp], }); @@ -43,7 +43,7 @@ function rule(whitelist) { return; } - if (matchesStringOrRegExp(scheme, whitelist)) { + if (matchesStringOrRegExp(scheme, list)) { return; } diff --git a/lib/rules/function-url-scheme-blacklist/README.md b/lib/rules/function-url-scheme-disallowed-list/README.md similarity index 90% rename from lib/rules/function-url-scheme-blacklist/README.md rename to lib/rules/function-url-scheme-disallowed-list/README.md index 2b40614126..a6dadce430 100644 --- a/lib/rules/function-url-scheme-blacklist/README.md +++ b/lib/rules/function-url-scheme-disallowed-list/README.md @@ -1,6 +1,6 @@ -# function-url-scheme-blacklist +# function-url-scheme-disallowed-list -Specify a blacklist of disallowed URL schemes. +Specify a list of disallowed URL schemes. ```css @@ -9,6 +9,8 @@ a { background-image: url('http://www.example.com/file.jpg'); } * This URL scheme */ ``` +This rule was previously called, and is aliased as, `function-url-scheme-blacklist`. + A [URL scheme](https://url.spec.whatwg.org/#syntax-url-scheme) consists of alphanumeric, `+`, `-`, and `.` characters. It can appear at the start of a URL and is followed by `:`. This rule ignores: diff --git a/lib/rules/function-url-scheme-blacklist/__tests__/index.js b/lib/rules/function-url-scheme-disallowed-list/__tests__/index.js similarity index 100% rename from lib/rules/function-url-scheme-blacklist/__tests__/index.js rename to lib/rules/function-url-scheme-disallowed-list/__tests__/index.js diff --git a/lib/rules/function-url-scheme-blacklist/index.js b/lib/rules/function-url-scheme-disallowed-list/index.js similarity index 90% rename from lib/rules/function-url-scheme-blacklist/index.js rename to lib/rules/function-url-scheme-disallowed-list/index.js index 9cb557fb96..18f7af4c23 100644 --- a/lib/rules/function-url-scheme-blacklist/index.js +++ b/lib/rules/function-url-scheme-disallowed-list/index.js @@ -11,16 +11,16 @@ const report = require('../../utils/report'); const ruleMessages = require('../../utils/ruleMessages'); const validateOptions = require('../../utils/validateOptions'); -const ruleName = 'function-url-scheme-blacklist'; +const ruleName = 'function-url-scheme-disallowed-list'; const messages = ruleMessages(ruleName, { rejected: (scheme) => `Unexpected URL scheme "${scheme}:"`, }); -function rule(blacklist) { +function rule(list) { return (root, result) => { const validOptions = validateOptions(result, ruleName, { - actual: blacklist, + actual: list, possible: [_.isString, _.isRegExp], }); @@ -43,7 +43,7 @@ function rule(blacklist) { return; } - if (!matchesStringOrRegExp(scheme, blacklist)) { + if (!matchesStringOrRegExp(scheme, list)) { return; } diff --git a/lib/rules/index.js b/lib/rules/index.js index 241ce9fadf..4846a04021 100644 --- a/lib/rules/index.js +++ b/lib/rules/index.js @@ -7,7 +7,10 @@ const importLazy = require('import-lazy'); /** @type {{[k: string]: Function}} */ const rules = { 'alpha-value-notation': importLazy(() => require('./alpha-value-notation'))(), - 'at-rule-blacklist': importLazy(() => require('./at-rule-blacklist'))(), + 'at-rule-allowed-list': importLazy(() => require('./at-rule-allowed-list'))(), + // Renamed to at-rule-disallowed-list + 'at-rule-blacklist': importLazy(() => require('./at-rule-disallowed-list'))(), + 'at-rule-disallowed-list': importLazy(() => require('./at-rule-disallowed-list'))(), 'at-rule-empty-line-before': importLazy(() => require('./at-rule-empty-line-before'))(), 'at-rule-name-case': importLazy(() => require('./at-rule-name-case'))(), 'at-rule-name-newline-after': importLazy(() => require('./at-rule-name-newline-after'))(), @@ -15,11 +18,14 @@ const rules = { 'at-rule-name-space-after': importLazy(() => require('./at-rule-name-space-after'))(), 'at-rule-no-unknown': importLazy(() => require('./at-rule-no-unknown'))(), 'at-rule-no-vendor-prefix': importLazy(() => require('./at-rule-no-vendor-prefix'))(), - 'at-rule-property-requirelist': importLazy(() => require('./at-rule-property-requirelist'))(), + 'at-rule-property-required-list': importLazy(() => require('./at-rule-property-required-list'))(), + // Renamed to at-rule-required-list + 'at-rule-property-requirelist': importLazy(() => require('./at-rule-property-required-list'))(), 'at-rule-semicolon-newline-after': importLazy(() => require('./at-rule-semicolon-newline-after'), )(), - 'at-rule-whitelist': importLazy(() => require('./at-rule-whitelist'))(), + // Renamed to at-rule-allowed-list + 'at-rule-whitelist': importLazy(() => require('./at-rule-allowed-list'))(), 'block-closing-brace-empty-line-before': importLazy(() => require('./block-closing-brace-empty-line-before'), )(), @@ -57,7 +63,9 @@ const rules = { 'comment-empty-line-before': importLazy(() => require('./comment-empty-line-before'))(), 'comment-no-empty': importLazy(() => require('./comment-no-empty'))(), 'comment-whitespace-inside': importLazy(() => require('./comment-whitespace-inside'))(), - 'comment-word-blacklist': importLazy(() => require('./comment-word-blacklist'))(), + // Renamed to comment-word-disallowed-list + 'comment-word-blacklist': importLazy(() => require('./comment-word-disallowed-list'))(), + 'comment-word-disallowed-list': importLazy(() => require('./comment-word-disallowed-list'))(), 'custom-media-pattern': importLazy(() => require('./custom-media-pattern'))(), 'custom-property-empty-line-before': importLazy(() => require('./custom-property-empty-line-before'), @@ -99,17 +107,33 @@ const rules = { 'declaration-colon-space-before': importLazy(() => require('./declaration-colon-space-before'))(), 'declaration-empty-line-before': importLazy(() => require('./declaration-empty-line-before'))(), 'declaration-no-important': importLazy(() => require('./declaration-no-important'))(), + 'declaration-property-unit-allowed-list': importLazy(() => + require('./declaration-property-unit-allowed-list'), + )(), + // Renamed to declaration-property-unit-disallowed-list 'declaration-property-unit-blacklist': importLazy(() => - require('./declaration-property-unit-blacklist'), + require('./declaration-property-unit-disallowed-list'), + )(), + 'declaration-property-unit-disallowed-list': importLazy(() => + require('./declaration-property-unit-disallowed-list'), )(), + // Renamed to declaration-property-unit-allowed-list 'declaration-property-unit-whitelist': importLazy(() => - require('./declaration-property-unit-whitelist'), + require('./declaration-property-unit-allowed-list'), + )(), + 'declaration-property-value-allowed-list': importLazy(() => + require('./declaration-property-value-allowed-list'), )(), + // Renamed to declaration-property-value-disallowed-list 'declaration-property-value-blacklist': importLazy(() => - require('./declaration-property-value-blacklist'), + require('./declaration-property-value-disallowed-list'), )(), + 'declaration-property-value-disallowed-list': importLazy(() => + require('./declaration-property-value-disallowed-list'), + )(), + // Renamed to declaration-property-value-allowed-list 'declaration-property-value-whitelist': importLazy(() => - require('./declaration-property-value-whitelist'), + require('./declaration-property-value-allowed-list'), )(), 'font-family-no-missing-generic-family-keyword': importLazy(() => require('./font-family-no-missing-generic-family-keyword'), @@ -117,7 +141,9 @@ const rules = { 'font-family-name-quotes': importLazy(() => require('./font-family-name-quotes'))(), 'font-family-no-duplicate-names': importLazy(() => require('./font-family-no-duplicate-names'))(), 'font-weight-notation': importLazy(() => require('./font-weight-notation'))(), - 'function-blacklist': importLazy(() => require('./function-blacklist'))(), + 'function-allowed-list': importLazy(() => require('./function-allowed-list'))(), + // Renamed to function-disallowed-list + 'function-blacklist': importLazy(() => require('./function-disallowed-list'))(), 'function-calc-no-invalid': importLazy(() => require('./function-calc-no-invalid'))(), 'function-calc-no-unspaced-operator': importLazy(() => require('./function-calc-no-unspaced-operator'), @@ -126,6 +152,7 @@ const rules = { 'function-comma-newline-before': importLazy(() => require('./function-comma-newline-before'))(), 'function-comma-space-after': importLazy(() => require('./function-comma-space-after'))(), 'function-comma-space-before': importLazy(() => require('./function-comma-space-before'))(), + 'function-disallowed-list': importLazy(() => require('./function-disallowed-list'))(), 'function-linear-gradient-no-nonstandard-direction': importLazy(() => require('./function-linear-gradient-no-nonstandard-direction'), )(), @@ -141,10 +168,23 @@ const rules = { require('./function-url-no-scheme-relative'), )(), 'function-url-quotes': importLazy(() => require('./function-url-quotes'))(), - 'function-url-scheme-blacklist': importLazy(() => require('./function-url-scheme-blacklist'))(), - 'function-url-scheme-whitelist': importLazy(() => require('./function-url-scheme-whitelist'))(), - 'function-whitelist': importLazy(() => require('./function-whitelist'))(), + 'function-url-scheme-allowed-list': importLazy(() => + require('./function-url-scheme-allowed-list'), + )(), + // Renamed to function-url-scheme-disallowed-list + 'function-url-scheme-blacklist': importLazy(() => + require('./function-url-scheme-disallowed-list'), + )(), + 'function-url-scheme-disallowed-list': importLazy(() => + require('./function-url-scheme-disallowed-list'), + )(), + // Renamed to function-url-scheme-allowed-list + 'function-url-scheme-whitelist': importLazy(() => + require('./function-url-scheme-allowed-list'), + )(), 'function-whitespace-after': importLazy(() => require('./function-whitespace-after'))(), + // Renamed to function-allowed-list + 'function-whitelist': importLazy(() => require('./function-allowed-list'))(), 'hue-degree-notation': importLazy(() => require('./hue-degree-notation'))(), 'keyframe-declaration-no-important': importLazy(() => require('./keyframe-declaration-no-important'), @@ -161,16 +201,29 @@ const rules = { 'media-feature-colon-space-before': importLazy(() => require('./media-feature-colon-space-before'), )(), - 'media-feature-name-blacklist': importLazy(() => require('./media-feature-name-blacklist'))(), + 'media-feature-name-allowed-list': importLazy(() => + require('./media-feature-name-allowed-list'), + )(), + // Renamed to media-feature-name-disallowed-list + 'media-feature-name-blacklist': importLazy(() => + require('./media-feature-name-disallowed-list'), + )(), 'media-feature-name-case': importLazy(() => require('./media-feature-name-case'))(), + 'media-feature-name-disallowed-list': importLazy(() => + require('./media-feature-name-disallowed-list'), + )(), 'media-feature-name-no-unknown': importLazy(() => require('./media-feature-name-no-unknown'))(), 'media-feature-name-no-vendor-prefix': importLazy(() => require('./media-feature-name-no-vendor-prefix'), )(), + 'media-feature-name-value-allowed-list': importLazy(() => + require('./media-feature-name-value-allowed-list'), + )(), 'media-feature-name-value-whitelist': importLazy(() => - require('./media-feature-name-value-whitelist'), + require('./media-feature-name-value-allowed-list'), )(), - 'media-feature-name-whitelist': importLazy(() => require('./media-feature-name-whitelist'))(), + // Renamed to media-feature-name-allowed-list + 'media-feature-name-whitelist': importLazy(() => require('./media-feature-name-allowed-list'))(), 'media-feature-parentheses-space-inside': importLazy(() => require('./media-feature-parentheses-space-inside'), )(), @@ -209,17 +262,28 @@ const rules = { 'number-leading-zero': importLazy(() => require('./number-leading-zero'))(), 'number-max-precision': importLazy(() => require('./number-max-precision'))(), 'number-no-trailing-zeros': importLazy(() => require('./number-no-trailing-zeros'))(), - 'property-blacklist': importLazy(() => require('./property-blacklist'))(), + 'property-allowed-list': importLazy(() => require('./property-allowed-list'))(), + // Renamed to property-disallowed-list + 'property-blacklist': importLazy(() => require('./property-disallowed-list'))(), 'property-case': importLazy(() => require('./property-case'))(), + 'property-disallowed-list': importLazy(() => require('./property-disallowed-list'))(), 'property-no-unknown': importLazy(() => require('./property-no-unknown'))(), 'property-no-vendor-prefix': importLazy(() => require('./property-no-vendor-prefix'))(), - 'property-whitelist': importLazy(() => require('./property-whitelist'))(), + // Renamed to property-allowed-list + 'property-whitelist': importLazy(() => require('./property-allowed-list'))(), 'rule-empty-line-before': importLazy(() => require('./rule-empty-line-before'))(), 'selector-attribute-brackets-space-inside': importLazy(() => require('./selector-attribute-brackets-space-inside'), )(), + 'selector-attribute-operator-allowed-list': importLazy(() => + require('./selector-attribute-operator-allowed-list'), + )(), + // Renamed to selector-attribute-operator-disallowed-list 'selector-attribute-operator-blacklist': importLazy(() => - require('./selector-attribute-operator-blacklist'), + require('./selector-attribute-operator-disallowed-list'), + )(), + 'selector-attribute-operator-disallowed-list': importLazy(() => + require('./selector-attribute-operator-disallowed-list'), )(), 'selector-attribute-operator-space-after': importLazy(() => require('./selector-attribute-operator-space-after'), @@ -227,19 +291,32 @@ const rules = { 'selector-attribute-operator-space-before': importLazy(() => require('./selector-attribute-operator-space-before'), )(), + // Renamed to selector-attribute-operator-allowed-list 'selector-attribute-operator-whitelist': importLazy(() => - require('./selector-attribute-operator-whitelist'), + require('./selector-attribute-operator-allowed-list'), )(), 'selector-attribute-quotes': importLazy(() => require('./selector-attribute-quotes'))(), 'selector-class-pattern': importLazy(() => require('./selector-class-pattern'))(), - 'selector-combinator-blacklist': importLazy(() => require('./selector-combinator-blacklist'))(), + 'selector-combinator-allowed-list': importLazy(() => + require('./selector-combinator-allowed-list'), + )(), + // Renamed to selector-combinator-disallowed-list + 'selector-combinator-blacklist': importLazy(() => + require('./selector-combinator-disallowed-list'), + )(), + 'selector-combinator-disallowed-list': importLazy(() => + require('./selector-combinator-disallowed-list'), + )(), 'selector-combinator-space-after': importLazy(() => require('./selector-combinator-space-after'), )(), 'selector-combinator-space-before': importLazy(() => require('./selector-combinator-space-before'), )(), - 'selector-combinator-whitelist': importLazy(() => require('./selector-combinator-whitelist'))(), + // Renamed to selector-combinator-allowed-list + 'selector-combinator-whitelist': importLazy(() => + require('./selector-combinator-allowed-list'), + )(), 'selector-descendant-combinator-no-non-space': importLazy(() => require('./selector-descendant-combinator-no-non-space'), )(), @@ -271,31 +348,47 @@ const rules = { 'selector-nested-pattern': importLazy(() => require('./selector-nested-pattern'))(), 'selector-no-qualifying-type': importLazy(() => require('./selector-no-qualifying-type'))(), 'selector-no-vendor-prefix': importLazy(() => require('./selector-no-vendor-prefix'))(), + 'selector-pseudo-class-allowed-list': importLazy(() => + require('./selector-pseudo-class-allowed-list'), + )(), + // Renamed to selector-pseudo-class-disallowed-list 'selector-pseudo-class-blacklist': importLazy(() => - require('./selector-pseudo-class-blacklist'), + require('./selector-pseudo-class-disallowed-list'), )(), 'selector-pseudo-class-case': importLazy(() => require('./selector-pseudo-class-case'))(), + 'selector-pseudo-class-disallowed-list': importLazy(() => + require('./selector-pseudo-class-disallowed-list'), + )(), 'selector-pseudo-class-no-unknown': importLazy(() => require('./selector-pseudo-class-no-unknown'), )(), 'selector-pseudo-class-parentheses-space-inside': importLazy(() => require('./selector-pseudo-class-parentheses-space-inside'), )(), + // Renamed to selector-pseudo-class-allowed-list 'selector-pseudo-class-whitelist': importLazy(() => - require('./selector-pseudo-class-whitelist'), + require('./selector-pseudo-class-allowed-list'), )(), + 'selector-pseudo-element-allowed-list': importLazy(() => + require('./selector-pseudo-element-allowed-list'), + )(), + // Renamed to selector-pseudo-element-disallowed-list 'selector-pseudo-element-blacklist': importLazy(() => - require('./selector-pseudo-element-blacklist'), + require('./selector-pseudo-element-disallowed-list'), )(), 'selector-pseudo-element-case': importLazy(() => require('./selector-pseudo-element-case'))(), 'selector-pseudo-element-colon-notation': importLazy(() => require('./selector-pseudo-element-colon-notation'), )(), + 'selector-pseudo-element-disallowed-list': importLazy(() => + require('./selector-pseudo-element-disallowed-list'), + )(), 'selector-pseudo-element-no-unknown': importLazy(() => require('./selector-pseudo-element-no-unknown'), )(), + // Renamed to selector-pseudo-element-allowed-list 'selector-pseudo-element-whitelist': importLazy(() => - require('./selector-pseudo-element-whitelist'), + require('./selector-pseudo-element-allowed-list'), )(), 'selector-type-case': importLazy(() => require('./selector-type-case'))(), 'selector-type-no-unknown': importLazy(() => require('./selector-type-no-unknown'))(), @@ -306,10 +399,14 @@ const rules = { 'string-quotes': importLazy(() => require('./string-quotes'))(), 'time-min-milliseconds': importLazy(() => require('./time-min-milliseconds'))(), 'unicode-bom': importLazy(() => require('./unicode-bom'))(), - 'unit-blacklist': importLazy(() => require('./unit-blacklist'))(), + 'unit-allowed-list': importLazy(() => require('./unit-allowed-list'))(), + // Renamed to unit-disallowed-list + 'unit-blacklist': importLazy(() => require('./unit-disallowed-list'))(), 'unit-case': importLazy(() => require('./unit-case'))(), + 'unit-disallowed-list': importLazy(() => require('./unit-disallowed-list'))(), 'unit-no-unknown': importLazy(() => require('./unit-no-unknown'))(), - 'unit-whitelist': importLazy(() => require('./unit-whitelist'))(), + // Renamed to unit-allowed-list + 'unit-whitelist': importLazy(() => require('./unit-allowed-list'))(), 'value-keyword-case': importLazy(() => require('./value-keyword-case'))(), 'value-list-comma-newline-after': importLazy(() => require('./value-list-comma-newline-after'))(), 'value-list-comma-newline-before': importLazy(() => diff --git a/lib/rules/media-feature-name-whitelist/README.md b/lib/rules/media-feature-name-allowed-list/README.md similarity index 84% rename from lib/rules/media-feature-name-whitelist/README.md rename to lib/rules/media-feature-name-allowed-list/README.md index 927f6e412c..4c5c28abcf 100644 --- a/lib/rules/media-feature-name-whitelist/README.md +++ b/lib/rules/media-feature-name-allowed-list/README.md @@ -1,6 +1,6 @@ -# media-feature-name-whitelist +# media-feature-name-allowed-list -Specify a whitelist of allowed media feature names. +Specify a list of allowed media feature names. ```css @@ -9,6 +9,8 @@ Specify a whitelist of allowed media feature names. * This media feature name */ ``` +This rule was previously called, and is aliased as, `media-feature-name-whitelist`. + ## Options `array|string|regex`: `["array", "of", "unprefixed", /media-features/ or "regex"]|"media-feature"|/regex/` diff --git a/lib/rules/media-feature-name-whitelist/__tests__/index.js b/lib/rules/media-feature-name-allowed-list/__tests__/index.js similarity index 100% rename from lib/rules/media-feature-name-whitelist/__tests__/index.js rename to lib/rules/media-feature-name-allowed-list/__tests__/index.js diff --git a/lib/rules/media-feature-name-whitelist/index.js b/lib/rules/media-feature-name-allowed-list/index.js similarity index 93% rename from lib/rules/media-feature-name-whitelist/index.js rename to lib/rules/media-feature-name-allowed-list/index.js index 04fbb8c9f7..66da909ff2 100644 --- a/lib/rules/media-feature-name-whitelist/index.js +++ b/lib/rules/media-feature-name-allowed-list/index.js @@ -14,16 +14,16 @@ const report = require('../../utils/report'); const ruleMessages = require('../../utils/ruleMessages'); const validateOptions = require('../../utils/validateOptions'); -const ruleName = 'media-feature-name-whitelist'; +const ruleName = 'media-feature-name-allowed-list'; const messages = ruleMessages(ruleName, { rejected: (name) => `Unexpected media feature name "${name}"`, }); -function rule(whitelist) { +function rule(list) { return (root, result) => { const validOptions = validateOptions(result, ruleName, { - actual: whitelist, + actual: list, possible: [_.isString, _.isRegExp], }); @@ -53,7 +53,7 @@ function rule(whitelist) { return; } - if (matchesStringOrRegExp(value, whitelist)) { + if (matchesStringOrRegExp(value, list)) { return; } diff --git a/lib/rules/media-feature-name-blacklist/README.md b/lib/rules/media-feature-name-disallowed-list/README.md similarity index 84% rename from lib/rules/media-feature-name-blacklist/README.md rename to lib/rules/media-feature-name-disallowed-list/README.md index e288ab6cf0..aa4b012208 100644 --- a/lib/rules/media-feature-name-blacklist/README.md +++ b/lib/rules/media-feature-name-disallowed-list/README.md @@ -1,6 +1,6 @@ -# media-feature-name-blacklist +# media-feature-name-disallowed-list -Specify a blacklist of disallowed media feature names. +Specify a list of disallowed media feature names. ```css @@ -9,6 +9,8 @@ Specify a blacklist of disallowed media feature names. * This media feature name */ ``` +This rule was previously called, and is aliased as, `media-feature-name-blacklist`. + ## Options `array|string|regex`: `["array", "of", "unprefixed", /media-features/ or "regex"]|"media-feature"|/regex/` diff --git a/lib/rules/media-feature-name-blacklist/__tests__/index.js b/lib/rules/media-feature-name-disallowed-list/__tests__/index.js similarity index 100% rename from lib/rules/media-feature-name-blacklist/__tests__/index.js rename to lib/rules/media-feature-name-disallowed-list/__tests__/index.js diff --git a/lib/rules/media-feature-name-blacklist/index.js b/lib/rules/media-feature-name-disallowed-list/index.js similarity index 93% rename from lib/rules/media-feature-name-blacklist/index.js rename to lib/rules/media-feature-name-disallowed-list/index.js index 3b4009d026..cf05074f7b 100644 --- a/lib/rules/media-feature-name-blacklist/index.js +++ b/lib/rules/media-feature-name-disallowed-list/index.js @@ -14,16 +14,16 @@ const report = require('../../utils/report'); const ruleMessages = require('../../utils/ruleMessages'); const validateOptions = require('../../utils/validateOptions'); -const ruleName = 'media-feature-name-blacklist'; +const ruleName = 'media-feature-name-disallowed-list'; const messages = ruleMessages(ruleName, { rejected: (name) => `Unexpected media feature name "${name}"`, }); -function rule(blacklist) { +function rule(list) { return (root, result) => { const validOptions = validateOptions(result, ruleName, { - actual: blacklist, + actual: list, possible: [_.isString, _.isRegExp], }); @@ -53,7 +53,7 @@ function rule(blacklist) { return; } - if (!matchesStringOrRegExp(value, blacklist)) { + if (!matchesStringOrRegExp(value, list)) { return; } diff --git a/lib/rules/media-feature-name-value-whitelist/README.md b/lib/rules/media-feature-name-value-allowed-list/README.md similarity index 84% rename from lib/rules/media-feature-name-value-whitelist/README.md rename to lib/rules/media-feature-name-value-allowed-list/README.md index c0b5c0aff3..0e45c430d8 100644 --- a/lib/rules/media-feature-name-value-whitelist/README.md +++ b/lib/rules/media-feature-name-value-allowed-list/README.md @@ -1,6 +1,6 @@ -# media-feature-name-value-whitelist +# media-feature-name-value-allowed-list -Specify a whitelist of allowed media feature name and value pairs. +Specify a list of allowed media feature name and value pairs. ```css @@ -9,6 +9,8 @@ Specify a whitelist of allowed media feature name and value pairs. * These features and values */ ``` +This rule was previously called, and is aliased as, `media-feature-name-value-whitelist`. + ## Options ```js @@ -18,7 +20,7 @@ Specify a whitelist of allowed media feature name and value pairs. } ``` -If a media feature name is found in the object, only its whitelisted values are +If a media feature name is found in the object, only its allowed-listed values are allowed. If the media feature name is not included in the object, anything goes. If a name or value is surrounded with `/` (e.g. `"/width$/"`), it is interpreted diff --git a/lib/rules/media-feature-name-value-whitelist/__tests__/index.js b/lib/rules/media-feature-name-value-allowed-list/__tests__/index.js similarity index 92% rename from lib/rules/media-feature-name-value-whitelist/__tests__/index.js rename to lib/rules/media-feature-name-value-allowed-list/__tests__/index.js index c5e1e8dfda..7ac33c41f6 100644 --- a/lib/rules/media-feature-name-value-whitelist/__tests__/index.js +++ b/lib/rules/media-feature-name-value-allowed-list/__tests__/index.js @@ -36,15 +36,15 @@ testRule({ }, { code: '@media screen and (min-width: $sm) {}', - description: 'Non-standard syntax in whitelist', + description: 'Non-standard syntax in allowed list', }, { code: '@media (color) {}', - description: 'Boolean context, media feature in whitelist', + description: 'Boolean context, media feature in allowed list', }, { code: '@media (update) {}', - description: 'Boolean context, media feature NOT in whitelist', + description: 'Boolean context, media feature NOT in allowed list', }, { code: '@media (update /* pw:ned */) {}', @@ -52,7 +52,7 @@ testRule({ }, { code: '@media screen and (min-width <= 768px) {}', - description: 'Range context, media feature in whitelist', + description: 'Range context, media feature in allowed list', }, ], @@ -86,7 +86,7 @@ testRule({ }, { code: '@media screen and (min-width: $md) {}', - description: 'Non-standard syntax NOT in whitelist', + description: 'Non-standard syntax NOT in allowed list', message: messages.rejected('min-width', '$md'), line: 1, column: 31, diff --git a/lib/rules/media-feature-name-value-whitelist/index.js b/lib/rules/media-feature-name-value-allowed-list/index.js similarity index 86% rename from lib/rules/media-feature-name-value-whitelist/index.js rename to lib/rules/media-feature-name-value-allowed-list/index.js index a78c5f4d7c..60272c91af 100644 --- a/lib/rules/media-feature-name-value-whitelist/index.js +++ b/lib/rules/media-feature-name-value-allowed-list/index.js @@ -13,16 +13,16 @@ const report = require('../../utils/report'); const ruleMessages = require('../../utils/ruleMessages'); const validateOptions = require('../../utils/validateOptions'); -const ruleName = 'media-feature-name-value-whitelist'; +const ruleName = 'media-feature-name-value-allowed-list'; const messages = ruleMessages(ruleName, { rejected: (name, value) => `Unexpected value "${value}" for name "${name}"`, }); -function rule(whitelist) { +function rule(list) { return (root, result) => { const validOptions = validateOptions(result, ruleName, { - actual: whitelist, + actual: list, possible: [_.isObject], }); @@ -59,15 +59,15 @@ function rule(whitelist) { const value = valueNode.value; const unprefixedMediaFeatureName = postcss.vendor.unprefixed(mediaFeatureName); - const featureWhitelist = _.find(whitelist, (v, whitelistFeatureName) => - matchesStringOrRegExp(unprefixedMediaFeatureName, whitelistFeatureName), + const allowedValues = _.find(list, (v, featureName) => + matchesStringOrRegExp(unprefixedMediaFeatureName, featureName), ); - if (featureWhitelist === undefined) { + if (allowedValues === undefined) { return; } - if (matchesStringOrRegExp(value, featureWhitelist)) { + if (matchesStringOrRegExp(value, allowedValues)) { return; } diff --git a/lib/rules/property-whitelist/README.md b/lib/rules/property-allowed-list/README.md similarity index 90% rename from lib/rules/property-whitelist/README.md rename to lib/rules/property-allowed-list/README.md index d527268b87..4383c3164c 100644 --- a/lib/rules/property-whitelist/README.md +++ b/lib/rules/property-allowed-list/README.md @@ -1,6 +1,6 @@ -# property-whitelist +# property-allowed-list -Specify a whitelist of allowed properties. +Specify a list of allowed properties. ```css @@ -9,6 +9,8 @@ a { display: block; } * This property */ ``` +This rule was previously called, and is aliased as, `property-whitelist`. + This rule ignores variables (`$sass`, `@less`, `--custom-property`). ## Options diff --git a/lib/rules/property-whitelist/__tests__/index.js b/lib/rules/property-allowed-list/__tests__/index.js similarity index 100% rename from lib/rules/property-whitelist/__tests__/index.js rename to lib/rules/property-allowed-list/__tests__/index.js diff --git a/lib/rules/property-whitelist/index.js b/lib/rules/property-allowed-list/index.js similarity index 87% rename from lib/rules/property-whitelist/index.js rename to lib/rules/property-allowed-list/index.js index 9772024db1..28f9df5be8 100644 --- a/lib/rules/property-whitelist/index.js +++ b/lib/rules/property-allowed-list/index.js @@ -11,16 +11,16 @@ const report = require('../../utils/report'); const ruleMessages = require('../../utils/ruleMessages'); const validateOptions = require('../../utils/validateOptions'); -const ruleName = 'property-whitelist'; +const ruleName = 'property-allowed-list'; const messages = ruleMessages(ruleName, { rejected: (property) => `Unexpected property "${property}"`, }); -function rule(whitelist) { +function rule(list) { return (root, result) => { const validOptions = validateOptions(result, ruleName, { - actual: whitelist, + actual: list, possible: [_.isString, _.isRegExp], }); @@ -39,7 +39,7 @@ function rule(whitelist) { return; } - if (matchesStringOrRegExp(postcss.vendor.unprefixed(prop), whitelist)) { + if (matchesStringOrRegExp(postcss.vendor.unprefixed(prop), list)) { return; } diff --git a/lib/rules/property-blacklist/README.md b/lib/rules/property-disallowed-list/README.md similarity index 88% rename from lib/rules/property-blacklist/README.md rename to lib/rules/property-disallowed-list/README.md index e5c400c28c..012981f710 100644 --- a/lib/rules/property-blacklist/README.md +++ b/lib/rules/property-disallowed-list/README.md @@ -1,6 +1,6 @@ -# property-blacklist +# property-disallowed-list -Specify a blacklist of disallowed properties. +Specify a list of disallowed properties. ```css @@ -9,6 +9,8 @@ a { text-rendering: optimizeLegibility; } * This property */ ``` +This rule was previously called, and is aliased as, `property-blacklist`. + ## Options `array|string`: `["array", "of", "unprefixed", /properties/ or "regex"]|"property"|"/regex/"`|/regex/ diff --git a/lib/rules/property-blacklist/__tests__/index.js b/lib/rules/property-disallowed-list/__tests__/index.js similarity index 100% rename from lib/rules/property-blacklist/__tests__/index.js rename to lib/rules/property-disallowed-list/__tests__/index.js diff --git a/lib/rules/property-blacklist/index.js b/lib/rules/property-disallowed-list/index.js similarity index 87% rename from lib/rules/property-blacklist/index.js rename to lib/rules/property-disallowed-list/index.js index 2ef2754a7a..21aff9a130 100644 --- a/lib/rules/property-blacklist/index.js +++ b/lib/rules/property-disallowed-list/index.js @@ -11,16 +11,16 @@ const report = require('../../utils/report'); const ruleMessages = require('../../utils/ruleMessages'); const validateOptions = require('../../utils/validateOptions'); -const ruleName = 'property-blacklist'; +const ruleName = 'property-disallowed-list'; const messages = ruleMessages(ruleName, { rejected: (property) => `Unexpected property "${property}"`, }); -function rule(blacklist) { +function rule(list) { return (root, result) => { const validOptions = validateOptions(result, ruleName, { - actual: blacklist, + actual: list, possible: [_.isString, _.isRegExp], }); @@ -39,7 +39,7 @@ function rule(blacklist) { return; } - if (!matchesStringOrRegExp(postcss.vendor.unprefixed(prop), blacklist)) { + if (!matchesStringOrRegExp(postcss.vendor.unprefixed(prop), list)) { return; } diff --git a/lib/rules/selector-attribute-operator-whitelist/README.md b/lib/rules/selector-attribute-operator-allowed-list/README.md similarity index 77% rename from lib/rules/selector-attribute-operator-whitelist/README.md rename to lib/rules/selector-attribute-operator-allowed-list/README.md index 881eb6e92d..6cdbae223b 100644 --- a/lib/rules/selector-attribute-operator-whitelist/README.md +++ b/lib/rules/selector-attribute-operator-allowed-list/README.md @@ -1,6 +1,6 @@ -# selector-attribute-operator-whitelist +# selector-attribute-operator-allowed-list -Specify a whitelist of allowed attribute operators. +Specify a list of allowed attribute operators. ```css @@ -9,6 +9,8 @@ Specify a whitelist of allowed attribute operators. * This operator */ ``` +This rule was previously called, and is aliased as, `selector-attribute-operator-whitelist`. + ## Options `array|string`: `["array", "of", "operators"]|"operator"` diff --git a/lib/rules/selector-attribute-operator-whitelist/__tests__/index.js b/lib/rules/selector-attribute-operator-allowed-list/__tests__/index.js similarity index 100% rename from lib/rules/selector-attribute-operator-whitelist/__tests__/index.js rename to lib/rules/selector-attribute-operator-allowed-list/__tests__/index.js diff --git a/lib/rules/selector-attribute-operator-whitelist/index.js b/lib/rules/selector-attribute-operator-allowed-list/index.js similarity index 85% rename from lib/rules/selector-attribute-operator-whitelist/index.js rename to lib/rules/selector-attribute-operator-allowed-list/index.js index bc63e28049..ae31e7ec8d 100644 --- a/lib/rules/selector-attribute-operator-whitelist/index.js +++ b/lib/rules/selector-attribute-operator-allowed-list/index.js @@ -9,18 +9,18 @@ const report = require('../../utils/report'); const ruleMessages = require('../../utils/ruleMessages'); const validateOptions = require('../../utils/validateOptions'); -const ruleName = 'selector-attribute-operator-whitelist'; +const ruleName = 'selector-attribute-operator-allowed-list'; const messages = ruleMessages(ruleName, { rejected: (operator) => `Unexpected operator "${operator}"`, }); -function rule(whitelistInput) { - const whitelist = [].concat(whitelistInput); +function rule(listInput) { + const list = [].concat(listInput); return (root, result) => { const validOptions = validateOptions(result, ruleName, { - actual: whitelist, + actual: list, possible: [_.isString], }); @@ -41,7 +41,7 @@ function rule(whitelistInput) { selectorTree.walkAttributes((attributeNode) => { const operator = attributeNode.operator; - if (!operator || (operator && whitelist.includes(operator))) { + if (!operator || (operator && list.includes(operator))) { return; } diff --git a/lib/rules/selector-attribute-operator-blacklist/README.md b/lib/rules/selector-attribute-operator-disallowed-list/README.md similarity index 72% rename from lib/rules/selector-attribute-operator-blacklist/README.md rename to lib/rules/selector-attribute-operator-disallowed-list/README.md index a9412812a1..97b51a25d3 100644 --- a/lib/rules/selector-attribute-operator-blacklist/README.md +++ b/lib/rules/selector-attribute-operator-disallowed-list/README.md @@ -1,6 +1,6 @@ -# selector-attribute-operator-blacklist +# selector-attribute-operator-disallowed-list -Specify a blacklist of disallowed attribute operators. +Specify a list of disallowed attribute operators. ```css @@ -9,6 +9,8 @@ Specify a blacklist of disallowed attribute operators. * This operator */ ``` +This rule was previously called, and is aliased as, `selector-attribute-operator-blacklist`. + ## Options `array|string`: `["array", "of", "operators"]|"operator"` diff --git a/lib/rules/selector-attribute-operator-blacklist/__tests__/index.js b/lib/rules/selector-attribute-operator-disallowed-list/__tests__/index.js similarity index 100% rename from lib/rules/selector-attribute-operator-blacklist/__tests__/index.js rename to lib/rules/selector-attribute-operator-disallowed-list/__tests__/index.js diff --git a/lib/rules/selector-attribute-operator-blacklist/index.js b/lib/rules/selector-attribute-operator-disallowed-list/index.js similarity index 85% rename from lib/rules/selector-attribute-operator-blacklist/index.js rename to lib/rules/selector-attribute-operator-disallowed-list/index.js index 1943c55e8f..a48ae4a28d 100644 --- a/lib/rules/selector-attribute-operator-blacklist/index.js +++ b/lib/rules/selector-attribute-operator-disallowed-list/index.js @@ -9,18 +9,18 @@ const report = require('../../utils/report'); const ruleMessages = require('../../utils/ruleMessages'); const validateOptions = require('../../utils/validateOptions'); -const ruleName = 'selector-attribute-operator-blacklist'; +const ruleName = 'selector-attribute-operator-disallowed-list'; const messages = ruleMessages(ruleName, { rejected: (operator) => `Unexpected operator "${operator}"`, }); -function rule(blacklistInput) { - const blacklist = [].concat(blacklistInput); +function rule(listInput) { + const list = [].concat(listInput); return (root, result) => { const validOptions = validateOptions(result, ruleName, { - actual: blacklist, + actual: list, possible: [_.isString], }); @@ -41,7 +41,7 @@ function rule(blacklistInput) { selectorTree.walkAttributes((attributeNode) => { const operator = attributeNode.operator; - if (!operator || (operator && !blacklist.includes(operator))) { + if (!operator || (operator && !list.includes(operator))) { return; } diff --git a/lib/rules/selector-combinator-whitelist/README.md b/lib/rules/selector-combinator-allowed-list/README.md similarity index 81% rename from lib/rules/selector-combinator-whitelist/README.md rename to lib/rules/selector-combinator-allowed-list/README.md index dbcb5ea332..9181f40b93 100644 --- a/lib/rules/selector-combinator-whitelist/README.md +++ b/lib/rules/selector-combinator-allowed-list/README.md @@ -1,6 +1,6 @@ -# selector-combinator-whitelist +# selector-combinator-allowed-list -Specify a whitelist of allowed combinators. +Specify a list of allowed combinators. ```css @@ -9,6 +9,8 @@ Specify a whitelist of allowed combinators. * This combinator */ ``` +This rule was previously called, and is aliased as, `selector-combinator-whitelist`. + This rule normalizes the whitespace descendant combinator to be a single space. This rule ignores [reference combinators](https://www.w3.org/TR/selectors4/#idref-combinators) e.g. `/for/`. diff --git a/lib/rules/selector-combinator-whitelist/__tests__/index.js b/lib/rules/selector-combinator-allowed-list/__tests__/index.js similarity index 100% rename from lib/rules/selector-combinator-whitelist/__tests__/index.js rename to lib/rules/selector-combinator-allowed-list/__tests__/index.js diff --git a/lib/rules/selector-combinator-whitelist/index.js b/lib/rules/selector-combinator-allowed-list/index.js similarity index 91% rename from lib/rules/selector-combinator-whitelist/index.js rename to lib/rules/selector-combinator-allowed-list/index.js index ef8044e546..3b7f6b75a1 100644 --- a/lib/rules/selector-combinator-whitelist/index.js +++ b/lib/rules/selector-combinator-allowed-list/index.js @@ -10,16 +10,16 @@ const report = require('../../utils/report'); const ruleMessages = require('../../utils/ruleMessages'); const validateOptions = require('../../utils/validateOptions'); -const ruleName = 'selector-combinator-whitelist'; +const ruleName = 'selector-combinator-allowed-list'; const messages = ruleMessages(ruleName, { rejected: (combinator) => `Unexpected combinator "${combinator}"`, }); -function rule(whitelist) { +function rule(list) { return (root, result) => { const validOptions = validateOptions(result, ruleName, { - actual: whitelist, + actual: list, possible: [_.isString], }); @@ -42,7 +42,7 @@ function rule(whitelist) { const value = normalizeCombinator(combinatorNode.value); - if (whitelist.includes(value)) { + if (list.includes(value)) { return; } diff --git a/lib/rules/selector-combinator-blacklist/README.md b/lib/rules/selector-combinator-disallowed-list/README.md similarity index 80% rename from lib/rules/selector-combinator-blacklist/README.md rename to lib/rules/selector-combinator-disallowed-list/README.md index 1f232d18f5..98685b9867 100644 --- a/lib/rules/selector-combinator-blacklist/README.md +++ b/lib/rules/selector-combinator-disallowed-list/README.md @@ -1,6 +1,6 @@ -# selector-combinator-blacklist +# selector-combinator-disallowed-list -Specify a blacklist of disallowed combinators. +Specify a list of disallowed combinators. ```css @@ -9,6 +9,8 @@ Specify a blacklist of disallowed combinators. * This combinator */ ``` +This rule was previously called, and is aliased as, `selector-combinator-blacklist`. + This rule normalizes the whitespace descendant combinator to be a single space. This rule ignores [reference combinators](https://www.w3.org/TR/selectors4/#idref-combinators) e.g. `/for/`. diff --git a/lib/rules/selector-combinator-blacklist/__tests__/index.js b/lib/rules/selector-combinator-disallowed-list/__tests__/index.js similarity index 100% rename from lib/rules/selector-combinator-blacklist/__tests__/index.js rename to lib/rules/selector-combinator-disallowed-list/__tests__/index.js diff --git a/lib/rules/selector-combinator-blacklist/index.js b/lib/rules/selector-combinator-disallowed-list/index.js similarity index 91% rename from lib/rules/selector-combinator-blacklist/index.js rename to lib/rules/selector-combinator-disallowed-list/index.js index 2e60e377a8..c06631c3dc 100644 --- a/lib/rules/selector-combinator-blacklist/index.js +++ b/lib/rules/selector-combinator-disallowed-list/index.js @@ -10,16 +10,16 @@ const report = require('../../utils/report'); const ruleMessages = require('../../utils/ruleMessages'); const validateOptions = require('../../utils/validateOptions'); -const ruleName = 'selector-combinator-blacklist'; +const ruleName = 'selector-combinator-disallowed-list'; const messages = ruleMessages(ruleName, { rejected: (combinator) => `Unexpected combinator "${combinator}"`, }); -function rule(blacklist) { +function rule(list) { return (root, result) => { const validOptions = validateOptions(result, ruleName, { - actual: blacklist, + actual: list, possible: [_.isString], }); @@ -42,7 +42,7 @@ function rule(blacklist) { const value = normalizeCombinator(combinatorNode.value); - if (!blacklist.includes(value)) { + if (!list.includes(value)) { return; } diff --git a/lib/rules/selector-pseudo-class-whitelist/README.md b/lib/rules/selector-pseudo-class-allowed-list/README.md similarity index 84% rename from lib/rules/selector-pseudo-class-whitelist/README.md rename to lib/rules/selector-pseudo-class-allowed-list/README.md index 52822e1831..b22b2711fa 100644 --- a/lib/rules/selector-pseudo-class-whitelist/README.md +++ b/lib/rules/selector-pseudo-class-allowed-list/README.md @@ -1,6 +1,6 @@ -# selector-pseudo-class-whitelist +# selector-pseudo-class-allowed-list -Specify a whitelist of allowed pseudo-class selectors. +Specify a list of allowed pseudo-class selectors. ```css @@ -9,6 +9,8 @@ Specify a whitelist of allowed pseudo-class selectors. * This pseudo-class selector */ ``` +This rule was previously called, and is aliased as, `selector-pseudo-class-whitelist`. + This rule ignores selectors that use variable interpolation e.g. `:#{$variable} {}`. ## Options diff --git a/lib/rules/selector-pseudo-class-whitelist/__tests__/index.js b/lib/rules/selector-pseudo-class-allowed-list/__tests__/index.js similarity index 100% rename from lib/rules/selector-pseudo-class-whitelist/__tests__/index.js rename to lib/rules/selector-pseudo-class-allowed-list/__tests__/index.js diff --git a/lib/rules/selector-pseudo-class-whitelist/index.js b/lib/rules/selector-pseudo-class-allowed-list/index.js similarity index 93% rename from lib/rules/selector-pseudo-class-whitelist/index.js rename to lib/rules/selector-pseudo-class-allowed-list/index.js index cfe70b5b90..55f3da6f6b 100644 --- a/lib/rules/selector-pseudo-class-whitelist/index.js +++ b/lib/rules/selector-pseudo-class-allowed-list/index.js @@ -11,16 +11,16 @@ const report = require('../../utils/report'); const ruleMessages = require('../../utils/ruleMessages'); const validateOptions = require('../../utils/validateOptions'); -const ruleName = 'selector-pseudo-class-whitelist'; +const ruleName = 'selector-pseudo-class-allowed-list'; const messages = ruleMessages(ruleName, { rejected: (selector) => `Unexpected pseudo-class "${selector}"`, }); -function rule(whitelist) { +function rule(list) { return (root, result) => { const validOptions = validateOptions(result, ruleName, { - actual: whitelist, + actual: list, possible: [_.isString, _.isRegExp], }); @@ -50,7 +50,7 @@ function rule(whitelist) { const name = value.slice(1); - if (matchesStringOrRegExp(postcss.vendor.unprefixed(name), whitelist)) { + if (matchesStringOrRegExp(postcss.vendor.unprefixed(name), list)) { return; } diff --git a/lib/rules/selector-pseudo-class-blacklist/README.md b/lib/rules/selector-pseudo-class-disallowed-list/README.md similarity index 83% rename from lib/rules/selector-pseudo-class-blacklist/README.md rename to lib/rules/selector-pseudo-class-disallowed-list/README.md index b559b805f7..bb21ebf65a 100644 --- a/lib/rules/selector-pseudo-class-blacklist/README.md +++ b/lib/rules/selector-pseudo-class-disallowed-list/README.md @@ -1,6 +1,6 @@ -# selector-pseudo-class-blacklist +# selector-pseudo-class-disallowed-list -Specify a blacklist of disallowed pseudo-class selectors. +Specify a list of disallowed pseudo-class selectors. ```css @@ -9,6 +9,8 @@ Specify a blacklist of disallowed pseudo-class selectors. * This pseudo-class selector */ ``` +This rule was previously called, and is aliased as, `selector-pseudo-class-blacklist`. + This rule ignores selectors that use variable interpolation e.g. `:#{$variable} {}`. ## Options diff --git a/lib/rules/selector-pseudo-class-blacklist/__tests__/index.js b/lib/rules/selector-pseudo-class-disallowed-list/__tests__/index.js similarity index 100% rename from lib/rules/selector-pseudo-class-blacklist/__tests__/index.js rename to lib/rules/selector-pseudo-class-disallowed-list/__tests__/index.js diff --git a/lib/rules/selector-pseudo-class-blacklist/index.js b/lib/rules/selector-pseudo-class-disallowed-list/index.js similarity index 93% rename from lib/rules/selector-pseudo-class-blacklist/index.js rename to lib/rules/selector-pseudo-class-disallowed-list/index.js index 8d95034e5b..ff36ae15ce 100644 --- a/lib/rules/selector-pseudo-class-blacklist/index.js +++ b/lib/rules/selector-pseudo-class-disallowed-list/index.js @@ -11,16 +11,16 @@ const report = require('../../utils/report'); const ruleMessages = require('../../utils/ruleMessages'); const validateOptions = require('../../utils/validateOptions'); -const ruleName = 'selector-pseudo-class-blacklist'; +const ruleName = 'selector-pseudo-class-disallowed-list'; const messages = ruleMessages(ruleName, { rejected: (selector) => `Unexpected pseudo-class "${selector}"`, }); -function rule(blacklist) { +function rule(list) { return (root, result) => { const validOptions = validateOptions(result, ruleName, { - actual: blacklist, + actual: list, possible: [_.isString, _.isRegExp], }); @@ -51,7 +51,7 @@ function rule(blacklist) { const name = value.slice(1); - if (!matchesStringOrRegExp(postcss.vendor.unprefixed(name), blacklist)) { + if (!matchesStringOrRegExp(postcss.vendor.unprefixed(name), list)) { return; } diff --git a/lib/rules/selector-pseudo-element-blacklist/README.md b/lib/rules/selector-pseudo-element-allowed-list/README.md similarity index 81% rename from lib/rules/selector-pseudo-element-blacklist/README.md rename to lib/rules/selector-pseudo-element-allowed-list/README.md index e1db5bf654..2ed1068195 100644 --- a/lib/rules/selector-pseudo-element-blacklist/README.md +++ b/lib/rules/selector-pseudo-element-allowed-list/README.md @@ -1,6 +1,6 @@ -# selector-pseudo-element-blacklist +# selector-pseudo-element-allowed-list -Specify a blacklist of disallowed pseudo-element selectors. +Specify a list of allowed pseudo-element selectors. ```css @@ -9,6 +9,8 @@ Specify a blacklist of disallowed pseudo-element selectors. * This pseudo-element selector */ ``` +This rule was previously called, and is aliased as, `selector-pseudo-element-whitelist`. + This rule ignores: - CSS2 pseudo-elements i.e. those prefixed with a single colon @@ -28,27 +30,27 @@ The following patterns are considered violations: ```css -a::before {} +a::after {} ``` ```css -a::my-pseudo-element {} +a::not-my-pseudo-element {} ``` +The following patterns are _not_ considered violations: + ```css -a::MY-OTHER-pseudo-element {} +a::before {} ``` -The following patterns are _not_ considered violations: - ```css -a::after {} +a::my-pseudo-element {} ``` ```css -a::not-my-pseudo-element {} +a::MY-OTHER-pseudo-element {} ``` diff --git a/lib/rules/selector-pseudo-element-whitelist/__tests__/index.js b/lib/rules/selector-pseudo-element-allowed-list/__tests__/index.js similarity index 100% rename from lib/rules/selector-pseudo-element-whitelist/__tests__/index.js rename to lib/rules/selector-pseudo-element-allowed-list/__tests__/index.js diff --git a/lib/rules/selector-pseudo-element-whitelist/index.js b/lib/rules/selector-pseudo-element-allowed-list/index.js similarity index 93% rename from lib/rules/selector-pseudo-element-whitelist/index.js rename to lib/rules/selector-pseudo-element-allowed-list/index.js index bbd0569ccb..3c39bf2e9d 100644 --- a/lib/rules/selector-pseudo-element-whitelist/index.js +++ b/lib/rules/selector-pseudo-element-allowed-list/index.js @@ -11,16 +11,16 @@ const report = require('../../utils/report'); const ruleMessages = require('../../utils/ruleMessages'); const validateOptions = require('../../utils/validateOptions'); -const ruleName = 'selector-pseudo-element-whitelist'; +const ruleName = 'selector-pseudo-element-allowed-list'; const messages = ruleMessages(ruleName, { rejected: (selector) => `Unexpected pseudo-element "${selector}"`, }); -function rule(whitelist) { +function rule(list) { return (root, result) => { const validOptions = validateOptions(result, ruleName, { - actual: whitelist, + actual: list, possible: [_.isString, _.isRegExp], }); @@ -50,7 +50,7 @@ function rule(whitelist) { const name = value.slice(2); - if (matchesStringOrRegExp(postcss.vendor.unprefixed(name), whitelist)) { + if (matchesStringOrRegExp(postcss.vendor.unprefixed(name), list)) { return; } diff --git a/lib/rules/selector-pseudo-element-whitelist/README.md b/lib/rules/selector-pseudo-element-disallowed-list/README.md similarity index 81% rename from lib/rules/selector-pseudo-element-whitelist/README.md rename to lib/rules/selector-pseudo-element-disallowed-list/README.md index 66d305c00e..0db5b8df2c 100644 --- a/lib/rules/selector-pseudo-element-whitelist/README.md +++ b/lib/rules/selector-pseudo-element-disallowed-list/README.md @@ -1,6 +1,6 @@ -# selector-pseudo-element-whitelist +# selector-pseudo-element-disallowed-list -Specify a whitelist of allowed pseudo-element selectors. +Specify a list of disallowed pseudo-element selectors. ```css @@ -9,6 +9,8 @@ Specify a whitelist of allowed pseudo-element selectors. * This pseudo-element selector */ ``` +This rule was previously called, and is aliased as, `selector-pseudo-element-blacklist`. + This rule ignores: - CSS2 pseudo-elements i.e. those prefixed with a single colon @@ -28,27 +30,27 @@ The following patterns are considered violations: ```css -a::after {} +a::before {} ``` ```css -a::not-my-pseudo-element {} +a::my-pseudo-element {} ``` -The following patterns are _not_ considered violations: - ```css -a::before {} +a::MY-OTHER-pseudo-element {} ``` +The following patterns are _not_ considered violations: + ```css -a::my-pseudo-element {} +a::after {} ``` ```css -a::MY-OTHER-pseudo-element {} +a::not-my-pseudo-element {} ``` diff --git a/lib/rules/selector-pseudo-element-blacklist/__tests__/index.js b/lib/rules/selector-pseudo-element-disallowed-list/__tests__/index.js similarity index 100% rename from lib/rules/selector-pseudo-element-blacklist/__tests__/index.js rename to lib/rules/selector-pseudo-element-disallowed-list/__tests__/index.js diff --git a/lib/rules/selector-pseudo-element-blacklist/index.js b/lib/rules/selector-pseudo-element-disallowed-list/index.js similarity index 93% rename from lib/rules/selector-pseudo-element-blacklist/index.js rename to lib/rules/selector-pseudo-element-disallowed-list/index.js index 55cf8a882b..0c9552b39b 100644 --- a/lib/rules/selector-pseudo-element-blacklist/index.js +++ b/lib/rules/selector-pseudo-element-disallowed-list/index.js @@ -11,16 +11,16 @@ const report = require('../../utils/report'); const ruleMessages = require('../../utils/ruleMessages'); const validateOptions = require('../../utils/validateOptions'); -const ruleName = 'selector-pseudo-element-blacklist'; +const ruleName = 'selector-pseudo-element-disallowed-list'; const messages = ruleMessages(ruleName, { rejected: (selector) => `Unexpected pseudo-element "${selector}"`, }); -function rule(blacklist) { +function rule(list) { return (root, result) => { const validOptions = validateOptions(result, ruleName, { - actual: blacklist, + actual: list, possible: [_.isString, _.isRegExp], }); @@ -50,7 +50,7 @@ function rule(blacklist) { const name = value.slice(2); - if (!matchesStringOrRegExp(postcss.vendor.unprefixed(name), blacklist)) { + if (!matchesStringOrRegExp(postcss.vendor.unprefixed(name), list)) { return; } diff --git a/lib/rules/unit-whitelist/README.md b/lib/rules/unit-allowed-list/README.md similarity index 92% rename from lib/rules/unit-whitelist/README.md rename to lib/rules/unit-allowed-list/README.md index 9f70de7677..2c34eda820 100644 --- a/lib/rules/unit-whitelist/README.md +++ b/lib/rules/unit-allowed-list/README.md @@ -1,6 +1,6 @@ -# unit-whitelist +# unit-allowed-list -Specify a whitelist of allowed units. +Specify a list of allowed units. ```css @@ -9,6 +9,8 @@ a { width: 100px; } * These units */ ``` +This rule was previously called, and is aliased as, `unit-whitelist`. + ## Options `array|string`: `["array", "of", "units"]|"unit"` diff --git a/lib/rules/unit-whitelist/__tests__/index.js b/lib/rules/unit-allowed-list/__tests__/index.js similarity index 100% rename from lib/rules/unit-whitelist/__tests__/index.js rename to lib/rules/unit-allowed-list/__tests__/index.js diff --git a/lib/rules/unit-whitelist/index.js b/lib/rules/unit-allowed-list/index.js similarity index 90% rename from lib/rules/unit-whitelist/index.js rename to lib/rules/unit-allowed-list/index.js index c54d9e6827..f544fe5ca6 100644 --- a/lib/rules/unit-whitelist/index.js +++ b/lib/rules/unit-allowed-list/index.js @@ -13,21 +13,21 @@ const validateObjectWithArrayProps = require('../../utils/validateObjectWithArra const validateOptions = require('../../utils/validateOptions'); const valueParser = require('postcss-value-parser'); -const ruleName = 'unit-whitelist'; +const ruleName = 'unit-allowed-list'; const messages = ruleMessages(ruleName, { rejected: (unit) => `Unexpected unit "${unit}"`, }); -function rule(whitelistInput, options) { - const whitelist = [].concat(whitelistInput); +function rule(listInput, options) { + const list = [].concat(listInput); return (root, result) => { const validOptions = validateOptions( result, ruleName, { - actual: whitelist, + actual: list, possible: [_.isString], }, { @@ -55,7 +55,7 @@ function rule(whitelistInput, options) { const unit = getUnitFromValueNode(valueNode); - if (!unit || (unit && whitelist.includes(unit.toLowerCase()))) { + if (!unit || (unit && list.includes(unit.toLowerCase()))) { return; } diff --git a/lib/rules/unit-blacklist/README.md b/lib/rules/unit-disallowed-list/README.md similarity index 94% rename from lib/rules/unit-blacklist/README.md rename to lib/rules/unit-disallowed-list/README.md index 551a609daa..2f20017030 100644 --- a/lib/rules/unit-blacklist/README.md +++ b/lib/rules/unit-disallowed-list/README.md @@ -1,6 +1,6 @@ -# unit-blacklist +# unit-disallowed-list -Specify a blacklist of disallowed units. +Specify a list of disallowed units. ```css @@ -9,6 +9,8 @@ a { width: 100px; } * These units */ ``` +This rule was previously called, and is aliased as, `unit-blacklist`. + ## Options `array|string`: `["array", "of", "units"]|"unit"` diff --git a/lib/rules/unit-blacklist/__tests__/index.js b/lib/rules/unit-disallowed-list/__tests__/index.js similarity index 100% rename from lib/rules/unit-blacklist/__tests__/index.js rename to lib/rules/unit-disallowed-list/__tests__/index.js diff --git a/lib/rules/unit-blacklist/index.js b/lib/rules/unit-disallowed-list/index.js similarity index 94% rename from lib/rules/unit-blacklist/index.js rename to lib/rules/unit-disallowed-list/index.js index 821b0dd8b5..d1f574a5d4 100644 --- a/lib/rules/unit-blacklist/index.js +++ b/lib/rules/unit-disallowed-list/index.js @@ -14,7 +14,7 @@ const validateObjectWithArrayProps = require('../../utils/validateObjectWithArra const validateOptions = require('../../utils/validateOptions'); const valueParser = require('postcss-value-parser'); -const ruleName = 'unit-blacklist'; +const ruleName = 'unit-disallowed-list'; const messages = ruleMessages(ruleName, { rejected: (unit) => `Unexpected unit "${unit}"`, @@ -28,15 +28,15 @@ const getMediaFeatureName = (mediaFeatureNode) => { return /((-?\w*)*)/i.exec(value)[1]; }; -function rule(blacklistInput, options) { - const blacklist = [].concat(blacklistInput); +function rule(listInput, options) { + const list = [].concat(listInput); return (root, result) => { const validOptions = validateOptions( result, ruleName, { - actual: blacklist, + actual: list, possible: [_.isString], }, { @@ -57,7 +57,7 @@ function rule(blacklistInput, options) { const unit = getUnitFromValueNode(valueNode); // There is not unit or it is not configured as a violation - if (!unit || (unit && !blacklist.includes(unit.toLowerCase()))) { + if (!unit || (unit && !list.includes(unit.toLowerCase()))) { return; } diff --git a/lib/utils/__tests__/checkAgainstRule.test.js b/lib/utils/__tests__/checkAgainstRule.test.js index 13a2ee22a6..df353eb45f 100644 --- a/lib/utils/__tests__/checkAgainstRule.test.js +++ b/lib/utils/__tests__/checkAgainstRule.test.js @@ -60,4 +60,24 @@ describe('checkAgainstRule', () => { expect(warnings[0].line).toBe(3); expect(warnings[0].column).toBe(1); }); + + it('warns against a renamed rule when an aliased rule is used', () => { + const root = postcss.parse('a { top: 10px; }'); + + const warnings = []; + + checkAgainstRule( + { + ruleName: 'unit-whitelist', + ruleSettings: ['em'], + root, + }, + (warning) => warnings.push(warning), + ); + + expect(warnings).toHaveLength(1); + expect(warnings[0].rule).toBe('unit-allowed-list'); + expect(warnings[0].line).toBe(1); + expect(warnings[0].column).toBe(10); + }); }); diff --git a/scripts/visual-config.json b/scripts/visual-config.json index cd1a36cf58..beedc00f06 100644 --- a/scripts/visual-config.json +++ b/scripts/visual-config.json @@ -1,7 +1,7 @@ { "rules": { "color-no-invalid-hex": true, - "declaration-property-unit-blacklist": { "margin": ["px"] }, + "unit-disallowed-list": ["px"], "function-comma-space-after": ["always-single-line"], "selector-max-specificity": ["0,1,0", { "severity": "warning" }] }