@rslint/core 0.6.0 → 0.6.2-canary.1781671243
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/bin/rslint.cjs +11 -14
- package/dist/0~engine.js +2 -1
- package/dist/cli.js +10 -9
- package/dist/eslint-plugin/index.js +61 -1
- package/dist/eslint-plugin/lint-worker.js +62 -1
- package/dist/index.js +18 -2
- package/package.json +13 -14
package/bin/rslint.cjs
CHANGED
|
@@ -3,20 +3,13 @@ const startTime = Date.now();
|
|
|
3
3
|
const path = require('node:path');
|
|
4
4
|
const { pathToFileURL } = require('node:url');
|
|
5
5
|
const os = require('node:os');
|
|
6
|
-
const fs = require('node:fs');
|
|
7
6
|
|
|
8
7
|
function getBinPath() {
|
|
9
|
-
//
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return path.resolve(__dirname, './rslint.exe');
|
|
15
|
-
}
|
|
16
|
-
// published: the Go binary lives in the @rslint/native-{tuple} subpackage,
|
|
17
|
-
// reached via its `./bin` export. npm installs only the subpackage matching
|
|
18
|
-
// the host os/cpu/libc, so on linux we just try gnu then musl and use
|
|
19
|
-
// whichever got installed — no libc sniffing (Go binaries are static, the
|
|
8
|
+
// The Go binary lives in the @rslint/native-{tuple} platform package, reached
|
|
9
|
+
// via its `./bin` export. Resolution is identical in dev and prod: `pnpm build`
|
|
10
|
+
// drops the host binary into npm/rslint/{tuple}/, and npm installs only the
|
|
11
|
+
// subpackage matching the host os/cpu/libc. On linux we just try gnu then musl
|
|
12
|
+
// and use whichever resolved — no libc sniffing (Go binaries are static, the
|
|
20
13
|
// gnu/musl distinction doesn't matter to them).
|
|
21
14
|
const arch = os.arch();
|
|
22
15
|
const tuples =
|
|
@@ -42,10 +35,14 @@ async function main() {
|
|
|
42
35
|
pathToFileURL(path.resolve(__dirname, '../dist/cli.js')).href
|
|
43
36
|
);
|
|
44
37
|
const exitCode = await run(binPath, process.argv.slice(2), startTime);
|
|
45
|
-
process.exit(
|
|
38
|
+
// process.exit() would tear down before async-buffered stdout writes (pipes,
|
|
39
|
+
// Windows TTYs) flush, truncating the lint tail. Setting exitCode lets the
|
|
40
|
+
// event loop drain naturally; run()'s cleanup guarantees nothing keeps it
|
|
41
|
+
// alive.
|
|
42
|
+
process.exitCode = exitCode;
|
|
46
43
|
}
|
|
47
44
|
|
|
48
45
|
main().catch((err) => {
|
|
49
46
|
process.stderr.write(`rslint: ${err}\n`);
|
|
50
|
-
process.
|
|
47
|
+
process.exitCode = 1;
|
|
51
48
|
});
|
package/dist/0~engine.js
CHANGED
|
@@ -261,6 +261,7 @@ const SIGNAL_EXIT_CODES = {
|
|
|
261
261
|
async function runEngine(opts) {
|
|
262
262
|
const stdout = opts.stdout ?? process.stdout;
|
|
263
263
|
const stderr = opts.stderr ?? process.stderr;
|
|
264
|
+
const stdoutIsTTY = true === stdout.isTTY;
|
|
264
265
|
const child = spawn(opts.binPath, opts.goArgs, {
|
|
265
266
|
stdio: [
|
|
266
267
|
'pipe',
|
|
@@ -356,7 +357,7 @@ async function runEngine(opts) {
|
|
|
356
357
|
configs: opts.configs,
|
|
357
358
|
eslintPlugins: opts.eslintPluginEntries,
|
|
358
359
|
runtime: {
|
|
359
|
-
|
|
360
|
+
stdoutIsTTY,
|
|
360
361
|
singleThreaded: opts.runtime?.singleThreaded
|
|
361
362
|
}
|
|
362
363
|
}));
|
package/dist/cli.js
CHANGED
|
@@ -849,14 +849,14 @@ function getCrawler(patterns, inputOptions = {}) {
|
|
|
849
849
|
relative
|
|
850
850
|
];
|
|
851
851
|
}
|
|
852
|
-
function
|
|
852
|
+
async function glob(patternsOrOptions, options) {
|
|
853
853
|
if (patternsOrOptions && (null == options ? void 0 : options.patterns)) throw new Error("Cannot pass patterns as both an argument and an option");
|
|
854
854
|
const isModern = isReadonlyArray(patternsOrOptions) || "string" == typeof patternsOrOptions;
|
|
855
855
|
const opts = isModern ? options : patternsOrOptions;
|
|
856
856
|
const patterns = isModern ? patternsOrOptions : patternsOrOptions.patterns;
|
|
857
857
|
const [crawler, relative] = getCrawler(patterns, opts);
|
|
858
|
-
if (!relative) return crawler.
|
|
859
|
-
return formatPaths(crawler.
|
|
858
|
+
if (!relative) return crawler.withPromise();
|
|
859
|
+
return formatPaths(await crawler.withPromise(), relative);
|
|
860
860
|
}
|
|
861
861
|
const JS_CONFIG_FILES = [
|
|
862
862
|
'rslint.config.js',
|
|
@@ -881,9 +881,9 @@ function findJSConfigUp(startDir) {
|
|
|
881
881
|
dir = parent;
|
|
882
882
|
}
|
|
883
883
|
}
|
|
884
|
-
function findJSConfigsInDir(startDir) {
|
|
884
|
+
async function findJSConfigsInDir(startDir) {
|
|
885
885
|
const resolved = node_path.resolve(startDir);
|
|
886
|
-
|
|
886
|
+
const matches = await glob([
|
|
887
887
|
'**/rslint.config.{js,mjs,ts,mts}'
|
|
888
888
|
], {
|
|
889
889
|
cwd: resolved,
|
|
@@ -893,9 +893,10 @@ function findJSConfigsInDir(startDir) {
|
|
|
893
893
|
'**/node_modules/**',
|
|
894
894
|
'**/.git/**'
|
|
895
895
|
]
|
|
896
|
-
})
|
|
896
|
+
});
|
|
897
|
+
return matches.map((p)=>node_path.normalize(p));
|
|
897
898
|
}
|
|
898
|
-
function discoverConfigs(files, dirs, cwd, explicitConfig) {
|
|
899
|
+
async function discoverConfigs(files, dirs, cwd, explicitConfig) {
|
|
899
900
|
const configs = new Map();
|
|
900
901
|
const addConfig = (configPath)=>{
|
|
901
902
|
if (!configs.has(configPath)) configs.set(configPath, node_path.dirname(configPath));
|
|
@@ -920,7 +921,7 @@ function discoverConfigs(files, dirs, cwd, explicitConfig) {
|
|
|
920
921
|
const configPath = findJSConfigUp(startDir);
|
|
921
922
|
if (configPath) addConfig(configPath);
|
|
922
923
|
}
|
|
923
|
-
for (const dir of scanDirs)for (const configPath of findJSConfigsInDir(dir))addConfig(configPath);
|
|
924
|
+
for (const dir of scanDirs)for (const configPath of (await findJSConfigsInDir(dir)))addConfig(configPath);
|
|
924
925
|
return configs;
|
|
925
926
|
}
|
|
926
927
|
function isGlobalIgnoreEntry(entry) {
|
|
@@ -1070,7 +1071,7 @@ async function run(binPath, argv, startTime) {
|
|
|
1070
1071
|
...args.rest
|
|
1071
1072
|
];
|
|
1072
1073
|
const { files, dirs } = classifyArgs(args.positionals, cwd);
|
|
1073
|
-
const configs = discoverConfigs(files, dirs, cwd, args.config);
|
|
1074
|
+
const configs = await discoverConfigs(files, dirs, cwd, args.config);
|
|
1074
1075
|
const jsConfigs = new Map();
|
|
1075
1076
|
for (const [configPath, configDir] of configs)if (isJSConfigFile(configPath)) jsConfigs.set(configPath, configDir);
|
|
1076
1077
|
if (jsConfigs.size > 0) return runWithJSConfigs(binPath, jsConfigs, goArgs, cwd, args.singleThreaded);
|
|
@@ -3,7 +3,7 @@ import { fileURLToPath, pathToFileURL } from "node:url";
|
|
|
3
3
|
import { StringDecoder } from "node:string_decoder";
|
|
4
4
|
import { createRequire } from "node:module";
|
|
5
5
|
import { readFileSync } from "node:fs";
|
|
6
|
-
import {
|
|
6
|
+
import { execSync } from "node:child_process";
|
|
7
7
|
import node_path from "node:path";
|
|
8
8
|
import { __webpack_require__ } from "./612.js";
|
|
9
9
|
__webpack_require__.add({
|
|
@@ -20902,6 +20902,66 @@ async function createPluginLintHost(configs, onLog, singleThreaded) {
|
|
|
20902
20902
|
}
|
|
20903
20903
|
};
|
|
20904
20904
|
}
|
|
20905
|
+
function isMuslFromFilesystem() {
|
|
20906
|
+
try {
|
|
20907
|
+
return readFileSync('/usr/bin/ldd', 'utf-8').includes('musl');
|
|
20908
|
+
} catch {
|
|
20909
|
+
return null;
|
|
20910
|
+
}
|
|
20911
|
+
}
|
|
20912
|
+
function isMuslFromReport() {
|
|
20913
|
+
const report = process.report;
|
|
20914
|
+
if ('function' != typeof report?.getReport) return null;
|
|
20915
|
+
report.excludeNetwork = true;
|
|
20916
|
+
const parsed = report.getReport();
|
|
20917
|
+
if (parsed.header?.glibcVersionRuntime) return false;
|
|
20918
|
+
if (Array.isArray(parsed.sharedObjects)) return parsed.sharedObjects.some((f)=>f.includes('libc.musl-') || f.includes('ld-musl-'));
|
|
20919
|
+
return null;
|
|
20920
|
+
}
|
|
20921
|
+
function isMuslFromChildProcess() {
|
|
20922
|
+
try {
|
|
20923
|
+
return execSync('ldd --version', {
|
|
20924
|
+
encoding: 'utf8'
|
|
20925
|
+
}).includes('musl');
|
|
20926
|
+
} catch {
|
|
20927
|
+
return false;
|
|
20928
|
+
}
|
|
20929
|
+
}
|
|
20930
|
+
function isMusl() {
|
|
20931
|
+
let musl = isMuslFromFilesystem();
|
|
20932
|
+
if (null === musl) musl = isMuslFromReport();
|
|
20933
|
+
if (null === musl) musl = isMuslFromChildProcess();
|
|
20934
|
+
return musl ?? false;
|
|
20935
|
+
}
|
|
20936
|
+
function platformTuple() {
|
|
20937
|
+
const { platform, arch } = process;
|
|
20938
|
+
switch(platform){
|
|
20939
|
+
case 'darwin':
|
|
20940
|
+
return `darwin-${arch}`;
|
|
20941
|
+
case 'win32':
|
|
20942
|
+
return `win32-${arch}-msvc`;
|
|
20943
|
+
case 'linux':
|
|
20944
|
+
return `linux-${arch}-${isMusl() ? 'musl' : 'gnu'}`;
|
|
20945
|
+
default:
|
|
20946
|
+
throw new Error(`@rslint/core: unsupported platform ${platform}-${arch} (no native parser binary)`);
|
|
20947
|
+
}
|
|
20948
|
+
}
|
|
20949
|
+
function platformPackageName() {
|
|
20950
|
+
return `@rslint/native-${platformTuple()}`;
|
|
20951
|
+
}
|
|
20952
|
+
const load_binding_require = createRequire(import.meta.url);
|
|
20953
|
+
function loadBinding() {
|
|
20954
|
+
const pkg = platformPackageName();
|
|
20955
|
+
try {
|
|
20956
|
+
return load_binding_require(pkg);
|
|
20957
|
+
} catch (cause) {
|
|
20958
|
+
const err = new Error(`@rslint/core: failed to load the native parser from "${pkg}". Ensure the matching optional dependency is installed (reinstall after removing node_modules and the lockfile if it is missing).`);
|
|
20959
|
+
err.cause = cause;
|
|
20960
|
+
throw err;
|
|
20961
|
+
}
|
|
20962
|
+
}
|
|
20963
|
+
const binding = loadBinding();
|
|
20964
|
+
const parse = binding.parse;
|
|
20905
20965
|
const VISITOR_KEYS_TABLE = {
|
|
20906
20966
|
AccessorProperty: [
|
|
20907
20967
|
'decorators',
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { parentPort, workerData } from "node:worker_threads";
|
|
2
2
|
import { readFileSync } from "node:fs";
|
|
3
|
-
import {
|
|
3
|
+
import { createRequire } from "node:module";
|
|
4
|
+
import { execSync } from "node:child_process";
|
|
4
5
|
import node_path from "node:path";
|
|
5
6
|
import { pathToFileURL } from "node:url";
|
|
6
7
|
import { __webpack_require__ } from "./612.js";
|
|
@@ -20333,6 +20334,66 @@ __webpack_require__.d(lib_namespaceObject, {
|
|
|
20333
20334
|
analyze: ()=>analyze,
|
|
20334
20335
|
version: ()=>version
|
|
20335
20336
|
});
|
|
20337
|
+
function isMuslFromFilesystem() {
|
|
20338
|
+
try {
|
|
20339
|
+
return readFileSync('/usr/bin/ldd', 'utf-8').includes('musl');
|
|
20340
|
+
} catch {
|
|
20341
|
+
return null;
|
|
20342
|
+
}
|
|
20343
|
+
}
|
|
20344
|
+
function isMuslFromReport() {
|
|
20345
|
+
const report = process.report;
|
|
20346
|
+
if ('function' != typeof report?.getReport) return null;
|
|
20347
|
+
report.excludeNetwork = true;
|
|
20348
|
+
const parsed = report.getReport();
|
|
20349
|
+
if (parsed.header?.glibcVersionRuntime) return false;
|
|
20350
|
+
if (Array.isArray(parsed.sharedObjects)) return parsed.sharedObjects.some((f)=>f.includes('libc.musl-') || f.includes('ld-musl-'));
|
|
20351
|
+
return null;
|
|
20352
|
+
}
|
|
20353
|
+
function isMuslFromChildProcess() {
|
|
20354
|
+
try {
|
|
20355
|
+
return execSync('ldd --version', {
|
|
20356
|
+
encoding: 'utf8'
|
|
20357
|
+
}).includes('musl');
|
|
20358
|
+
} catch {
|
|
20359
|
+
return false;
|
|
20360
|
+
}
|
|
20361
|
+
}
|
|
20362
|
+
function isMusl() {
|
|
20363
|
+
let musl = isMuslFromFilesystem();
|
|
20364
|
+
if (null === musl) musl = isMuslFromReport();
|
|
20365
|
+
if (null === musl) musl = isMuslFromChildProcess();
|
|
20366
|
+
return musl ?? false;
|
|
20367
|
+
}
|
|
20368
|
+
function platformTuple() {
|
|
20369
|
+
const { platform, arch } = process;
|
|
20370
|
+
switch(platform){
|
|
20371
|
+
case 'darwin':
|
|
20372
|
+
return `darwin-${arch}`;
|
|
20373
|
+
case 'win32':
|
|
20374
|
+
return `win32-${arch}-msvc`;
|
|
20375
|
+
case 'linux':
|
|
20376
|
+
return `linux-${arch}-${isMusl() ? 'musl' : 'gnu'}`;
|
|
20377
|
+
default:
|
|
20378
|
+
throw new Error(`@rslint/core: unsupported platform ${platform}-${arch} (no native parser binary)`);
|
|
20379
|
+
}
|
|
20380
|
+
}
|
|
20381
|
+
function platformPackageName() {
|
|
20382
|
+
return `@rslint/native-${platformTuple()}`;
|
|
20383
|
+
}
|
|
20384
|
+
const load_binding_require = createRequire(import.meta.url);
|
|
20385
|
+
function loadBinding() {
|
|
20386
|
+
const pkg = platformPackageName();
|
|
20387
|
+
try {
|
|
20388
|
+
return load_binding_require(pkg);
|
|
20389
|
+
} catch (cause) {
|
|
20390
|
+
const err = new Error(`@rslint/core: failed to load the native parser from "${pkg}". Ensure the matching optional dependency is installed (reinstall after removing node_modules and the lockfile if it is missing).`);
|
|
20391
|
+
err.cause = cause;
|
|
20392
|
+
throw err;
|
|
20393
|
+
}
|
|
20394
|
+
}
|
|
20395
|
+
const binding = loadBinding();
|
|
20396
|
+
const parse = binding.parse;
|
|
20336
20397
|
const VISITOR_KEYS_TABLE = {
|
|
20337
20398
|
AccessorProperty: [
|
|
20338
20399
|
'decorators',
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
import { spawn } from "child_process";
|
|
2
|
-
import
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
3
|
import { RSLintService } from "./service.js";
|
|
4
|
+
const node_require = createRequire(import.meta.url);
|
|
5
|
+
function resolveRslintBinary() {
|
|
6
|
+
const arch = process.arch;
|
|
7
|
+
const tuples = 'linux' === process.platform ? [
|
|
8
|
+
`linux-${arch}-gnu`,
|
|
9
|
+
`linux-${arch}-musl`
|
|
10
|
+
] : 'win32' === process.platform ? [
|
|
11
|
+
`win32-${arch}-msvc`
|
|
12
|
+
] : [
|
|
13
|
+
`${process.platform}-${arch}`
|
|
14
|
+
];
|
|
15
|
+
for (const tuple of tuples)try {
|
|
16
|
+
return node_require.resolve(`@rslint/native-${tuple}/bin`);
|
|
17
|
+
} catch {}
|
|
18
|
+
throw new Error(`rslint: no native binary for ${process.platform}-${arch} (looked for @rslint/native-{${tuples.join(',')}})`);
|
|
19
|
+
}
|
|
4
20
|
class NodeRslintService {
|
|
5
21
|
nextMessageId;
|
|
6
22
|
pendingMessages;
|
|
@@ -12,7 +28,7 @@ class NodeRslintService {
|
|
|
12
28
|
constructor(options = {}){
|
|
13
29
|
this.nextMessageId = 1;
|
|
14
30
|
this.pendingMessages = new Map();
|
|
15
|
-
this.rslintPath = options.rslintPath ||
|
|
31
|
+
this.rslintPath = options.rslintPath || resolveRslintBinary();
|
|
16
32
|
this.process = spawn(this.rslintPath, [
|
|
17
33
|
'--api'
|
|
18
34
|
], {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rslint/core",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.2-canary.1781671243",
|
|
4
4
|
"exports": {
|
|
5
5
|
".": {
|
|
6
6
|
"@typescript/source": "./src/index.ts",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"globals": "17.6.0",
|
|
67
67
|
"tinyglobby": "0.2.15",
|
|
68
68
|
"typescript": "5.9.3",
|
|
69
|
-
"@rslint/api": "0.6.
|
|
69
|
+
"@rslint/api": "0.6.2-canary.1781671243"
|
|
70
70
|
},
|
|
71
71
|
"peerDependencies": {
|
|
72
72
|
"jiti": "^2.0.0"
|
|
@@ -77,22 +77,21 @@
|
|
|
77
77
|
}
|
|
78
78
|
},
|
|
79
79
|
"optionalDependencies": {
|
|
80
|
-
"@rslint/native-darwin-
|
|
81
|
-
"@rslint/native-darwin-
|
|
82
|
-
"@rslint/native-linux-
|
|
83
|
-
"@rslint/native-linux-
|
|
84
|
-
"@rslint/native-linux-
|
|
85
|
-
"@rslint/native-
|
|
86
|
-
"@rslint/native-
|
|
87
|
-
"@rslint/native-win32-x64-msvc": "0.6.
|
|
80
|
+
"@rslint/native-darwin-x64": "0.6.2-canary.1781671243",
|
|
81
|
+
"@rslint/native-darwin-arm64": "0.6.2-canary.1781671243",
|
|
82
|
+
"@rslint/native-linux-arm64-gnu": "0.6.2-canary.1781671243",
|
|
83
|
+
"@rslint/native-linux-x64-gnu": "0.6.2-canary.1781671243",
|
|
84
|
+
"@rslint/native-linux-x64-musl": "0.6.2-canary.1781671243",
|
|
85
|
+
"@rslint/native-linux-arm64-musl": "0.6.2-canary.1781671243",
|
|
86
|
+
"@rslint/native-win32-arm64-msvc": "0.6.2-canary.1781671243",
|
|
87
|
+
"@rslint/native-win32-x64-msvc": "0.6.2-canary.1781671243"
|
|
88
88
|
},
|
|
89
89
|
"dependencies": {
|
|
90
|
-
"picomatch": "4.0.4"
|
|
91
|
-
"@rslint/native": "0.6.0"
|
|
90
|
+
"picomatch": "4.0.4"
|
|
92
91
|
},
|
|
93
92
|
"scripts": {
|
|
94
|
-
"build:bin": "
|
|
95
|
-
"build:debug": "
|
|
93
|
+
"build:bin": "node ../../scripts/place-host-build.mjs bin",
|
|
94
|
+
"build:debug": "node ../../scripts/place-host-build.mjs bin --debug",
|
|
96
95
|
"build:js": "rslib build",
|
|
97
96
|
"dev": "rslib build --watch",
|
|
98
97
|
"build": "pnpm build:bin && pnpm build:js",
|