vize 0.48.0 → 0.52.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.
@@ -1,4 +1,5 @@
1
1
  import type { LintPreset, RuleSeverity, RuleCategory } from "./core.js";
2
+ import type { LintRulesConfig } from "./rules.js";
2
3
 
3
4
  // ============================================================================
4
5
  // LinterConfig
@@ -22,7 +23,7 @@ export interface LinterConfig {
22
23
  /**
23
24
  * Rules to enable/disable
24
25
  */
25
- rules?: Record<string, RuleSeverity>;
26
+ rules?: LintRulesConfig;
26
27
 
27
28
  /**
28
29
  * Category-level severity overrides
@@ -135,46 +136,128 @@ export interface FormatterConfig {
135
136
  export interface LspConfig {
136
137
  /**
137
138
  * Enable LSP
138
- * @default true
139
+ * @default false
139
140
  */
140
141
  enabled?: boolean;
141
142
 
142
143
  /**
143
- * Enable diagnostics
144
- * @default true
144
+ * Enable linter diagnostics.
145
+ * Prefer this over `diagnostics` for new configs.
146
+ * @default false
147
+ */
148
+ lint?: boolean;
149
+
150
+ /**
151
+ * Enable linter diagnostics.
152
+ * @deprecated Use `lint` instead.
153
+ * @default false
145
154
  */
146
155
  diagnostics?: boolean;
147
156
 
148
157
  /**
149
- * Enable completions
150
- * @default true
158
+ * Enable type checking diagnostics and type-aware LSP features.
159
+ * @default false
160
+ */
161
+ typecheck?: boolean;
162
+
163
+ /**
164
+ * Enable the editor assistance bundle: completion, hover, navigation,
165
+ * symbols, rename, code lens, semantic tokens, links, folding, inlay hints,
166
+ * and file rename handling. Formatting stays separately opt-in.
167
+ * @default false
168
+ */
169
+ editor?: boolean;
170
+
171
+ /**
172
+ * Enable completions.
173
+ * @default false
151
174
  */
152
175
  completion?: boolean;
153
176
 
154
177
  /**
155
178
  * Enable hover information
156
- * @default true
179
+ * @default false
157
180
  */
158
181
  hover?: boolean;
159
182
 
160
183
  /**
161
184
  * Enable go-to-definition
162
- * @default true
185
+ * @default false
163
186
  */
164
187
  definition?: boolean;
165
188
 
189
+ /**
190
+ * Enable find references
191
+ * @default false
192
+ */
193
+ references?: boolean;
194
+
195
+ /**
196
+ * Enable document symbols
197
+ * @default false
198
+ */
199
+ documentSymbols?: boolean;
200
+
201
+ /**
202
+ * Enable workspace symbols
203
+ * @default false
204
+ */
205
+ workspaceSymbols?: boolean;
206
+
166
207
  /**
167
208
  * Enable formatting via LSP
168
- * @default true
209
+ * @default false
169
210
  */
170
211
  formatting?: boolean;
171
212
 
172
213
  /**
173
214
  * Enable code actions
174
- * @default true
215
+ * @default false
175
216
  */
176
217
  codeActions?: boolean;
177
218
 
219
+ /**
220
+ * Enable rename
221
+ * @default false
222
+ */
223
+ rename?: boolean;
224
+
225
+ /**
226
+ * Enable code lens
227
+ * @default false
228
+ */
229
+ codeLens?: boolean;
230
+
231
+ /**
232
+ * Enable semantic tokens
233
+ * @default false
234
+ */
235
+ semanticTokens?: boolean;
236
+
237
+ /**
238
+ * Enable document links
239
+ * @default false
240
+ */
241
+ documentLinks?: boolean;
242
+
243
+ /**
244
+ * Enable folding ranges
245
+ * @default false
246
+ */
247
+ foldingRanges?: boolean;
248
+
249
+ /**
250
+ * Enable inlay hints
251
+ * @default false
252
+ */
253
+ inlayHints?: boolean;
254
+
255
+ /**
256
+ * Enable file rename edits
257
+ * @default false
258
+ */
259
+ fileRename?: boolean;
260
+
178
261
  /**
179
262
  * Use Corsa for type checking in LSP
180
263
  * @default false
package/dist/cli.d.mts DELETED
@@ -1 +0,0 @@
1
- export { };
package/dist/cli.mjs DELETED
@@ -1,136 +0,0 @@
1
- import { loadConfig } from "./config.mjs";
2
- import { createRequire } from "module";
3
- import { readFileSync } from "fs";
4
- //#region src/cli.ts
5
- const require = createRequire(import.meta.url);
6
- function isMusl() {
7
- const report = process.report?.getReport();
8
- if (typeof report === "object" && report !== null && "header" in report) return !report.header.glibcVersionRuntime;
9
- try {
10
- return readFileSync(require("child_process").execSync("which ldd").toString().trim(), "utf8").includes("musl");
11
- } catch {
12
- return true;
13
- }
14
- }
15
- function getBindingPackageName() {
16
- const { platform, arch } = process;
17
- switch (platform) {
18
- case "darwin": switch (arch) {
19
- case "x64": return "@vizejs/native-darwin-x64";
20
- case "arm64": return "@vizejs/native-darwin-arm64";
21
- default: throw new Error(`Unsupported architecture on macOS: ${arch}`);
22
- }
23
- case "win32": switch (arch) {
24
- case "x64": return "@vizejs/native-win32-x64-msvc";
25
- case "arm64": return "@vizejs/native-win32-arm64-msvc";
26
- default: throw new Error(`Unsupported architecture on Windows: ${arch}`);
27
- }
28
- case "linux": switch (arch) {
29
- case "x64": return isMusl() ? "@vizejs/native-linux-x64-musl" : "@vizejs/native-linux-x64-gnu";
30
- case "arm64": return isMusl() ? "@vizejs/native-linux-arm64-musl" : "@vizejs/native-linux-arm64-gnu";
31
- default: throw new Error(`Unsupported architecture on Linux: ${arch}`);
32
- }
33
- default: throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`);
34
- }
35
- }
36
- function loadNative() {
37
- const pkg = getBindingPackageName();
38
- try {
39
- return require(pkg);
40
- } catch (e) {
41
- console.error(`Failed to load native binding: ${pkg}`);
42
- console.error("Try reinstalling: npm install vize");
43
- throw e;
44
- }
45
- }
46
- function parseLintCommand(args) {
47
- const patterns = [];
48
- const options = {};
49
- const sharedConfig = { configMode: "root" };
50
- for (let i = 0; i < args.length; i++) {
51
- const arg = args[i];
52
- if (arg === "--format" || arg === "-f") options.format = args[++i];
53
- else if (arg === "--max-warnings") options.maxWarnings = Number.parseInt(args[++i], 10);
54
- else if (arg === "--quiet" || arg === "-q") options.quiet = true;
55
- else if (arg === "--fix") options.fix = true;
56
- else if (arg === "--help-level") options.helpLevel = args[++i];
57
- else if (arg === "--preset") options.preset = args[++i];
58
- else if (arg === "--config" || arg === "-c") {
59
- const configFile = args[++i];
60
- if (!configFile) throw new Error("Missing path after --config");
61
- sharedConfig.configFile = configFile;
62
- } else if (arg === "--no-config") sharedConfig.configMode = "none";
63
- else if (!arg.startsWith("-")) patterns.push(arg);
64
- }
65
- return {
66
- patterns,
67
- options,
68
- sharedConfig
69
- };
70
- }
71
- async function runLint(args) {
72
- const { patterns, options, sharedConfig } = parseLintCommand(args);
73
- const config = await loadConfig(process.cwd(), {
74
- mode: sharedConfig.configMode,
75
- configFile: sharedConfig.configFile,
76
- env: {
77
- mode: process.env.NODE_ENV ?? "development",
78
- command: "lint"
79
- }
80
- });
81
- if (sharedConfig.configFile && !config) throw new Error(`Could not find config file: ${sharedConfig.configFile}`);
82
- if (config?.linter?.enabled === false) {
83
- process.stderr.write("[vize] Skipping lint because linter.enabled is false in vize.config.\n");
84
- return;
85
- }
86
- options.preset ??= config?.linter?.preset;
87
- if (patterns.length === 0) patterns.push(".");
88
- const result = loadNative().lint(patterns, {
89
- format: options.format,
90
- max_warnings: options.maxWarnings,
91
- quiet: options.quiet,
92
- fix: options.fix,
93
- help_level: options.helpLevel,
94
- preset: options.preset
95
- });
96
- if (result.output) {
97
- process.stdout.write(result.output);
98
- if (!result.output.endsWith("\n")) process.stdout.write("\n");
99
- }
100
- if (options.fix) process.stderr.write("\nNote: --fix is not yet implemented\n");
101
- if (result.errorCount > 0) process.exit(1);
102
- if (options.maxWarnings !== void 0 && result.warningCount > options.maxWarnings) {
103
- process.stderr.write(`\nToo many warnings (${result.warningCount} > max ${options.maxWarnings})\n`);
104
- process.exit(1);
105
- }
106
- }
107
- const NAPI_COMMANDS = new Set(["lint"]);
108
- async function main() {
109
- const args = process.argv.slice(2);
110
- const command = args[0];
111
- if (!command) {
112
- console.error("Usage: vize <command> [options]");
113
- console.error("Commands: lint");
114
- process.exit(1);
115
- }
116
- if (NAPI_COMMANDS.has(command)) {
117
- const commandArgs = args.slice(1);
118
- switch (command) {
119
- case "lint":
120
- await runLint(commandArgs);
121
- break;
122
- }
123
- } else {
124
- console.error(`Unknown command: ${command}`);
125
- console.error("For commands not yet available via NAPI, install from source: cargo install vize");
126
- process.exit(1);
127
- }
128
- }
129
- main().catch((error) => {
130
- console.error(error instanceof Error ? error.message : String(error));
131
- process.exit(1);
132
- });
133
- //#endregion
134
- export {};
135
-
136
- //# sourceMappingURL=cli.mjs.map
package/dist/cli.mjs.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"cli.mjs","names":[],"sources":["../src/cli.ts"],"sourcesContent":["import { createRequire } from \"module\";\nimport { readFileSync } from \"fs\";\nimport { loadConfig } from \"./config.js\";\n\nconst require = createRequire(import.meta.url);\n\n// ============================================================================\n// Native binding loader (oxlint pattern)\n// ============================================================================\n\nfunction isMusl(): boolean {\n const report = process.report?.getReport();\n if (typeof report === \"object\" && report !== null && \"header\" in report) {\n const header = (report as { header: { glibcVersionRuntime?: string } }).header;\n return !header.glibcVersionRuntime;\n }\n try {\n const lddPath = require(\"child_process\").execSync(\"which ldd\").toString().trim();\n return readFileSync(lddPath, \"utf8\").includes(\"musl\");\n } catch {\n return true;\n }\n}\n\nfunction getBindingPackageName(): string {\n const { platform, arch } = process;\n\n switch (platform) {\n case \"darwin\":\n switch (arch) {\n case \"x64\":\n return \"@vizejs/native-darwin-x64\";\n case \"arm64\":\n return \"@vizejs/native-darwin-arm64\";\n default:\n throw new Error(`Unsupported architecture on macOS: ${arch}`);\n }\n case \"win32\":\n switch (arch) {\n case \"x64\":\n return \"@vizejs/native-win32-x64-msvc\";\n case \"arm64\":\n return \"@vizejs/native-win32-arm64-msvc\";\n default:\n throw new Error(`Unsupported architecture on Windows: ${arch}`);\n }\n case \"linux\":\n switch (arch) {\n case \"x64\":\n return isMusl() ? \"@vizejs/native-linux-x64-musl\" : \"@vizejs/native-linux-x64-gnu\";\n case \"arm64\":\n return isMusl() ? \"@vizejs/native-linux-arm64-musl\" : \"@vizejs/native-linux-arm64-gnu\";\n default:\n throw new Error(`Unsupported architecture on Linux: ${arch}`);\n }\n default:\n throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`);\n }\n}\n\ninterface NativeBinding {\n lint: (\n patterns: string[],\n options?: {\n format?: string;\n max_warnings?: number;\n quiet?: boolean;\n fix?: boolean;\n help_level?: string;\n preset?: string;\n },\n ) => LintResult;\n}\n\nfunction loadNative(): NativeBinding {\n const pkg = getBindingPackageName();\n try {\n return require(pkg);\n } catch (e) {\n console.error(`Failed to load native binding: ${pkg}`);\n console.error(\"Try reinstalling: npm install vize\");\n throw e;\n }\n}\n\n// ============================================================================\n// Lint command\n// ============================================================================\n\ninterface LintOptions {\n format?: string;\n maxWarnings?: number;\n quiet?: boolean;\n fix?: boolean;\n helpLevel?: string;\n preset?: string;\n}\n\ninterface LintResult {\n output: string;\n errorCount: number;\n warningCount: number;\n fileCount: number;\n timeMs: number;\n}\n\ninterface SharedConfigOptions {\n configFile?: string;\n configMode: \"root\" | \"none\";\n}\n\ninterface ParsedLintCommand {\n patterns: string[];\n options: LintOptions;\n sharedConfig: SharedConfigOptions;\n}\n\nfunction parseLintCommand(args: string[]): ParsedLintCommand {\n const patterns: string[] = [];\n const options: LintOptions = {};\n const sharedConfig: SharedConfigOptions = {\n configMode: \"root\",\n };\n\n for (let i = 0; i < args.length; i++) {\n const arg = args[i];\n if (arg === \"--format\" || arg === \"-f\") {\n options.format = args[++i];\n } else if (arg === \"--max-warnings\") {\n options.maxWarnings = Number.parseInt(args[++i], 10);\n } else if (arg === \"--quiet\" || arg === \"-q\") {\n options.quiet = true;\n } else if (arg === \"--fix\") {\n options.fix = true;\n } else if (arg === \"--help-level\") {\n options.helpLevel = args[++i];\n } else if (arg === \"--preset\") {\n options.preset = args[++i];\n } else if (arg === \"--config\" || arg === \"-c\") {\n const configFile = args[++i];\n if (!configFile) {\n throw new Error(\"Missing path after --config\");\n }\n sharedConfig.configFile = configFile;\n } else if (arg === \"--no-config\") {\n sharedConfig.configMode = \"none\";\n } else if (!arg.startsWith(\"-\")) {\n patterns.push(arg);\n }\n }\n\n return { patterns, options, sharedConfig };\n}\n\nasync function runLint(args: string[]): Promise<void> {\n const { patterns, options, sharedConfig } = parseLintCommand(args);\n const config = await loadConfig(process.cwd(), {\n mode: sharedConfig.configMode,\n configFile: sharedConfig.configFile,\n env: {\n mode: process.env.NODE_ENV ?? \"development\",\n command: \"lint\",\n },\n });\n\n if (sharedConfig.configFile && !config) {\n throw new Error(`Could not find config file: ${sharedConfig.configFile}`);\n }\n\n if (config?.linter?.enabled === false) {\n process.stderr.write(\"[vize] Skipping lint because linter.enabled is false in vize.config.\\n\");\n return;\n }\n\n options.preset ??= config?.linter?.preset;\n\n if (patterns.length === 0) {\n patterns.push(\".\");\n }\n\n const native = loadNative();\n const result = native.lint(patterns, {\n format: options.format,\n max_warnings: options.maxWarnings,\n quiet: options.quiet,\n fix: options.fix,\n help_level: options.helpLevel,\n preset: options.preset,\n });\n\n if (result.output) {\n process.stdout.write(result.output);\n if (!result.output.endsWith(\"\\n\")) {\n process.stdout.write(\"\\n\");\n }\n }\n\n if (options.fix) {\n process.stderr.write(\"\\nNote: --fix is not yet implemented\\n\");\n }\n\n if (result.errorCount > 0) {\n process.exit(1);\n }\n\n if (options.maxWarnings !== undefined && result.warningCount > options.maxWarnings) {\n process.stderr.write(\n `\\nToo many warnings (${result.warningCount} > max ${options.maxWarnings})\\n`,\n );\n process.exit(1);\n }\n}\n\n// ============================================================================\n// Command router\n// ============================================================================\n\nconst NAPI_COMMANDS = new Set([\"lint\"]);\n\nasync function main(): Promise<void> {\n const args = process.argv.slice(2);\n const command = args[0];\n\n if (!command) {\n console.error(\"Usage: vize <command> [options]\");\n console.error(\"Commands: lint\");\n process.exit(1);\n }\n\n if (NAPI_COMMANDS.has(command)) {\n const commandArgs = args.slice(1);\n switch (command) {\n case \"lint\":\n await runLint(commandArgs);\n break;\n }\n } else {\n console.error(`Unknown command: ${command}`);\n console.error(\n \"For commands not yet available via NAPI, install from source: cargo install vize\",\n );\n process.exit(1);\n }\n}\n\nvoid main().catch((error) => {\n console.error(error instanceof Error ? error.message : String(error));\n process.exit(1);\n});\n"],"mappings":";;;;AAIA,MAAM,UAAU,cAAc,OAAO,KAAK,IAAI;AAM9C,SAAS,SAAkB;CACzB,MAAM,SAAS,QAAQ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