stylelint-config-crisp 1.0.17 → 1.0.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -85,7 +85,7 @@ This is the list of configured syntaxes, plugins and rules used by Stylelint Con
85
85
  #### Crisp rules
86
86
  - [at-rule-conditional-parentheses](https://github.com/crisp-oss/stylelint-config-crisp/blob/master/rules/at-rule-conditional-parentheses.js): Enforces parentheses in conditions of at-rules (`@if`, `@elseif`, `@while`)
87
87
  - [rule-empty-line-before](https://github.com/crisp-oss/stylelint-config-crisp/blob/master/rules/rule-empty-line-before.js): Requires an empty line before multi-line rules the same way [rule-empty-line-before](https://stylelint.io/user-guide/rules/rule-empty-line-before/) does, but properly handles Sass interpolation `#{}` in selectors
88
- - [selector-class-interpolation](https://github.com/crisp-oss/stylelint-config-crisp/blob/master/rules/selector-class-interpolation.js): Enforces class selectors to use Sass interpolation
88
+ - [selector-class-interpolation](https://github.com/crisp-oss/stylelint-config-crisp/blob/master/rules/selector-class-interpolation.js): Enforces class selectors to use Sass interpolation (this rule is only applied to Vue files)
89
89
 
90
90
  ## License
91
91
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stylelint-config-crisp",
3
- "version": "1.0.17",
3
+ "version": "1.0.18",
4
4
  "description": "Custom Stylelint Rules for Crisp",
5
5
  "author": "Crisp IM SAS",
6
6
  "main": "index.js",
@@ -40,7 +40,20 @@ const ruleFunction = (primaryOption, secondaryOptions = {}, context) => {
40
40
 
41
41
  // Determine if the resolved selector should be ignored
42
42
  const isIgnored = ignoreSelectors.some(ignoreItem => {
43
- return isRegExp(ignoreItem) ? ignoreItem.test(resolvedSelector) : ignoreItem === resolvedSelector;
43
+ if (typeof ignoreItem === "string") {
44
+ // Check if it's a stringified regex (e.g., "/pattern/")
45
+ if (ignoreItem.startsWith("/") && ignoreItem.endsWith("/")) {
46
+ const regexPattern = ignoreItem.slice(1, -1);
47
+ const regex = new RegExp(regexPattern);
48
+ return regex.test(resolvedSelector);
49
+ }
50
+
51
+ // It's a regular string
52
+ return ignoreItem === resolvedSelector;
53
+ }
54
+
55
+ // It's a real RegExp
56
+ return ignoreItem.test(resolvedSelector);
44
57
  });
45
58
 
46
59
  if (isIgnored) {
@@ -85,14 +98,9 @@ function resolveSelector(rule, parentSelector = "") {
85
98
  return parentSelector ? (parentSelector + " " + rule.selector).trim() : rule.selector;
86
99
  }
87
100
 
88
- // Helper function to check if a value is a RegExp
89
- function isRegExp(value) {
90
- return value instanceof RegExp;
91
- }
92
-
93
101
  // Helper function to check if a value is a RegExp or a string
94
102
  function isStringOrRegExp(value) {
95
- return isRegExp(value) || typeof value === "string";
103
+ return value instanceof RegExp || typeof value === "string";
96
104
  }
97
105
 
98
106
  // Check if the rule is a top-level class selector