@unocss/eslint-plugin 0.62.3 → 0.62.4

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/index.cjs CHANGED
@@ -1,23 +1,18 @@
1
1
  'use strict';
2
2
 
3
- const MagicString = require('magic-string');
4
3
  const node_path = require('node:path');
5
- const synckit = require('synckit');
6
4
  const utils = require('@typescript-eslint/utils');
5
+ const synckit = require('synckit');
7
6
  const dirs = require('./dirs.cjs');
7
+ const MagicString = require('magic-string');
8
8
  require('node:url');
9
9
 
10
10
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
11
11
 
12
12
  const MagicString__default = /*#__PURE__*/_interopDefaultCompat(MagicString);
13
13
 
14
- const configsRecommended = {
15
- plugins: ["@unocss"],
16
- rules: {
17
- "@unocss/order": "warn",
18
- "@unocss/order-attributify": "warn"
19
- }
20
- };
14
+ const CLASS_FIELDS = ["class", "classname"];
15
+ const AST_NODES_WITH_QUOTES = ["Literal", "VLiteral"];
21
16
 
22
17
  const syncAction = synckit.createSyncFn(node_path.join(dirs.distDir, "worker.mjs"));
23
18
  const createRule = utils.ESLintUtils.RuleCreator(
@@ -80,77 +75,6 @@ const orderAttributify = createRule({
80
75
  }
81
76
  });
82
77
 
83
- const CLASS_FIELDS = ["class", "classname"];
84
- const AST_NODES_WITH_QUOTES = ["Literal", "VLiteral"];
85
-
86
- const order = createRule({
87
- name: "order",
88
- meta: {
89
- type: "layout",
90
- fixable: "code",
91
- docs: {
92
- description: "Order of UnoCSS utilities in class attribute"
93
- },
94
- messages: {
95
- "invalid-order": "UnoCSS utilities are not ordered"
96
- },
97
- schema: []
98
- },
99
- defaultOptions: [],
100
- create(context) {
101
- function checkLiteral(node) {
102
- if (typeof node.value !== "string" || !node.value.trim())
103
- return;
104
- const input = node.value;
105
- const sorted = syncAction(
106
- context.settings.unocss?.configPath,
107
- "sort",
108
- input
109
- ).trim();
110
- if (sorted !== input) {
111
- context.report({
112
- node,
113
- messageId: "invalid-order",
114
- fix(fixer) {
115
- if (AST_NODES_WITH_QUOTES.includes(node.type))
116
- return fixer.replaceTextRange([node.range[0] + 1, node.range[1] - 1], sorted);
117
- else
118
- return fixer.replaceText(node, sorted);
119
- }
120
- });
121
- }
122
- }
123
- const scriptVisitor = {
124
- JSXAttribute(node) {
125
- if (typeof node.name.name === "string" && CLASS_FIELDS.includes(node.name.name.toLowerCase()) && node.value) {
126
- if (node.value.type === "Literal")
127
- checkLiteral(node.value);
128
- }
129
- },
130
- SvelteAttribute(node) {
131
- if (node.key.name === "class") {
132
- if (node.value?.[0].type === "SvelteLiteral")
133
- checkLiteral(node.value[0]);
134
- }
135
- }
136
- };
137
- const templateBodyVisitor = {
138
- VAttribute(node) {
139
- if (node.key.name === "class") {
140
- if (node.value.type === "VLiteral")
141
- checkLiteral(node.value);
142
- }
143
- }
144
- };
145
- const parserServices = context?.sourceCode.parserServices || context.parserServices;
146
- if (parserServices == null || parserServices.defineTemplateBodyVisitor == null) {
147
- return scriptVisitor;
148
- } else {
149
- return parserServices?.defineTemplateBodyVisitor(templateBodyVisitor, scriptVisitor);
150
- }
151
- }
152
- });
153
-
154
78
  const blocklist = createRule({
155
79
  name: "blocklist",
156
80
  meta: {
@@ -340,6 +264,74 @@ const enforceClassCompile = createRule({
340
264
  }
341
265
  });
342
266
 
267
+ const order = createRule({
268
+ name: "order",
269
+ meta: {
270
+ type: "layout",
271
+ fixable: "code",
272
+ docs: {
273
+ description: "Order of UnoCSS utilities in class attribute"
274
+ },
275
+ messages: {
276
+ "invalid-order": "UnoCSS utilities are not ordered"
277
+ },
278
+ schema: []
279
+ },
280
+ defaultOptions: [],
281
+ create(context) {
282
+ function checkLiteral(node) {
283
+ if (typeof node.value !== "string" || !node.value.trim())
284
+ return;
285
+ const input = node.value;
286
+ const sorted = syncAction(
287
+ context.settings.unocss?.configPath,
288
+ "sort",
289
+ input
290
+ ).trim();
291
+ if (sorted !== input) {
292
+ context.report({
293
+ node,
294
+ messageId: "invalid-order",
295
+ fix(fixer) {
296
+ if (AST_NODES_WITH_QUOTES.includes(node.type))
297
+ return fixer.replaceTextRange([node.range[0] + 1, node.range[1] - 1], sorted);
298
+ else
299
+ return fixer.replaceText(node, sorted);
300
+ }
301
+ });
302
+ }
303
+ }
304
+ const scriptVisitor = {
305
+ JSXAttribute(node) {
306
+ if (typeof node.name.name === "string" && CLASS_FIELDS.includes(node.name.name.toLowerCase()) && node.value) {
307
+ if (node.value.type === "Literal")
308
+ checkLiteral(node.value);
309
+ }
310
+ },
311
+ SvelteAttribute(node) {
312
+ if (node.key.name === "class") {
313
+ if (node.value?.[0].type === "SvelteLiteral")
314
+ checkLiteral(node.value[0]);
315
+ }
316
+ }
317
+ };
318
+ const templateBodyVisitor = {
319
+ VAttribute(node) {
320
+ if (node.key.name === "class") {
321
+ if (node.value.type === "VLiteral")
322
+ checkLiteral(node.value);
323
+ }
324
+ }
325
+ };
326
+ const parserServices = context?.sourceCode.parserServices || context.parserServices;
327
+ if (parserServices == null || parserServices.defineTemplateBodyVisitor == null) {
328
+ return scriptVisitor;
329
+ } else {
330
+ return parserServices?.defineTemplateBodyVisitor(templateBodyVisitor, scriptVisitor);
331
+ }
332
+ }
333
+ });
334
+
343
335
  const plugin = {
344
336
  rules: {
345
337
  order,
@@ -359,6 +351,14 @@ const configsFlat = {
359
351
  }
360
352
  };
361
353
 
354
+ const configsRecommended = {
355
+ plugins: ["@unocss"],
356
+ rules: {
357
+ "@unocss/order": "warn",
358
+ "@unocss/order-attributify": "warn"
359
+ }
360
+ };
361
+
362
362
  const index = {
363
363
  ...plugin,
364
364
  configs: {
package/dist/index.mjs CHANGED
@@ -1,17 +1,12 @@
1
- import MagicString from 'magic-string';
2
1
  import { join } from 'node:path';
3
- import { createSyncFn } from 'synckit';
4
2
  import { ESLintUtils } from '@typescript-eslint/utils';
3
+ import { createSyncFn } from 'synckit';
5
4
  import { distDir } from './dirs.mjs';
5
+ import MagicString from 'magic-string';
6
6
  import 'node:url';
7
7
 
8
- const configsRecommended = {
9
- plugins: ["@unocss"],
10
- rules: {
11
- "@unocss/order": "warn",
12
- "@unocss/order-attributify": "warn"
13
- }
14
- };
8
+ const CLASS_FIELDS = ["class", "classname"];
9
+ const AST_NODES_WITH_QUOTES = ["Literal", "VLiteral"];
15
10
 
16
11
  const syncAction = createSyncFn(join(distDir, "worker.mjs"));
17
12
  const createRule = ESLintUtils.RuleCreator(
@@ -74,77 +69,6 @@ const orderAttributify = createRule({
74
69
  }
75
70
  });
76
71
 
77
- const CLASS_FIELDS = ["class", "classname"];
78
- const AST_NODES_WITH_QUOTES = ["Literal", "VLiteral"];
79
-
80
- const order = createRule({
81
- name: "order",
82
- meta: {
83
- type: "layout",
84
- fixable: "code",
85
- docs: {
86
- description: "Order of UnoCSS utilities in class attribute"
87
- },
88
- messages: {
89
- "invalid-order": "UnoCSS utilities are not ordered"
90
- },
91
- schema: []
92
- },
93
- defaultOptions: [],
94
- create(context) {
95
- function checkLiteral(node) {
96
- if (typeof node.value !== "string" || !node.value.trim())
97
- return;
98
- const input = node.value;
99
- const sorted = syncAction(
100
- context.settings.unocss?.configPath,
101
- "sort",
102
- input
103
- ).trim();
104
- if (sorted !== input) {
105
- context.report({
106
- node,
107
- messageId: "invalid-order",
108
- fix(fixer) {
109
- if (AST_NODES_WITH_QUOTES.includes(node.type))
110
- return fixer.replaceTextRange([node.range[0] + 1, node.range[1] - 1], sorted);
111
- else
112
- return fixer.replaceText(node, sorted);
113
- }
114
- });
115
- }
116
- }
117
- const scriptVisitor = {
118
- JSXAttribute(node) {
119
- if (typeof node.name.name === "string" && CLASS_FIELDS.includes(node.name.name.toLowerCase()) && node.value) {
120
- if (node.value.type === "Literal")
121
- checkLiteral(node.value);
122
- }
123
- },
124
- SvelteAttribute(node) {
125
- if (node.key.name === "class") {
126
- if (node.value?.[0].type === "SvelteLiteral")
127
- checkLiteral(node.value[0]);
128
- }
129
- }
130
- };
131
- const templateBodyVisitor = {
132
- VAttribute(node) {
133
- if (node.key.name === "class") {
134
- if (node.value.type === "VLiteral")
135
- checkLiteral(node.value);
136
- }
137
- }
138
- };
139
- const parserServices = context?.sourceCode.parserServices || context.parserServices;
140
- if (parserServices == null || parserServices.defineTemplateBodyVisitor == null) {
141
- return scriptVisitor;
142
- } else {
143
- return parserServices?.defineTemplateBodyVisitor(templateBodyVisitor, scriptVisitor);
144
- }
145
- }
146
- });
147
-
148
72
  const blocklist = createRule({
149
73
  name: "blocklist",
150
74
  meta: {
@@ -334,6 +258,74 @@ const enforceClassCompile = createRule({
334
258
  }
335
259
  });
336
260
 
261
+ const order = createRule({
262
+ name: "order",
263
+ meta: {
264
+ type: "layout",
265
+ fixable: "code",
266
+ docs: {
267
+ description: "Order of UnoCSS utilities in class attribute"
268
+ },
269
+ messages: {
270
+ "invalid-order": "UnoCSS utilities are not ordered"
271
+ },
272
+ schema: []
273
+ },
274
+ defaultOptions: [],
275
+ create(context) {
276
+ function checkLiteral(node) {
277
+ if (typeof node.value !== "string" || !node.value.trim())
278
+ return;
279
+ const input = node.value;
280
+ const sorted = syncAction(
281
+ context.settings.unocss?.configPath,
282
+ "sort",
283
+ input
284
+ ).trim();
285
+ if (sorted !== input) {
286
+ context.report({
287
+ node,
288
+ messageId: "invalid-order",
289
+ fix(fixer) {
290
+ if (AST_NODES_WITH_QUOTES.includes(node.type))
291
+ return fixer.replaceTextRange([node.range[0] + 1, node.range[1] - 1], sorted);
292
+ else
293
+ return fixer.replaceText(node, sorted);
294
+ }
295
+ });
296
+ }
297
+ }
298
+ const scriptVisitor = {
299
+ JSXAttribute(node) {
300
+ if (typeof node.name.name === "string" && CLASS_FIELDS.includes(node.name.name.toLowerCase()) && node.value) {
301
+ if (node.value.type === "Literal")
302
+ checkLiteral(node.value);
303
+ }
304
+ },
305
+ SvelteAttribute(node) {
306
+ if (node.key.name === "class") {
307
+ if (node.value?.[0].type === "SvelteLiteral")
308
+ checkLiteral(node.value[0]);
309
+ }
310
+ }
311
+ };
312
+ const templateBodyVisitor = {
313
+ VAttribute(node) {
314
+ if (node.key.name === "class") {
315
+ if (node.value.type === "VLiteral")
316
+ checkLiteral(node.value);
317
+ }
318
+ }
319
+ };
320
+ const parserServices = context?.sourceCode.parserServices || context.parserServices;
321
+ if (parserServices == null || parserServices.defineTemplateBodyVisitor == null) {
322
+ return scriptVisitor;
323
+ } else {
324
+ return parserServices?.defineTemplateBodyVisitor(templateBodyVisitor, scriptVisitor);
325
+ }
326
+ }
327
+ });
328
+
337
329
  const plugin = {
338
330
  rules: {
339
331
  order,
@@ -353,6 +345,14 @@ const configsFlat = {
353
345
  }
354
346
  };
355
347
 
348
+ const configsRecommended = {
349
+ plugins: ["@unocss"],
350
+ rules: {
351
+ "@unocss/order": "warn",
352
+ "@unocss/order-attributify": "warn"
353
+ }
354
+ };
355
+
356
356
  const index = {
357
357
  ...plugin,
358
358
  configs: {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unocss/eslint-plugin",
3
3
  "type": "module",
4
- "version": "0.62.3",
4
+ "version": "0.62.4",
5
5
  "description": "ESLint plugin for UnoCSS",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -35,15 +35,15 @@
35
35
  "node": ">=14"
36
36
  },
37
37
  "dependencies": {
38
- "@typescript-eslint/utils": "^8.2.0",
38
+ "@typescript-eslint/utils": "^8.5.0",
39
39
  "magic-string": "^0.30.11",
40
40
  "synckit": "^0.9.1",
41
- "@unocss/config": "0.62.3",
42
- "@unocss/core": "0.62.3"
41
+ "@unocss/core": "0.62.4",
42
+ "@unocss/config": "0.62.4"
43
43
  },
44
44
  "devDependencies": {
45
45
  "vue-eslint-parser": "^9.4.3",
46
- "@unocss/eslint-plugin": "0.62.3"
46
+ "@unocss/eslint-plugin": "0.62.4"
47
47
  },
48
48
  "scripts": {
49
49
  "build": "unbuild",