@rslint/core 0.6.3 → 0.6.5
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.js +23 -0
- package/dist/770.js +18 -0
- package/dist/cli.d.ts +10 -0
- package/dist/cli.js +104 -97
- package/dist/config-loader.js +33 -2
- package/dist/eslint-plugin/index.js +31 -2
- package/dist/index.d.ts +103 -385
- package/dist/index.js +262 -139
- package/dist/internal.d.ts +135 -0
- package/dist/internal.js +151 -0
- package/dist/service.d.ts +33 -27
- package/dist/service.js +7 -20
- package/package.json +21 -23
- package/bin/rslint.cjs +0 -48
- package/dist/34.js +0 -33
- package/dist/browser.d.ts +0 -52
- package/dist/browser.js +0 -115
package/bin/rslint.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import nodeModule from 'node:module';
|
|
3
|
+
|
|
4
|
+
// Enable on-disk code caching for modules loaded by Node.js.
|
|
5
|
+
// Available in Node.js >= 22.8.0.
|
|
6
|
+
const { enableCompileCache } = nodeModule;
|
|
7
|
+
if (enableCompileCache) {
|
|
8
|
+
try {
|
|
9
|
+
enableCompileCache();
|
|
10
|
+
} catch {
|
|
11
|
+
// Ignore cache setup errors; the CLI should still run normally.
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
async function main() {
|
|
16
|
+
const { runCLI } = await import('../dist/cli.js');
|
|
17
|
+
await runCLI();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
main().catch((err) => {
|
|
21
|
+
process.stderr.write(`rslint: ${err}\n`);
|
|
22
|
+
process.exitCode = 1;
|
|
23
|
+
});
|
package/dist/770.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
const resolve_binary_require = createRequire(import.meta.url);
|
|
3
|
+
function resolveRslintBinary() {
|
|
4
|
+
const arch = process.arch;
|
|
5
|
+
const tuples = 'linux' === process.platform ? [
|
|
6
|
+
`linux-${arch}-gnu`,
|
|
7
|
+
`linux-${arch}-musl`
|
|
8
|
+
] : 'win32' === process.platform ? [
|
|
9
|
+
`win32-${arch}-msvc`
|
|
10
|
+
] : [
|
|
11
|
+
`${process.platform}-${arch}`
|
|
12
|
+
];
|
|
13
|
+
for (const tuple of tuples)try {
|
|
14
|
+
return resolve_binary_require.resolve(`@rslint/native-${tuple}/bin`);
|
|
15
|
+
} catch {}
|
|
16
|
+
throw new Error(`rslint: no native binary for ${process.platform}-${arch} (looked for @rslint/native-{${tuples.join(',')}})`);
|
|
17
|
+
}
|
|
18
|
+
export { resolveRslintBinary };
|
package/dist/cli.d.ts
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
1
|
export declare function run(binPath: string, argv: string[], startTime: number): Promise<number>;
|
|
2
2
|
|
|
3
|
+
export declare function runCLI({ argv, }?: RunCLIOptions): Promise<void>;
|
|
4
|
+
|
|
5
|
+
export declare type RunCLIOptions = {
|
|
6
|
+
/**
|
|
7
|
+
* The command-line arguments to parse, matching the shape of Node.js `process.argv`
|
|
8
|
+
* @default process.argv
|
|
9
|
+
*/
|
|
10
|
+
argv?: string[];
|
|
11
|
+
};
|
|
12
|
+
|
|
3
13
|
export { }
|
package/dist/cli.js
CHANGED
|
@@ -1,101 +1,13 @@
|
|
|
1
|
-
import node_path from "node:path";
|
|
2
|
-
import node_fs from "node:fs";
|
|
3
|
-
import { parseArgs } from "node:util";
|
|
4
|
-
import picomatch from "picomatch";
|
|
5
1
|
import fs_0, * as __rspack_external_fs from "fs";
|
|
6
2
|
import path_0, { basename, dirname, normalize, posix, relative as external_path_relative, resolve, sep } from "path";
|
|
7
3
|
import { fileURLToPath } from "url";
|
|
8
4
|
import { createRequire } from "module";
|
|
5
|
+
import picomatch from "picomatch";
|
|
6
|
+
import node_fs from "node:fs";
|
|
7
|
+
import node_path from "node:path";
|
|
8
|
+
import { parseArgs } from "node:util";
|
|
9
9
|
import { loadConfigFile, collectPluginMeta, normalizeConfig } from "./config-loader.js";
|
|
10
|
-
|
|
11
|
-
return /\.(ts|mts|js|mjs)$/.test(filePath);
|
|
12
|
-
}
|
|
13
|
-
function args_parseArgs(argv) {
|
|
14
|
-
const { values, tokens } = parseArgs({
|
|
15
|
-
args: argv,
|
|
16
|
-
strict: false,
|
|
17
|
-
tokens: true,
|
|
18
|
-
options: {
|
|
19
|
-
config: {
|
|
20
|
-
type: 'string'
|
|
21
|
-
},
|
|
22
|
-
init: {
|
|
23
|
-
type: 'boolean'
|
|
24
|
-
},
|
|
25
|
-
singleThreaded: {
|
|
26
|
-
type: 'boolean'
|
|
27
|
-
},
|
|
28
|
-
format: {
|
|
29
|
-
type: 'string'
|
|
30
|
-
},
|
|
31
|
-
'max-warnings': {
|
|
32
|
-
type: 'string'
|
|
33
|
-
},
|
|
34
|
-
rule: {
|
|
35
|
-
type: 'string',
|
|
36
|
-
multiple: true
|
|
37
|
-
},
|
|
38
|
-
trace: {
|
|
39
|
-
type: 'string'
|
|
40
|
-
},
|
|
41
|
-
cpuprof: {
|
|
42
|
-
type: 'string'
|
|
43
|
-
},
|
|
44
|
-
'start-time': {
|
|
45
|
-
type: 'string'
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
const flags = [];
|
|
50
|
-
const positionalsBefore = [];
|
|
51
|
-
const positionalsAfter = [];
|
|
52
|
-
let seenTerminator = false;
|
|
53
|
-
for (const token of tokens)if ('option' === token.kind) {
|
|
54
|
-
if ('config' === token.name || 'init' === token.name || 'start-time' === token.name) continue;
|
|
55
|
-
flags.push(token.rawName);
|
|
56
|
-
if (null != token.value) flags.push(token.value);
|
|
57
|
-
} else if ('option-terminator' === token.kind) seenTerminator = true;
|
|
58
|
-
else if ('positional' === token.kind) if (seenTerminator) positionalsAfter.push(token.value);
|
|
59
|
-
else positionalsBefore.push(token.value);
|
|
60
|
-
const positionals = [
|
|
61
|
-
...positionalsBefore,
|
|
62
|
-
...positionalsAfter
|
|
63
|
-
];
|
|
64
|
-
const rest = seenTerminator ? [
|
|
65
|
-
...flags,
|
|
66
|
-
...positionalsBefore,
|
|
67
|
-
'--',
|
|
68
|
-
...positionalsAfter
|
|
69
|
-
] : [
|
|
70
|
-
...flags,
|
|
71
|
-
...positionalsBefore
|
|
72
|
-
];
|
|
73
|
-
return {
|
|
74
|
-
config: values.config ?? null,
|
|
75
|
-
init: values.init ?? false,
|
|
76
|
-
singleThreaded: values.singleThreaded ?? false,
|
|
77
|
-
rest,
|
|
78
|
-
positionals
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
function classifyArgs(positionals, cwd) {
|
|
82
|
-
const files = [];
|
|
83
|
-
const dirs = [];
|
|
84
|
-
for (const arg of positionals){
|
|
85
|
-
const resolved = node_path.resolve(cwd, arg);
|
|
86
|
-
try {
|
|
87
|
-
const real = node_fs.realpathSync(resolved);
|
|
88
|
-
if (node_fs.statSync(real).isDirectory()) dirs.push(real);
|
|
89
|
-
else files.push(real);
|
|
90
|
-
} catch {
|
|
91
|
-
files.push(resolved);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
return {
|
|
95
|
-
files,
|
|
96
|
-
dirs
|
|
97
|
-
};
|
|
98
|
-
}
|
|
10
|
+
import { resolveRslintBinary } from "./770.js";
|
|
99
11
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
100
12
|
function cleanPath(path) {
|
|
101
13
|
let normalized = normalize(path);
|
|
@@ -898,12 +810,12 @@ async function findJSConfigsInDir(startDir) {
|
|
|
898
810
|
}
|
|
899
811
|
async function discoverConfigs(files, dirs, cwd, explicitConfig) {
|
|
900
812
|
const configs = new Map();
|
|
901
|
-
const addConfig = (configPath)=>{
|
|
902
|
-
if (!configs.has(configPath)) configs.set(configPath,
|
|
813
|
+
const addConfig = (configPath, configDirectory = node_path.dirname(configPath))=>{
|
|
814
|
+
if (!configs.has(configPath)) configs.set(configPath, configDirectory);
|
|
903
815
|
};
|
|
904
816
|
if (explicitConfig) {
|
|
905
817
|
const resolved = node_path.resolve(cwd, explicitConfig);
|
|
906
|
-
addConfig(resolved);
|
|
818
|
+
addConfig(resolved, cwd);
|
|
907
819
|
return configs;
|
|
908
820
|
}
|
|
909
821
|
const startDirs = new Set();
|
|
@@ -985,6 +897,96 @@ function filterConfigsByParentIgnores(configEntries) {
|
|
|
985
897
|
}
|
|
986
898
|
return result;
|
|
987
899
|
}
|
|
900
|
+
function isJSConfigFile(filePath) {
|
|
901
|
+
return /\.(ts|mts|js|mjs)$/.test(filePath);
|
|
902
|
+
}
|
|
903
|
+
function args_parseArgs(argv) {
|
|
904
|
+
const { values, tokens } = parseArgs({
|
|
905
|
+
args: argv,
|
|
906
|
+
strict: false,
|
|
907
|
+
tokens: true,
|
|
908
|
+
options: {
|
|
909
|
+
config: {
|
|
910
|
+
type: 'string',
|
|
911
|
+
short: 'c'
|
|
912
|
+
},
|
|
913
|
+
init: {
|
|
914
|
+
type: 'boolean'
|
|
915
|
+
},
|
|
916
|
+
singleThreaded: {
|
|
917
|
+
type: 'boolean'
|
|
918
|
+
},
|
|
919
|
+
format: {
|
|
920
|
+
type: 'string'
|
|
921
|
+
},
|
|
922
|
+
'max-warnings': {
|
|
923
|
+
type: 'string'
|
|
924
|
+
},
|
|
925
|
+
rule: {
|
|
926
|
+
type: 'string',
|
|
927
|
+
multiple: true
|
|
928
|
+
},
|
|
929
|
+
trace: {
|
|
930
|
+
type: 'string'
|
|
931
|
+
},
|
|
932
|
+
cpuprof: {
|
|
933
|
+
type: 'string'
|
|
934
|
+
},
|
|
935
|
+
'start-time': {
|
|
936
|
+
type: 'string'
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
});
|
|
940
|
+
const flags = [];
|
|
941
|
+
const positionalsBefore = [];
|
|
942
|
+
const positionalsAfter = [];
|
|
943
|
+
let seenTerminator = false;
|
|
944
|
+
for (const token of tokens)if ('option' === token.kind) {
|
|
945
|
+
if ('config' === token.name || 'init' === token.name || 'start-time' === token.name) continue;
|
|
946
|
+
flags.push(token.rawName);
|
|
947
|
+
if (null != token.value) flags.push(token.value);
|
|
948
|
+
} else if ('option-terminator' === token.kind) seenTerminator = true;
|
|
949
|
+
else if ('positional' === token.kind) if (seenTerminator) positionalsAfter.push(token.value);
|
|
950
|
+
else positionalsBefore.push(token.value);
|
|
951
|
+
const positionals = [
|
|
952
|
+
...positionalsBefore,
|
|
953
|
+
...positionalsAfter
|
|
954
|
+
];
|
|
955
|
+
const rest = seenTerminator ? [
|
|
956
|
+
...flags,
|
|
957
|
+
...positionalsBefore,
|
|
958
|
+
'--',
|
|
959
|
+
...positionalsAfter
|
|
960
|
+
] : [
|
|
961
|
+
...flags,
|
|
962
|
+
...positionalsBefore
|
|
963
|
+
];
|
|
964
|
+
return {
|
|
965
|
+
config: values.config ?? null,
|
|
966
|
+
init: values.init ?? false,
|
|
967
|
+
singleThreaded: values.singleThreaded ?? false,
|
|
968
|
+
rest,
|
|
969
|
+
positionals
|
|
970
|
+
};
|
|
971
|
+
}
|
|
972
|
+
function classifyArgs(positionals, cwd) {
|
|
973
|
+
const files = [];
|
|
974
|
+
const dirs = [];
|
|
975
|
+
for (const arg of positionals){
|
|
976
|
+
const resolved = node_path.resolve(cwd, arg);
|
|
977
|
+
try {
|
|
978
|
+
const real = node_fs.realpathSync(resolved);
|
|
979
|
+
if (node_fs.statSync(real).isDirectory()) dirs.push(real);
|
|
980
|
+
else files.push(real);
|
|
981
|
+
} catch {
|
|
982
|
+
files.push(resolved);
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
return {
|
|
986
|
+
files,
|
|
987
|
+
dirs
|
|
988
|
+
};
|
|
989
|
+
}
|
|
988
990
|
async function runWithJSConfigs(binPath, configs, goArgs, cwd, singleThreaded) {
|
|
989
991
|
const configEntries = [];
|
|
990
992
|
const dirToPath = new Map();
|
|
@@ -1088,4 +1090,9 @@ async function run(binPath, argv, startTime) {
|
|
|
1088
1090
|
cwd
|
|
1089
1091
|
});
|
|
1090
1092
|
}
|
|
1091
|
-
|
|
1093
|
+
async function runCLI({ argv = process.argv } = {}) {
|
|
1094
|
+
const startTime = Date.now();
|
|
1095
|
+
const exitCode = await run(resolveRslintBinary(), argv.slice(2), startTime);
|
|
1096
|
+
process.exitCode = exitCode;
|
|
1097
|
+
}
|
|
1098
|
+
export { findJSConfigUp, glob, run, runCLI };
|
package/dist/config-loader.js
CHANGED
|
@@ -1,6 +1,37 @@
|
|
|
1
1
|
import node_path from "node:path";
|
|
2
2
|
import { pathToFileURL } from "node:url";
|
|
3
|
-
|
|
3
|
+
const NATIVE_PLUGINS = [
|
|
4
|
+
"@typescript-eslint",
|
|
5
|
+
'import',
|
|
6
|
+
'jest',
|
|
7
|
+
'jsx-a11y',
|
|
8
|
+
'promise',
|
|
9
|
+
'react',
|
|
10
|
+
'react-hooks',
|
|
11
|
+
'unicorn'
|
|
12
|
+
];
|
|
13
|
+
const NATIVE_PLUGIN_DECL_ALIASES = [
|
|
14
|
+
'eslint-plugin-import',
|
|
15
|
+
'eslint-plugin-jest',
|
|
16
|
+
'eslint-plugin-jsx-a11y',
|
|
17
|
+
'eslint-plugin-promise',
|
|
18
|
+
'eslint-plugin-react-hooks',
|
|
19
|
+
'eslint-plugin-unicorn'
|
|
20
|
+
];
|
|
21
|
+
const NATIVE_PLUGIN_RESERVED_NAMES = new Set([
|
|
22
|
+
...NATIVE_PLUGINS,
|
|
23
|
+
...NATIVE_PLUGIN_DECL_ALIASES
|
|
24
|
+
]);
|
|
25
|
+
function defineConfig(config) {
|
|
26
|
+
return config;
|
|
27
|
+
}
|
|
28
|
+
function globalIgnores(ignorePatterns) {
|
|
29
|
+
if (!Array.isArray(ignorePatterns)) throw new TypeError('ignorePatterns must be an array');
|
|
30
|
+
if (0 === ignorePatterns.length) throw new TypeError('ignorePatterns must contain at least one pattern');
|
|
31
|
+
return {
|
|
32
|
+
ignores: ignorePatterns
|
|
33
|
+
};
|
|
34
|
+
}
|
|
4
35
|
function selectPluginSource(entry) {
|
|
5
36
|
if (null == entry || 'object' != typeof entry) return null;
|
|
6
37
|
const e = entry;
|
|
@@ -127,4 +158,4 @@ function collectPluginMeta(configs) {
|
|
|
127
158
|
pluginConfigs
|
|
128
159
|
};
|
|
129
160
|
}
|
|
130
|
-
export { collectPluginMeta, loadConfigFile, normalizeConfig };
|
|
161
|
+
export { collectPluginMeta, defineConfig, globalIgnores, loadConfigFile, normalizeConfig };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Worker } from "node:worker_threads";
|
|
2
2
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
3
3
|
import { StringDecoder } from "node:string_decoder";
|
|
4
|
-
import
|
|
4
|
+
import node_path from "node:path";
|
|
5
|
+
import node_module, { createRequire } from "node:module";
|
|
5
6
|
import { readFileSync } from "node:fs";
|
|
6
7
|
import { execSync } from "node:child_process";
|
|
7
|
-
import node_path from "node:path";
|
|
8
8
|
import { __webpack_require__ } from "./612.js";
|
|
9
9
|
__webpack_require__.add({
|
|
10
10
|
"../../node_modules/.pnpm/esrecurse@4.3.0/node_modules/esrecurse/esrecurse.js" (__unused_rspack_module, exports, __webpack_require__) {
|
|
@@ -20396,6 +20396,34 @@ class CancelFlagPool {
|
|
|
20396
20396
|
let testWorkerEntry;
|
|
20397
20397
|
const resolveWorkerFile = ()=>testWorkerEntry ?? fileURLToPath(new URL('./lint-worker.js', import.meta.url));
|
|
20398
20398
|
const WORKER_EXIT_GRACE_MS = 5000;
|
|
20399
|
+
let nodeCompileCacheDir;
|
|
20400
|
+
let nodeCompileCacheDirResolved = false;
|
|
20401
|
+
function getNodeCompileCacheDir() {
|
|
20402
|
+
if (nodeCompileCacheDirResolved) return nodeCompileCacheDir;
|
|
20403
|
+
nodeCompileCacheDirResolved = true;
|
|
20404
|
+
if (process.env.NODE_DISABLE_COMPILE_CACHE) return;
|
|
20405
|
+
if (process.env.NODE_COMPILE_CACHE) {
|
|
20406
|
+
nodeCompileCacheDir = process.env.NODE_COMPILE_CACHE;
|
|
20407
|
+
return nodeCompileCacheDir;
|
|
20408
|
+
}
|
|
20409
|
+
const { enableCompileCache, getCompileCacheDir } = node_module;
|
|
20410
|
+
if (!enableCompileCache || !getCompileCacheDir) return;
|
|
20411
|
+
try {
|
|
20412
|
+
enableCompileCache();
|
|
20413
|
+
const cacheDirectory = getCompileCacheDir();
|
|
20414
|
+
nodeCompileCacheDir = cacheDirectory ? node_path.dirname(cacheDirectory) : void 0;
|
|
20415
|
+
return nodeCompileCacheDir;
|
|
20416
|
+
} catch {
|
|
20417
|
+
return;
|
|
20418
|
+
}
|
|
20419
|
+
}
|
|
20420
|
+
function workerEnvWithCompileCache() {
|
|
20421
|
+
const directory = getNodeCompileCacheDir();
|
|
20422
|
+
return directory ? {
|
|
20423
|
+
...process.env,
|
|
20424
|
+
NODE_COMPILE_CACHE: directory
|
|
20425
|
+
} : void 0;
|
|
20426
|
+
}
|
|
20399
20427
|
async function terminateWorker(worker) {
|
|
20400
20428
|
worker.stdout?.destroy();
|
|
20401
20429
|
worker.stderr?.destroy();
|
|
@@ -20590,6 +20618,7 @@ class WorkerPool {
|
|
|
20590
20618
|
cancelSab: this.cancelPool.sharedBuffer,
|
|
20591
20619
|
configs: this.opts.configs
|
|
20592
20620
|
},
|
|
20621
|
+
env: workerEnvWithCompileCache(),
|
|
20593
20622
|
stdout: true,
|
|
20594
20623
|
stderr: true
|
|
20595
20624
|
};
|