@master/eslint-plugin-css 2.0.0-rc.37 → 2.0.0-rc.39

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.
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ var indexOfAll = require('./index-of-all.cjs');
4
+
3
5
  function findLoc(text, lines, startLine, endLine) {
4
6
  const targetLines = text.match(/.+(?:\r\n|\n)?/g);
5
7
  let checkingTargetLine = 0;
@@ -8,16 +10,19 @@ function findLoc(text, lines, startLine, endLine) {
8
10
  for(let i = startLine; i <= endLine; i++){
9
11
  const sourceCodeLine = lines[i - 1];
10
12
  const content = targetLines[checkingTargetLine].replace(/\r\n|\n/, '');
11
- const index = sourceCodeLine.indexOf(content);
12
- if (index !== -1) {
13
- if (index === 0 || sourceCodeLine[index - 1].match(/^|[\s"'']/)) {
13
+ const indexes = indexOfAll.indexOfAll(sourceCodeLine, content);
14
+ if (indexes.length > 0) {
15
+ for (const index of indexes){
16
+ if (index !== 0 && sourceCodeLine[index - 1].match(/\w/) || index + content.length < sourceCodeLine.length && sourceCodeLine[index + content.length].match(/\w/)) {
17
+ continue;
18
+ }
14
19
  if (checkingTargetLine === 0) {
15
20
  resultStart = {
16
21
  line: i,
17
22
  column: index
18
23
  };
19
24
  }
20
- if (checkingTargetLine === targetLines.length - 1 && (sourceCodeLine[index + content.length - 1].match(/$|[\s"'']/) || sourceCodeLine[index + content.length].match(/[\s"'']/))) {
25
+ if (checkingTargetLine === targetLines.length - 1) {
21
26
  return {
22
27
  start: resultStart,
23
28
  end: {
@@ -1,3 +1,5 @@
1
+ import { indexOfAll } from './index-of-all.mjs';
2
+
1
3
  function findLoc(text, lines, startLine, endLine) {
2
4
  const targetLines = text.match(/.+(?:\r\n|\n)?/g);
3
5
  let checkingTargetLine = 0;
@@ -6,16 +8,19 @@ function findLoc(text, lines, startLine, endLine) {
6
8
  for(let i = startLine; i <= endLine; i++){
7
9
  const sourceCodeLine = lines[i - 1];
8
10
  const content = targetLines[checkingTargetLine].replace(/\r\n|\n/, '');
9
- const index = sourceCodeLine.indexOf(content);
10
- if (index !== -1) {
11
- if (index === 0 || sourceCodeLine[index - 1].match(/^|[\s"'']/)) {
11
+ const indexes = indexOfAll(sourceCodeLine, content);
12
+ if (indexes.length > 0) {
13
+ for (const index of indexes){
14
+ if (index !== 0 && sourceCodeLine[index - 1].match(/\w/) || index + content.length < sourceCodeLine.length && sourceCodeLine[index + content.length].match(/\w/)) {
15
+ continue;
16
+ }
12
17
  if (checkingTargetLine === 0) {
13
18
  resultStart = {
14
19
  line: i,
15
20
  column: index
16
21
  };
17
22
  }
18
- if (checkingTargetLine === targetLines.length - 1 && (sourceCodeLine[index + content.length - 1].match(/$|[\s"'']/) || sourceCodeLine[index + content.length].match(/[\s"'']/))) {
23
+ if (checkingTargetLine === targetLines.length - 1) {
19
24
  return {
20
25
  start: resultStart,
21
26
  end: {
@@ -0,0 +1,12 @@
1
+ 'use strict';
2
+
3
+ function indexOfAll(arr, value) {
4
+ const result = [];
5
+ let i = -1;
6
+ while((i = arr.indexOf(value, i + 1)) !== -1){
7
+ result.push(i);
8
+ }
9
+ return result;
10
+ }
11
+
12
+ exports.indexOfAll = indexOfAll;
@@ -0,0 +1 @@
1
+ export declare function indexOfAll(arr: any[] | string, value: any): number[];
@@ -0,0 +1,10 @@
1
+ function indexOfAll(arr, value) {
2
+ const result = [];
3
+ let i = -1;
4
+ while((i = arr.indexOf(value, i + 1)) !== -1){
5
+ result.push(i);
6
+ }
7
+ return result;
8
+ }
9
+
10
+ export { indexOfAll };
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.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"}
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 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.39","@master/css-explore-config":"^2.0.0-rc.39","@master/css-validator":"^2.0.0-rc.39","@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.39","@master/css-shared":"^2.0.0-rc.39","@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.39"}