@minimalstuff/tooling 0.6.0 → 0.8.0-next.0
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/LICENSE +21 -0
- package/README.md +166 -96
- package/dist/cli/index.d.mts +1 -8
- package/dist/cli/index.mjs +420 -170
- package/dist/knip/knip.d.mts +16 -0
- package/dist/knip/knip.mjs +70 -0
- package/dist/oxc/fmt.d.mts +10 -9
- package/dist/oxc/fmt.mjs +33 -13
- package/dist/oxc/lint.d.mts +13 -12
- package/dist/oxc/lint.mjs +94 -79
- package/dist/shared-B_NHkjil.mjs +16 -0
- package/package.json +130 -100
- package/preset/.editorconfig +4 -0
- package/dist/shared-CoSP_HvN.mjs +0 -11
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Sonny
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,159 +1,229 @@
|
|
|
1
|
+
# @minimalstuff/tooling
|
|
2
|
+
|
|
1
3
|
## Features
|
|
2
4
|
|
|
3
|
-
-
|
|
4
|
-
-
|
|
5
|
+
- [OXC](https://oxc.rs/) presets: oxlint and oxfmt
|
|
6
|
+
- [Knip](https://knip.dev/) preset, with AdonisJS support
|
|
7
|
+
- EditorConfig preset
|
|
5
8
|
- CLI for quick project setup
|
|
6
9
|
|
|
7
|
-
##
|
|
10
|
+
## Requirements
|
|
11
|
+
|
|
12
|
+
- Node >= 26
|
|
13
|
+
- `oxlint`, `oxfmt` and `oxlint-tsgolint` (optional peer dependencies, for the OXC presets)
|
|
14
|
+
- `knip` >= 6.42.1 (optional peer dependency, for the Knip preset)
|
|
15
|
+
- `@adonisjs/eslint-plugin` ^2.2.2 (optional peer dependency, required when `adonisjs: true` is used in the oxlint preset; the CLI installs it)
|
|
8
16
|
|
|
9
17
|
> [!IMPORTANT]
|
|
10
|
-
>
|
|
18
|
+
> API changes are breaking changes. Before 1.0, new or stricter `error`-level rules are breaking too: they ship in a minor release, which `^0.x` ranges never pick up automatically. New `warn`-level rules and relaxed rules are not breaking.
|
|
19
|
+
|
|
20
|
+
## Setup
|
|
11
21
|
|
|
12
|
-
### CLI
|
|
22
|
+
### CLI
|
|
13
23
|
|
|
14
|
-
|
|
24
|
+
Run this command in your project root directory:
|
|
15
25
|
|
|
16
26
|
```bash
|
|
17
27
|
pnpm dlx @minimalstuff/tooling@latest
|
|
18
28
|
```
|
|
19
29
|
|
|
30
|
+
The CLI lets you pick the tools to set up: EditorConfig, OXC, Knip and VSCode settings. For OXC and Knip, it lets you pick the presets (`react`, `adonisjs`, `vitest`) once, pre-selected from the dependencies it detects. Knip is pre-selected unless a knip config already exists. When `adonisjs` is kept, the generated `knip.ts` targets the root (`adonisjs: true`) or the workspaces (`apps/*`, `packages/*`) whose `package.json` has an `@adonisjs/*` dependency. It asks before overwriting an existing config file and only adds the `package.json` scripts that do not exist yet:
|
|
31
|
+
|
|
32
|
+
| Script | Command |
|
|
33
|
+
| -------------- | -------------------------------------------------- |
|
|
34
|
+
| `lint` | `oxlint` |
|
|
35
|
+
| `lint:fix` | `oxlint --fix` |
|
|
36
|
+
| `format` | `oxfmt && oxlint --fix` |
|
|
37
|
+
| `format:check` | `oxfmt --check` |
|
|
38
|
+
| `typecheck` | `tsc --noEmit` |
|
|
39
|
+
| `knip` | `knip` |
|
|
40
|
+
| `check` | `pnpm lint && pnpm format:check && pnpm typecheck` |
|
|
41
|
+
|
|
42
|
+
With Knip and OXC selected, `check` also runs `pnpm knip` at the end. Knip alone only adds the `knip` script.
|
|
43
|
+
|
|
20
44
|
### Manual install
|
|
21
45
|
|
|
22
46
|
```bash
|
|
23
|
-
pnpm add -D oxlint oxfmt @minimalstuff/tooling
|
|
47
|
+
pnpm add -D oxlint oxfmt oxlint-tsgolint @minimalstuff/tooling
|
|
48
|
+
# optional, for the AdonisJS oxlint preset
|
|
49
|
+
pnpm add -D @adonisjs/eslint-plugin
|
|
50
|
+
# optional, for the Knip preset
|
|
51
|
+
pnpm add -D knip
|
|
24
52
|
```
|
|
25
53
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
#### oxlint
|
|
54
|
+
## oxlint
|
|
29
55
|
|
|
30
56
|
```ts
|
|
31
57
|
// oxlint.config.ts
|
|
32
|
-
import { defineConfig } from 'oxlint';
|
|
33
58
|
import { minimalstuffPreset } from '@minimalstuff/tooling/oxc/lint';
|
|
34
59
|
|
|
35
|
-
export default
|
|
36
|
-
|
|
60
|
+
export default minimalstuffPreset({
|
|
61
|
+
react: true,
|
|
62
|
+
ignorePatterns: ['tmp/**'],
|
|
63
|
+
rules: {
|
|
64
|
+
'no-console': 'warn',
|
|
65
|
+
},
|
|
37
66
|
});
|
|
38
67
|
```
|
|
39
68
|
|
|
40
|
-
|
|
69
|
+
`minimalstuffPreset` returns the root config. Any oxlint option (`rules`, `overrides`, `plugins`, `extends`, ...) can be passed next to the preset options:
|
|
41
70
|
|
|
42
|
-
| Option
|
|
43
|
-
|
|
|
44
|
-
| `react`
|
|
45
|
-
| `adonisjs`
|
|
46
|
-
| `
|
|
71
|
+
| Option | Type | Default | Enables |
|
|
72
|
+
| ---------- | --------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
73
|
+
| `react` | `boolean` | `false` | `react` and `jsx-a11y` plugins, `react/rules-of-hooks` and `react/only-export-components` |
|
|
74
|
+
| `adonisjs` | `boolean` | `false` | `@adonisjs/eslint-plugin` lazy import rules, Lucid-aware `no-floating-promises`, AdonisJS ignore patterns (needs `@adonisjs/eslint-plugin` as a dev dependency, the CLI installs it) |
|
|
75
|
+
| `vitest` | `boolean` | `false` | `vitest` plugin |
|
|
47
76
|
|
|
48
|
-
|
|
49
|
-
import {
|
|
50
|
-
ADONISJS_DEFAULT_IGNORE_PATTERNS,
|
|
51
|
-
minimalstuffPreset,
|
|
52
|
-
} from '@minimalstuff/tooling/oxc/lint';
|
|
77
|
+
With both `adonisjs` and `react`, the Inertia rules (`no-backend-import-in-frontend`, `prefer-adonisjs-inertia-link`, `prefer-adonisjs-inertia-form`) are enabled on `**/inertia/**/*.{ts,tsx}`.
|
|
53
78
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
79
|
+
The base preset enables the `typescript`, `unicorn` and `oxc` plugins, the `correctness` category as `error`, and type-aware linting with type checking (`typeAware`, `typeCheck`) with a set of strict `typescript/*` rules.
|
|
80
|
+
|
|
81
|
+
It also enables the `promise` plugin and these async rules:
|
|
82
|
+
|
|
83
|
+
- `no-await-in-loop`: `warn`, turned off for test files (`**/*.{test,spec}.{ts,tsx,js,jsx}` and `**/tests/**`)
|
|
84
|
+
- `error`: `promise/param-names`, `promise/no-return-in-finally`, `promise/no-multiple-resolved`, `promise/no-new-statics`, `promise/valid-params`
|
|
85
|
+
- `warn`: `promise/no-nesting`
|
|
86
|
+
|
|
87
|
+
### Merge semantics
|
|
88
|
+
|
|
89
|
+
- `rules`: yours override the preset's
|
|
90
|
+
- `overrides`: yours come after the preset's
|
|
91
|
+
- `plugins`, `jsPlugins`: yours are added to the preset's
|
|
92
|
+
- `extends`: yours come after the preset's
|
|
93
|
+
- `ignorePatterns`: the defaults are kept and yours are appended
|
|
94
|
+
|
|
95
|
+
### Default ignore patterns
|
|
96
|
+
|
|
97
|
+
- Always: `**/node_modules/**`, `**/dist/**`, `**/build/**`, `**/routeTree.gen.ts`, `**/*.yml`, `**/*.yaml`
|
|
98
|
+
- With `adonisjs`: `**/.adonisjs/**`, `**/bin/*`, `**/database/schema.ts`
|
|
64
99
|
|
|
65
|
-
|
|
100
|
+
## oxfmt
|
|
66
101
|
|
|
67
102
|
```ts
|
|
68
103
|
// oxfmt.config.ts
|
|
69
104
|
import { minimalstuffPreset } from '@minimalstuff/tooling/oxc/fmt';
|
|
70
105
|
|
|
71
|
-
export default minimalstuffPreset();
|
|
106
|
+
export default minimalstuffPreset({ printWidth: 100 });
|
|
72
107
|
```
|
|
73
108
|
|
|
74
|
-
|
|
109
|
+
Defaults: `printWidth: 80`, `tabWidth: 2`, `useTabs: true`, `semi: true`, `singleQuote: true`, `quoteProps: 'as-needed'`, `bracketSpacing: true`, `arrowParens: 'always'`, `trailingComma: 'es5'`, `htmlWhitespaceSensitivity: 'ignore'`.
|
|
110
|
+
|
|
111
|
+
Imports are sorted natively with `sortImports`, alphabetically, in three groups separated by a blank line: side effects, then `builtin` and `external`, then `@/` and `~/` internal imports and relative imports.
|
|
112
|
+
|
|
113
|
+
| Option | Type | Default | Description |
|
|
114
|
+
| ---------- | --------- | ------- | -------------------------------- |
|
|
115
|
+
| `adonisjs` | `boolean` | `false` | Add the AdonisJS ignore patterns |
|
|
116
|
+
|
|
117
|
+
Any other oxfmt option overrides the defaults. `ignorePatterns` are appended to the defaults (the oxlint ones plus `**/CHANGELOG.md`), never replaced.
|
|
118
|
+
|
|
119
|
+
## knip
|
|
75
120
|
|
|
76
121
|
```ts
|
|
77
|
-
|
|
122
|
+
// knip.ts
|
|
123
|
+
import { minimalstuffPreset } from '@minimalstuff/tooling/knip';
|
|
124
|
+
|
|
125
|
+
export default minimalstuffPreset({ adonisjs: true });
|
|
78
126
|
```
|
|
79
127
|
|
|
80
|
-
|
|
128
|
+
Monorepo, with the AdonisJS app(s) in workspaces:
|
|
81
129
|
|
|
82
130
|
```ts
|
|
83
|
-
|
|
84
|
-
ADONISJS_DEFAULT_IGNORE_PATTERNS,
|
|
85
|
-
minimalstuffPreset,
|
|
86
|
-
OXFMT_DEFAULT_IGNORE_PATTERNS,
|
|
87
|
-
} from '@minimalstuff/tooling/oxc/fmt';
|
|
88
|
-
|
|
89
|
-
export default minimalstuffPreset({
|
|
90
|
-
ignorePatterns: [
|
|
91
|
-
...OXFMT_DEFAULT_IGNORE_PATTERNS,
|
|
92
|
-
...ADONISJS_DEFAULT_IGNORE_PATTERNS,
|
|
93
|
-
],
|
|
94
|
-
});
|
|
131
|
+
export default minimalstuffPreset({ adonisjs: ['apps/webapp'] });
|
|
95
132
|
```
|
|
96
133
|
|
|
97
|
-
|
|
134
|
+
`minimalstuffPreset` returns the root config. Any knip option (`entry`, `project`, `ignore`, `ignoreDependencies`, `workspaces`, ...) can be passed next to the preset option. Without `adonisjs`, it returns your config as is: knip's built-in plugins (vite, vitest, playwright, tsdown, oxlint, ...) already cover most setups.
|
|
135
|
+
|
|
136
|
+
| Option | Type | Default | Description |
|
|
137
|
+
| ---------- | ------------------------------ | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
138
|
+
| `adonisjs` | `boolean \| readonly string[]` | `false` | `true` applies the AdonisJS config to the root workspace. A list of paths applies it to each of those workspaces (under `workspaces[path]`, monorepo case) |
|
|
139
|
+
|
|
140
|
+
Knip has no AdonisJS or Japa plugin, so everything Adonis loads by convention would be reported as unused. The AdonisJS config declares:
|
|
141
|
+
|
|
142
|
+
- `entry`: `adonisrc.ts`, `ace.js`, `bin/*.ts`, `start/**`, `config/**`, `providers/**`, `commands/**`, `database/{migrations,seeders,factories}/**`, `tests/bootstrap.ts`, Japa specs (`tests/**/*.spec.{ts,js}`, `app/**/*.spec.{ts,js}`), and the Inertia files (`inertia/{app,ssr}.{ts,tsx}`, `inertia/app/{app,ssr}.{ts,tsx}`, `inertia/pages/**/*.{ts,tsx}`, pages are resolved by name at runtime)
|
|
143
|
+
- `project`: `**/*.{ts,tsx,js}`
|
|
144
|
+
- `ignore`: `.adonisjs/**` (generated), `database/schema.ts` (generated by Lucid)
|
|
145
|
+
- `ignoreDependencies`: `pg`, `mysql2`, `better-sqlite3`, `sqlite3` (database drivers only referenced by name in `config/database.ts`), `pino-pretty` (logger transport referenced by name), `hot-hook` (only referenced in `package.json`)
|
|
146
|
+
|
|
147
|
+
### Merge semantics
|
|
148
|
+
|
|
149
|
+
For the targeted workspace(s):
|
|
98
150
|
|
|
99
|
-
|
|
151
|
+
- arrays (`entry`, `project`, `ignore`, `ignoreDependencies`, ...): yours are appended to the preset's (a single string is accepted)
|
|
152
|
+
- other keys (booleans, objects such as plugin configs): yours win
|
|
100
153
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
154
|
+
With `adonisjs: true`, the preset is merged into the root keys. If you define `workspaces['.']` yourself, knip ignores the root keys: use `adonisjs: ['.']` instead. With a list of paths, the root keys are left untouched and each listed workspace gets the preset merged with its own `workspaces[path]` entry.
|
|
155
|
+
|
|
156
|
+
## Migrating from 0.7
|
|
157
|
+
|
|
158
|
+
In 0.x a minor bump is breaking, so `^0.7.0` never resolves to 0.8: upgrade explicitly.
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
pnpm add -D @minimalstuff/tooling@^0.8.0
|
|
109
162
|
```
|
|
110
163
|
|
|
111
|
-
|
|
164
|
+
- AdonisJS projects (`adonisjs: true`) must install the plugin themselves: `pnpm add -D @adonisjs/eslint-plugin`. It is now an optional peer dependency instead of a dependency of this package.
|
|
165
|
+
- The base oxlint preset now enables the `promise` plugin and the async rules listed in [oxlint](#oxlint): the error-level ones may surface new errors.
|
|
112
166
|
|
|
113
|
-
|
|
167
|
+
## Migrating from 0.6
|
|
114
168
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
"rootDir": "./",
|
|
120
|
-
"outDir": "./build"
|
|
121
|
-
}
|
|
122
|
-
}
|
|
169
|
+
In 0.x a minor bump is breaking, so `^0.6.0` never resolves to 0.7: upgrade explicitly.
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
pnpm add -D @minimalstuff/tooling@^0.7.0 oxlint@latest oxfmt@latest oxlint-tsgolint@latest
|
|
123
173
|
```
|
|
124
174
|
|
|
125
|
-
|
|
175
|
+
Requirements changed:
|
|
176
|
+
|
|
177
|
+
- Node >= 26.
|
|
178
|
+
- Peers: `oxlint >= 1.89.0`, `oxfmt >= 0.74.0`, `oxlint-tsgolint >= 7.0.2004`.
|
|
179
|
+
|
|
180
|
+
oxlint: the preset now returns the root config instead of being passed to `extends`.
|
|
126
181
|
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
182
|
+
```ts
|
|
183
|
+
// before
|
|
184
|
+
export default defineConfig({
|
|
185
|
+
ignorePatterns: [...ADONISJS_DEFAULT_IGNORE_PATTERNS, 'tmp/**'],
|
|
186
|
+
extends: [minimalstuffPreset({ react: true, adonisjs: true })],
|
|
187
|
+
rules: { 'no-console': 'warn' },
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
// after
|
|
191
|
+
export default minimalstuffPreset({
|
|
192
|
+
react: true,
|
|
193
|
+
adonisjs: true,
|
|
194
|
+
ignorePatterns: ['tmp/**'],
|
|
195
|
+
rules: { 'no-console': 'warn' },
|
|
196
|
+
});
|
|
135
197
|
```
|
|
136
198
|
|
|
137
|
-
|
|
199
|
+
oxfmt: `OXFMT_DEFAULT_IGNORE_PATTERNS` and `ADONISJS_DEFAULT_IGNORE_PATTERNS` are no longer exported.
|
|
200
|
+
|
|
201
|
+
```ts
|
|
202
|
+
// before
|
|
203
|
+
export default minimalstuffPreset({
|
|
204
|
+
ignorePatterns: [
|
|
205
|
+
...OXFMT_DEFAULT_IGNORE_PATTERNS,
|
|
206
|
+
...ADONISJS_DEFAULT_IGNORE_PATTERNS,
|
|
207
|
+
],
|
|
208
|
+
});
|
|
138
209
|
|
|
139
|
-
|
|
140
|
-
{
|
|
141
|
-
"extends": "@minimalstuff/tooling/tsconfigs/tsconfig.react",
|
|
142
|
-
"compilerOptions": {
|
|
143
|
-
"rootDir": "./",
|
|
144
|
-
"outDir": "./build"
|
|
145
|
-
}
|
|
146
|
-
}
|
|
210
|
+
// after
|
|
211
|
+
export default minimalstuffPreset({ adonisjs: true });
|
|
147
212
|
```
|
|
148
213
|
|
|
149
|
-
|
|
214
|
+
Other changes:
|
|
215
|
+
|
|
216
|
+
- The `perfectionist` option is removed. Imports are now sorted alphabetically by oxfmt: run `pnpm format` once.
|
|
217
|
+
- Remove the ignore patterns that are now defaults from your configs.
|
|
218
|
+
- The `eslint-plugin-perfectionist` dependency is no longer needed.
|
|
219
|
+
- Correctness rules are now errors and new type-aware rules are enabled (see [oxlint](#oxlint)): `pnpm lint` may fail where it passed before.
|
|
220
|
+
- The CLI only adds missing scripts, so update existing ones by hand: drop `--fix-dangerously` from `lint:fix` and replace `format: "pnpm lint:fix; oxfmt ."` with `format: "oxfmt && oxlint --fix"` (see [CLI](#cli)).
|
|
221
|
+
- Optional: add Knip (see [knip](#knip)).
|
|
150
222
|
|
|
151
|
-
|
|
152
|
-
Create an automation token at [npmjs.com/access-tokens](https://www.npmjs.com/access-tokens) (scope: package publish for `@minimalstuff/ui`).
|
|
223
|
+
## Publishing
|
|
153
224
|
|
|
154
|
-
|
|
155
|
-
In the repo: **Settings → Secrets and variables → Actions**. Add a secret named `NPM_TOKEN` with the token value.
|
|
225
|
+
Publishing uses npm [trusted publishing](https://docs.npmjs.com/trusted-publishers) (OIDC), no token needed. On npmjs.com, `@minimalstuff/tooling` > **Settings > Trusted publishing** must list GitHub Actions with organization `minimalstuff`, repository `tooling` and workflow `publish.yml`. Publishing a GitHub release triggers the workflow.
|
|
156
226
|
|
|
157
|
-
|
|
227
|
+
## License
|
|
158
228
|
|
|
159
|
-
|
|
229
|
+
[MIT](LICENSE)
|
package/dist/cli/index.d.mts
CHANGED
|
@@ -1,8 +1 @@
|
|
|
1
|
-
|
|
2
|
-
type ConfigTool = 'editorconfig' | 'oxc' | 'vscode';
|
|
3
|
-
declare const DEFAULT_SELECTED_TOOLS: ConfigTool[];
|
|
4
|
-
interface PromptResult {
|
|
5
|
-
tools: ConfigTool[];
|
|
6
|
-
}
|
|
7
|
-
//#endregion
|
|
8
|
-
export { ConfigTool, DEFAULT_SELECTED_TOOLS, PromptResult };
|
|
1
|
+
export {}
|