@utoo/lint 0.2.9 → 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 CHANGED
@@ -79,22 +79,35 @@ Without a config file, `utoo-lint` uses its built-in default rules. It supports
79
79
  Create `utlint.config.ts`:
80
80
 
81
81
  ```ts
82
- import { defineConfig, globalIgnores } from "@utoo/lint/config";
82
+ import { defineConfig } from "@utoo/lint/config";
83
83
  import frontend from "@utoo/lint/configs/frontend";
84
84
 
85
- export default defineConfig(
86
- globalIgnores(["dist/", "coverage/"]),
87
- {
88
- ...frontend,
89
- files: ["src/**/*.{js,jsx,ts,tsx}"],
90
- rules: {
91
- ...frontend.rules,
92
- "no-console": "warn"
93
- }
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"
94
92
  }
95
- );
93
+ });
96
94
  ```
97
95
 
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:
99
+
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` |
104
+
105
+ Override project-specific rules after spreading `frontend.rules`, and append
106
+ framework-generated directories to `frontend.ignores`, as shown above.
107
+
108
+ The preset intentionally enables no formatter or type-checker integration.
109
+ Keep Prettier (or another formatter) and `tsc` as independent project steps.
110
+
98
111
  The CLI discovers the config and uses its `files` patterns:
99
112
 
100
113
  ```bash
@@ -235,6 +248,22 @@ Raw reports include active diagnostics, suppressed diagnostics, fixed outputs,
235
248
  and an exit code. The compatibility layer also exports `Linter`, `CLIEngine`,
236
249
  `RuleTester`, and `SourceCode` APIs.
237
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
+
238
267
  ## Supported platforms
239
268
 
240
269
  The package installs a platform-specific optional dependency containing the
@@ -254,6 +283,7 @@ development.
254
283
  - [Rule status](https://github.com/utooland/utoo-lint/blob/main/docs/rule-status.md)
255
284
  - [Configuration](https://github.com/utooland/utoo-lint/blob/main/docs/configuration.md)
256
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)
257
287
  - [Migrating from ESLint](https://github.com/utooland/utoo-lint/blob/main/docs/eslint-migration.md)
258
288
  - [Benchmarks](https://github.com/utooland/utoo-lint/tree/main/benchmarks)
259
289
  - [Security policy](https://github.com/utooland/utoo-lint/blob/main/SECURITY.md)
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, { encoding: "utf8" });
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), { encoding: "utf8" });
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;