@master/eslint-plugin-css 2.0.0-rc.61 → 2.0.0-rc.63
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/common.cjs +7 -0
- package/dist/common.d.ts +2 -0
- package/dist/common.mjs +4 -0
- package/dist/create-rule.cjs +1 -1
- package/dist/create-rule.mjs +1 -1
- package/dist/functions/filter-collision-classes.cjs +1 -1
- package/dist/functions/filter-collision-classes.mjs +2 -2
- package/dist/rules/class-collision.cjs +44 -38
- package/dist/rules/class-collision.mjs +44 -38
- package/dist/rules/class-order.cjs +23 -134
- package/dist/rules/class-order.mjs +24 -135
- package/dist/rules/class-validation.cjs +26 -37
- package/dist/rules/class-validation.mjs +26 -37
- package/dist/utils/define-visitors.cjs +24 -25
- package/dist/utils/define-visitors.d.ts +2 -1
- package/dist/utils/define-visitors.mjs +24 -25
- package/dist/utils/resolve-class-node.cjs +144 -0
- package/dist/utils/resolve-class-node.d.ts +12 -0
- package/dist/utils/resolve-class-node.mjs +142 -0
- package/dist/utils/resolve-context.cjs +6 -2
- package/dist/utils/resolve-context.mjs +6 -2
- package/dist/utils/with-visit-class-node.cjs +56 -0
- package/dist/utils/with-visit-class-node.d.ts +4 -0
- package/dist/utils/with-visit-class-node.mjs +54 -0
- package/package.json +1 -1
- package/dist/utils/extract-classnames-from-value.cjs +0 -34
- package/dist/utils/extract-classnames-from-value.d.ts +0 -6
- package/dist/utils/extract-classnames-from-value.mjs +0 -32
- package/dist/utils/extract-range-from-node.cjs +0 -18
- package/dist/utils/extract-range-from-node.d.ts +0 -1
- package/dist/utils/extract-range-from-node.mjs +0 -16
- package/dist/utils/extract-value-from-node.cjs +0 -23
- package/dist/utils/extract-value-from-node.d.ts +0 -1
- package/dist/utils/extract-value-from-node.mjs +0 -21
- package/dist/utils/find-loc.cjs +0 -51
- package/dist/utils/find-loc.d.ts +0 -7
- package/dist/utils/find-loc.mjs +0 -49
- package/dist/utils/get-template-element-body.cjs +0 -12
- package/dist/utils/get-template-element-body.d.ts +0 -1
- package/dist/utils/get-template-element-body.mjs +0 -10
- package/dist/utils/get-template-element-prefix.cjs +0 -11
- package/dist/utils/get-template-element-prefix.d.ts +0 -1
- package/dist/utils/get-template-element-prefix.mjs +0 -9
- package/dist/utils/get-template-element-suffix.cjs +0 -10
- package/dist/utils/get-template-element-suffix.d.ts +0 -1
- package/dist/utils/get-template-element-suffix.mjs +0 -8
- package/dist/utils/index-of-all.cjs +0 -12
- package/dist/utils/index-of-all.d.ts +0 -1
- package/dist/utils/index-of-all.mjs +0 -10
- package/dist/utils/parse-node-recursive.cjs +0 -129
- package/dist/utils/parse-node-recursive.d.ts +0 -13
- package/dist/utils/parse-node-recursive.mjs +0 -127
|
@@ -15,8 +15,12 @@ function resolveContext(context) {
|
|
|
15
15
|
} else {
|
|
16
16
|
config = exploreConfig({
|
|
17
17
|
name: resolvedSettings.config,
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
cwd: context.cwd,
|
|
19
|
+
found (_, configPath) {
|
|
20
|
+
if (process.env.DEBUG) {
|
|
21
|
+
console.log('Found config:', configPath);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
20
24
|
});
|
|
21
25
|
}
|
|
22
26
|
css$1 = new css.MasterCSS(config);
|
|
@@ -13,8 +13,12 @@ function resolveContext(context) {
|
|
|
13
13
|
} else {
|
|
14
14
|
config = exploreConfig({
|
|
15
15
|
name: resolvedSettings.config,
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
cwd: context.cwd,
|
|
17
|
+
found (_, configPath) {
|
|
18
|
+
if (process.env.DEBUG) {
|
|
19
|
+
console.log('Found config:', configPath);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
18
22
|
});
|
|
19
23
|
}
|
|
20
24
|
css = new MasterCSS(config);
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var resolveClassNode = require('./resolve-class-node.cjs');
|
|
4
|
+
|
|
5
|
+
function withVisitClassNode(visit, context) {
|
|
6
|
+
const visitNode = (node)=>{
|
|
7
|
+
switch(node.type){
|
|
8
|
+
case 'BinaryExpression':
|
|
9
|
+
case 'Identifier':
|
|
10
|
+
return;
|
|
11
|
+
case 'TemplateLiteral':
|
|
12
|
+
node.expressions?.forEach(visitNode);
|
|
13
|
+
node.quasis.forEach(visitNode);
|
|
14
|
+
return;
|
|
15
|
+
case 'JSXExpressionContainer':
|
|
16
|
+
visitNode(node.expression);
|
|
17
|
+
return;
|
|
18
|
+
case 'ConditionalExpression':
|
|
19
|
+
visitNode(node.consequent);
|
|
20
|
+
visitNode(node.alternate);
|
|
21
|
+
return;
|
|
22
|
+
case 'ArrayExpression':
|
|
23
|
+
node.elements.forEach((el)=>{
|
|
24
|
+
visitNode(el);
|
|
25
|
+
});
|
|
26
|
+
return;
|
|
27
|
+
case 'LogicalExpression':
|
|
28
|
+
visitNode(node.right);
|
|
29
|
+
return;
|
|
30
|
+
case 'ObjectExpression':
|
|
31
|
+
node.properties.forEach((prop)=>{
|
|
32
|
+
visitNode(prop);
|
|
33
|
+
});
|
|
34
|
+
return;
|
|
35
|
+
case 'Property':
|
|
36
|
+
if (node.shorthand) return;
|
|
37
|
+
if (node.value && [
|
|
38
|
+
'Literal',
|
|
39
|
+
'ArrayExpression',
|
|
40
|
+
'ObjectExpression'
|
|
41
|
+
].includes(node.value.type) && typeof node.value?.value !== 'boolean') {
|
|
42
|
+
visitNode(node.value);
|
|
43
|
+
} else if (node.key.type === 'Literal') {
|
|
44
|
+
visitNode(node.key);
|
|
45
|
+
}
|
|
46
|
+
return;
|
|
47
|
+
default:
|
|
48
|
+
let resolved = resolveClassNode(node, context);
|
|
49
|
+
if (!resolved) return;
|
|
50
|
+
visit(node, resolved);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
return visitNode;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
module.exports = withVisitClassNode;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { RuleContext } from '@typescript-eslint/utils/ts-eslint';
|
|
2
|
+
import resolveClassNode from './resolve-class-node';
|
|
3
|
+
import { TSESTree } from '@typescript-eslint/utils';
|
|
4
|
+
export default function withVisitClassNode(visit: (node: TSESTree.Node, resolved: ReturnType<typeof resolveClassNode>) => void, context: RuleContext<any, any[]>): (node: any) => void;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import resolveClassNode from './resolve-class-node.mjs';
|
|
2
|
+
|
|
3
|
+
function withVisitClassNode(visit, context) {
|
|
4
|
+
const visitNode = (node)=>{
|
|
5
|
+
switch(node.type){
|
|
6
|
+
case 'BinaryExpression':
|
|
7
|
+
case 'Identifier':
|
|
8
|
+
return;
|
|
9
|
+
case 'TemplateLiteral':
|
|
10
|
+
node.expressions?.forEach(visitNode);
|
|
11
|
+
node.quasis.forEach(visitNode);
|
|
12
|
+
return;
|
|
13
|
+
case 'JSXExpressionContainer':
|
|
14
|
+
visitNode(node.expression);
|
|
15
|
+
return;
|
|
16
|
+
case 'ConditionalExpression':
|
|
17
|
+
visitNode(node.consequent);
|
|
18
|
+
visitNode(node.alternate);
|
|
19
|
+
return;
|
|
20
|
+
case 'ArrayExpression':
|
|
21
|
+
node.elements.forEach((el)=>{
|
|
22
|
+
visitNode(el);
|
|
23
|
+
});
|
|
24
|
+
return;
|
|
25
|
+
case 'LogicalExpression':
|
|
26
|
+
visitNode(node.right);
|
|
27
|
+
return;
|
|
28
|
+
case 'ObjectExpression':
|
|
29
|
+
node.properties.forEach((prop)=>{
|
|
30
|
+
visitNode(prop);
|
|
31
|
+
});
|
|
32
|
+
return;
|
|
33
|
+
case 'Property':
|
|
34
|
+
if (node.shorthand) return;
|
|
35
|
+
if (node.value && [
|
|
36
|
+
'Literal',
|
|
37
|
+
'ArrayExpression',
|
|
38
|
+
'ObjectExpression'
|
|
39
|
+
].includes(node.value.type) && typeof node.value?.value !== 'boolean') {
|
|
40
|
+
visitNode(node.value);
|
|
41
|
+
} else if (node.key.type === 'Literal') {
|
|
42
|
+
visitNode(node.key);
|
|
43
|
+
}
|
|
44
|
+
return;
|
|
45
|
+
default:
|
|
46
|
+
let resolved = resolveClassNode(node, context);
|
|
47
|
+
if (!resolved) return;
|
|
48
|
+
visit(node, resolved);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
return visitNode;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export { withVisitClassNode as default };
|
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":"vitest","type-check":"tsc --noEmit","lint":"eslint"},"keywords":["mastercss","eslint","eslintplugin"],"license":"MIT","description":"Master CSS ESLint Plugin","author":"Aoyue Design LLC.","funding":"https://rc.css.master.co/sponsor","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":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.cjs"},"./configs/*":{"types":"./dist/configs/*.d.ts","import":"./dist/configs/*.mjs","require":"./dist/configs/*.cjs"}},"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":"vitest","type-check":"tsc --noEmit","lint":"eslint"},"keywords":["mastercss","eslint","eslintplugin"],"license":"MIT","description":"Master CSS ESLint Plugin","author":"Aoyue Design LLC.","funding":"https://rc.css.master.co/sponsor","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":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.cjs"},"./configs/*":{"types":"./dist/configs/*.d.ts","import":"./dist/configs/*.mjs","require":"./dist/configs/*.cjs"}},"files":["dist"],"publishConfig":{"access":"public","provenance":true},"dependencies":{"@master/css":"^2.0.0-rc.63","@master/css-explore-config":"^2.0.0-rc.63","@master/css-validator":"^2.0.0-rc.63","@typescript-eslint/utils":"^8.29.1","typescript-eslint":"^8.29.1"},"devDependencies":{"@angular-eslint/template-parser":"^19.3.0","@angular/compiler":"^17.2.2","@master/css-explore-config":"^2.0.0-rc.63","@typescript-eslint/rule-tester":"^8.29.1","eslint":"^9.24.0","eslint-plugin-markdown":"^5.1.0","eslint-plugin-mdx":"^3.4.0","shared":"^2.0.0-rc.63","svelte-eslint-parser":"^1.1.2","ts-node":"^10.9.2","vue-eslint-parser":"^10.1.3"},"version":"2.0.0-rc.63"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const separatorRegEx = /([\t\n\f\r ]+)/;
|
|
4
|
-
function extractClassnamesFromValue(classStr) {
|
|
5
|
-
if (typeof classStr !== 'string') {
|
|
6
|
-
return {
|
|
7
|
-
classNames: [],
|
|
8
|
-
whitespaces: [],
|
|
9
|
-
headSpace: false,
|
|
10
|
-
tailSpace: false
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
const parts = classStr.split(separatorRegEx);
|
|
14
|
-
if (parts[0] === '') {
|
|
15
|
-
parts.shift();
|
|
16
|
-
}
|
|
17
|
-
if (parts[parts.length - 1] === '') {
|
|
18
|
-
parts.pop();
|
|
19
|
-
}
|
|
20
|
-
const headSpace = separatorRegEx.test(parts[0]);
|
|
21
|
-
const tailSpace = separatorRegEx.test(parts[parts.length - 1]);
|
|
22
|
-
const isClass = (_, i)=>headSpace ? i % 2 !== 0 : i % 2 === 0;
|
|
23
|
-
const isNotClass = (_, i)=>headSpace ? i % 2 === 0 : i % 2 !== 0;
|
|
24
|
-
const classNames = parts.filter(isClass);
|
|
25
|
-
const whitespaces = parts.filter(isNotClass);
|
|
26
|
-
return {
|
|
27
|
-
classNames: classNames,
|
|
28
|
-
whitespaces: whitespaces,
|
|
29
|
-
headSpace: headSpace,
|
|
30
|
-
tailSpace: tailSpace
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
module.exports = extractClassnamesFromValue;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
const separatorRegEx = /([\t\n\f\r ]+)/;
|
|
2
|
-
function extractClassnamesFromValue(classStr) {
|
|
3
|
-
if (typeof classStr !== 'string') {
|
|
4
|
-
return {
|
|
5
|
-
classNames: [],
|
|
6
|
-
whitespaces: [],
|
|
7
|
-
headSpace: false,
|
|
8
|
-
tailSpace: false
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
const parts = classStr.split(separatorRegEx);
|
|
12
|
-
if (parts[0] === '') {
|
|
13
|
-
parts.shift();
|
|
14
|
-
}
|
|
15
|
-
if (parts[parts.length - 1] === '') {
|
|
16
|
-
parts.pop();
|
|
17
|
-
}
|
|
18
|
-
const headSpace = separatorRegEx.test(parts[0]);
|
|
19
|
-
const tailSpace = separatorRegEx.test(parts[parts.length - 1]);
|
|
20
|
-
const isClass = (_, i)=>headSpace ? i % 2 !== 0 : i % 2 === 0;
|
|
21
|
-
const isNotClass = (_, i)=>headSpace ? i % 2 === 0 : i % 2 !== 0;
|
|
22
|
-
const classNames = parts.filter(isClass);
|
|
23
|
-
const whitespaces = parts.filter(isNotClass);
|
|
24
|
-
return {
|
|
25
|
-
classNames: classNames,
|
|
26
|
-
whitespaces: whitespaces,
|
|
27
|
-
headSpace: headSpace,
|
|
28
|
-
tailSpace: tailSpace
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export { extractClassnamesFromValue as default };
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
function extractRangeFromNode(node) {
|
|
4
|
-
if (node.type === 'TextAttribute' && node.name === 'class') {
|
|
5
|
-
return [
|
|
6
|
-
node.valueSpan.fullStart.offset,
|
|
7
|
-
node.valueSpan.end.offset
|
|
8
|
-
];
|
|
9
|
-
}
|
|
10
|
-
switch(node.value.type){
|
|
11
|
-
case 'JSXExpressionContainer':
|
|
12
|
-
return node.value.expression.range;
|
|
13
|
-
default:
|
|
14
|
-
return node.value.range;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
module.exports = extractRangeFromNode;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function extractRangeFromNode(node: any): any;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
function extractRangeFromNode(node) {
|
|
2
|
-
if (node.type === 'TextAttribute' && node.name === 'class') {
|
|
3
|
-
return [
|
|
4
|
-
node.valueSpan.fullStart.offset,
|
|
5
|
-
node.valueSpan.end.offset
|
|
6
|
-
];
|
|
7
|
-
}
|
|
8
|
-
switch(node.value.type){
|
|
9
|
-
case 'JSXExpressionContainer':
|
|
10
|
-
return node.value.expression.range;
|
|
11
|
-
default:
|
|
12
|
-
return node.value.range;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export { extractRangeFromNode as default };
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
function extractValueFromNode(node) {
|
|
4
|
-
if (node.type === 'TextAttribute' && node.name === 'class') {
|
|
5
|
-
return node.value;
|
|
6
|
-
}
|
|
7
|
-
switch(node.value.type){
|
|
8
|
-
case 'JSXExpressionContainer':
|
|
9
|
-
return node.value.expression.value;
|
|
10
|
-
case 'VExpressionContainer':
|
|
11
|
-
switch(node.value.expression.type){
|
|
12
|
-
case 'ArrayExpression':
|
|
13
|
-
return node.value.expression.elements;
|
|
14
|
-
case 'ObjectExpression':
|
|
15
|
-
return node.value.expression.properties;
|
|
16
|
-
}
|
|
17
|
-
return node.value.expression.value;
|
|
18
|
-
default:
|
|
19
|
-
return node.value.value;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
module.exports = extractValueFromNode;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function extractValueFromNode(node: any): any;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
function extractValueFromNode(node) {
|
|
2
|
-
if (node.type === 'TextAttribute' && node.name === 'class') {
|
|
3
|
-
return node.value;
|
|
4
|
-
}
|
|
5
|
-
switch(node.value.type){
|
|
6
|
-
case 'JSXExpressionContainer':
|
|
7
|
-
return node.value.expression.value;
|
|
8
|
-
case 'VExpressionContainer':
|
|
9
|
-
switch(node.value.expression.type){
|
|
10
|
-
case 'ArrayExpression':
|
|
11
|
-
return node.value.expression.elements;
|
|
12
|
-
case 'ObjectExpression':
|
|
13
|
-
return node.value.expression.properties;
|
|
14
|
-
}
|
|
15
|
-
return node.value.expression.value;
|
|
16
|
-
default:
|
|
17
|
-
return node.value.value;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export { extractValueFromNode as default };
|
package/dist/utils/find-loc.cjs
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var indexOfAll = require('./index-of-all.cjs');
|
|
4
|
-
|
|
5
|
-
function findLoc(text, lines, startLine, startColumn, endLine, endColumn) {
|
|
6
|
-
const targetLines = text.match(/.+(?:\r\n|\n)?/g);
|
|
7
|
-
let checkingTargetLine = 0;
|
|
8
|
-
let resultStart = null;
|
|
9
|
-
let checking = false;
|
|
10
|
-
for(let i = startLine; i <= endLine; i++){
|
|
11
|
-
const sourceCodeLine = lines[i - 1];
|
|
12
|
-
const content = targetLines[checkingTargetLine].replace(/\r\n|\n/, '');
|
|
13
|
-
const indexes = indexOfAll.indexOfAll(sourceCodeLine, content);
|
|
14
|
-
if (indexes.length > 0) {
|
|
15
|
-
for (const index of indexes){
|
|
16
|
-
if (i === startLine && index < startColumn || i === endLine && index > endColumn) {
|
|
17
|
-
continue;
|
|
18
|
-
}
|
|
19
|
-
if (index !== 0 && sourceCodeLine[index - 1].match(/\w/) || index + content.length < sourceCodeLine.length && sourceCodeLine[index + content.length].match(/\w/)) {
|
|
20
|
-
continue;
|
|
21
|
-
}
|
|
22
|
-
if (checkingTargetLine === 0) {
|
|
23
|
-
resultStart = {
|
|
24
|
-
line: i,
|
|
25
|
-
column: index
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
if (checkingTargetLine === targetLines.length - 1) {
|
|
29
|
-
return {
|
|
30
|
-
start: resultStart,
|
|
31
|
-
end: {
|
|
32
|
-
line: i,
|
|
33
|
-
column: index + text.length
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
checking = true;
|
|
38
|
-
checkingTargetLine++;
|
|
39
|
-
}
|
|
40
|
-
} else {
|
|
41
|
-
if (checking) {
|
|
42
|
-
checking = false;
|
|
43
|
-
checkingTargetLine = 0;
|
|
44
|
-
resultStart = null;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
return null;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
module.exports = findLoc;
|
package/dist/utils/find-loc.d.ts
DELETED
package/dist/utils/find-loc.mjs
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { indexOfAll } from './index-of-all.mjs';
|
|
2
|
-
|
|
3
|
-
function findLoc(text, lines, startLine, startColumn, endLine, endColumn) {
|
|
4
|
-
const targetLines = text.match(/.+(?:\r\n|\n)?/g);
|
|
5
|
-
let checkingTargetLine = 0;
|
|
6
|
-
let resultStart = null;
|
|
7
|
-
let checking = false;
|
|
8
|
-
for(let i = startLine; i <= endLine; i++){
|
|
9
|
-
const sourceCodeLine = lines[i - 1];
|
|
10
|
-
const content = targetLines[checkingTargetLine].replace(/\r\n|\n/, '');
|
|
11
|
-
const indexes = indexOfAll(sourceCodeLine, content);
|
|
12
|
-
if (indexes.length > 0) {
|
|
13
|
-
for (const index of indexes){
|
|
14
|
-
if (i === startLine && index < startColumn || i === endLine && index > endColumn) {
|
|
15
|
-
continue;
|
|
16
|
-
}
|
|
17
|
-
if (index !== 0 && sourceCodeLine[index - 1].match(/\w/) || index + content.length < sourceCodeLine.length && sourceCodeLine[index + content.length].match(/\w/)) {
|
|
18
|
-
continue;
|
|
19
|
-
}
|
|
20
|
-
if (checkingTargetLine === 0) {
|
|
21
|
-
resultStart = {
|
|
22
|
-
line: i,
|
|
23
|
-
column: index
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
if (checkingTargetLine === targetLines.length - 1) {
|
|
27
|
-
return {
|
|
28
|
-
start: resultStart,
|
|
29
|
-
end: {
|
|
30
|
-
line: i,
|
|
31
|
-
column: index + text.length
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
checking = true;
|
|
36
|
-
checkingTargetLine++;
|
|
37
|
-
}
|
|
38
|
-
} else {
|
|
39
|
-
if (checking) {
|
|
40
|
-
checking = false;
|
|
41
|
-
checkingTargetLine = 0;
|
|
42
|
-
resultStart = null;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return null;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export { findLoc as default };
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
function getTemplateElementBody(text, prefix, suffix) {
|
|
4
|
-
let arr = text.split(prefix);
|
|
5
|
-
arr.shift();
|
|
6
|
-
const body = arr.join(prefix);
|
|
7
|
-
arr = body.split(suffix);
|
|
8
|
-
arr.pop();
|
|
9
|
-
return arr.join(suffix);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
module.exports = getTemplateElementBody;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function getTemplateElementBody(text: any, prefix: any, suffix: any): any;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function getTemplateElementPrefix(text: any, raw: any): any;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function getTemplateElementSuffix(text: any, raw: any): any;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function indexOfAll(arr: any[] | string, value: any): number[];
|