@utoo/lint 0.2.0 → 0.2.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 +91 -11
- package/bin/fishlint.js +429 -64
- package/bin/migrate.js +8 -6
- package/index.cjs +275 -130
- package/index.d.ts +5 -1
- package/index.js +275 -130
- package/lib/config-loader.cjs +87 -0
- package/lib/config-loader.js +81 -0
- package/lib/load-config.js +23 -0
- package/package.json +15 -6
- package/schema.json +1 -1
package/README.md
CHANGED
|
@@ -18,15 +18,15 @@ Run the linter with:
|
|
|
18
18
|
pnpm exec utoo-lint src
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
If no target is provided, `utoo-lint` uses `files` from
|
|
22
|
-
`
|
|
23
|
-
current directory. It skips `.git`, `.zig-cache`,
|
|
24
|
-
`zig-out`.
|
|
21
|
+
If no target is provided, `utoo-lint` uses `files` from the selected
|
|
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`.
|
|
25
25
|
|
|
26
26
|
Use a config file:
|
|
27
27
|
|
|
28
28
|
```bash
|
|
29
|
-
pnpm exec utoo-lint --config=
|
|
29
|
+
pnpm exec utoo-lint --config=utlint.config.json src
|
|
30
30
|
```
|
|
31
31
|
|
|
32
32
|
Run a focused rule set:
|
|
@@ -41,9 +41,31 @@ Use machine-readable output:
|
|
|
41
41
|
pnpm exec utoo-lint --format=json src
|
|
42
42
|
```
|
|
43
43
|
|
|
44
|
+
## Autofix
|
|
45
|
+
|
|
46
|
+
Apply safe fixes from all enabled rules that support autofix:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
pnpm exec utoo-lint --fix src
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Preview the result without changing files:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
pnpm exec utoo-lint --fix-dry-run --format=json src
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
`--fix` writes fixed source back to disk. `--fix-dry-run` never writes files;
|
|
59
|
+
with JSON output, changed sources are returned in the `outputs` array. Fixes run
|
|
60
|
+
until the source is stable, subject to a safety pass limit. Diagnostics remain
|
|
61
|
+
when a rule or a particular code shape cannot be fixed safely. The current
|
|
62
|
+
[rule status](https://github.com/fireairforce/utoo-lint/blob/main/docs/rule-status.md)
|
|
63
|
+
lists autofix coverage by rule.
|
|
64
|
+
|
|
44
65
|
## Configuration
|
|
45
66
|
|
|
46
|
-
|
|
67
|
+
For a static config readable by both the npm CLI and raw native binary, create
|
|
68
|
+
`utlint.config.json`:
|
|
47
69
|
|
|
48
70
|
```json
|
|
49
71
|
{
|
|
@@ -57,10 +79,55 @@ Create a `utoo.json` file:
|
|
|
57
79
|
}
|
|
58
80
|
```
|
|
59
81
|
|
|
82
|
+
For a typed config executed by the npm/Node CLI, create `utlint.config.ts`:
|
|
83
|
+
|
|
84
|
+
```ts
|
|
85
|
+
import { defineConfig } from "@utoo/lint/config";
|
|
86
|
+
|
|
87
|
+
export default defineConfig({
|
|
88
|
+
files: ["src/**/*.{js,jsx,ts,tsx}"],
|
|
89
|
+
ignores: ["dist", "node_modules"],
|
|
90
|
+
rules: {
|
|
91
|
+
"no-console": "off",
|
|
92
|
+
"no-debugger": "error"
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
The two canonical names represent one active config and are not implicitly
|
|
98
|
+
merged. For the npm/Node entry point, discovery is nearest-directory-first.
|
|
99
|
+
Within the same directory, `utlint.config.ts` takes precedence over
|
|
100
|
+
`utlint.config.json`; deprecated `utoo.json` and `utoo-lint.json` files are
|
|
101
|
+
checked afterward for temporary backward compatibility. Rule-related CLI
|
|
102
|
+
options such as `--rules`, individual rule toggles, and fishlint's `--rule` are
|
|
103
|
+
applied after the selected config.
|
|
104
|
+
|
|
105
|
+
Project-config `files` and `ignores` patterns are relative to the selected
|
|
106
|
+
config file's directory. In a flat config array, they select the entries that
|
|
107
|
+
apply to each file; matching entries are combined in order and later rule
|
|
108
|
+
values override earlier values. The npm CLI, JavaScript API, and fishlint
|
|
109
|
+
compatibility command perform this rule resolution per file.
|
|
110
|
+
|
|
111
|
+
TypeScript config is trusted executable code. Its default export must be a
|
|
112
|
+
JSON-serializable object or flat config array. The npm wrapper executes it and
|
|
113
|
+
materializes the result as JSON before invoking the native binary. The raw
|
|
114
|
+
binary does not execute or discover TypeScript; it searches for
|
|
115
|
+
`utlint.config.json` and then the legacy JSON names. Direct native use therefore
|
|
116
|
+
requires a JSON config. The raw binary applies only its `rules`;
|
|
117
|
+
config-driven `files` and `ignores` filtering and default target selection are
|
|
118
|
+
npm/Node wrapper features. Pass lint targets explicitly when invoking the raw
|
|
119
|
+
binary. As in ESLint, selecting a config disables rules not present in its
|
|
120
|
+
resolved `rules` map. When no config is selected, utoo-lint uses its built-in
|
|
121
|
+
default rules.
|
|
122
|
+
|
|
123
|
+
Rule severities use ESLint's exit behavior: warnings are reported with exit
|
|
124
|
+
status 0, while errors return exit status 1. Use fishlint's `--max-warnings`
|
|
125
|
+
option when warnings should fail CI.
|
|
126
|
+
|
|
60
127
|
Start from the packaged frontend template:
|
|
61
128
|
|
|
62
129
|
```bash
|
|
63
|
-
cp node_modules/@utoo/lint/configs/frontend.json
|
|
130
|
+
cp node_modules/@utoo/lint/configs/frontend.json utlint.config.json
|
|
64
131
|
```
|
|
65
132
|
|
|
66
133
|
## ESLint Migration
|
|
@@ -68,14 +135,14 @@ cp node_modules/@utoo/lint/configs/frontend.json utoo.json
|
|
|
68
135
|
Convert an existing ESLint config into the native utoo format:
|
|
69
136
|
|
|
70
137
|
```bash
|
|
71
|
-
pnpm exec utoo-lint migrate eslint --from eslint.config.js --output
|
|
138
|
+
pnpm exec utoo-lint migrate eslint --from eslint.config.js --output utlint.config.json
|
|
72
139
|
```
|
|
73
140
|
|
|
74
141
|
The package also provides compatibility bins for common replacement flows:
|
|
75
142
|
|
|
76
143
|
```bash
|
|
77
|
-
pnpm exec eslint --config
|
|
78
|
-
pnpm exec fishlint eslint --disable-setup --config
|
|
144
|
+
pnpm exec eslint --config utlint.config.json src
|
|
145
|
+
pnpm exec fishlint eslint --disable-setup --config utlint.config.json --glob src
|
|
79
146
|
```
|
|
80
147
|
|
|
81
148
|
## JavaScript API
|
|
@@ -84,7 +151,7 @@ pnpm exec fishlint eslint --disable-setup --config utoo.json --glob src
|
|
|
84
151
|
import { lintFiles } from "@utoo/lint";
|
|
85
152
|
|
|
86
153
|
const report = lintFiles(["src"], {
|
|
87
|
-
config: "
|
|
154
|
+
config: "utlint.config.json",
|
|
88
155
|
rules: ["no-debugger"]
|
|
89
156
|
});
|
|
90
157
|
|
|
@@ -97,6 +164,19 @@ manually.
|
|
|
97
164
|
|
|
98
165
|
CommonJS is supported through `require("@utoo/lint")`.
|
|
99
166
|
|
|
167
|
+
Set `fix: true` to compute fixed output through the JavaScript API. Raw
|
|
168
|
+
`lintFiles()` and `lintText()` reports expose changed sources in `outputs`
|
|
169
|
+
without writing them. The ESLint-compatible API follows the usual two-step
|
|
170
|
+
flow:
|
|
171
|
+
|
|
172
|
+
```js
|
|
173
|
+
import { ESLint } from "@utoo/lint";
|
|
174
|
+
|
|
175
|
+
const eslint = new ESLint({ fix: true });
|
|
176
|
+
const results = await eslint.lintFiles(["src"]);
|
|
177
|
+
await ESLint.outputFixes(results);
|
|
178
|
+
```
|
|
179
|
+
|
|
100
180
|
## Binary Resolution
|
|
101
181
|
|
|
102
182
|
`@utoo/lint` installs a platform-specific optional dependency containing the
|