@utoo/lint 0.2.1 → 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 +57 -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:
|
|
@@ -64,7 +64,8 @@ lists autofix coverage by rule.
|
|
|
64
64
|
|
|
65
65
|
## Configuration
|
|
66
66
|
|
|
67
|
-
|
|
67
|
+
For a static config readable by both the npm CLI and raw native binary, create
|
|
68
|
+
`utlint.config.json`:
|
|
68
69
|
|
|
69
70
|
```json
|
|
70
71
|
{
|
|
@@ -78,10 +79,55 @@ Create a `utoo.json` file:
|
|
|
78
79
|
}
|
|
79
80
|
```
|
|
80
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
|
+
|
|
81
127
|
Start from the packaged frontend template:
|
|
82
128
|
|
|
83
129
|
```bash
|
|
84
|
-
cp node_modules/@utoo/lint/configs/frontend.json
|
|
130
|
+
cp node_modules/@utoo/lint/configs/frontend.json utlint.config.json
|
|
85
131
|
```
|
|
86
132
|
|
|
87
133
|
## ESLint Migration
|
|
@@ -89,14 +135,14 @@ cp node_modules/@utoo/lint/configs/frontend.json utoo.json
|
|
|
89
135
|
Convert an existing ESLint config into the native utoo format:
|
|
90
136
|
|
|
91
137
|
```bash
|
|
92
|
-
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
|
|
93
139
|
```
|
|
94
140
|
|
|
95
141
|
The package also provides compatibility bins for common replacement flows:
|
|
96
142
|
|
|
97
143
|
```bash
|
|
98
|
-
pnpm exec eslint --config
|
|
99
|
-
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
|
|
100
146
|
```
|
|
101
147
|
|
|
102
148
|
## JavaScript API
|
|
@@ -105,7 +151,7 @@ pnpm exec fishlint eslint --disable-setup --config utoo.json --glob src
|
|
|
105
151
|
import { lintFiles } from "@utoo/lint";
|
|
106
152
|
|
|
107
153
|
const report = lintFiles(["src"], {
|
|
108
|
-
config: "
|
|
154
|
+
config: "utlint.config.json",
|
|
109
155
|
rules: ["no-debugger"]
|
|
110
156
|
});
|
|
111
157
|
|