@utoo/lint 0.2.1 → 0.2.3

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
@@ -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 `utoo.json` or
22
- `utoo-lint.json`. When no config file or `files` entry exists, it scans the
23
- current directory. It skips `.git`, `.zig-cache`, `node_modules`, `vendor`, and
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=utoo.json src
29
+ pnpm exec utoo-lint --config=utlint.config.json src
30
30
  ```
31
31
 
32
32
  Run a focused rule set:
@@ -64,7 +64,23 @@ lists autofix coverage by rule.
64
64
 
65
65
  ## Configuration
66
66
 
67
- Create a `utoo.json` file:
67
+ `utoo-lint` supports two canonical project config formats:
68
+
69
+ | Config | Use it when | Raw native binary |
70
+ | --- | --- | --- |
71
+ | `utlint.config.ts` | You want typed authoring, imports, or computed values. | No |
72
+ | `utlint.config.json` | You want a static, runtime-independent config. | Yes |
73
+
74
+ The npm CLI discovers either format automatically. It can also select one
75
+ explicitly:
76
+
77
+ ```bash
78
+ pnpm exec utoo-lint --config=utlint.config.ts src
79
+ pnpm exec utoo-lint --config=utlint.config.json src
80
+ ```
81
+
82
+ For a static config readable by both the npm CLI and raw native binary, create
83
+ `utlint.config.json`:
68
84
 
69
85
  ```json
70
86
  {
@@ -78,10 +94,55 @@ Create a `utoo.json` file:
78
94
  }
79
95
  ```
80
96
 
97
+ For a typed config executed by the npm/Node CLI, create `utlint.config.ts`:
98
+
99
+ ```ts
100
+ import { defineConfig } from "@utoo/lint/config";
101
+
102
+ export default defineConfig({
103
+ files: ["src/**/*.{js,jsx,ts,tsx}"],
104
+ ignores: ["dist", "node_modules"],
105
+ rules: {
106
+ "no-console": "off",
107
+ "no-debugger": "error"
108
+ }
109
+ });
110
+ ```
111
+
112
+ The two canonical names represent one active config and are not implicitly
113
+ merged. For the npm/Node entry point, discovery is nearest-directory-first.
114
+ Within the same directory, `utlint.config.ts` takes precedence over
115
+ `utlint.config.json`; deprecated `utoo.json` and `utoo-lint.json` files are
116
+ checked afterward for temporary backward compatibility. Rule-related CLI
117
+ options such as `--rules`, individual rule toggles, and fishlint's `--rule` are
118
+ applied after the selected config.
119
+
120
+ Project-config `files` and `ignores` patterns are relative to the selected
121
+ config file's directory. In a flat config array, they select the entries that
122
+ apply to each file; matching entries are combined in order and later rule
123
+ values override earlier values. The npm CLI, JavaScript API, and fishlint
124
+ compatibility command perform this rule resolution per file.
125
+
126
+ TypeScript config is trusted executable code. Its default export must be a
127
+ JSON-serializable object or flat config array. The npm wrapper executes it and
128
+ materializes the result as JSON before invoking the native binary. The raw
129
+ binary does not execute or discover TypeScript; it searches for
130
+ `utlint.config.json` and then the legacy JSON names. Direct native use therefore
131
+ requires a JSON config. The raw binary applies only its `rules`;
132
+ config-driven `files` and `ignores` filtering and default target selection are
133
+ npm/Node wrapper features. Pass lint targets explicitly when invoking the raw
134
+ binary. As in ESLint, selecting a config disables rules not present in its
135
+ resolved `rules` map. When no config is selected, utoo-lint uses its built-in
136
+ default rules.
137
+
138
+ Rule severities use ESLint's exit behavior: warnings are reported with exit
139
+ status 0, while errors return exit status 1. Use fishlint's `--max-warnings`
140
+ option when warnings should fail CI.
141
+
81
142
  Start from the packaged frontend template:
82
143
 
83
144
  ```bash
84
- cp node_modules/@utoo/lint/configs/frontend.json utoo.json
145
+ cp node_modules/@utoo/lint/configs/frontend.json utlint.config.json
85
146
  ```
86
147
 
87
148
  ## ESLint Migration
@@ -89,14 +150,14 @@ cp node_modules/@utoo/lint/configs/frontend.json utoo.json
89
150
  Convert an existing ESLint config into the native utoo format:
90
151
 
91
152
  ```bash
92
- pnpm exec utoo-lint migrate eslint --from eslint.config.js --output utoo.json
153
+ pnpm exec utoo-lint migrate eslint --from eslint.config.js --output utlint.config.json
93
154
  ```
94
155
 
95
156
  The package also provides compatibility bins for common replacement flows:
96
157
 
97
158
  ```bash
98
- pnpm exec eslint --config utoo.json src
99
- pnpm exec fishlint eslint --disable-setup --config utoo.json --glob src
159
+ pnpm exec eslint --config utlint.config.json src
160
+ pnpm exec fishlint eslint --disable-setup --config utlint.config.json --glob src
100
161
  ```
101
162
 
102
163
  ## JavaScript API
@@ -105,7 +166,7 @@ pnpm exec fishlint eslint --disable-setup --config utoo.json --glob src
105
166
  import { lintFiles } from "@utoo/lint";
106
167
 
107
168
  const report = lintFiles(["src"], {
108
- config: "utoo.json",
169
+ config: "utlint.config.json",
109
170
  rules: ["no-debugger"]
110
171
  });
111
172