Skip to content

Commit

Permalink
Add regex support to ignoreSelectors option of `selector-no-vendor-…
Browse files Browse the repository at this point in the history
…prefix` (#6327)
  • Loading branch information
ybiquitous committed Sep 7, 2022
1 parent ff99bc3 commit 4f59219
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/rotten-onions-occur.md
@@ -0,0 +1,5 @@
---
"stylelint": minor
---

Added: regex support for `ignoreSelectors` option of `selector-no-vendor-prefix`
2 changes: 1 addition & 1 deletion lib/rules/selector-no-vendor-prefix/README.md
Expand Up @@ -43,7 +43,7 @@ input::placeholder {}

## Optional secondary options

### `ignoreSelectors: ["/regex/", "non-regex"]`
### `ignoreSelectors: ["/regex/", /regex/, "non-regex"]`

Ignore vendor prefixes for selectors.

Expand Down
5 changes: 4 additions & 1 deletion lib/rules/selector-no-vendor-prefix/__tests__/index.js
Expand Up @@ -113,7 +113,7 @@ testRule({

testRule({
ruleName,
config: [true, { ignoreSelectors: ['::-webkit-input-placeholder', '/-moz-.*/'] }],
config: [true, { ignoreSelectors: ['::-webkit-input-placeholder', '/-moz-.*/', /-screen$/] }],
fix: true,

accept: [
Expand All @@ -123,6 +123,9 @@ testRule({
{
code: 'input::-moz-placeholder { color: pink; }',
},
{
code: ':-webkit-full-screen a {}',
},
],

reject: [
Expand Down
4 changes: 2 additions & 2 deletions lib/rules/selector-no-vendor-prefix/index.js
Expand Up @@ -7,7 +7,7 @@ const parseSelector = require('../../utils/parseSelector');
const report = require('../../utils/report');
const ruleMessages = require('../../utils/ruleMessages');
const validateOptions = require('../../utils/validateOptions');
const { isString } = require('../../utils/validateTypes');
const { isString, isRegExp } = require('../../utils/validateTypes');

const ruleName = 'selector-no-vendor-prefix';

Expand All @@ -30,7 +30,7 @@ const rule = (primary, secondaryOptions, context) => {
{
actual: secondaryOptions,
possible: {
ignoreSelectors: [isString],
ignoreSelectors: [isString, isRegExp],
},
optional: true,
},
Expand Down

0 comments on commit 4f59219

Please sign in to comment.