Skip to content

Commit

Permalink
Add regex support to ignoreTypes option of selector-type-case (#6326
Browse files Browse the repository at this point in the history
)
  • Loading branch information
ybiquitous committed Sep 7, 2022
1 parent 244bde0 commit ff99bc3
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/fast-papayas-dress.md
@@ -0,0 +1,5 @@
---
"stylelint": minor
---

Added: regex support for `ignoreTypes` option of `selector-type-case`
2 changes: 1 addition & 1 deletion lib/rules/selector-type-case/README.md
Expand Up @@ -69,7 +69,7 @@ LI {}

## Optional secondary options

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

Given:

Expand Down
5 changes: 4 additions & 1 deletion lib/rules/selector-type-case/__tests__/index.js
Expand Up @@ -305,7 +305,7 @@ testRule({

testRule({
ruleName,
config: ['lower', { ignoreTypes: ['$childClass', '/(p|P)arent.*/'] }],
config: ['lower', { ignoreTypes: ['$childClass', '/(p|P)arent.*/', /foo$/i] }],

accept: [
{
Expand All @@ -314,6 +314,9 @@ testRule({
{
code: '$childClass { color: pink; }',
},
{
code: 'myFoo { color: pink; }',
},
],

reject: [
Expand Down
4 changes: 2 additions & 2 deletions lib/rules/selector-type-case/index.js
Expand Up @@ -8,7 +8,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 { mixedCaseSvgTypeSelectors } = require('../../reference/selectors');

const ruleName = 'selector-type-case';
Expand All @@ -35,7 +35,7 @@ const rule = (primary, secondaryOptions, context) => {
{
actual: secondaryOptions,
possible: {
ignoreTypes: [isString],
ignoreTypes: [isString, isRegExp],
},
optional: true,
},
Expand Down

0 comments on commit ff99bc3

Please sign in to comment.