Skip to content

Commit

Permalink
Deprecate *-blacklist/*-requirelist/*-whitelist rules
Browse files Browse the repository at this point in the history
This applies deprecation warnings when these rules are used, tests to
check there is a deprecation warning and re-includes them in
documentation.
  • Loading branch information
kevindew committed Aug 24, 2020
1 parent af05f79 commit 99877b6
Show file tree
Hide file tree
Showing 82 changed files with 889 additions and 0 deletions.
26 changes: 26 additions & 0 deletions docs/user-guide/rules/list.md
Expand Up @@ -102,10 +102,14 @@ Grouped first by the following categories and then by the [_thing_](http://apps.
### Function

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

### Keyframes

Expand All @@ -122,7 +126,9 @@ Grouped first by the following categories and then by the [_thing_](http://apps.
### Unit

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

### Shorthand property

Expand All @@ -139,17 +145,23 @@ Grouped first by the following categories and then by the [_thing_](http://apps.
### Property

- [`property-allowed-list`](../../../lib/rules/property-allowed-list/README.md): Specify a list of allowed properties.
- [`property-blacklist`](../../../lib/rules/property-blacklist/README.md): Specify a list of disallowed properties. **(deprecated)**
- [`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 (Autofixable).
- [`property-whitelist`](../../../lib/rules/property-whitelist/README.md): Specify a list of allowed properties. **(deprecated)**

### 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-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-blacklist`](../../../lib/rules/declaration-property-unit-blacklist/README.md): Specify a list of disallowed property and unit pairs within declarations. **(deprecated)**
- [`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-unit-whitelist`](../../../lib/rules/declaration-property-unit-whitelist/README.md): Specify a list of allowed property and unit pairs within declarations. **(deprecated)**
- [`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-blacklist`](../../../lib/rules/declaration-property-value-blacklist/README.md): Specify a list of disallowed property and value pairs within declarations. **(deprecated)**
- [`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-property-value-whitelist`](../../../lib/rules/declaration-property-value-whitelist/README.md): Specify a list of allowed property and value pairs within declarations. **(deprecated)**

### Declaration block

Expand All @@ -158,10 +170,14 @@ Grouped first by the following categories and then by the [_thing_](http://apps.
### Selector

- [`selector-attribute-operator-allowed-list`](../../../lib/rules/selector-attribute-operator-allowed-list/README.md): Specify a list of allowed attribute operators.
- [`selector-attribute-operator-blacklist`](../../../lib/rules/selector-attribute-operator-blacklist/README.md): Specify a list of disallowed attribute operators. **(deprecated)**
- [`selector-attribute-operator-disallowed-list`](../../../lib/rules/selector-attribute-operator-disallowed-list/README.md): Specify a list of disallowed attribute operators.
- [`selector-attribute-operator-whitelist`](../../../lib/rules/selector-attribute-operator-whitelist/README.md): Specify a list of allowed attribute operators. **(deprecated)**
- [`selector-class-pattern`](../../../lib/rules/selector-class-pattern/README.md): Specify a pattern for class selectors.
- [`selector-combinator-allowed-list`](../../../lib/rules/selector-combinator-allowed-list/README.md): Specify a list of allowed combinators.
- [`selector-combinator-blacklist`](../../../lib/rules/selector-combinator-blacklist/README.md): Specify a list of disallowed combinators. **(deprecated)**
- [`selector-combinator-disallowed-list`](../../../lib/rules/selector-combinator-disallowed-list/README.md): Specify a list of disallowed combinators.
- [`selector-combinator-whitelist`](../../../lib/rules/selector-combinator-whitelist/README.md): Specify a list of allowed combinators. **(deprecated)**
- [`selector-id-pattern`](../../../lib/rules/selector-id-pattern/README.md): Specify a pattern for ID selectors.
- [`selector-max-attribute`](../../../lib/rules/selector-max-attribute/README.md): Limit the number of attribute selectors in a selector.
- [`selector-max-class`](../../../lib/rules/selector-max-class/README.md): Limit the number of classes in a selector.
Expand All @@ -177,17 +193,23 @@ Grouped first by the following categories and then by the [_thing_](http://apps.
- [`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 (Autofixable).
- [`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-blacklist`](../../../lib/rules/selector-pseudo-class-blacklist/README.md): Specify a list of disallowed pseudo-class selectors. **(deprecated)**
- [`selector-pseudo-class-disallowed-list`](../../../lib/rules/selector-pseudo-class-disallowed-list/README.md): Specify a list of disallowed pseudo-class selectors.
- [`selector-pseudo-class-whitelist`](../../../lib/rules/selector-pseudo-class-whitelist/README.md): Specify a list of allowed pseudo-class selectors. **(deprecated)**
- [`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-blacklist`](../../../lib/rules/selector-pseudo-element-blacklist/README.md): Specify a list of disallowed pseudo-element selectors. **(deprecated)**
- [`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-disallowed-list`](../../../lib/rules/selector-pseudo-element-disallowed-list/README.md): Specify a list of disallowed pseudo-element selectors.
- [`selector-pseudo-element-whitelist`](../../../lib/rules/selector-pseudo-element-whitelist/README.md): Specify a list of allowed pseudo-element selectors. **(deprecated)**

### Media feature

- [`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-blacklist`](../../../lib/rules/media-feature-name-blacklist/README.md): Specify a list of disallowed media feature names. **(deprecated)**
- [`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 (Autofixable).
- [`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.
- [`media-feature-name-whitelist`](../../../lib/rules/media-feature-name-whitelist/README.md): Specify a list of allowed media feature names. **(deprecated)**

### Custom media

Expand All @@ -196,12 +218,16 @@ Grouped first by the following categories and then by the [_thing_](http://apps.
### At-rule

- [`at-rule-allowed-list`](../../../lib/rules/at-rule-allowed-list/README.md): Specify a list of allowed at-rules.
- [`at-rule-blacklist`](../../../lib/rules/at-rule-blacklist/README.md): Specify a list of disallowed at-rules. **(deprecated)**
- [`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 (Autofixable).
- [`at-rule-property-required-list`](../../../lib/rules/at-rule-property-required-list/README.md): Specify a list of required properties for an at-rule.
- [`at-rule-property-requirelist`](../../../lib/rules/at-rule-property-requirelist/README.md): Specify a list of required properties for an at-rule. **(deprecated)**
- [`at-rule-whitelist`](../../../lib/rules/at-rule-whitelist/README.md): Specify a list of allowed at-rules. **(deprecated)**

### Comment

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

### General / Sheet
Expand Down
2 changes: 2 additions & 0 deletions lib/rules/at-rule-blacklist/README.md
@@ -1,5 +1,7 @@
# at-rule-blacklist

**_Deprecated: Instead use the [`at-rule-disallowed-list`](../at-rule-disallowed-list/README.md) rule._**

Specify a list of disallowed at-rules.

<!-- prettier-ignore -->
Expand Down
23 changes: 23 additions & 0 deletions lib/rules/at-rule-blacklist/__tests__/index.js
@@ -1,7 +1,30 @@
'use strict';

const standalone = require('../../../standalone');
const { messages, ruleName } = require('..');

it('warns that the rule is deprecated', () => {
const config = {
rules: {
[ruleName]: ['extend'],
},
};

const code = '';

return standalone({ code, config }).then((output) => {
const result = output.results[0];

expect(result.deprecations).toHaveLength(1);
expect(result.deprecations[0].text).toEqual(
`'${ruleName}' has been deprecated. Instead use 'at-rule-disallowed-list'.`,
);
expect(result.deprecations[0].reference).toEqual(
`https://stylelint.io/user-guide/rules/${ruleName}/`,
);
});
});

testRule({
ruleName,

Expand Down
5 changes: 5 additions & 0 deletions lib/rules/at-rule-blacklist/index.js
Expand Up @@ -29,6 +29,11 @@ function rule(listInput) {
return;
}

result.warn(`'${ruleName}' has been deprecated. Instead use 'at-rule-disallowed-list'.`, {
stylelintType: 'deprecation',
stylelintReference: `https://stylelint.io/user-guide/rules/${ruleName}/`,
});

root.walkAtRules((atRule) => {
const name = atRule.name;

Expand Down
2 changes: 2 additions & 0 deletions lib/rules/at-rule-property-requirelist/README.md
@@ -1,5 +1,7 @@
# at-rule-property-requirelist

**_Deprecated: Instead use the [`at-rule-property-required-list`](../at-rule-property-required-list/README.md) rule._**

Specify a list of required properties for an at-rule.

<!-- prettier-ignore -->
Expand Down
23 changes: 23 additions & 0 deletions lib/rules/at-rule-property-requirelist/__tests__/index.js
@@ -1,7 +1,30 @@
'use strict';

const standalone = require('../../../standalone');
const { messages, ruleName } = require('..');

it('warns that the rule is deprecated', () => {
const config = {
rules: {
[ruleName]: { page: ['margin'] },
},
};

const code = '';

return standalone({ code, config }).then((output) => {
const result = output.results[0];

expect(result.deprecations).toHaveLength(1);
expect(result.deprecations[0].text).toEqual(
`'${ruleName}' has been deprecated. Instead use 'at-rule-property-required-list'.`,
);
expect(result.deprecations[0].reference).toEqual(
`https://stylelint.io/user-guide/rules/${ruleName}/`,
);
});
});

testRule({
ruleName,
config: {
Expand Down
8 changes: 8 additions & 0 deletions lib/rules/at-rule-property-requirelist/index.js
Expand Up @@ -25,6 +25,14 @@ function rule(list) {
return;
}

result.warn(
`'${ruleName}' has been deprecated. Instead use 'at-rule-property-required-list'.`,
{
stylelintType: 'deprecation',
stylelintReference: `https://stylelint.io/user-guide/rules/${ruleName}/`,
},
);

root.walkAtRules((atRule) => {
if (!isStandardSyntaxAtRule(atRule)) {
return;
Expand Down
2 changes: 2 additions & 0 deletions lib/rules/at-rule-whitelist/README.md
@@ -1,5 +1,7 @@
# at-rule-whitelist

**_Deprecated: Instead use the [`at-rule-allowed-list`](../at-rule-allowed-list/README.md) rule._**

Specify a list of allowed at-rules.

<!-- prettier-ignore -->
Expand Down
23 changes: 23 additions & 0 deletions lib/rules/at-rule-whitelist/__tests__/index.js
@@ -1,7 +1,30 @@
'use strict';

const standalone = require('../../../standalone');
const { messages, ruleName } = require('..');

it('warns that the rule is deprecated', () => {
const config = {
rules: {
[ruleName]: ['extend'],
},
};

const code = '';

return standalone({ code, config }).then((output) => {
const result = output.results[0];

expect(result.deprecations).toHaveLength(1);
expect(result.deprecations[0].text).toEqual(
`'${ruleName}' has been deprecated. Instead use 'at-rule-allowed-list'.`,
);
expect(result.deprecations[0].reference).toEqual(
`https://stylelint.io/user-guide/rules/${ruleName}/`,
);
});
});

testRule({
ruleName,

Expand Down
5 changes: 5 additions & 0 deletions lib/rules/at-rule-whitelist/index.js
Expand Up @@ -29,6 +29,11 @@ function rule(listInput) {
return;
}

result.warn(`'${ruleName}' has been deprecated. Instead use 'at-rule-allowed-list'.`, {
stylelintType: 'deprecation',
stylelintReference: `https://stylelint.io/user-guide/rules/${ruleName}/`,
});

root.walkAtRules((atRule) => {
const name = atRule.name;

Expand Down
2 changes: 2 additions & 0 deletions lib/rules/comment-word-blacklist/README.md
@@ -1,5 +1,7 @@
# comment-word-blacklist

**_Deprecated: Instead use the [`comment-word-disallowed-list`](../comment-word-disallowed-list/README.md) rule._**

Specify a list of disallowed words within comments.

<!-- prettier-ignore -->
Expand Down
23 changes: 23 additions & 0 deletions lib/rules/comment-word-blacklist/__tests__/index.js
@@ -1,7 +1,30 @@
'use strict';

const standalone = require('../../../standalone');
const { messages, ruleName } = require('..');

it('warns that the rule is deprecated', () => {
const config = {
rules: {
[ruleName]: ['bad-word'],
},
};

const code = '';

return standalone({ code, config }).then((output) => {
const result = output.results[0];

expect(result.deprecations).toHaveLength(1);
expect(result.deprecations[0].text).toEqual(
`'${ruleName}' has been deprecated. Instead use 'comment-word-disallowed-list'.`,
);
expect(result.deprecations[0].reference).toEqual(
`https://stylelint.io/user-guide/rules/${ruleName}/`,
);
});
});

testRule({
ruleName,
config: ['bad-word'],
Expand Down
5 changes: 5 additions & 0 deletions lib/rules/comment-word-blacklist/index.js
Expand Up @@ -26,6 +26,11 @@ function rule(list) {
return;
}

result.warn(`'${ruleName}' has been deprecated. Instead use 'comment-word-disallowed-list'.`, {
stylelintType: 'deprecation',
stylelintReference: `https://stylelint.io/user-guide/rules/${ruleName}/`,
});

root.walkComments((comment) => {
const text = comment.text;
const rawComment = comment.toString();
Expand Down
2 changes: 2 additions & 0 deletions lib/rules/declaration-property-unit-blacklist/README.md
@@ -1,5 +1,7 @@
# declaration-property-unit-blacklist

**_Deprecated: Instead use the [`declaration-property-unit-disallowed-list`](../declaration-property-unit-disallowed-list/README.md) rule._**

Specify a list of disallowed property and unit pairs within declarations.

<!-- prettier-ignore -->
Expand Down
23 changes: 23 additions & 0 deletions lib/rules/declaration-property-unit-blacklist/__tests__/index.js
@@ -1,7 +1,30 @@
'use strict';

const standalone = require('../../../standalone');
const { messages, ruleName } = require('..');

it('warns that the rule is deprecated', () => {
const config = {
rules: {
[ruleName]: [{ margin: ['em'] }],
},
};

const code = '';

return standalone({ code, config }).then((output) => {
const result = output.results[0];

expect(result.deprecations).toHaveLength(1);
expect(result.deprecations[0].text).toEqual(
`'${ruleName}' has been deprecated. Instead use 'declaration-property-unit-disallowed-list'.`,
);
expect(result.deprecations[0].reference).toEqual(
`https://stylelint.io/user-guide/rules/${ruleName}/`,
);
});
});

testRule({
ruleName,

Expand Down
8 changes: 8 additions & 0 deletions lib/rules/declaration-property-unit-blacklist/index.js
Expand Up @@ -29,6 +29,14 @@ function rule(list) {
return;
}

result.warn(
`'${ruleName}' has been deprecated. Instead use 'declaration-property-unit-disallowed-list'.`,
{
stylelintType: 'deprecation',
stylelintReference: `https://stylelint.io/user-guide/rules/${ruleName}/`,
},
);

root.walkDecls((decl) => {
const prop = decl.prop;
const value = decl.value;
Expand Down
2 changes: 2 additions & 0 deletions lib/rules/declaration-property-unit-whitelist/README.md
@@ -1,5 +1,7 @@
# declaration-property-unit-whitelist

**_Deprecated: Instead use the [`declaration-property-unit-allowed-list`](../declaration-property-unit-allowed-list/README.md) rule._**

Specify a list of allowed property and unit pairs within declarations.

<!-- prettier-ignore -->
Expand Down

0 comments on commit 99877b6

Please sign in to comment.