@utoo/lint 0.2.8 → 0.3.4
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 +201 -172
- package/bin/fishlint.js +23 -3
- package/bin/migrate.js +555 -39
- package/bin/utoo-lint.js +15 -15
- package/configs/frontend.d.ts +54 -2
- package/configs/frontend.json +16 -1
- package/index.cjs +277 -60
- package/index.d.ts +14 -1
- package/index.js +277 -60
- package/package.json +13 -11
- package/schema.json +89 -36
package/README.md
CHANGED
|
@@ -2,252 +2,239 @@
|
|
|
2
2
|
|
|
3
3
|

|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
[](https://www.npmjs.com/package/@utoo/lint)
|
|
6
|
+
[](https://nodejs.org/)
|
|
7
|
+
[](https://github.com/utooland/utoo-lint/actions/workflows/ci.yml)
|
|
8
|
+
[](https://github.com/utooland/utoo-lint/blob/main/LICENSE)
|
|
6
9
|
|
|
7
|
-
|
|
10
|
+
A high-performance linter for JavaScript and TypeScript, written in Zig and
|
|
11
|
+
powered by [Yuku](https://github.com/yuku-toolchain/yuku).
|
|
8
12
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
```
|
|
13
|
+
`@utoo/lint` combines a native lint engine with familiar configuration, CLI,
|
|
14
|
+
and JavaScript APIs.
|
|
12
15
|
|
|
13
|
-
|
|
16
|
+
[Installation](#installation) · [Quick start](#quick-start) ·
|
|
17
|
+
[Rules](https://github.com/utooland/utoo-lint/blob/main/docs/rule-status.md) ·
|
|
18
|
+
[Configuration](https://github.com/utooland/utoo-lint/blob/main/docs/configuration.md) ·
|
|
19
|
+
[GitHub](https://github.com/utooland/utoo-lint)
|
|
14
20
|
|
|
15
|
-
|
|
21
|
+
## Why utoo-lint?
|
|
16
22
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
23
|
+
- **Native performance** — Zig and Yuku power parsing, semantic analysis, and
|
|
24
|
+
parallel file linting.
|
|
25
|
+
- **Broad rule coverage** — More than 300 rules cover JavaScript, TypeScript,
|
|
26
|
+
React, JSX accessibility, and imports.
|
|
27
|
+
- **Familiar configuration** — Use typed `utlint.config.ts` or static
|
|
28
|
+
`utlint.config.json`, with ESLint-style rule names and severities.
|
|
29
|
+
- **Practical workflows** — Safe autofix, suppression comments, JSON output,
|
|
30
|
+
and ESM/CommonJS APIs are included.
|
|
31
|
+
- **Portable installation** — Prebuilt binaries are available for macOS,
|
|
32
|
+
Linux, and Windows on supported architectures.
|
|
20
33
|
|
|
21
|
-
|
|
22
|
-
`utlint.config.ts` or `utlint.config.json`. When no config file or `files` entry
|
|
23
|
-
exists, it scans the current directory. It skips `.git`, `.zig-cache`,
|
|
24
|
-
`node_modules`, `vendor`, and `zig-out`.
|
|
34
|
+
## Installation
|
|
25
35
|
|
|
26
|
-
|
|
36
|
+
`@utoo/lint` requires Node.js 20 or later.
|
|
27
37
|
|
|
28
|
-
|
|
29
|
-
pnpm exec utoo-lint --config=utlint.config.json src
|
|
30
|
-
```
|
|
38
|
+
### utoo
|
|
31
39
|
|
|
32
|
-
|
|
40
|
+
[utoo](https://utoo.land/en/docs/utoo) is a fast, npm-compatible package
|
|
41
|
+
manager written in Rust. Install it once if it is not already available:
|
|
33
42
|
|
|
34
43
|
```bash
|
|
35
|
-
|
|
44
|
+
npm install -g utoo
|
|
36
45
|
```
|
|
37
46
|
|
|
38
|
-
|
|
47
|
+
Add `@utoo/lint` as a development dependency:
|
|
39
48
|
|
|
40
49
|
```bash
|
|
41
|
-
|
|
50
|
+
ut install @utoo/lint -D
|
|
42
51
|
```
|
|
43
52
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
automatically; pass `--color` to force it or `--no-color` to disable it. JSON
|
|
47
|
-
output remains stable for editor and CI integrations.
|
|
48
|
-
|
|
49
|
-
## Autofix
|
|
53
|
+
In an existing project, run `ut install` without a package name to install all
|
|
54
|
+
dependencies declared in `package.json`.
|
|
50
55
|
|
|
51
|
-
|
|
56
|
+
### Other package managers
|
|
52
57
|
|
|
53
58
|
```bash
|
|
54
|
-
pnpm
|
|
59
|
+
pnpm add -D @utoo/lint
|
|
60
|
+
npm install --save-dev @utoo/lint
|
|
55
61
|
```
|
|
56
62
|
|
|
57
|
-
|
|
63
|
+
The package selects the native binary for the current platform. No Zig
|
|
64
|
+
toolchain is required.
|
|
65
|
+
|
|
66
|
+
## Quick start
|
|
67
|
+
|
|
68
|
+
### Run with the default rules
|
|
58
69
|
|
|
59
70
|
```bash
|
|
60
|
-
|
|
71
|
+
utx @utoo/lint src
|
|
61
72
|
```
|
|
62
73
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
until the source is stable, subject to a safety pass limit. Diagnostics remain
|
|
66
|
-
when a rule or a particular code shape cannot be fixed safely. The current
|
|
67
|
-
[rule status](https://github.com/fireairforce/utoo-lint/blob/main/docs/rule-status.md)
|
|
68
|
-
lists autofix coverage by rule.
|
|
74
|
+
Without a config file, `utoo-lint` uses its built-in default rules. It supports
|
|
75
|
+
`.js`, `.jsx`, `.ts`, `.tsx`, `.mjs`, `.cjs`, `.mts`, and `.cts` files.
|
|
69
76
|
|
|
70
|
-
|
|
77
|
+
### Add a typed config
|
|
71
78
|
|
|
72
|
-
|
|
79
|
+
Create `utlint.config.ts`:
|
|
73
80
|
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
```
|
|
81
|
+
```ts
|
|
82
|
+
import { defineConfig } from "@utoo/lint/config";
|
|
83
|
+
import frontend from "@utoo/lint/configs/frontend";
|
|
78
84
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
85
|
+
export default defineConfig({
|
|
86
|
+
...frontend,
|
|
87
|
+
ignores: [...frontend.ignores, ".next", "storybook-static"],
|
|
88
|
+
rules: {
|
|
89
|
+
...frontend.rules,
|
|
90
|
+
"no-console": "off",
|
|
91
|
+
"react/no-forward-ref": "off"
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
```
|
|
84
95
|
|
|
85
|
-
|
|
86
|
-
|
|
96
|
+
The frontend preset uses `error` for correctness and safety checks that should
|
|
97
|
+
fail CI, and `warn` for migration or maintainability checks that should remain
|
|
98
|
+
visible without blocking adoption:
|
|
87
99
|
|
|
88
|
-
|
|
100
|
+
| Severity | Added frontend guardrails |
|
|
101
|
+
| --- | --- |
|
|
102
|
+
| `error` | `react-hooks/rules-of-hooks`, `react/jsx-key`, `react/no-children-prop`, `react/no-danger-with-children`, `react/void-dom-elements-no-children`, `no-script-url`, `promise/no-nesting` |
|
|
103
|
+
| `warn` | `react-hooks/exhaustive-deps`, `react/no-array-index-key`, `react/no-unstable-nested-components`, `react/no-forward-ref`, `unused-imports/no-unused-imports`, `@typescript-eslint/no-unused-vars`, `@typescript-eslint/ban-types` |
|
|
89
104
|
|
|
90
|
-
|
|
105
|
+
Override project-specific rules after spreading `frontend.rules`, and append
|
|
106
|
+
framework-generated directories to `frontend.ignores`, as shown above.
|
|
91
107
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
| `utlint.config.ts` | You want typed authoring, imports, or computed values. | No |
|
|
95
|
-
| `utlint.config.json` | You want a static, runtime-independent config. | Yes |
|
|
108
|
+
The preset intentionally enables no formatter or type-checker integration.
|
|
109
|
+
Keep Prettier (or another formatter) and `tsc` as independent project steps.
|
|
96
110
|
|
|
97
|
-
The
|
|
98
|
-
explicitly:
|
|
111
|
+
The CLI discovers the config and uses its `files` patterns:
|
|
99
112
|
|
|
100
113
|
```bash
|
|
101
|
-
|
|
102
|
-
pnpm exec utoo-lint --config=utlint.config.json src
|
|
114
|
+
utx @utoo/lint
|
|
103
115
|
```
|
|
104
116
|
|
|
105
|
-
|
|
106
|
-
|
|
117
|
+
See the
|
|
118
|
+
[configuration guide](https://github.com/utooland/utoo-lint/blob/main/docs/configuration.md)
|
|
119
|
+
for flat config arrays, global ignores, rule options, and config precedence.
|
|
120
|
+
|
|
121
|
+
### Add package scripts
|
|
107
122
|
|
|
108
123
|
```json
|
|
109
124
|
{
|
|
110
|
-
"
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
"rules": {
|
|
114
|
-
"no-console": "off",
|
|
115
|
-
"no-debugger": "error"
|
|
125
|
+
"scripts": {
|
|
126
|
+
"lint": "utoo-lint src",
|
|
127
|
+
"lint:fix": "utoo-lint --fix src"
|
|
116
128
|
}
|
|
117
129
|
}
|
|
118
130
|
```
|
|
119
131
|
|
|
120
|
-
|
|
132
|
+
With utoo, run these scripts as `ut lint` and `ut lint:fix`.
|
|
121
133
|
|
|
122
|
-
|
|
123
|
-
import { defineConfig } from "@utoo/lint/config";
|
|
134
|
+
## Common commands
|
|
124
135
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
});
|
|
133
|
-
```
|
|
136
|
+
| Task | Command |
|
|
137
|
+
| --- | --- |
|
|
138
|
+
| Lint files | `utx @utoo/lint src` |
|
|
139
|
+
| Apply safe fixes | `utx @utoo/lint --fix src` |
|
|
140
|
+
| Preview fixes as JSON | `utx @utoo/lint --fix-dry-run --format=json src` |
|
|
141
|
+
| Select rules for one run | `utx @utoo/lint --rules=no-debugger,no-unused-vars src` |
|
|
142
|
+
| Use an explicit config | `utx @utoo/lint --config=utlint.config.json src` |
|
|
134
143
|
|
|
135
|
-
|
|
144
|
+
Run `utx @utoo/lint --help` for all CLI options.
|
|
136
145
|
|
|
137
|
-
|
|
138
|
-
import { defineConfig } from "@utoo/lint/config";
|
|
139
|
-
import frontend from "@utoo/lint/configs/frontend";
|
|
146
|
+
## Configuration
|
|
140
147
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
rules: {
|
|
144
|
-
...frontend.rules,
|
|
145
|
-
"no-console": "off",
|
|
146
|
-
},
|
|
147
|
-
});
|
|
148
|
-
```
|
|
148
|
+
`utoo-lint` supports two canonical config formats. They are alternative
|
|
149
|
+
representations of one active config and are not merged together.
|
|
149
150
|
|
|
150
|
-
|
|
151
|
-
|
|
151
|
+
| Config | Best for | Raw native binary |
|
|
152
|
+
| --- | --- | --- |
|
|
153
|
+
| `utlint.config.ts` | Typed authoring, imports, presets, and computed values | No |
|
|
154
|
+
| `utlint.config.json` | Static configuration and JSON Schema validation | Yes |
|
|
152
155
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
156
|
+
Rule severities follow ESLint conventions: `off`, `warn`, `error`, `0`, `1`,
|
|
157
|
+
and `2`. A selected config enables only the rules present in its resolved
|
|
158
|
+
`rules` map.
|
|
159
|
+
|
|
160
|
+
The npm CLI and JavaScript API load both formats. The raw native binary loads
|
|
161
|
+
JSON only. See the
|
|
162
|
+
[configuration guide](https://github.com/utooland/utoo-lint/blob/main/docs/configuration.md)
|
|
163
|
+
for the complete behavior.
|
|
164
|
+
|
|
165
|
+
## Autofix
|
|
166
|
+
|
|
167
|
+
Apply safe fixes in place:
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
utx @utoo/lint --fix src
|
|
165
171
|
```
|
|
166
172
|
|
|
167
|
-
|
|
168
|
-
generated `name`. Only such global entries prune directories during target
|
|
169
|
-
discovery. By contrast, `ignores` beside `files`, `rules`, or another config
|
|
170
|
-
key is entry-scoped: it prevents that entry from applying to matching files,
|
|
171
|
-
but does not exclude them from other entries. With no CLI targets, global
|
|
172
|
-
ignores filter the config's `files` patterns, or the current-directory scan
|
|
173
|
-
when no `files` are configured. Directory patterns such as `dist/` and
|
|
174
|
-
`.next/` are relative to the config; use `**/generated/` to match at any depth.
|
|
175
|
-
This intentionally follows [ESLint flat config ignore semantics](https://eslint.org/docs/latest/use/configure/ignore).
|
|
176
|
-
|
|
177
|
-
The two canonical names represent one active config and are not implicitly
|
|
178
|
-
merged. For the npm/Node entry point, discovery is nearest-directory-first.
|
|
179
|
-
Within the same directory, `utlint.config.ts` takes precedence over
|
|
180
|
-
`utlint.config.json`; deprecated `utoo.json` and `utoo-lint.json` files are
|
|
181
|
-
checked afterward for temporary backward compatibility. Rule-related CLI
|
|
182
|
-
options such as `--rules`, individual rule toggles, and fishlint's `--rule` are
|
|
183
|
-
applied after the selected config.
|
|
184
|
-
|
|
185
|
-
Project-config `files` and `ignores` patterns are relative to the selected
|
|
186
|
-
config file's directory. In a flat config array, they select the entries that
|
|
187
|
-
apply to each file; matching entries are combined in order and later rule
|
|
188
|
-
values override earlier values. The npm CLI, JavaScript API, and fishlint
|
|
189
|
-
compatibility command perform this rule resolution per file.
|
|
190
|
-
|
|
191
|
-
TypeScript config is trusted executable code. Its default export must be a
|
|
192
|
-
JSON-serializable object or flat config array. The npm wrapper executes it and
|
|
193
|
-
materializes the result as JSON before invoking the native binary. The raw
|
|
194
|
-
binary does not execute or discover TypeScript; it searches for
|
|
195
|
-
`utlint.config.json` and then the legacy JSON names. Direct native use therefore
|
|
196
|
-
requires a JSON config. The raw binary applies only its `rules`;
|
|
197
|
-
config-driven `files` and `ignores` filtering and default target selection are
|
|
198
|
-
npm/Node wrapper features. Pass lint targets explicitly when invoking the raw
|
|
199
|
-
binary. As in ESLint, selecting a config disables rules not present in its
|
|
200
|
-
resolved `rules` map. When no config is selected, utoo-lint uses its built-in
|
|
201
|
-
default rules.
|
|
202
|
-
|
|
203
|
-
Rule severities use ESLint's exit behavior: warnings are reported with exit
|
|
204
|
-
status 0, while errors return exit status 1. Use fishlint's `--max-warnings`
|
|
205
|
-
option when warnings should fail CI.
|
|
206
|
-
|
|
207
|
-
Start from the packaged frontend template:
|
|
173
|
+
Preview fixes without writing files:
|
|
208
174
|
|
|
209
175
|
```bash
|
|
210
|
-
|
|
176
|
+
utx @utoo/lint --fix-dry-run --format=json src
|
|
211
177
|
```
|
|
212
178
|
|
|
213
|
-
|
|
179
|
+
Fixes run until the source is stable, subject to a safety pass limit. The
|
|
180
|
+
[rule status](https://github.com/utooland/utoo-lint/blob/main/docs/rule-status.md)
|
|
181
|
+
documents autofix support for each rule.
|
|
214
182
|
|
|
215
|
-
|
|
183
|
+
## Suppression comments
|
|
216
184
|
|
|
217
|
-
|
|
218
|
-
|
|
185
|
+
Use suppression comments for intentional exceptions without disabling a rule
|
|
186
|
+
in project configuration:
|
|
187
|
+
|
|
188
|
+
```js
|
|
189
|
+
// utlint-ignore no-debugger: generated breakpoint
|
|
190
|
+
debugger;
|
|
219
191
|
```
|
|
220
192
|
|
|
221
|
-
|
|
193
|
+
| Directive | Scope |
|
|
194
|
+
| --- | --- |
|
|
195
|
+
| `utlint-ignore [rule]` | The next line of code |
|
|
196
|
+
| `utlint-ignore-all [rule]` | The entire file when placed before any code |
|
|
197
|
+
| `utlint-ignore-start [rule]` | The start of a suppressed range |
|
|
198
|
+
| `utlint-ignore-end [rule]` | The end of a suppressed range |
|
|
199
|
+
|
|
200
|
+
A directive may target one rule ID. Omitting it creates or closes an all-rules
|
|
201
|
+
suppression. Parse errors are never suppressed, and suppressed fixes are not
|
|
202
|
+
applied.
|
|
203
|
+
|
|
204
|
+
See the
|
|
205
|
+
[suppression comments guide](https://github.com/utooland/utoo-lint/blob/main/docs/suppressions.md)
|
|
206
|
+
for range examples and API behavior.
|
|
207
|
+
|
|
208
|
+
## Migrating from ESLint
|
|
209
|
+
|
|
210
|
+
Convert an existing ESLint config into a native utoo-lint config:
|
|
222
211
|
|
|
223
212
|
```bash
|
|
224
|
-
|
|
225
|
-
|
|
213
|
+
utx @utoo/lint migrate eslint \
|
|
214
|
+
--from eslint.config.js \
|
|
215
|
+
--output utlint.config.json
|
|
226
216
|
```
|
|
227
217
|
|
|
218
|
+
The package also exposes `eslint` and `fishlint` compatibility commands for
|
|
219
|
+
incremental replacement workflows. See the
|
|
220
|
+
[migration guide](https://github.com/utooland/utoo-lint/blob/main/docs/eslint-migration.md)
|
|
221
|
+
for supported mappings and known differences.
|
|
222
|
+
|
|
228
223
|
## JavaScript API
|
|
229
224
|
|
|
225
|
+
The package provides ESM and CommonJS entry points:
|
|
226
|
+
|
|
230
227
|
```js
|
|
231
228
|
import { lintFiles } from "@utoo/lint";
|
|
232
229
|
|
|
233
230
|
const report = lintFiles(["src"], {
|
|
234
|
-
config: "utlint.config.
|
|
235
|
-
rules: ["no-debugger"]
|
|
231
|
+
config: "utlint.config.ts"
|
|
236
232
|
});
|
|
237
233
|
|
|
238
234
|
console.log(report.diagnostics);
|
|
239
235
|
```
|
|
240
236
|
|
|
241
|
-
|
|
242
|
-
as the CLI, so migration scripts usually do not need to expand config `files`
|
|
243
|
-
manually.
|
|
244
|
-
|
|
245
|
-
CommonJS is supported through `require("@utoo/lint")`.
|
|
246
|
-
|
|
247
|
-
Set `fix: true` to compute fixed output through the JavaScript API. Raw
|
|
248
|
-
`lintFiles()` and `lintText()` reports expose changed sources in `outputs`
|
|
249
|
-
without writing them. The ESLint-compatible API follows the usual two-step
|
|
250
|
-
flow:
|
|
237
|
+
An ESLint-style API is also available:
|
|
251
238
|
|
|
252
239
|
```js
|
|
253
240
|
import { ESLint } from "@utoo/lint";
|
|
@@ -257,8 +244,50 @@ const results = await eslint.lintFiles(["src"]);
|
|
|
257
244
|
await ESLint.outputFixes(results);
|
|
258
245
|
```
|
|
259
246
|
|
|
260
|
-
|
|
247
|
+
Raw reports include active diagnostics, suppressed diagnostics, fixed outputs,
|
|
248
|
+
and an exit code. The compatibility layer also exports `Linter`, `CLIEngine`,
|
|
249
|
+
`RuleTester`, and `SourceCode` APIs.
|
|
250
|
+
|
|
251
|
+
The Node wrapper captures up to 64 MiB from each native stdout and stderr
|
|
252
|
+
stream by default. Programmatic `run`, `runCli`, and `runFishlint` calls can set
|
|
253
|
+
`maxBuffer` to another positive byte count. Set `UTOO_LINT_MAX_BUFFER` to apply
|
|
254
|
+
the same limit to CLI invocations; output beyond the configured bound reports
|
|
255
|
+
`ENOBUFS` instead of being truncated.
|
|
256
|
+
|
|
257
|
+
## WebAssembly
|
|
258
|
+
|
|
259
|
+
For browser playgrounds and in-memory Node ESM usage, install the independent
|
|
260
|
+
`@utoo/lint-wasm` package. It ships a freestanding WebAssembly module rather
|
|
261
|
+
than selecting one of the native platform packages used by `@utoo/lint`.
|
|
262
|
+
|
|
263
|
+
See the
|
|
264
|
+
[WebAssembly guide](https://github.com/utooland/utoo-lint/blob/main/docs/wasm.md)
|
|
265
|
+
for its API, runtime boundaries, and Web Worker recommendation.
|
|
266
|
+
|
|
267
|
+
## Supported platforms
|
|
268
|
+
|
|
269
|
+
The package installs a platform-specific optional dependency containing the
|
|
270
|
+
native binary.
|
|
271
|
+
|
|
272
|
+
| Operating system | Architectures |
|
|
273
|
+
| --- | --- |
|
|
274
|
+
| macOS | arm64, x64 |
|
|
275
|
+
| Linux | arm64, x64 |
|
|
276
|
+
| Windows | x64 |
|
|
277
|
+
|
|
278
|
+
Set `UTOO_LINT_BIN=/path/to/utoo-lint` to use a custom binary during local
|
|
279
|
+
development.
|
|
280
|
+
|
|
281
|
+
## Documentation
|
|
282
|
+
|
|
283
|
+
- [Rule status](https://github.com/utooland/utoo-lint/blob/main/docs/rule-status.md)
|
|
284
|
+
- [Configuration](https://github.com/utooland/utoo-lint/blob/main/docs/configuration.md)
|
|
285
|
+
- [Suppression comments](https://github.com/utooland/utoo-lint/blob/main/docs/suppressions.md)
|
|
286
|
+
- [WebAssembly](https://github.com/utooland/utoo-lint/blob/main/docs/wasm.md)
|
|
287
|
+
- [Migrating from ESLint](https://github.com/utooland/utoo-lint/blob/main/docs/eslint-migration.md)
|
|
288
|
+
- [Benchmarks](https://github.com/utooland/utoo-lint/tree/main/benchmarks)
|
|
289
|
+
- [Security policy](https://github.com/utooland/utoo-lint/blob/main/SECURITY.md)
|
|
290
|
+
|
|
291
|
+
## License
|
|
261
292
|
|
|
262
|
-
|
|
263
|
-
native `utoo-lint` binary. Set `UTOO_LINT_BIN=/path/to/utoo-lint` to force a
|
|
264
|
-
specific binary during local development.
|
|
293
|
+
[MIT](https://github.com/utooland/utoo-lint/blob/main/LICENSE)
|
package/bin/fishlint.js
CHANGED
|
@@ -61,6 +61,8 @@ const STYLELINT_VALUE_FLAGS = new Set([
|
|
|
61
61
|
"-f",
|
|
62
62
|
"-o"
|
|
63
63
|
]);
|
|
64
|
+
const DEFAULT_NATIVE_MAX_BUFFER = 64 * 1024 * 1024;
|
|
65
|
+
const nativeOutputMaxBuffer = readNativeMaxBuffer();
|
|
64
66
|
|
|
65
67
|
if (isVersionRequest(values)) {
|
|
66
68
|
printVersion();
|
|
@@ -182,7 +184,10 @@ const needsReportOutput =
|
|
|
182
184
|
ignoredFiltered.diagnostics.length > 0 ||
|
|
183
185
|
usesJsonWithMetadataFormat(nativeValues) ||
|
|
184
186
|
ruleResolution.configuredRules.size > 0;
|
|
185
|
-
const result = spawnSync(binary, needsReportOutput ? withJsonFormat(ruleConfig.args) : ruleConfig.args, {
|
|
187
|
+
const result = spawnSync(binary, needsReportOutput ? withJsonFormat(ruleConfig.args) : ruleConfig.args, {
|
|
188
|
+
encoding: "utf8",
|
|
189
|
+
maxBuffer: nativeOutputMaxBuffer
|
|
190
|
+
});
|
|
186
191
|
|
|
187
192
|
if (result.error) {
|
|
188
193
|
console.error(`utoo-lint: failed to run native binary: ${result.error.message}`);
|
|
@@ -1102,7 +1107,7 @@ function runFlatConfigGroups(binary, translatedArgs, selectedConfig, ruleOverrid
|
|
|
1102
1107
|
...withoutConfigAndTargets(translatedArgs),
|
|
1103
1108
|
`--config=${runtimeConfig.file}`,
|
|
1104
1109
|
...group.files
|
|
1105
|
-
]), { encoding: "utf8" });
|
|
1110
|
+
]), { encoding: "utf8", maxBuffer: nativeOutputMaxBuffer });
|
|
1106
1111
|
cleanupRuleConfig(runtimeConfig);
|
|
1107
1112
|
if (result.error) {
|
|
1108
1113
|
return { error: result.error };
|
|
@@ -1500,13 +1505,28 @@ function parseJsonReport(stdout) {
|
|
|
1500
1505
|
}
|
|
1501
1506
|
|
|
1502
1507
|
function jsonDiagnosticCounts(binary, args) {
|
|
1503
|
-
const result = spawnSync(binary, withJsonFormat(args), {
|
|
1508
|
+
const result = spawnSync(binary, withJsonFormat(args), {
|
|
1509
|
+
encoding: "utf8",
|
|
1510
|
+
maxBuffer: nativeOutputMaxBuffer
|
|
1511
|
+
});
|
|
1504
1512
|
if (result.error) {
|
|
1505
1513
|
return null;
|
|
1506
1514
|
}
|
|
1507
1515
|
return diagnosticCounts(result.stdout ?? "");
|
|
1508
1516
|
}
|
|
1509
1517
|
|
|
1518
|
+
function readNativeMaxBuffer() {
|
|
1519
|
+
const configured = process.env.UTOO_LINT_MAX_BUFFER;
|
|
1520
|
+
if (configured === undefined || configured === "") {
|
|
1521
|
+
return DEFAULT_NATIVE_MAX_BUFFER;
|
|
1522
|
+
}
|
|
1523
|
+
const value = Number(configured);
|
|
1524
|
+
if (!Number.isSafeInteger(value) || value <= 0) {
|
|
1525
|
+
throw new TypeError("UTOO_LINT_MAX_BUFFER must be a positive integer byte count");
|
|
1526
|
+
}
|
|
1527
|
+
return value;
|
|
1528
|
+
}
|
|
1529
|
+
|
|
1510
1530
|
function withJsonFormat(args) {
|
|
1511
1531
|
const values = [];
|
|
1512
1532
|
let foundFormat = false;
|