@unocss/eslint-plugin 66.5.10-beta.1 → 66.5.11
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/dirs-DMLliOn8.cjs +13 -0
- package/dist/dirs-DTjbV7PE.mjs +7 -0
- package/dist/dirs.cjs +2 -7
- package/dist/dirs.d.cts +3 -2
- package/dist/dirs.d.mts +3 -2
- package/dist/dirs.mjs +2 -4
- package/dist/index.cjs +461 -554
- package/dist/index.d.cts +64 -37
- package/dist/index.d.mts +64 -37
- package/dist/index.mjs +430 -548
- package/dist/worker.d.mts +957 -0
- package/dist/worker.mjs +87 -105
- package/package.json +18 -12
- package/dist/dirs.d.ts +0 -3
- package/dist/index.d.ts +0 -45
package/dist/worker.mjs
CHANGED
|
@@ -1,130 +1,112 @@
|
|
|
1
|
-
import { dirname } from
|
|
2
|
-
import process from
|
|
3
|
-
import {
|
|
4
|
-
import { loadConfig } from
|
|
5
|
-
import { runAsWorker } from
|
|
1
|
+
import { dirname } from "node:path";
|
|
2
|
+
import process from "node:process";
|
|
3
|
+
import { collapseVariantGroup, createGenerator, notNull, parseVariantGroup } from "@unocss/core";
|
|
4
|
+
import { loadConfig } from "@unocss/config";
|
|
5
|
+
import { runAsWorker } from "synckit";
|
|
6
6
|
|
|
7
|
+
//#region ../../virtual-shared/integration/src/sort-rules.ts
|
|
7
8
|
async function sortRules(rules, uno) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
if (expandedResult?.prefixes.length)
|
|
35
|
-
sorted = collapseVariantGroup(sorted, expandedResult.prefixes);
|
|
36
|
-
return [...unknown, sorted].join(" ").trim();
|
|
9
|
+
const unknown = [];
|
|
10
|
+
if (!uno.config.details) uno.config.details = true;
|
|
11
|
+
const expandedResult = parseVariantGroup(rules);
|
|
12
|
+
rules = expandedResult.expanded;
|
|
13
|
+
const result = [];
|
|
14
|
+
const arr = rules.split(/\s+/g);
|
|
15
|
+
for (const i of arr) {
|
|
16
|
+
var _token$0$;
|
|
17
|
+
if (!i) continue;
|
|
18
|
+
const token = await uno.parseToken(i);
|
|
19
|
+
if (token == null) {
|
|
20
|
+
unknown.push(i);
|
|
21
|
+
result.push(void 0);
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
const variantRank = (((_token$0$ = token[0][5]) === null || _token$0$ === void 0 || (_token$0$ = _token$0$.variantHandlers) === null || _token$0$ === void 0 ? void 0 : _token$0$.length) || 0) * 1e5;
|
|
25
|
+
const order = token[0][0] + variantRank;
|
|
26
|
+
result.push([order, i]);
|
|
27
|
+
}
|
|
28
|
+
let sorted = result.filter(notNull).sort((a, b) => {
|
|
29
|
+
let result$1 = a[0] - b[0];
|
|
30
|
+
if (result$1 === 0) result$1 = a[1].localeCompare(b[1]);
|
|
31
|
+
return result$1;
|
|
32
|
+
}).map((i) => i[1]).join(" ");
|
|
33
|
+
if (expandedResult === null || expandedResult === void 0 ? void 0 : expandedResult.prefixes.length) sorted = collapseVariantGroup(sorted, expandedResult.prefixes);
|
|
34
|
+
return [...unknown, sorted].join(" ").trim();
|
|
37
35
|
}
|
|
38
36
|
|
|
37
|
+
//#endregion
|
|
38
|
+
//#region src/worker.ts
|
|
39
|
+
var _process$env;
|
|
39
40
|
const promises = /* @__PURE__ */ new Map();
|
|
40
|
-
process.env.ESLINT
|
|
41
|
+
(_process$env = process.env).ESLINT || (_process$env.ESLINT = "true");
|
|
41
42
|
function getSearchCwd(id) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const realPath = id.slice(0, id.lastIndexOf("/"));
|
|
45
|
-
return dirname(realPath);
|
|
46
|
-
}
|
|
47
|
-
return dirname(id);
|
|
43
|
+
if (id.match(/\.\w+\/[^/]+$/)) return dirname(id.slice(0, id.lastIndexOf("/")));
|
|
44
|
+
return dirname(id);
|
|
48
45
|
}
|
|
49
46
|
async function _getGenerator(configPath, id) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
throw new Error("[@unocss/eslint-plugin] No config file found, create a `uno.config.ts` file in your project root and try again.");
|
|
57
|
-
return createGenerator({
|
|
58
|
-
...config,
|
|
59
|
-
warn: false
|
|
60
|
-
});
|
|
47
|
+
const { config, sources } = await loadConfig(configPath ? process.cwd() : id ? getSearchCwd(id) : process.cwd(), configPath);
|
|
48
|
+
if (!sources.length) throw new Error("[@unocss/eslint-plugin] No config file found, create a `uno.config.ts` file in your project root and try again.");
|
|
49
|
+
return createGenerator({
|
|
50
|
+
...config,
|
|
51
|
+
warn: false
|
|
52
|
+
});
|
|
61
53
|
}
|
|
62
54
|
function getCacheKey(configPath, id) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
return `dir:${getSearchCwd(id)}`;
|
|
67
|
-
return `cwd:${process.cwd()}`;
|
|
55
|
+
if (configPath) return `config:${configPath}`;
|
|
56
|
+
if (id) return `dir:${getSearchCwd(id)}`;
|
|
57
|
+
return `cwd:${process.cwd()}`;
|
|
68
58
|
}
|
|
69
59
|
async function getGenerator(configPath, id) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
60
|
+
const cacheKey = getCacheKey(configPath, id);
|
|
61
|
+
let promise = promises.get(cacheKey);
|
|
62
|
+
if (!promise) {
|
|
63
|
+
promise = _getGenerator(configPath, id);
|
|
64
|
+
promises.set(cacheKey, promise);
|
|
65
|
+
}
|
|
66
|
+
return await promise;
|
|
77
67
|
}
|
|
78
68
|
function setGenerator(generator, configPath) {
|
|
79
|
-
|
|
80
|
-
|
|
69
|
+
const cacheKey = configPath ? `config:${configPath}` : `cwd:${process.cwd()}`;
|
|
70
|
+
promises.set(cacheKey, Promise.resolve(generator));
|
|
81
71
|
}
|
|
82
72
|
async function actionSort(configPath, classes, id) {
|
|
83
|
-
|
|
73
|
+
return await sortRules(classes, await getGenerator(configPath, id));
|
|
84
74
|
}
|
|
85
75
|
async function actionBlocklist(configPath, classes, id) {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
for (const rule2 of rules) {
|
|
110
|
-
if (rule2)
|
|
111
|
-
blocked.set(raw, getMeta(raw, rule2[1]));
|
|
112
|
-
}
|
|
113
|
-
};
|
|
114
|
-
await Promise.all(values.map(matchBlocked));
|
|
115
|
-
return [...blocked];
|
|
76
|
+
const uno = await getGenerator(configPath, id);
|
|
77
|
+
const blocked = /* @__PURE__ */ new Map();
|
|
78
|
+
const values = [...(await uno.applyExtractors(classes, id)).values()];
|
|
79
|
+
const getMeta = (raw, meta) => {
|
|
80
|
+
return (meta === null || meta === void 0 ? void 0 : meta.message) ? {
|
|
81
|
+
...meta,
|
|
82
|
+
message: typeof meta.message === "function" ? meta.message(raw) : meta.message
|
|
83
|
+
} : meta;
|
|
84
|
+
};
|
|
85
|
+
const matchBlocked = async (raw) => {
|
|
86
|
+
if (blocked.has(raw)) return;
|
|
87
|
+
const rule = uno.getBlocked(raw);
|
|
88
|
+
if (rule) {
|
|
89
|
+
blocked.set(raw, getMeta(raw, rule[1]));
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
let current = raw;
|
|
93
|
+
for (const p of uno.config.preprocess) current = p(raw);
|
|
94
|
+
const rules = (await uno.matchVariants(raw, current)).map((r) => r && uno.getBlocked(r[1]));
|
|
95
|
+
for (const rule$1 of rules) if (rule$1) blocked.set(raw, getMeta(raw, rule$1[1]));
|
|
96
|
+
};
|
|
97
|
+
await Promise.all(values.map(matchBlocked));
|
|
98
|
+
return [...blocked];
|
|
116
99
|
}
|
|
117
100
|
async function runAsync(configPath, action, ...args) {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
return actionBlocklist(configPath, ...args);
|
|
123
|
-
}
|
|
101
|
+
switch (action) {
|
|
102
|
+
case "sort": return actionSort(configPath, ...args);
|
|
103
|
+
case "blocklist": return actionBlocklist(configPath, ...args);
|
|
104
|
+
}
|
|
124
105
|
}
|
|
125
106
|
function run(configPath, action, ...args) {
|
|
126
|
-
|
|
107
|
+
return runAsync(configPath, action, ...args);
|
|
127
108
|
}
|
|
128
109
|
runAsWorker(run);
|
|
129
110
|
|
|
130
|
-
|
|
111
|
+
//#endregion
|
|
112
|
+
export { getGenerator, run, runAsync, setGenerator };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unocss/eslint-plugin",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "66.5.
|
|
4
|
+
"version": "66.5.11",
|
|
5
5
|
"description": "ESLint plugin for UnoCSS",
|
|
6
6
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -22,12 +22,19 @@
|
|
|
22
22
|
"sideEffects": false,
|
|
23
23
|
"exports": {
|
|
24
24
|
".": {
|
|
25
|
-
"import":
|
|
26
|
-
|
|
25
|
+
"import": {
|
|
26
|
+
"types": "./dist/index.d.mts",
|
|
27
|
+
"default": "./dist/index.mjs"
|
|
28
|
+
},
|
|
29
|
+
"require": {
|
|
30
|
+
"types": "./dist/index.d.cts",
|
|
31
|
+
"default": "./dist/index.cjs"
|
|
32
|
+
}
|
|
27
33
|
}
|
|
28
34
|
},
|
|
29
35
|
"main": "dist/index.cjs",
|
|
30
36
|
"module": "dist/index.mjs",
|
|
37
|
+
"types": "dist/index.d.mts",
|
|
31
38
|
"files": [
|
|
32
39
|
"dist"
|
|
33
40
|
],
|
|
@@ -35,23 +42,22 @@
|
|
|
35
42
|
"node": ">=14"
|
|
36
43
|
},
|
|
37
44
|
"dependencies": {
|
|
38
|
-
"@typescript-eslint/utils": "^8.
|
|
45
|
+
"@typescript-eslint/utils": "^8.50.1",
|
|
39
46
|
"magic-string": "^0.30.21",
|
|
40
47
|
"synckit": "^0.11.11",
|
|
41
|
-
"@unocss/config": "66.5.
|
|
42
|
-
"@unocss/core": "66.5.
|
|
43
|
-
"@unocss/rule-utils": "66.5.
|
|
48
|
+
"@unocss/config": "66.5.11",
|
|
49
|
+
"@unocss/core": "66.5.11",
|
|
50
|
+
"@unocss/rule-utils": "66.5.11"
|
|
44
51
|
},
|
|
45
52
|
"devDependencies": {
|
|
46
53
|
"@typescript/native-preview": "latest",
|
|
47
|
-
"svelte-eslint-parser": "^1.4.
|
|
54
|
+
"svelte-eslint-parser": "^1.4.1",
|
|
48
55
|
"vue-eslint-parser": "^10.2.0",
|
|
49
|
-
"@unocss/eslint-plugin": "66.5.
|
|
56
|
+
"@unocss/eslint-plugin": "66.5.11"
|
|
50
57
|
},
|
|
51
58
|
"scripts": {
|
|
52
|
-
"build": "
|
|
59
|
+
"build": "tsdown --config-loader unrun",
|
|
53
60
|
"typecheck": "tsgo --noEmit",
|
|
54
|
-
"lint": "nr build && cd ./fixtures && eslint ./src"
|
|
55
|
-
"test:attw": "attw --pack"
|
|
61
|
+
"lint": "nr build && cd ./fixtures && eslint ./src"
|
|
56
62
|
}
|
|
57
63
|
}
|
package/dist/dirs.d.ts
DELETED
package/dist/index.d.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import * as _typescript_eslint_utils_ts_eslint from '@typescript-eslint/utils/ts-eslint';
|
|
2
|
-
|
|
3
|
-
declare module '@typescript-eslint/utils/ts-eslint' {
|
|
4
|
-
interface SharedConfigurationSettings {
|
|
5
|
-
unocss?: {
|
|
6
|
-
configPath?: string;
|
|
7
|
-
};
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
declare const _default: {
|
|
12
|
-
configs: {
|
|
13
|
-
recommended: {
|
|
14
|
-
plugins: string[];
|
|
15
|
-
rules: {
|
|
16
|
-
readonly '@unocss/order': "warn";
|
|
17
|
-
readonly '@unocss/order-attributify': "warn";
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
flat: {
|
|
21
|
-
plugins: {
|
|
22
|
-
unocss: {
|
|
23
|
-
rules: {
|
|
24
|
-
order: _typescript_eslint_utils_ts_eslint.AnyRuleModule;
|
|
25
|
-
'order-attributify': _typescript_eslint_utils_ts_eslint.AnyRuleModule;
|
|
26
|
-
blocklist: _typescript_eslint_utils_ts_eslint.AnyRuleModule;
|
|
27
|
-
'enforce-class-compile': _typescript_eslint_utils_ts_eslint.AnyRuleModule;
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
|
-
rules: {
|
|
32
|
-
readonly 'unocss/order': "warn";
|
|
33
|
-
readonly 'unocss/order-attributify': "warn";
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
rules: {
|
|
38
|
-
order: _typescript_eslint_utils_ts_eslint.AnyRuleModule;
|
|
39
|
-
'order-attributify': _typescript_eslint_utils_ts_eslint.AnyRuleModule;
|
|
40
|
-
blocklist: _typescript_eslint_utils_ts_eslint.AnyRuleModule;
|
|
41
|
-
'enforce-class-compile': _typescript_eslint_utils_ts_eslint.AnyRuleModule;
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
export = _default;
|