stylelint-config-crisp 1.0.24 → 1.0.26

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stylelint-config-crisp",
3
- "version": "1.0.24",
3
+ "version": "1.0.26",
4
4
  "description": "Custom Stylelint Rules for Crisp",
5
5
  "author": "Crisp IM SAS",
6
6
  "main": "index.js",
@@ -64,7 +64,7 @@ const ruleFunction = (primaryOption, secondaryOptions = {}, context) => {
64
64
  }
65
65
 
66
66
  // Skip selector if ignored via rule options
67
- if (isSelectorIgnored(rule, secondaryOptions.ignoreSelectors || [])) {
67
+ if (isSelectorIgnoredOptions(rule, secondaryOptions.ignoreSelectors || [])) {
68
68
  return;
69
69
  }
70
70
 
@@ -80,25 +80,8 @@ const ruleFunction = (primaryOption, secondaryOptions = {}, context) => {
80
80
  let isInterpolated = isInterpolatedClassSelector(rule);
81
81
 
82
82
  if (!isInterpolated) {
83
- // Skip classes elements outside of CSS file scope
84
- if (fileScopeClass) {
85
- if (rule.selector.startsWith(".")) {
86
- // Extract base part from BEM selector
87
- const regex = /^(\.[\w-]+?)(?:--|__)[\w-]+$/;
88
-
89
- const match = rule.selector.match(regex);
90
- const base = match ? match[1] : null;
91
-
92
- if (base && base !== `.${fileScopeClass}`) {
93
- return;
94
- }
95
- }
96
-
97
- if (rule.selector.startsWith("&.")) {
98
- if (!rule.selector.startsWith(`&.${fileScopeClass}`)) {
99
- return;
100
- }
101
- }
83
+ if (isSelectorIgnored(rule, fileScopeClass)) {
84
+ return;
102
85
  }
103
86
 
104
87
  if (context.fix) {
@@ -138,7 +121,7 @@ function isStringOrRegExp(value) {
138
121
  }
139
122
 
140
123
  // Check if selector is ignored via options
141
- function isSelectorIgnored(rule, ignoreSelectors = []) {
124
+ function isSelectorIgnoredOptions(rule, ignoreSelectors = []) {
142
125
  // Resolve the actual selector name
143
126
  const resolvedSelector = resolveSelector(rule);
144
127
 
@@ -163,6 +146,34 @@ function isSelectorIgnored(rule, ignoreSelectors = []) {
163
146
  return isIgnored;
164
147
  }
165
148
 
149
+ // Check if selector is ignored (out of file scope)
150
+ function isSelectorIgnored(rule, fileScopeClass) {
151
+ // Skip classes elements outside of CSS file scope
152
+ if (fileScopeClass) {
153
+ if (rule.selector.startsWith(".")) {
154
+ // Extract base part from BEM selector
155
+ const regex = /(\.[\w-]+?)(?=--|__|\s|:|$)/;
156
+ const match = rule.selector.match(regex);
157
+
158
+ if (match) {
159
+ const base = match[1];
160
+
161
+ if (base !== `.${fileScopeClass}`) {
162
+ return true;
163
+ }
164
+ }
165
+ }
166
+
167
+ if (rule.selector.startsWith("&.")) {
168
+ if (!rule.selector.startsWith(`&.${fileScopeClass}`)) {
169
+ return true;
170
+ }
171
+ }
172
+ }
173
+
174
+ return false;
175
+ }
176
+
166
177
  // Check if the rule is a top-level class selector
167
178
  function isTopLevelClassSelector(rule) {
168
179
  return rule.parent && rule.parent.type === "root" && rule.selector.startsWith(".");