oxlint-tui 1.1.0 → 1.1.2
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 +16 -13
- package/dist/rendering.js +5 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import fs from "node:fs";
|
|
3
3
|
import readline from "readline";
|
|
4
|
-
import { execSync,
|
|
4
|
+
import { execSync, spawn } from "node:child_process";
|
|
5
5
|
import { stdout, stdin, exit, platform, argv } from "node:process";
|
|
6
|
-
import {} from "./types.js";
|
|
7
6
|
import { render } from "./rendering.js";
|
|
8
7
|
const OXLINT_VERSION = "1.41.0";
|
|
9
8
|
const TSGOLINT_VERSION = "0.11.1";
|
|
@@ -25,7 +24,7 @@ const KEY_MAP = {
|
|
|
25
24
|
r: { type: "RUN_LINT" },
|
|
26
25
|
x: { type: "RUN_SINGLE_RULE" },
|
|
27
26
|
};
|
|
28
|
-
let state = {
|
|
27
|
+
export let state = {
|
|
29
28
|
activePane: 0,
|
|
30
29
|
selectedCategoryIndex: 0,
|
|
31
30
|
selectedRuleIndex: 0,
|
|
@@ -72,7 +71,7 @@ function runLint({ rule = null } = {}) {
|
|
|
72
71
|
state.message += " with --type-aware";
|
|
73
72
|
state.message += "...";
|
|
74
73
|
state.messageType = "info";
|
|
75
|
-
render(
|
|
74
|
+
render();
|
|
76
75
|
const npxCmd = platform === "win32" ? "npx.cmd" : "npx";
|
|
77
76
|
const args = ["-q", "--yes", "--package", `oxlint@${OXLINT_VERSION}`];
|
|
78
77
|
if (typeAware) {
|
|
@@ -120,7 +119,7 @@ function runLint({ rule = null } = {}) {
|
|
|
120
119
|
state.message = cleanError ? `Error: ${cleanError.substring(0, 50)}...` : "Lint failed";
|
|
121
120
|
state.messageType = "error";
|
|
122
121
|
}
|
|
123
|
-
render(
|
|
122
|
+
render();
|
|
124
123
|
});
|
|
125
124
|
}
|
|
126
125
|
function execute(action) {
|
|
@@ -176,19 +175,19 @@ function execute(action) {
|
|
|
176
175
|
[currentCategory]: updatedRules,
|
|
177
176
|
},
|
|
178
177
|
};
|
|
179
|
-
render(
|
|
178
|
+
render();
|
|
180
179
|
return;
|
|
181
180
|
}
|
|
182
181
|
case "MOVE_RIGHT":
|
|
183
182
|
if (activePane !== 1) {
|
|
184
183
|
state = { ...state, activePane: activePane + 1 };
|
|
185
|
-
render(
|
|
184
|
+
render();
|
|
186
185
|
}
|
|
187
186
|
return;
|
|
188
187
|
case "MOVE_LEFT":
|
|
189
188
|
if (activePane !== 0) {
|
|
190
189
|
state = { ...state, activePane: activePane - 1 };
|
|
191
|
-
render(
|
|
190
|
+
render();
|
|
192
191
|
}
|
|
193
192
|
return;
|
|
194
193
|
case "MOVE_UP":
|
|
@@ -210,7 +209,7 @@ function execute(action) {
|
|
|
210
209
|
ruleScroll: updateScroll(nextIndex, state.ruleScroll, viewportHeight),
|
|
211
210
|
};
|
|
212
211
|
}
|
|
213
|
-
render(
|
|
212
|
+
render();
|
|
214
213
|
return;
|
|
215
214
|
case "MOVE_DOWN":
|
|
216
215
|
if (activePane === 0) {
|
|
@@ -231,7 +230,7 @@ function execute(action) {
|
|
|
231
230
|
ruleScroll: updateScroll(nextIndex, state.ruleScroll, viewportHeight),
|
|
232
231
|
};
|
|
233
232
|
}
|
|
234
|
-
render(
|
|
233
|
+
render();
|
|
235
234
|
return;
|
|
236
235
|
}
|
|
237
236
|
}
|
|
@@ -321,8 +320,12 @@ function updateScroll(idx, currentScroll, viewHeight) {
|
|
|
321
320
|
function openUrl(url) {
|
|
322
321
|
if (!url)
|
|
323
322
|
return;
|
|
324
|
-
const
|
|
325
|
-
|
|
323
|
+
const cmd = platform === "darwin" ? "open" : platform === "win32" ? "explorer" : "xdg-open";
|
|
324
|
+
const process = spawn(cmd, [url], {
|
|
325
|
+
detached: true,
|
|
326
|
+
stdio: "ignore",
|
|
327
|
+
});
|
|
328
|
+
process.unref();
|
|
326
329
|
}
|
|
327
330
|
const write = (str) => stdout.write(str);
|
|
328
331
|
const enterAltScreen = () => write("\x1b[?1049h\x1b[?25l");
|
|
@@ -337,4 +340,4 @@ stdin.on("keypress", (_, key) => {
|
|
|
337
340
|
});
|
|
338
341
|
stdout.on("resize", render);
|
|
339
342
|
enterAltScreen();
|
|
340
|
-
render(
|
|
343
|
+
render();
|
package/dist/rendering.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { state } from "./index.js";
|
|
1
2
|
import { stdout } from "node:process";
|
|
2
3
|
export const COLORS = {
|
|
3
4
|
reset: "\x1b[0m",
|
|
@@ -129,7 +130,10 @@ function drawDetails(buffer, x, y, width, height, rule, isActive) {
|
|
|
129
130
|
});
|
|
130
131
|
});
|
|
131
132
|
}
|
|
132
|
-
export function render(
|
|
133
|
+
export function render() {
|
|
134
|
+
if (!state || !state.categories) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
133
137
|
const { columns = 80, rows = 24 } = stdout;
|
|
134
138
|
const currentCategory = state.categories[state.selectedCategoryIndex];
|
|
135
139
|
const rules = state.rulesByCategory[currentCategory] || [];
|