oxlint-tui 1.0.0 → 1.0.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/README.md +1 -1
- package/package.json +2 -2
- package/tui.js +7 -2
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ A lightweight, dependency-free Node.js Terminal User Interface (TUI) for browsin
|
|
|
4
4
|
|
|
5
5
|
It automatically loads your local configuration to show you the status of the rules toggled in your project.
|
|
6
6
|
|
|
7
|
-

|
|
7
|
+

|
|
8
8
|
|
|
9
9
|
## Why?
|
|
10
10
|
|
package/package.json
CHANGED
package/tui.js
CHANGED
|
@@ -117,6 +117,10 @@ function getRuleStatus(ruleName, category, config) {
|
|
|
117
117
|
return 'off';
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
+
function stripJsonComments(json) {
|
|
121
|
+
return json.replace(/\\"|"(?:\\"|[^"])*"|(\/\/.*|\/\*[\s\S]*?\*\/)/g, (m, g) => g ? "" : m);
|
|
122
|
+
}
|
|
123
|
+
|
|
120
124
|
function loadRules() {
|
|
121
125
|
let rulesData;
|
|
122
126
|
let config = { rules: {}, categories: {} };
|
|
@@ -145,7 +149,9 @@ function loadRules() {
|
|
|
145
149
|
if (configPathToLoad) {
|
|
146
150
|
try {
|
|
147
151
|
const configFile = fs.readFileSync(configPathToLoad, 'utf8');
|
|
148
|
-
|
|
152
|
+
const cleanConfig = stripJsonComments(configFile);
|
|
153
|
+
config = JSON.parse(cleanConfig);
|
|
154
|
+
|
|
149
155
|
} catch (e) {
|
|
150
156
|
console.error(`${COLORS.error}Error: Failed to parse '${configPathToLoad}'.${COLORS.reset}`);
|
|
151
157
|
console.error(`${COLORS.warn}${e.message}${COLORS.reset}`);
|
|
@@ -171,7 +177,6 @@ function loadRules() {
|
|
|
171
177
|
|
|
172
178
|
const categories = Object.keys(map).sort();
|
|
173
179
|
|
|
174
|
-
// Sort rules - active first, then Alphabetical
|
|
175
180
|
categories.forEach(c => {
|
|
176
181
|
map[c].sort((a, b) => {
|
|
177
182
|
if (a.isActive && !b.isActive) return -1;
|