@master/eslint-plugin-css 2.0.0-rc.62 → 2.0.0-rc.64

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.
@@ -31,20 +31,17 @@ var classOrder = createRule({
31
31
  }, (node, { raw, start, end, nodes, classValueRawMap, classValues })=>{
32
32
  if (nodes.length <= 1) return;
33
33
  let orderedClasses = css.sortReadableClasses(classValues, css$1);
34
- let orderedRaw = nodes.map((node, i)=>{
35
- if (node.type === 'class') {
34
+ let orderedRaw = nodes.map((eachNode, i)=>{
35
+ if (eachNode.type === 'class') {
36
36
  const value = orderedClasses.shift();
37
37
  return classValueRawMap.get(value);
38
38
  }
39
- if (node.type === 'space' && (orderedClasses.length !== 0 || i === nodes.length - 1)) {
40
- return node.raw;
39
+ if (eachNode.type === 'space' && (orderedClasses.length !== 0 || i === nodes.length - 1)) {
40
+ return eachNode.raw;
41
41
  }
42
42
  return '';
43
43
  }).join('');
44
44
  if (raw !== orderedRaw) {
45
- if (node.type === 'TemplateElement') {
46
- orderedRaw = '`' + orderedRaw + '`';
47
- }
48
45
  context.report({
49
46
  node,
50
47
  loc: {
@@ -29,20 +29,17 @@ var classOrder = createRule({
29
29
  }, (node, { raw, start, end, nodes, classValueRawMap, classValues })=>{
30
30
  if (nodes.length <= 1) return;
31
31
  let orderedClasses = sortReadableClasses(classValues, css);
32
- let orderedRaw = nodes.map((node, i)=>{
33
- if (node.type === 'class') {
32
+ let orderedRaw = nodes.map((eachNode, i)=>{
33
+ if (eachNode.type === 'class') {
34
34
  const value = orderedClasses.shift();
35
35
  return classValueRawMap.get(value);
36
36
  }
37
- if (node.type === 'space' && (orderedClasses.length !== 0 || i === nodes.length - 1)) {
38
- return node.raw;
37
+ if (eachNode.type === 'space' && (orderedClasses.length !== 0 || i === nodes.length - 1)) {
38
+ return eachNode.raw;
39
39
  }
40
40
  return '';
41
41
  }).join('');
42
42
  if (raw !== orderedRaw) {
43
- if (node.type === 'TemplateElement') {
44
- orderedRaw = '`' + orderedRaw + '`';
45
- }
46
43
  context.report({
47
44
  node,
48
45
  loc: {
@@ -28,14 +28,14 @@ var classValidation = createRule({
28
28
  return defineVisitors({
29
29
  context,
30
30
  settings
31
- }, (node, { classNodes })=>{
31
+ }, (_, { classNodes })=>{
32
32
  for (const node of classNodes){
33
33
  const { matched, errors } = cssValidator.validate(node.value, css);
34
34
  if (errors.length > 0) {
35
35
  for (const error of errors){
36
36
  if (matched) {
37
37
  context.report({
38
- loc: node.loc,
38
+ node,
39
39
  messageId: 'invalidClass',
40
40
  data: {
41
41
  message: error.message + '.'
@@ -43,7 +43,7 @@ var classValidation = createRule({
43
43
  });
44
44
  } else if (options.disallowUnknownClass) {
45
45
  context.report({
46
- loc: node.loc,
46
+ node,
47
47
  messageId: 'disallowUnknownClass',
48
48
  data: {
49
49
  message: `"${node.raw}" is not a valid or known class.`
@@ -26,14 +26,14 @@ var classValidation = createRule({
26
26
  return defineVisitors({
27
27
  context,
28
28
  settings
29
- }, (node, { classNodes })=>{
29
+ }, (_, { classNodes })=>{
30
30
  for (const node of classNodes){
31
31
  const { matched, errors } = validate(node.value, css);
32
32
  if (errors.length > 0) {
33
33
  for (const error of errors){
34
34
  if (matched) {
35
35
  context.report({
36
- loc: node.loc,
36
+ node,
37
37
  messageId: 'invalidClass',
38
38
  data: {
39
39
  message: error.message + '.'
@@ -41,7 +41,7 @@ var classValidation = createRule({
41
41
  });
42
42
  } else if (options.disallowUnknownClass) {
43
43
  context.report({
44
- loc: node.loc,
44
+ node,
45
45
  messageId: 'disallowUnknownClass',
46
46
  data: {
47
47
  message: `"${node.raw}" is not a valid or known class.`
@@ -45,8 +45,8 @@ function resolveClassNode(node, context) {
45
45
  }
46
46
  value = node.value.cooked;
47
47
  raw = node.value.raw;
48
- start = node.range[0];
49
- end = node.range[1];
48
+ start = node.range[0] + 1;
49
+ end = node.range[1] - 1;
50
50
  break;
51
51
  default:
52
52
  return;
@@ -71,7 +71,6 @@ function resolveClassNode(node, context) {
71
71
  const spaceRaw = match[0];
72
72
  const spaceStart = match.index;
73
73
  const spaceEnd = spaceStart + spaceRaw.length;
74
- // 處理前一段非空白 (class name)
75
74
  if (spaceStart > lastIndex) {
76
75
  const classRaw = raw.slice(lastIndex, spaceStart);
77
76
  const classValue = classRawValueMap.get(classRaw);
@@ -92,7 +91,6 @@ function resolveClassNode(node, context) {
92
91
  }
93
92
  });
94
93
  }
95
- // 處理空白
96
94
  const spaceStartOffset = start + spaceStart;
97
95
  const spaceEndOffset = start + spaceEnd;
98
96
  nodes.push({
@@ -109,7 +107,6 @@ function resolveClassNode(node, context) {
109
107
  });
110
108
  lastIndex = spaceEnd;
111
109
  }
112
- // 最後一段 class name(若結尾不是空白)
113
110
  if (lastIndex < raw.length) {
114
111
  const classRaw = raw.slice(lastIndex);
115
112
  const classValue = classRawValueMap.get(classRaw);
@@ -121,7 +118,7 @@ function resolveClassNode(node, context) {
121
118
  value: classValue,
122
119
  raw: classRaw,
123
120
  range: [
124
- startOffset,
121
+ start,
125
122
  endOffset
126
123
  ],
127
124
  loc: {
@@ -43,8 +43,8 @@ function resolveClassNode(node, context) {
43
43
  }
44
44
  value = node.value.cooked;
45
45
  raw = node.value.raw;
46
- start = node.range[0];
47
- end = node.range[1];
46
+ start = node.range[0] + 1;
47
+ end = node.range[1] - 1;
48
48
  break;
49
49
  default:
50
50
  return;
@@ -69,7 +69,6 @@ function resolveClassNode(node, context) {
69
69
  const spaceRaw = match[0];
70
70
  const spaceStart = match.index;
71
71
  const spaceEnd = spaceStart + spaceRaw.length;
72
- // 處理前一段非空白 (class name)
73
72
  if (spaceStart > lastIndex) {
74
73
  const classRaw = raw.slice(lastIndex, spaceStart);
75
74
  const classValue = classRawValueMap.get(classRaw);
@@ -90,7 +89,6 @@ function resolveClassNode(node, context) {
90
89
  }
91
90
  });
92
91
  }
93
- // 處理空白
94
92
  const spaceStartOffset = start + spaceStart;
95
93
  const spaceEndOffset = start + spaceEnd;
96
94
  nodes.push({
@@ -107,7 +105,6 @@ function resolveClassNode(node, context) {
107
105
  });
108
106
  lastIndex = spaceEnd;
109
107
  }
110
- // 最後一段 class name(若結尾不是空白)
111
108
  if (lastIndex < raw.length) {
112
109
  const classRaw = raw.slice(lastIndex);
113
110
  const classValue = classRawValueMap.get(classRaw);
@@ -119,7 +116,7 @@ function resolveClassNode(node, context) {
119
116
  value: classValue,
120
117
  raw: classRaw,
121
118
  range: [
122
- startOffset,
119
+ start,
123
120
  endOffset
124
121
  ],
125
122
  loc: {
@@ -9,14 +9,8 @@ function withVisitClassNode(visit, context) {
9
9
  case 'Identifier':
10
10
  return;
11
11
  case 'TemplateLiteral':
12
- if (node.expressions.length) {
13
- node.expressions.forEach((exp)=>{
14
- visitNode(exp);
15
- });
16
- }
17
- node.quasis.forEach((el)=>{
18
- visitNode(el);
19
- });
12
+ node.expressions?.forEach(visitNode);
13
+ node.quasis.forEach(visitNode);
20
14
  return;
21
15
  case 'JSXExpressionContainer':
22
16
  visitNode(node.expression);
@@ -7,14 +7,8 @@ function withVisitClassNode(visit, context) {
7
7
  case 'Identifier':
8
8
  return;
9
9
  case 'TemplateLiteral':
10
- if (node.expressions.length) {
11
- node.expressions.forEach((exp)=>{
12
- visitNode(exp);
13
- });
14
- }
15
- node.quasis.forEach((el)=>{
16
- visitNode(el);
17
- });
10
+ node.expressions?.forEach(visitNode);
11
+ node.quasis.forEach(visitNode);
18
12
  return;
19
13
  case 'JSXExpressionContainer':
20
14
  visitNode(node.expression);
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.62","@master/css-explore-config":"^2.0.0-rc.62","@master/css-validator":"^2.0.0-rc.62","@typescript-eslint/utils":"^8.29.1","typescript-eslint":"^8.29.1"},"devDependencies":{"@angular-eslint/template-parser":"^19.3.0","@master/css-explore-config":"^2.0.0-rc.62","@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.62","svelte-eslint-parser":"^1.1.2","ts-node":"^10.9.2","vue-eslint-parser":"^10.1.3"},"version":"2.0.0-rc.62"}
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.64","@master/css-explore-config":"^2.0.0-rc.64","@master/css-validator":"^2.0.0-rc.64","@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.64","@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.64","svelte-eslint-parser":"^1.1.2","ts-node":"^10.9.2","vue-eslint-parser":"^10.1.3"},"version":"2.0.0-rc.64"}