@master/eslint-plugin-css 2.0.0-rc.35 → 2.0.0-rc.37
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/dist/utils/find-loc.cjs
CHANGED
|
@@ -7,25 +7,28 @@ function findLoc(text, lines, startLine, endLine) {
|
|
|
7
7
|
let checking = false;
|
|
8
8
|
for(let i = startLine; i <= endLine; i++){
|
|
9
9
|
const sourceCodeLine = lines[i - 1];
|
|
10
|
-
const
|
|
10
|
+
const content = targetLines[checkingTargetLine].replace(/\r\n|\n/, '');
|
|
11
|
+
const index = sourceCodeLine.indexOf(content);
|
|
11
12
|
if (index !== -1) {
|
|
12
|
-
if (
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
column: index
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
if (checkingTargetLine === targetLines.length - 1) {
|
|
19
|
-
return {
|
|
20
|
-
start: resultStart,
|
|
21
|
-
end: {
|
|
13
|
+
if (index === 0 || sourceCodeLine[index - 1].match(/^|[\s"'']/)) {
|
|
14
|
+
if (checkingTargetLine === 0) {
|
|
15
|
+
resultStart = {
|
|
22
16
|
line: i,
|
|
23
|
-
column: index
|
|
24
|
-
}
|
|
25
|
-
}
|
|
17
|
+
column: index
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
if (checkingTargetLine === targetLines.length - 1 && (sourceCodeLine[index + content.length - 1].match(/$|[\s"'']/) || sourceCodeLine[index + content.length].match(/[\s"'']/))) {
|
|
21
|
+
return {
|
|
22
|
+
start: resultStart,
|
|
23
|
+
end: {
|
|
24
|
+
line: i,
|
|
25
|
+
column: index + text.length
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
checking = true;
|
|
30
|
+
checkingTargetLine++;
|
|
26
31
|
}
|
|
27
|
-
checking = true;
|
|
28
|
-
checkingTargetLine++;
|
|
29
32
|
} else {
|
|
30
33
|
if (checking) {
|
|
31
34
|
checking = false;
|
package/dist/utils/find-loc.mjs
CHANGED
|
@@ -5,25 +5,28 @@ function findLoc(text, lines, startLine, endLine) {
|
|
|
5
5
|
let checking = false;
|
|
6
6
|
for(let i = startLine; i <= endLine; i++){
|
|
7
7
|
const sourceCodeLine = lines[i - 1];
|
|
8
|
-
const
|
|
8
|
+
const content = targetLines[checkingTargetLine].replace(/\r\n|\n/, '');
|
|
9
|
+
const index = sourceCodeLine.indexOf(content);
|
|
9
10
|
if (index !== -1) {
|
|
10
|
-
if (
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
column: index
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
if (checkingTargetLine === targetLines.length - 1) {
|
|
17
|
-
return {
|
|
18
|
-
start: resultStart,
|
|
19
|
-
end: {
|
|
11
|
+
if (index === 0 || sourceCodeLine[index - 1].match(/^|[\s"'']/)) {
|
|
12
|
+
if (checkingTargetLine === 0) {
|
|
13
|
+
resultStart = {
|
|
20
14
|
line: i,
|
|
21
|
-
column: index
|
|
22
|
-
}
|
|
23
|
-
}
|
|
15
|
+
column: index
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
if (checkingTargetLine === targetLines.length - 1 && (sourceCodeLine[index + content.length - 1].match(/$|[\s"'']/) || sourceCodeLine[index + content.length].match(/[\s"'']/))) {
|
|
19
|
+
return {
|
|
20
|
+
start: resultStart,
|
|
21
|
+
end: {
|
|
22
|
+
line: i,
|
|
23
|
+
column: index + text.length
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
checking = true;
|
|
28
|
+
checkingTargetLine++;
|
|
24
29
|
}
|
|
25
|
-
checking = true;
|
|
26
|
-
checkingTargetLine++;
|
|
27
30
|
} else {
|
|
28
31
|
if (checking) {
|
|
29
32
|
checking = false;
|
|
@@ -52,7 +52,7 @@ var extractRangeFromNode = require('./extract-range-from-node.cjs');
|
|
|
52
52
|
switch(childNode.type){
|
|
53
53
|
case 'TemplateLiteral':
|
|
54
54
|
childNode.expressions.forEach((exp)=>{
|
|
55
|
-
parseNodeRecursive(rootNode, exp, cb, skipConditional, forceIsolation, ignoredKeys);
|
|
55
|
+
parseNodeRecursive(rootNode, exp, cb, skipConditional, forceIsolation, ignoredKeys, context);
|
|
56
56
|
});
|
|
57
57
|
const sourceCode = context.sourceCode;
|
|
58
58
|
originalClassNamesValue = sourceCode.getText(childNode);
|
|
@@ -63,15 +63,15 @@ var extractRangeFromNode = require('./extract-range-from-node.cjs');
|
|
|
63
63
|
}
|
|
64
64
|
break;
|
|
65
65
|
case 'ConditionalExpression':
|
|
66
|
-
parseNodeRecursive(rootNode, childNode.consequent, cb, skipConditional, forceIsolation, ignoredKeys);
|
|
67
|
-
parseNodeRecursive(rootNode, childNode.alternate, cb, skipConditional, forceIsolation, ignoredKeys);
|
|
66
|
+
parseNodeRecursive(rootNode, childNode.consequent, cb, skipConditional, forceIsolation, ignoredKeys, context);
|
|
67
|
+
parseNodeRecursive(rootNode, childNode.alternate, cb, skipConditional, forceIsolation, ignoredKeys, context);
|
|
68
68
|
return;
|
|
69
69
|
case 'LogicalExpression':
|
|
70
|
-
parseNodeRecursive(rootNode, childNode.right, cb, skipConditional, forceIsolation, ignoredKeys);
|
|
70
|
+
parseNodeRecursive(rootNode, childNode.right, cb, skipConditional, forceIsolation, ignoredKeys, context);
|
|
71
71
|
return;
|
|
72
72
|
case 'ArrayExpression':
|
|
73
73
|
childNode.elements.forEach((el)=>{
|
|
74
|
-
parseNodeRecursive(rootNode, el, cb, skipConditional, forceIsolation, ignoredKeys);
|
|
74
|
+
parseNodeRecursive(rootNode, el, cb, skipConditional, forceIsolation, ignoredKeys, context);
|
|
75
75
|
});
|
|
76
76
|
return;
|
|
77
77
|
case 'ObjectExpression':
|
|
@@ -85,11 +85,11 @@ var extractRangeFromNode = require('./extract-range-from-node.cjs');
|
|
|
85
85
|
// Ignore specific keys defined in settings
|
|
86
86
|
return;
|
|
87
87
|
}
|
|
88
|
-
parseNodeRecursive(rootNode, isUsedByClassNamesPlugin ? prop.key : prop.value, cb, skipConditional, forceIsolation, ignoredKeys);
|
|
88
|
+
parseNodeRecursive(rootNode, isUsedByClassNamesPlugin ? prop.key : prop.value, cb, skipConditional, forceIsolation, ignoredKeys, context);
|
|
89
89
|
});
|
|
90
90
|
return;
|
|
91
91
|
case 'Property':
|
|
92
|
-
parseNodeRecursive(rootNode, childNode.key, cb, skipConditional, forceIsolation, ignoredKeys);
|
|
92
|
+
parseNodeRecursive(rootNode, childNode.key, cb, skipConditional, forceIsolation, ignoredKeys, context);
|
|
93
93
|
return;
|
|
94
94
|
case 'Literal':
|
|
95
95
|
originalClassNamesValue = childNode.value;
|
|
@@ -10,4 +10,4 @@ import type { RuleContext } from '@typescript-eslint/utils/ts-eslint';
|
|
|
10
10
|
* @param {Array} ignoredKeys Optional, set object keys which should not be parsed e.g. for `cva`
|
|
11
11
|
* @returns {void}
|
|
12
12
|
*/
|
|
13
|
-
export declare function parseNodeRecursive(rootNode: any, childNode: any, cb: any, skipConditional
|
|
13
|
+
export declare function parseNodeRecursive(rootNode: any, childNode: any, cb: any, skipConditional: boolean, isolate: boolean, ignoredKeys: any[], context: RuleContext<any, any>): void;
|
|
@@ -50,7 +50,7 @@ import extractRangeFromNode from './extract-range-from-node.mjs';
|
|
|
50
50
|
switch(childNode.type){
|
|
51
51
|
case 'TemplateLiteral':
|
|
52
52
|
childNode.expressions.forEach((exp)=>{
|
|
53
|
-
parseNodeRecursive(rootNode, exp, cb, skipConditional, forceIsolation, ignoredKeys);
|
|
53
|
+
parseNodeRecursive(rootNode, exp, cb, skipConditional, forceIsolation, ignoredKeys, context);
|
|
54
54
|
});
|
|
55
55
|
const sourceCode = context.sourceCode;
|
|
56
56
|
originalClassNamesValue = sourceCode.getText(childNode);
|
|
@@ -61,15 +61,15 @@ import extractRangeFromNode from './extract-range-from-node.mjs';
|
|
|
61
61
|
}
|
|
62
62
|
break;
|
|
63
63
|
case 'ConditionalExpression':
|
|
64
|
-
parseNodeRecursive(rootNode, childNode.consequent, cb, skipConditional, forceIsolation, ignoredKeys);
|
|
65
|
-
parseNodeRecursive(rootNode, childNode.alternate, cb, skipConditional, forceIsolation, ignoredKeys);
|
|
64
|
+
parseNodeRecursive(rootNode, childNode.consequent, cb, skipConditional, forceIsolation, ignoredKeys, context);
|
|
65
|
+
parseNodeRecursive(rootNode, childNode.alternate, cb, skipConditional, forceIsolation, ignoredKeys, context);
|
|
66
66
|
return;
|
|
67
67
|
case 'LogicalExpression':
|
|
68
|
-
parseNodeRecursive(rootNode, childNode.right, cb, skipConditional, forceIsolation, ignoredKeys);
|
|
68
|
+
parseNodeRecursive(rootNode, childNode.right, cb, skipConditional, forceIsolation, ignoredKeys, context);
|
|
69
69
|
return;
|
|
70
70
|
case 'ArrayExpression':
|
|
71
71
|
childNode.elements.forEach((el)=>{
|
|
72
|
-
parseNodeRecursive(rootNode, el, cb, skipConditional, forceIsolation, ignoredKeys);
|
|
72
|
+
parseNodeRecursive(rootNode, el, cb, skipConditional, forceIsolation, ignoredKeys, context);
|
|
73
73
|
});
|
|
74
74
|
return;
|
|
75
75
|
case 'ObjectExpression':
|
|
@@ -83,11 +83,11 @@ import extractRangeFromNode from './extract-range-from-node.mjs';
|
|
|
83
83
|
// Ignore specific keys defined in settings
|
|
84
84
|
return;
|
|
85
85
|
}
|
|
86
|
-
parseNodeRecursive(rootNode, isUsedByClassNamesPlugin ? prop.key : prop.value, cb, skipConditional, forceIsolation, ignoredKeys);
|
|
86
|
+
parseNodeRecursive(rootNode, isUsedByClassNamesPlugin ? prop.key : prop.value, cb, skipConditional, forceIsolation, ignoredKeys, context);
|
|
87
87
|
});
|
|
88
88
|
return;
|
|
89
89
|
case 'Property':
|
|
90
|
-
parseNodeRecursive(rootNode, childNode.key, cb, skipConditional, forceIsolation, ignoredKeys);
|
|
90
|
+
parseNodeRecursive(rootNode, childNode.key, cb, skipConditional, forceIsolation, ignoredKeys, context);
|
|
91
91
|
return;
|
|
92
92
|
case 'Literal':
|
|
93
93
|
originalClassNamesValue = childNode.value;
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@master/eslint-plugin-css","type":"module","scripts":{"build":"techor build \"src/**/*.{js,ts}\"","dev":"pnpm build --watch","test":"jest","type-check":"tsc --noEmit","lint":"eslint src"},"keywords":["mastercss","eslint","eslintplugin"],"license":"MIT","description":"Master CSS ESLint Plugin","author":"Aoyue Design LLC.","funding":"https://css.master.co/docs/donate","homepage":"https://css.master.co","bugs":{"url":"https://github.com/master-co/css/issues"},"repository":{"type":"git","url":"https://github.com/master-co/css.git","directory":"packages/eslint-plugin"},"sideEffects":false,"main":"./dist/index.cjs","module":"./dist/index.mjs","jsnext:main":"./dist/index.mjs","esnext":"./dist/index.mjs","types":"./dist/index.d.ts","exports":{".":{"import":"./dist/index.mjs","require":"./dist/index.cjs","types":"./dist/index.d.ts"}},"files":["dist"],"publishConfig":{"access":"public","provenance":true},"dependencies":{"@master/css":"^2.0.0-rc.
|
|
1
|
+
{"name":"@master/eslint-plugin-css","type":"module","scripts":{"build":"techor build \"src/**/*.{js,ts}\"","dev":"pnpm build --watch","test":"jest","type-check":"tsc --noEmit","lint":"eslint src"},"keywords":["mastercss","eslint","eslintplugin"],"license":"MIT","description":"Master CSS ESLint Plugin","author":"Aoyue Design LLC.","funding":"https://css.master.co/docs/donate","homepage":"https://css.master.co","bugs":{"url":"https://github.com/master-co/css/issues"},"repository":{"type":"git","url":"https://github.com/master-co/css.git","directory":"packages/eslint-plugin"},"sideEffects":false,"main":"./dist/index.cjs","module":"./dist/index.mjs","jsnext:main":"./dist/index.mjs","esnext":"./dist/index.mjs","types":"./dist/index.d.ts","exports":{".":{"import":"./dist/index.mjs","require":"./dist/index.cjs","types":"./dist/index.d.ts"}},"files":["dist"],"publishConfig":{"access":"public","provenance":true},"dependencies":{"@master/css":"^2.0.0-rc.37","@master/css-explore-config":"^2.0.0-rc.37","@master/css-validator":"^2.0.0-rc.37","@typescript-eslint/utils":"^7.7.0","synckit":"^0.9.0","typescript-eslint":"^7.7.0"},"devDependencies":{"@angular-eslint/template-parser":"^17.3.0","@master/css-explore-config":"^2.0.0-rc.37","@master/css-shared":"^2.0.0-rc.37","@types/node":"^20.12.7","@typescript-eslint/rule-tester":"^7.7.0","eslint":"^8.57.0","eslint-plugin-markdown":"^4.0.1","eslint-plugin-mdx":"^3.1.5","svelte-eslint-parser":"^0.34.1","ts-node":"^10.9.2","vue-eslint-parser":"^9.4.2"},"version":"2.0.0-rc.37"}
|