eslint-plugin-better-stylelint 0.1.2 → 0.1.3
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.js +13 -3
- package/dist/worker.js +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
2
|
import { execFileSync } from "node:child_process";
|
|
3
3
|
import { createHash } from "node:crypto";
|
|
4
|
+
import fs from "node:fs";
|
|
5
|
+
import os from "node:os";
|
|
4
6
|
import path from "node:path";
|
|
5
7
|
import process from "node:process";
|
|
6
8
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
@@ -8,6 +10,7 @@ import { fileURLToPath, pathToFileURL } from "node:url";
|
|
|
8
10
|
const MAX_CACHE_ENTRIES = 100;
|
|
9
11
|
const CORE_TS_PATTERN = /core\.ts$/u;
|
|
10
12
|
const CORE_JS_PATTERN = /core\.js$/u;
|
|
13
|
+
const WORKER_BOOTSTRAP_PREFIX = "icebreaker-stylelint-worker-";
|
|
11
14
|
const resultCache = /* @__PURE__ */ new Map();
|
|
12
15
|
const configCacheIds = /* @__PURE__ */ new WeakMap();
|
|
13
16
|
let nextConfigCacheId = 0;
|
|
@@ -105,14 +108,17 @@ function getWorkerExecArgv() {
|
|
|
105
108
|
}
|
|
106
109
|
function resolveWorkerCommand(workerPath) {
|
|
107
110
|
if (workerPath.endsWith(".ts")) {
|
|
108
|
-
const workerEntry =
|
|
111
|
+
const workerEntry = pathToFileURL(workerPath).href;
|
|
112
|
+
const tsxLoaderEntry = pathToFileURL(require.resolve("tsx/esm")).href;
|
|
113
|
+
const bootstrapPath = path.join(os.tmpdir(), `${WORKER_BOOTSTRAP_PREFIX}${createHash("sha1").update(workerEntry).digest("hex")}.mjs`);
|
|
114
|
+
if (!fs.existsSync(bootstrapPath)) fs.writeFileSync(bootstrapPath, `import ${JSON.stringify(workerEntry)}\n`, "utf8");
|
|
109
115
|
return {
|
|
110
116
|
command: process.execPath,
|
|
111
117
|
args: [
|
|
112
118
|
...getWorkerExecArgv(),
|
|
113
119
|
"--import",
|
|
114
|
-
|
|
115
|
-
|
|
120
|
+
tsxLoaderEntry,
|
|
121
|
+
bootstrapPath
|
|
116
122
|
]
|
|
117
123
|
};
|
|
118
124
|
}
|
|
@@ -131,6 +137,10 @@ function getRunStylelintWorker() {
|
|
|
131
137
|
options
|
|
132
138
|
}),
|
|
133
139
|
encoding: "utf8",
|
|
140
|
+
env: {
|
|
141
|
+
...process.env,
|
|
142
|
+
ICEBREAKER_STYLELINT_WORKER: "1"
|
|
143
|
+
},
|
|
134
144
|
stdio: [
|
|
135
145
|
"pipe",
|
|
136
146
|
"pipe",
|
package/dist/worker.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
|
+
import fs from "node:fs";
|
|
2
3
|
import path from "node:path";
|
|
3
4
|
import process from "node:process";
|
|
4
5
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
5
|
-
import fs from "node:fs";
|
|
6
6
|
//#region src/worker.ts
|
|
7
7
|
function normalizeWarning(warning) {
|
|
8
8
|
return {
|
|
@@ -71,7 +71,7 @@ async function main() {
|
|
|
71
71
|
const response = await runStylelint(request.code, request.filename, request.options);
|
|
72
72
|
process.stdout.write(JSON.stringify(response));
|
|
73
73
|
}
|
|
74
|
-
if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) main().catch((error) => {
|
|
74
|
+
if (process.env["ICEBREAKER_STYLELINT_WORKER"] === "1" || process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) main().catch((error) => {
|
|
75
75
|
const message = error instanceof Error ? error.stack ?? error.message : String(error);
|
|
76
76
|
process.stderr.write(`${message}\n`);
|
|
77
77
|
process.exitCode = 1;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-better-stylelint",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.3",
|
|
5
5
|
"description": "Bridge Stylelint diagnostics into ESLint for style files and Vue SFCs",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|