diff --git a/lib/rules/property-allowed-list/README.md b/lib/rules/property-allowed-list/README.md index d1e7846503..8d853bf70e 100644 --- a/lib/rules/property-allowed-list/README.md +++ b/lib/rules/property-allowed-list/README.md @@ -13,7 +13,7 @@ This rule ignores variables (`$sass`, `@less`, `--custom-property`). ## Options -`array|string|regex`: `["array", "of", "unprefixed", /properties/, "regex"]|"property"|"/regex/"|/regex/` +`array|string|regex`: `["array", "of", /properties/, "regex"]|"property"|"/regex/"|/regex/` If a string is surrounded with `"/"` (e.g. `"/^background/"`), it is interpreted as a regular expression. This allows, for example, easy targeting of shorthands: `/^background/` will match `background`, `background-size`, `background-color`, etc. diff --git a/lib/rules/property-allowed-list/__tests__/index.js b/lib/rules/property-allowed-list/__tests__/index.js index 68c5ce8182..4e3ffd5c93 100644 --- a/lib/rules/property-allowed-list/__tests__/index.js +++ b/lib/rules/property-allowed-list/__tests__/index.js @@ -166,3 +166,39 @@ testRule({ }, ], }); + +testRule({ + ruleName, + + config: ['-webkit-text-stroke'], + + accept: [ + { + code: 'a { -webkit-text-stroke: 2px red; }', + }, + ], + + reject: [ + { + code: 'a { text-stroke: 2px red; }', + message: messages.rejected('text-stroke'), + line: 1, + column: 5, + }, + ], +}); + +testRule({ + ruleName, + + config: ['text-stroke'], + + accept: [ + { + code: 'a { -webkit-text-stroke: 2px red; }', + }, + { + code: 'a { text-stroke: 2px red; }', + }, + ], +}); diff --git a/lib/rules/property-allowed-list/index.js b/lib/rules/property-allowed-list/index.js index 3cd1a2d764..a146f8d0b4 100644 --- a/lib/rules/property-allowed-list/index.js +++ b/lib/rules/property-allowed-list/index.js @@ -42,7 +42,8 @@ const rule = (primary) => { return; } - if (matchesStringOrRegExp(vendor.unprefixed(prop), primary)) { + // either the prefix or unprefixed version is in the list + if (matchesStringOrRegExp([prop, vendor.unprefixed(prop)], primary)) { return; } diff --git a/lib/rules/property-disallowed-list/README.md b/lib/rules/property-disallowed-list/README.md index e438c61834..c5da123ef3 100644 --- a/lib/rules/property-disallowed-list/README.md +++ b/lib/rules/property-disallowed-list/README.md @@ -11,7 +11,7 @@ a { text-rendering: optimizeLegibility; } ## Options -`array|string|regex`: `["array", "of", "unprefixed", /properties/, "regex"]|"property"|"/regex/"|/regex/` +`array|string|regex`: `["array", "of", /properties/, "regex"]|"property"|"/regex/"|/regex/` If a string is surrounded with `"/"` (e.g. `"/^background/"`), it is interpreted as a regular expression. This allows, for example, easy targeting of shorthands: `/^background/` will match `background`, `background-size`, `background-color`, etc. diff --git a/lib/rules/property-disallowed-list/__tests__/index.js b/lib/rules/property-disallowed-list/__tests__/index.js index 644bf8e620..2f893bb94b 100644 --- a/lib/rules/property-disallowed-list/__tests__/index.js +++ b/lib/rules/property-disallowed-list/__tests__/index.js @@ -157,3 +157,45 @@ testRule({ }, ], }); + +testRule({ + ruleName, + + config: ['-webkit-text-stroke'], + + accept: [ + { + code: 'a { text-stroke: 2px red; }', + }, + ], + + reject: [ + { + code: 'a { -webkit-text-stroke: 2px red; }', + message: messages.rejected('-webkit-text-stroke'), + line: 1, + column: 5, + }, + ], +}); + +testRule({ + ruleName, + + config: ['text-stroke'], + + reject: [ + { + code: 'a { -webkit-text-stroke: 2px red; }', + message: messages.rejected('-webkit-text-stroke'), + line: 1, + column: 5, + }, + { + code: 'a { text-stroke: 2px red; }', + message: messages.rejected('text-stroke'), + line: 1, + column: 5, + }, + ], +}); diff --git a/lib/rules/property-disallowed-list/index.js b/lib/rules/property-disallowed-list/index.js index f4c9e5fe89..6979fe4c64 100644 --- a/lib/rules/property-disallowed-list/index.js +++ b/lib/rules/property-disallowed-list/index.js @@ -42,7 +42,8 @@ const rule = (primary) => { return; } - if (!matchesStringOrRegExp(vendor.unprefixed(prop), primary)) { + // either the prefix or unprefixed version is in the list + if (!matchesStringOrRegExp([prop, vendor.unprefixed(prop)], primary)) { return; } diff --git a/lib/utils/matchesStringOrRegExp.js b/lib/utils/matchesStringOrRegExp.js index 8486d52d1b..5d33bd2a96 100644 --- a/lib/utils/matchesStringOrRegExp.js +++ b/lib/utils/matchesStringOrRegExp.js @@ -8,7 +8,7 @@ * Any strings starting and ending with `/` are interpreted * as regular expressions. * - * @param {string} input + * @param {string | Array} input * @param {string | RegExp | Array} comparison * * @returns {false | {match: string, pattern: (string | RegExp), substring: string}}