@rslint/core 0.5.3 → 0.6.0

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.
Files changed (74) hide show
  1. package/bin/rslint.cjs +21 -4
  2. package/dist/0~engine.js +406 -0
  3. package/dist/34.js +33 -0
  4. package/dist/browser.d.ts +52 -39
  5. package/dist/browser.js +42 -74
  6. package/dist/cli.d.ts +3 -2
  7. package/dist/cli.js +1051 -93
  8. package/dist/config-loader.d.ts +45 -14
  9. package/dist/config-loader.js +95 -59
  10. package/dist/eslint-plugin/612.js +43 -0
  11. package/dist/eslint-plugin/index.d.ts +892 -0
  12. package/dist/eslint-plugin/index.js +26692 -0
  13. package/dist/eslint-plugin/lint-worker.js +26225 -0
  14. package/dist/eslint-plugin/types.d.ts +23 -0
  15. package/dist/eslint-plugin/types.js +1 -0
  16. package/dist/index.d.ts +626 -19
  17. package/dist/index.js +598 -15
  18. package/dist/service.d.ts +360 -30
  19. package/dist/service.js +19 -34
  20. package/package.json +27 -11
  21. package/dist/browser.d.ts.map +0 -1
  22. package/dist/cli.d.ts.map +0 -1
  23. package/dist/config-loader.d.ts.map +0 -1
  24. package/dist/configs/import.d.ts +0 -6
  25. package/dist/configs/import.d.ts.map +0 -1
  26. package/dist/configs/import.js +0 -7
  27. package/dist/configs/index.d.ts +0 -47
  28. package/dist/configs/index.d.ts.map +0 -1
  29. package/dist/configs/index.js +0 -36
  30. package/dist/configs/javascript.d.ts +0 -6
  31. package/dist/configs/javascript.d.ts.map +0 -1
  32. package/dist/configs/javascript.js +0 -72
  33. package/dist/configs/jest.d.ts +0 -7
  34. package/dist/configs/jest.d.ts.map +0 -1
  35. package/dist/configs/jest.js +0 -35
  36. package/dist/configs/jsx-a11y.d.ts +0 -6
  37. package/dist/configs/jsx-a11y.d.ts.map +0 -1
  38. package/dist/configs/jsx-a11y.js +0 -135
  39. package/dist/configs/promise.d.ts +0 -6
  40. package/dist/configs/promise.d.ts.map +0 -1
  41. package/dist/configs/promise.js +0 -20
  42. package/dist/configs/react-hooks.d.ts +0 -6
  43. package/dist/configs/react-hooks.d.ts.map +0 -1
  44. package/dist/configs/react-hooks.js +0 -24
  45. package/dist/configs/react.d.ts +0 -6
  46. package/dist/configs/react.d.ts.map +0 -1
  47. package/dist/configs/react.js +0 -31
  48. package/dist/configs/typescript.d.ts +0 -9
  49. package/dist/configs/typescript.d.ts.map +0 -1
  50. package/dist/configs/typescript.js +0 -122
  51. package/dist/configs/unicorn.d.ts +0 -8
  52. package/dist/configs/unicorn.d.ts.map +0 -1
  53. package/dist/configs/unicorn.js +0 -161
  54. package/dist/define-config.d.ts +0 -110
  55. package/dist/define-config.d.ts.map +0 -1
  56. package/dist/define-config.js +0 -6
  57. package/dist/index.d.ts.map +0 -1
  58. package/dist/node.d.ts +0 -31
  59. package/dist/node.d.ts.map +0 -1
  60. package/dist/node.js +0 -116
  61. package/dist/service.d.ts.map +0 -1
  62. package/dist/tsconfig.build.tsbuildinfo +0 -1
  63. package/dist/types.d.ts +0 -342
  64. package/dist/types.d.ts.map +0 -1
  65. package/dist/types.js +0 -1
  66. package/dist/utils/args.d.ts +0 -19
  67. package/dist/utils/args.d.ts.map +0 -1
  68. package/dist/utils/args.js +0 -101
  69. package/dist/utils/config-discovery.d.ts +0 -47
  70. package/dist/utils/config-discovery.d.ts.map +0 -1
  71. package/dist/utils/config-discovery.js +0 -238
  72. package/dist/worker.d.ts +0 -2
  73. package/dist/worker.d.ts.map +0 -1
  74. package/dist/worker.js +0 -114
@@ -1,14 +1,45 @@
1
- // Re-export utilities that external consumers may depend on
2
- export { JS_CONFIG_FILES, findJSConfig, findJSConfigUp, findJSConfigsInDir, } from './utils/config-discovery.js';
3
- /**
4
- * Load a JS/TS config file.
5
- * - .js/.mjs: native import()
6
- * - .ts/.mts: native import() when Node.js has TypeScript support (>= 22.6),
7
- * otherwise fall back to jiti
8
- */
9
- export declare function loadConfigFile(configPath: string): Promise<unknown>;
10
- /**
11
- * Validate and strip non-serializable fields from the config.
12
- */
13
- export declare function normalizeConfig(config: unknown): Record<string, unknown>[];
14
- //# sourceMappingURL=config-loader.d.ts.map
1
+ /**
2
+ * Derive, from normalized configs, the ESLint-plugin metadata the Go core
3
+ * needs (`{prefix, ruleNames}` for placeholder rules) and the worker-pool
4
+ * descriptors (only for configs that mount plugins — others stay
5
+ * zero-overhead). Shared by the CLI (cli.ts) and the VS Code extension
6
+ * (Rslint.ts) so both produce the identical `eslintPlugins` shape Go parses.
7
+ * ruleNames for a shared prefix are merged (set union) across configs: Go's
8
+ * placeholder registry is a per-prefix superset, while the worker routes the
9
+ * actual rules per-config. This is NOT a validation — a genuinely conflicting
10
+ * redefinition (same prefix, different plugin object) is caught at worker init
11
+ * (plugin-loader throws ESLint's `Cannot redefine plugin` error), not here.
12
+ */
13
+ export declare function collectPluginMeta(configs: ReadonlyArray<{
14
+ configPath: string;
15
+ configDirectory: string;
16
+ entries: ReadonlyArray<unknown>;
17
+ }>): {
18
+ eslintPluginEntries: Array<{
19
+ prefix: string;
20
+ ruleNames: string[];
21
+ }>;
22
+ pluginConfigs: PluginConfigDescriptor[];
23
+ };
24
+
25
+ /**
26
+ * Load a JS/TS config file.
27
+ * - .js/.mjs: native import()
28
+ * - .ts/.mts: native import() when Node.js has TypeScript support (>= 22.6),
29
+ * otherwise fall back to jiti
30
+ */
31
+ export declare function loadConfigFile(configPath: string): Promise<unknown>;
32
+
33
+ /**
34
+ * Validate and strip non-serializable fields from the config.
35
+ */
36
+ export declare function normalizeConfig(config: unknown): Record<string, unknown>[];
37
+
38
+ /** A worker-pool config descriptor: which config file to import and the
39
+ * directory key per-file plugin-lint tasks route on. */
40
+ export declare interface PluginConfigDescriptor {
41
+ configPath: string;
42
+ configDirectory: string;
43
+ }
44
+
45
+ export { }
@@ -1,33 +1,28 @@
1
- var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
2
- if (typeof path === "string" && /^\.\.?\//.test(path)) {
3
- return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
4
- return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
5
- });
6
- }
7
- return path;
8
- };
9
- import path from 'node:path';
10
- import { pathToFileURL } from 'node:url';
11
- // Re-export utilities that external consumers may depend on
12
- export { JS_CONFIG_FILES, findJSConfig, findJSConfigUp, findJSConfigsInDir, } from './utils/config-discovery.js';
13
- /**
14
- * Load a JS/TS config file.
15
- * - .js/.mjs: native import()
16
- * - .ts/.mts: native import() when Node.js has TypeScript support (>= 22.6),
17
- * otherwise fall back to jiti
18
- */
19
- export async function loadConfigFile(configPath) {
20
- const ext = path.extname(configPath);
21
- if (ext === '.js' || ext === '.mjs') {
22
- const mod = await import(__rewriteRelativeImportExtension(pathToFileURL(configPath).href));
1
+ import node_path from "node:path";
2
+ import { pathToFileURL } from "node:url";
3
+ import { NATIVE_PLUGIN_RESERVED_NAMES } from "./34.js";
4
+ function selectPluginSource(entry) {
5
+ if (null == entry || 'object' != typeof entry) return null;
6
+ const e = entry;
7
+ if (null != e.plugins && 'object' == typeof e.plugins && !Array.isArray(e.plugins)) return e.plugins;
8
+ return null;
9
+ }
10
+ function unwrapPluginModule(mod) {
11
+ if (null == mod || 'object' != typeof mod) return null;
12
+ const m = mod;
13
+ if (null != m.default && 'object' == typeof m.default) return m.default;
14
+ return mod;
15
+ }
16
+ async function loadConfigFile(configPath) {
17
+ const ext = node_path.extname(configPath);
18
+ if ('.js' === ext || '.mjs' === ext) {
19
+ const mod = await import(pathToFileURL(configPath).href);
23
20
  return mod.default ?? mod;
24
21
  }
25
- if (ext === '.ts' || ext === '.mts') {
26
- // Use feature detection to decide the loading strategy (same as rsbuild).
27
- // process.features.typescript is available in Node.js >= 22.6.
22
+ if ('.ts' === ext || '.mts' === ext) {
28
23
  const useNative = Boolean(process.features.typescript);
29
24
  if (useNative) {
30
- const mod = await import(__rewriteRelativeImportExtension(pathToFileURL(configPath).href));
25
+ const mod = await import(pathToFileURL(configPath).href);
31
26
  return mod.default ?? mod;
32
27
  }
33
28
  const jiti = await loadJiti(configPath);
@@ -35,60 +30,101 @@ export async function loadConfigFile(configPath) {
35
30
  const resolved = await jiti.import(configPath);
36
31
  return extractDefault(resolved);
37
32
  }
38
- throw new Error(`Failed to load TypeScript config file: ${configPath}\n` +
39
- `To load .ts config files, either:\n` +
40
- ` 1. Use Node.js >= 22.6 (with native TypeScript support)\n` +
41
- ` 2. Install jiti as a dependency: npm install -D jiti`);
33
+ throw new Error(`Failed to load TypeScript config file: ${configPath}\nTo load .ts config files, either:\n 1. Use Node.js >= 22.6 (with native TypeScript support)\n 2. Install jiti as a dependency: npm install -D jiti`);
42
34
  }
43
35
  throw new Error(`Unsupported config file extension: ${ext}`);
44
36
  }
45
- /**
46
- * Try to load jiti (optional peer dependency).
47
- */
48
37
  async function loadJiti(configPath) {
49
38
  try {
50
- const { createJiti } = await import('jiti');
51
- return createJiti(path.dirname(configPath), { interopDefault: true });
52
- }
53
- catch {
39
+ const { createJiti } = await import("jiti");
40
+ return createJiti(node_path.dirname(configPath), {
41
+ interopDefault: true
42
+ });
43
+ } catch {
54
44
  return null;
55
45
  }
56
46
  }
57
47
  function extractDefault(mod) {
58
- if (typeof mod === 'object' && mod !== null && 'default' in mod) {
59
- return mod.default;
60
- }
48
+ if ('object' == typeof mod && null !== mod && 'default' in mod) return mod.default;
61
49
  return mod;
62
50
  }
63
- /**
64
- * Validate and strip non-serializable fields from the config.
65
- */
66
- export function normalizeConfig(config) {
67
- if (!Array.isArray(config)) {
68
- throw new Error(`rslint config must export an array (flat config format), got ${typeof config}`);
69
- }
70
- return config
71
- .filter((entry, index) => {
72
- if (entry == null || typeof entry !== 'object') {
73
- console.warn(`[rslint] Config entry at index ${index} is not an object (got ${entry === null ? 'null' : typeof entry}), skipping.`);
51
+ function normalizeConfig(config) {
52
+ if (!Array.isArray(config)) throw new Error(`rslint config must export an array (flat config format), got ${typeof config}`);
53
+ return config.filter((entry, index)=>{
54
+ if (null == entry || 'object' != typeof entry) {
55
+ console.warn(`[rslint] Config entry at index ${index} is not an object (got ${null === entry ? 'null' : typeof entry}), skipping.`);
74
56
  return false;
75
57
  }
76
58
  return true;
77
- })
78
- .map((entry, index) => {
79
- if (entry.files != null && !Array.isArray(entry.files)) {
80
- throw new Error(`[rslint] Config entry at index ${index}: "files" must be an array, got ${typeof entry.files}`);
81
- }
82
- if (entry.ignores != null && !Array.isArray(entry.ignores)) {
83
- throw new Error(`[rslint] Config entry at index ${index}: "ignores" must be an array, got ${typeof entry.ignores}`);
59
+ }).map((entry, index)=>{
60
+ if (null != entry.files && !Array.isArray(entry.files)) throw new Error(`[rslint] Config entry at index ${index}: "files" must be an array, got ${typeof entry.files}`);
61
+ if (null != entry.ignores && !Array.isArray(entry.ignores)) throw new Error(`[rslint] Config entry at index ${index}: "ignores" must be an array, got ${typeof entry.ignores}`);
62
+ const pluginSource = selectPluginSource(entry);
63
+ const eslintPluginMeta = {};
64
+ const pluginPrefixes = [];
65
+ if (null != pluginSource) for (const prefix of Object.keys(pluginSource)){
66
+ if (NATIVE_PLUGIN_RESERVED_NAMES.has(prefix)) throw new Error(`[rslint] Config entry at index ${index}: plugins prefix "${prefix}" collides with the built-in plugin of the same name; choose a different prefix.`);
67
+ const plugin = unwrapPluginModule(pluginSource[prefix]);
68
+ const pluginRules = plugin?.rules;
69
+ if (null == pluginRules || 'object' != typeof pluginRules) throw new Error(`[rslint] Config entry at index ${index}: plugins["${prefix}"] must expose a "rules" object.`);
70
+ eslintPluginMeta[prefix] = {
71
+ ruleNames: Object.keys(pluginRules).sort()
72
+ };
73
+ pluginPrefixes.push(prefix);
84
74
  }
75
+ const stringPlugins = Array.isArray(entry.plugins) ? entry.plugins.filter((p)=>'string' == typeof p) : [];
76
+ const plugins = [
77
+ ...new Set([
78
+ ...stringPlugins,
79
+ ...pluginPrefixes
80
+ ])
81
+ ];
85
82
  return {
86
83
  files: entry.files,
87
84
  ignores: entry.ignores,
88
85
  languageOptions: entry.languageOptions,
89
86
  rules: entry.rules,
90
- plugins: entry.plugins,
87
+ plugins,
91
88
  settings: entry.settings,
89
+ ...pluginPrefixes.length > 0 ? {
90
+ eslintPlugins: eslintPluginMeta
91
+ } : {}
92
92
  };
93
93
  });
94
94
  }
95
+ function collectPluginMeta(configs) {
96
+ const isPluginMetaMap = (v)=>null !== v && 'object' == typeof v;
97
+ const byPrefix = new Map();
98
+ const pluginConfigs = [];
99
+ for (const c of configs){
100
+ let hasPlugins = false;
101
+ for (const entry of c.entries){
102
+ if (null === entry || 'object' != typeof entry || !('eslintPlugins' in entry)) continue;
103
+ const ep = entry.eslintPlugins;
104
+ if (isPluginMetaMap(ep)) for (const [prefix, meta] of Object.entries(ep)){
105
+ hasPlugins = true;
106
+ const existing = byPrefix.get(prefix);
107
+ if (existing) {
108
+ for (const name of meta.ruleNames)if (!existing.includes(name)) existing.push(name);
109
+ } else byPrefix.set(prefix, [
110
+ ...meta.ruleNames
111
+ ]);
112
+ }
113
+ }
114
+ if (hasPlugins) pluginConfigs.push({
115
+ configPath: c.configPath,
116
+ configDirectory: c.configDirectory
117
+ });
118
+ }
119
+ const eslintPluginEntries = [
120
+ ...byPrefix.entries()
121
+ ].map(([prefix, ruleNames])=>({
122
+ prefix,
123
+ ruleNames
124
+ }));
125
+ return {
126
+ eslintPluginEntries,
127
+ pluginConfigs
128
+ };
129
+ }
130
+ export { collectPluginMeta, loadConfigFile, normalizeConfig };
@@ -0,0 +1,43 @@
1
+ var __webpack_modules__ = {};
2
+ var __webpack_module_cache__ = {};
3
+ function __webpack_require__(moduleId) {
4
+ var cachedModule = __webpack_module_cache__[moduleId];
5
+ if (void 0 !== cachedModule) return cachedModule.exports;
6
+ var module = __webpack_module_cache__[moduleId] = {
7
+ exports: {}
8
+ };
9
+ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
10
+ return module.exports;
11
+ }
12
+ __webpack_require__.m = __webpack_modules__;
13
+ (()=>{
14
+ __webpack_require__.d = (exports, getters, values)=>{
15
+ var define = (defs, kind)=>{
16
+ for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports, key)) Object.defineProperty(exports, key, {
17
+ enumerable: true,
18
+ [kind]: defs[key]
19
+ });
20
+ };
21
+ define(getters, "get");
22
+ define(values, "value");
23
+ };
24
+ })();
25
+ (()=>{
26
+ __webpack_require__.add = function(modules) {
27
+ Object.assign(__webpack_require__.m, modules);
28
+ };
29
+ })();
30
+ (()=>{
31
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
32
+ })();
33
+ (()=>{
34
+ __webpack_require__.r = (exports)=>{
35
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports, Symbol.toStringTag, {
36
+ value: 'Module'
37
+ });
38
+ Object.defineProperty(exports, '__esModule', {
39
+ value: true
40
+ });
41
+ };
42
+ })();
43
+ export { __webpack_require__ };