@minimalstuff/tooling 0.7.0 → 0.8.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 +32 -155
- package/dist/cli/index.mjs +180 -97
- package/dist/oxc/lint.d.mts +2 -0
- package/dist/oxc/lint.mjs +26 -4
- package/package.json +130 -114
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,209 +1,86 @@
|
|
|
1
1
|
# @minimalstuff/tooling
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
- [OXC](https://oxc.rs/) presets: oxlint and oxfmt
|
|
6
|
-
- [Knip](https://knip.dev/) preset, with AdonisJS support
|
|
7
|
-
- EditorConfig preset
|
|
8
|
-
- CLI for quick project setup
|
|
3
|
+
Shared tooling configs: EditorConfig, OXC (oxlint + oxfmt), Knip. A CLI sets them up in a project.
|
|
9
4
|
|
|
10
5
|
## Requirements
|
|
11
6
|
|
|
12
7
|
- Node >= 26
|
|
13
|
-
- `oxlint
|
|
8
|
+
- `oxlint` >= 1.89.0, `oxfmt` >= 0.74.0 and `oxlint-tsgolint` >= 7.0.2004 (optional peer dependencies, for the OXC presets)
|
|
14
9
|
- `knip` >= 6.42.1 (optional peer dependency, for the Knip preset)
|
|
10
|
+
- `@adonisjs/eslint-plugin` ^2.2.2 (optional peer dependency, needed with `adonisjs: true` in the oxlint preset; the CLI installs it)
|
|
11
|
+
|
|
12
|
+
## Versioning
|
|
15
13
|
|
|
16
14
|
> [!IMPORTANT]
|
|
17
|
-
>
|
|
15
|
+
> Removing or changing an export or option is a breaking change. Before 1.0, new or stricter `error`-level rules and new required peer dependencies 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.
|
|
18
16
|
|
|
19
|
-
##
|
|
17
|
+
## Set up a project
|
|
20
18
|
|
|
21
|
-
### CLI
|
|
19
|
+
### With the CLI
|
|
22
20
|
|
|
23
|
-
Run this command
|
|
21
|
+
Run this command from the project root, in an interactive terminal:
|
|
24
22
|
|
|
25
23
|
```bash
|
|
26
24
|
pnpm dlx @minimalstuff/tooling@latest
|
|
27
25
|
```
|
|
28
26
|
|
|
29
|
-
The CLI
|
|
30
|
-
|
|
31
|
-
| Script | Command |
|
|
32
|
-
| -------------- | -------------------------------------------------- |
|
|
33
|
-
| `lint` | `oxlint` |
|
|
34
|
-
| `lint:fix` | `oxlint --fix` |
|
|
35
|
-
| `format` | `oxfmt && oxlint --fix` |
|
|
36
|
-
| `format:check` | `oxfmt --check` |
|
|
37
|
-
| `typecheck` | `tsc --noEmit` |
|
|
38
|
-
| `knip` | `knip` |
|
|
39
|
-
| `check` | `pnpm lint && pnpm format:check && pnpm typecheck` |
|
|
27
|
+
The CLI asks which tools to set up (EditorConfig, OXC, Knip), offers VS Code settings when OXC is selected, and asks for presets (`react`, `adonisjs`, `vitest`) pre-selected from your dependencies. It asks before overwriting a file and only adds the `package.json` scripts that are missing. It then installs the packages once as devDependencies with the detected package manager. See the [CLI reference](docs/cli.md) for details.
|
|
40
28
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
### Manual install
|
|
29
|
+
### Manually
|
|
44
30
|
|
|
45
31
|
```bash
|
|
46
32
|
pnpm add -D oxlint oxfmt oxlint-tsgolint @minimalstuff/tooling
|
|
33
|
+
# optional, for the AdonisJS oxlint preset
|
|
34
|
+
pnpm add -D @adonisjs/eslint-plugin
|
|
47
35
|
# optional, for the Knip preset
|
|
48
36
|
pnpm add -D knip
|
|
49
37
|
```
|
|
50
38
|
|
|
51
|
-
## oxlint
|
|
52
|
-
|
|
53
39
|
```ts
|
|
54
40
|
// oxlint.config.ts
|
|
55
41
|
import { minimalstuffPreset } from '@minimalstuff/tooling/oxc/lint';
|
|
56
42
|
|
|
57
|
-
export default minimalstuffPreset({
|
|
58
|
-
react: true,
|
|
59
|
-
ignorePatterns: ['tmp/**'],
|
|
60
|
-
rules: {
|
|
61
|
-
'no-console': 'warn',
|
|
62
|
-
},
|
|
63
|
-
});
|
|
43
|
+
export default minimalstuffPreset({ react: true });
|
|
64
44
|
```
|
|
65
45
|
|
|
66
|
-
`minimalstuffPreset` returns the root config. Any oxlint option (`rules`, `overrides`, `plugins`, `extends`, ...) can be passed next to the preset options:
|
|
67
|
-
|
|
68
|
-
| Option | Type | Default | Enables |
|
|
69
|
-
| ---------- | --------- | ------- | --------------------------------------------------------------------------------------------------------- |
|
|
70
|
-
| `react` | `boolean` | `false` | `react` and `jsx-a11y` plugins, `react/rules-of-hooks` and `react/only-export-components` |
|
|
71
|
-
| `adonisjs` | `boolean` | `false` | `@adonisjs/eslint-plugin` lazy import rules, Lucid-aware `no-floating-promises`, AdonisJS ignore patterns |
|
|
72
|
-
| `vitest` | `boolean` | `false` | `vitest` plugin |
|
|
73
|
-
|
|
74
|
-
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}`.
|
|
75
|
-
|
|
76
|
-
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.
|
|
77
|
-
|
|
78
|
-
### Merge semantics
|
|
79
|
-
|
|
80
|
-
- `rules`: yours override the preset's
|
|
81
|
-
- `overrides`: yours come after the preset's
|
|
82
|
-
- `plugins`, `jsPlugins`: yours are added to the preset's
|
|
83
|
-
- `extends`: yours come after the preset's
|
|
84
|
-
- `ignorePatterns`: the defaults are kept and yours are appended
|
|
85
|
-
|
|
86
|
-
### Default ignore patterns
|
|
87
|
-
|
|
88
|
-
- Always: `**/node_modules/**`, `**/dist/**`, `**/build/**`, `**/routeTree.gen.ts`, `**/*.yml`, `**/*.yaml`
|
|
89
|
-
- With `adonisjs`: `**/.adonisjs/**`, `**/bin/*`, `**/database/schema.ts`
|
|
90
|
-
|
|
91
|
-
## oxfmt
|
|
92
|
-
|
|
93
46
|
```ts
|
|
94
47
|
// oxfmt.config.ts
|
|
95
48
|
import { minimalstuffPreset } from '@minimalstuff/tooling/oxc/fmt';
|
|
96
49
|
|
|
97
|
-
export default minimalstuffPreset(
|
|
50
|
+
export default minimalstuffPreset();
|
|
98
51
|
```
|
|
99
52
|
|
|
100
|
-
Defaults: `printWidth: 80`, `tabWidth: 2`, `useTabs: true`, `semi: true`, `singleQuote: true`, `quoteProps: 'as-needed'`, `bracketSpacing: true`, `arrowParens: 'always'`, `trailingComma: 'es5'`, `htmlWhitespaceSensitivity: 'ignore'`.
|
|
101
|
-
|
|
102
|
-
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.
|
|
103
|
-
|
|
104
|
-
| Option | Type | Default | Description |
|
|
105
|
-
| ---------- | --------- | ------- | -------------------------------- |
|
|
106
|
-
| `adonisjs` | `boolean` | `false` | Add the AdonisJS ignore patterns |
|
|
107
|
-
|
|
108
|
-
Any other oxfmt option overrides the defaults. `ignorePatterns` are appended to the defaults (the oxlint ones plus `**/CHANGELOG.md`), never replaced.
|
|
109
|
-
|
|
110
|
-
## knip
|
|
111
|
-
|
|
112
53
|
```ts
|
|
113
54
|
// knip.ts
|
|
114
55
|
import { minimalstuffPreset } from '@minimalstuff/tooling/knip';
|
|
115
56
|
|
|
116
|
-
export default minimalstuffPreset(
|
|
57
|
+
export default minimalstuffPreset();
|
|
117
58
|
```
|
|
118
59
|
|
|
119
|
-
Monorepo, with the AdonisJS app(s) in workspaces:
|
|
120
|
-
|
|
121
|
-
```ts
|
|
122
|
-
export default minimalstuffPreset({ adonisjs: ['apps/webapp'] });
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
`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.
|
|
126
|
-
|
|
127
|
-
| Option | Type | Default | Description |
|
|
128
|
-
| ---------- | ------------------------------ | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
129
|
-
| `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) |
|
|
130
|
-
|
|
131
|
-
Knip has no AdonisJS or Japa plugin, so everything Adonis loads by convention would be reported as unused. The AdonisJS config declares:
|
|
132
|
-
|
|
133
|
-
- `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)
|
|
134
|
-
- `project`: `**/*.{ts,tsx,js}`
|
|
135
|
-
- `ignore`: `.adonisjs/**` (generated), `database/schema.ts` (generated by Lucid)
|
|
136
|
-
- `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`)
|
|
137
|
-
|
|
138
|
-
### Merge semantics
|
|
139
|
-
|
|
140
|
-
For the targeted workspace(s):
|
|
141
|
-
|
|
142
|
-
- arrays (`entry`, `project`, `ignore`, `ignoreDependencies`, ...): yours are appended to the preset's (a single string is accepted)
|
|
143
|
-
- other keys (booleans, objects such as plugin configs): yours win
|
|
144
|
-
|
|
145
|
-
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.
|
|
146
|
-
|
|
147
|
-
## Migrating from 0.6
|
|
148
|
-
|
|
149
|
-
In 0.x a minor bump is breaking, so `^0.6.0` never resolves to 0.7: upgrade explicitly.
|
|
150
|
-
|
|
151
60
|
```bash
|
|
152
|
-
|
|
61
|
+
cp node_modules/@minimalstuff/tooling/preset/.editorconfig .editorconfig
|
|
153
62
|
```
|
|
154
63
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
- Node >= 26.
|
|
158
|
-
- Peers: `oxlint >= 1.89.0`, `oxfmt >= 0.74.0`, `oxlint-tsgolint >= 7.0.2004`.
|
|
159
|
-
|
|
160
|
-
oxlint: the preset now returns the root config instead of being passed to `extends`.
|
|
161
|
-
|
|
162
|
-
```ts
|
|
163
|
-
// before
|
|
164
|
-
export default defineConfig({
|
|
165
|
-
ignorePatterns: [...ADONISJS_DEFAULT_IGNORE_PATTERNS, 'tmp/**'],
|
|
166
|
-
extends: [minimalstuffPreset({ react: true, adonisjs: true })],
|
|
167
|
-
rules: { 'no-console': 'warn' },
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
// after
|
|
171
|
-
export default minimalstuffPreset({
|
|
172
|
-
react: true,
|
|
173
|
-
adonisjs: true,
|
|
174
|
-
ignorePatterns: ['tmp/**'],
|
|
175
|
-
rules: { 'no-console': 'warn' },
|
|
176
|
-
});
|
|
177
|
-
```
|
|
64
|
+
See the [presets reference](docs/presets.md) for the options.
|
|
178
65
|
|
|
179
|
-
|
|
66
|
+
## Develop
|
|
180
67
|
|
|
181
|
-
```
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
ignorePatterns: [
|
|
185
|
-
...OXFMT_DEFAULT_IGNORE_PATTERNS,
|
|
186
|
-
...ADONISJS_DEFAULT_IGNORE_PATTERNS,
|
|
187
|
-
],
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
// after
|
|
191
|
-
export default minimalstuffPreset({ adonisjs: true });
|
|
68
|
+
```bash
|
|
69
|
+
pnpm install
|
|
70
|
+
pnpm checks
|
|
192
71
|
```
|
|
193
72
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
- The `perfectionist` option is removed. Imports are now sorted alphabetically by oxfmt: run `pnpm format` once.
|
|
197
|
-
- Remove the ignore patterns that are now defaults from your configs.
|
|
198
|
-
- The `eslint-plugin-perfectionist` dependency is no longer needed.
|
|
199
|
-
- Correctness rules are now errors and new type-aware rules are enabled (see [oxlint](#oxlint)): `pnpm lint` may fail where it passed before.
|
|
200
|
-
- 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)).
|
|
201
|
-
- Optional: add Knip (see [knip](#knip)).
|
|
73
|
+
`pnpm checks` runs the typecheck, lint, format check, Knip, unit tests and build. `pnpm test:package` installs the packed tarball into throwaway consumer projects with strict pnpm: it needs network access and runs in CI.
|
|
202
74
|
|
|
203
|
-
##
|
|
75
|
+
## Documentation
|
|
204
76
|
|
|
205
|
-
|
|
77
|
+
- [CLI reference](docs/cli.md)
|
|
78
|
+
- [Presets reference](docs/presets.md)
|
|
79
|
+
- [Upgrade guides](docs/migrating.md)
|
|
80
|
+
- [Release a version](docs/releasing.md) (for maintainers)
|
|
81
|
+
- [Changelog](CHANGELOG.md)
|
|
82
|
+
- [Issues](https://github.com/minimalstuff/tooling/issues)
|
|
206
83
|
|
|
207
|
-
|
|
84
|
+
## License
|
|
208
85
|
|
|
209
|
-
|
|
86
|
+
[MIT](LICENSE)
|
package/dist/cli/index.mjs
CHANGED
|
@@ -1,12 +1,47 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { cancel, confirm, intro, isCancel, log, multiselect } from "@clack/prompts";
|
|
2
|
+
import { cancel, confirm, intro, isCancel, log, multiselect, outro } from "@clack/prompts";
|
|
3
|
+
import color from "picocolors";
|
|
4
|
+
import { detectPackageManager, installPackage } from "@antfu/install-pkg";
|
|
3
5
|
import { existsSync } from "node:fs";
|
|
4
6
|
import { basename, dirname, join } from "node:path";
|
|
5
|
-
import color from "picocolors";
|
|
6
7
|
import { mkdir, readFile, readdir, writeFile } from "node:fs/promises";
|
|
7
8
|
import { parse, printParseErrorCode } from "jsonc-parser";
|
|
8
9
|
import { fileURLToPath } from "node:url";
|
|
9
|
-
|
|
10
|
+
// src/cli/install_dev_packages.ts
|
|
11
|
+
const DEFAULT_AGENT = "npm";
|
|
12
|
+
const PNPM_WORKSPACE_FILE = "pnpm-workspace.yaml";
|
|
13
|
+
var InstallPackagesError = class extends Error {
|
|
14
|
+
constructor(command, cause) {
|
|
15
|
+
super(`Installing packages failed. Run it yourself: ${command}`, { cause });
|
|
16
|
+
this.name = "InstallPackagesError";
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
function buildDevInstallCommand(agent, packageNames, hasPnpmWorkspace) {
|
|
20
|
+
return [
|
|
21
|
+
agent,
|
|
22
|
+
agent === "yarn" ? "add" : "install",
|
|
23
|
+
"-D",
|
|
24
|
+
...agent === "pnpm" && hasPnpmWorkspace ? ["-w"] : [],
|
|
25
|
+
...packageNames
|
|
26
|
+
].join(" ");
|
|
27
|
+
}
|
|
28
|
+
async function detectAgent(cwd) {
|
|
29
|
+
return (await detectPackageManager(cwd) ?? DEFAULT_AGENT).split("@")[0] ?? DEFAULT_AGENT;
|
|
30
|
+
}
|
|
31
|
+
async function installDevPackages(packageNames, cwd) {
|
|
32
|
+
if (packageNames.length === 0) return;
|
|
33
|
+
log.step(`Installing ${packageNames.join(", ")}`);
|
|
34
|
+
const agent = await detectAgent(cwd);
|
|
35
|
+
try {
|
|
36
|
+
await installPackage([...packageNames], {
|
|
37
|
+
dev: true,
|
|
38
|
+
cwd,
|
|
39
|
+
packageManager: agent
|
|
40
|
+
});
|
|
41
|
+
} catch (error) {
|
|
42
|
+
throw new InstallPackagesError(buildDevInstallCommand(agent, packageNames, existsSync(join(cwd, PNPM_WORKSPACE_FILE))), error);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
10
45
|
// src/constants.ts
|
|
11
46
|
const TOOLING_PACKAGE_NAME = "@minimalstuff/tooling";
|
|
12
47
|
const OXC_LINT_IMPORT = `${TOOLING_PACKAGE_NAME}/oxc/lint`;
|
|
@@ -21,6 +56,25 @@ const KNIP_CONFIG_FILE_NAMES = [
|
|
|
21
56
|
".knip.jsonc",
|
|
22
57
|
"knip.config.ts"
|
|
23
58
|
];
|
|
59
|
+
// src/cli/list_oxc_packages.ts
|
|
60
|
+
const BASE_OXC_PACKAGES = [
|
|
61
|
+
"oxfmt",
|
|
62
|
+
"oxlint",
|
|
63
|
+
"oxlint-tsgolint",
|
|
64
|
+
TOOLING_PACKAGE_NAME
|
|
65
|
+
];
|
|
66
|
+
const ADONISJS_ESLINT_PLUGIN_PACKAGE = "@adonisjs/eslint-plugin";
|
|
67
|
+
function listOxcPackages(presetFlags) {
|
|
68
|
+
if (!presetFlags.adonisjs) return [...BASE_OXC_PACKAGES];
|
|
69
|
+
return [...BASE_OXC_PACKAGES, ADONISJS_ESLINT_PLUGIN_PACKAGE];
|
|
70
|
+
}
|
|
71
|
+
// src/cli/list_dev_packages.ts
|
|
72
|
+
const KNIP_PACKAGES = ["knip", TOOLING_PACKAGE_NAME];
|
|
73
|
+
function listDevPackages(result) {
|
|
74
|
+
const oxcPackages = result.tools.includes("oxc") ? listOxcPackages(result.presetFlags) : [];
|
|
75
|
+
const knipPackages = result.tools.includes("knip") ? KNIP_PACKAGES : [];
|
|
76
|
+
return [.../* @__PURE__ */ new Set([...oxcPackages, ...knipPackages])];
|
|
77
|
+
}
|
|
24
78
|
const LEADING_WHITESPACE_PATTERN = /^([ \t]+)\S/m;
|
|
25
79
|
var InvalidJsonFileError = class extends Error {
|
|
26
80
|
constructor(filePath, reason) {
|
|
@@ -67,6 +121,7 @@ const REACT_PACKAGES = [
|
|
|
67
121
|
];
|
|
68
122
|
const VITEST_PACKAGES = ["vitest"];
|
|
69
123
|
const ADONISJS_SCOPE_PREFIX = "@adonisjs/";
|
|
124
|
+
const SUBPATH_IMPORT_PREFIX = "#";
|
|
70
125
|
function collectDependencyNames(manifests) {
|
|
71
126
|
const names = /* @__PURE__ */ new Set();
|
|
72
127
|
for (const manifest of manifests) for (const dependencies of [
|
|
@@ -85,6 +140,9 @@ function detectPresetFlags(manifests) {
|
|
|
85
140
|
adonisjs: [...names].some((name) => name.startsWith(ADONISJS_SCOPE_PREFIX))
|
|
86
141
|
};
|
|
87
142
|
}
|
|
143
|
+
function hasSubpathImports(manifests) {
|
|
144
|
+
return manifests.some(({ imports }) => Object.keys(imports ?? {}).some((key) => key.startsWith(SUBPATH_IMPORT_PREFIX)));
|
|
145
|
+
}
|
|
88
146
|
function toDetectedPresetNames(flags) {
|
|
89
147
|
return Object.keys(flags).filter((name) => flags[name]);
|
|
90
148
|
}
|
|
@@ -95,23 +153,16 @@ function toPresetFlags(names) {
|
|
|
95
153
|
vitest: names.includes("vitest")
|
|
96
154
|
};
|
|
97
155
|
}
|
|
156
|
+
async function listDirectoryManifestLocations(cwd, workspaceDirectory) {
|
|
157
|
+
const directoryPath = join(cwd, workspaceDirectory);
|
|
158
|
+
if (!existsSync(directoryPath)) return [];
|
|
159
|
+
return (await readdir(directoryPath, { withFileTypes: true })).filter((entry) => entry.isDirectory()).map((entry) => ({
|
|
160
|
+
workspacePath: `${workspaceDirectory}/${entry.name}`,
|
|
161
|
+
manifestPath: join(directoryPath, entry.name, "package.json")
|
|
162
|
+
})).filter(({ manifestPath }) => existsSync(manifestPath));
|
|
163
|
+
}
|
|
98
164
|
async function listWorkspaceManifestLocations(cwd) {
|
|
99
|
-
|
|
100
|
-
for (const workspaceDirectory of WORKSPACE_DIRECTORIES) {
|
|
101
|
-
const directoryPath = join(cwd, workspaceDirectory);
|
|
102
|
-
if (!existsSync(directoryPath)) continue;
|
|
103
|
-
const entries = await readdir(directoryPath, { withFileTypes: true });
|
|
104
|
-
for (const entry of entries) {
|
|
105
|
-
if (!entry.isDirectory()) continue;
|
|
106
|
-
const manifestPath = join(directoryPath, entry.name, "package.json");
|
|
107
|
-
if (!existsSync(manifestPath)) continue;
|
|
108
|
-
locations.push({
|
|
109
|
-
workspacePath: `${workspaceDirectory}/${entry.name}`,
|
|
110
|
-
manifestPath
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
return locations;
|
|
165
|
+
return (await Promise.all(WORKSPACE_DIRECTORIES.map((workspaceDirectory) => listDirectoryManifestLocations(cwd, workspaceDirectory)))).flat();
|
|
115
166
|
}
|
|
116
167
|
async function readWorkspaceManifests(cwd) {
|
|
117
168
|
const rootManifestPath = join(cwd, "package.json");
|
|
@@ -134,11 +185,15 @@ async function detectPresets(cwd) {
|
|
|
134
185
|
async function detectAdonisjsWorkspacePaths(cwd) {
|
|
135
186
|
return findAdonisjsWorkspacePaths(await readWorkspaceManifests(cwd));
|
|
136
187
|
}
|
|
188
|
+
async function detectSubpathImports(cwd) {
|
|
189
|
+
return hasSubpathImports((await readWorkspaceManifests(cwd)).map(({ manifest }) => manifest));
|
|
190
|
+
}
|
|
137
191
|
// src/cli/prompts.ts
|
|
192
|
+
const CANCELLED_EXIT_CODE = 130;
|
|
138
193
|
function exitWhenCancelled(answer) {
|
|
139
194
|
if (!isCancel(answer)) return answer;
|
|
140
195
|
cancel("Cancelled");
|
|
141
|
-
return process.exit(
|
|
196
|
+
return process.exit(CANCELLED_EXIT_CODE);
|
|
142
197
|
}
|
|
143
198
|
// src/cli/prompt_presets.ts
|
|
144
199
|
const TOOLS_USING_PRESETS = ["oxc", "knip"];
|
|
@@ -169,6 +224,87 @@ async function promptPresetsForTools(tools, cwd) {
|
|
|
169
224
|
if (!TOOLS_USING_PRESETS.some((tool) => tools.includes(tool))) return NO_PRESETS;
|
|
170
225
|
return promptPresets(cwd);
|
|
171
226
|
}
|
|
227
|
+
// src/cli/tool_options.ts
|
|
228
|
+
const MAIN_TOOLS = [
|
|
229
|
+
"editorconfig",
|
|
230
|
+
"oxc",
|
|
231
|
+
"knip"
|
|
232
|
+
];
|
|
233
|
+
const ALREADY_EXISTS_SUFFIX = " (already exists)";
|
|
234
|
+
function withExistingSuffix(label, isExisting) {
|
|
235
|
+
return isExisting ? `${label}${ALREADY_EXISTS_SUFFIX}` : label;
|
|
236
|
+
}
|
|
237
|
+
function buildToolOptions(existing) {
|
|
238
|
+
return [
|
|
239
|
+
{
|
|
240
|
+
value: "editorconfig",
|
|
241
|
+
label: withExistingSuffix("EditorConfig", existing.hasEditorConfig)
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
value: "oxc",
|
|
245
|
+
label: "OXC (oxlint + oxfmt)"
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
value: "knip",
|
|
249
|
+
label: withExistingSuffix("Knip (unused files, exports, dependencies)", existing.hasKnip)
|
|
250
|
+
}
|
|
251
|
+
];
|
|
252
|
+
}
|
|
253
|
+
function isInitiallySelected(tool, existing) {
|
|
254
|
+
if (tool === "editorconfig") return !existing.hasEditorConfig;
|
|
255
|
+
if (tool === "knip") return !existing.hasKnip;
|
|
256
|
+
return true;
|
|
257
|
+
}
|
|
258
|
+
function selectInitialTools(existing) {
|
|
259
|
+
return MAIN_TOOLS.filter((tool) => isInitiallySelected(tool, existing));
|
|
260
|
+
}
|
|
261
|
+
function canConfigureVscode(tools) {
|
|
262
|
+
return tools.includes("oxc");
|
|
263
|
+
}
|
|
264
|
+
// src/cli/prompt_tools.ts
|
|
265
|
+
const VSCODE_CONFIRM_MESSAGE = "Add OXC settings to .vscode/settings.json?";
|
|
266
|
+
const VSCODE_EXISTING_NOTE = " (it already exists, existing settings are kept)";
|
|
267
|
+
function findGitRoot(startDirectory) {
|
|
268
|
+
let directory = startDirectory;
|
|
269
|
+
while (true) {
|
|
270
|
+
if (existsSync(join(directory, ".git"))) return directory;
|
|
271
|
+
const parent = dirname(directory);
|
|
272
|
+
if (parent === directory) return null;
|
|
273
|
+
directory = parent;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
function existsAtAnyRoot(roots, entryNames) {
|
|
277
|
+
return roots.some((root) => entryNames.some((entryName) => existsSync(join(root, entryName))));
|
|
278
|
+
}
|
|
279
|
+
function detectExistingConfigs(cwd) {
|
|
280
|
+
const gitRoot = findGitRoot(cwd);
|
|
281
|
+
const roots = gitRoot && gitRoot !== cwd ? [cwd, gitRoot] : [cwd];
|
|
282
|
+
return {
|
|
283
|
+
hasEditorConfig: existsAtAnyRoot(roots, [".editorconfig"]),
|
|
284
|
+
hasVscode: existsAtAnyRoot(roots, [".vscode"]),
|
|
285
|
+
hasKnip: existsAtAnyRoot(roots, KNIP_CONFIG_FILE_NAMES)
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
async function promptMainTools(existing) {
|
|
289
|
+
return exitWhenCancelled(await multiselect({
|
|
290
|
+
message: "Select tools to configure",
|
|
291
|
+
options: buildToolOptions(existing),
|
|
292
|
+
initialValues: selectInitialTools(existing),
|
|
293
|
+
required: true
|
|
294
|
+
}));
|
|
295
|
+
}
|
|
296
|
+
async function promptVscodeSettings(existing) {
|
|
297
|
+
return exitWhenCancelled(await confirm({
|
|
298
|
+
message: existing.hasVscode ? `${VSCODE_CONFIRM_MESSAGE}${VSCODE_EXISTING_NOTE}` : VSCODE_CONFIRM_MESSAGE,
|
|
299
|
+
initialValue: !existing.hasVscode
|
|
300
|
+
}));
|
|
301
|
+
}
|
|
302
|
+
async function promptTools(cwd) {
|
|
303
|
+
const existing = detectExistingConfigs(cwd);
|
|
304
|
+
const tools = await promptMainTools(existing);
|
|
305
|
+
if (!canConfigureVscode(tools)) return tools;
|
|
306
|
+
return await promptVscodeSettings(existing) ? [...tools, "vscode"] : tools;
|
|
307
|
+
}
|
|
172
308
|
// src/cli/write_generated_file.ts
|
|
173
309
|
async function writeGeneratedFile(filePath, content) {
|
|
174
310
|
const fileName = basename(filePath);
|
|
@@ -193,7 +329,9 @@ async function updateEditorConfig(result) {
|
|
|
193
329
|
const INDENT = " ";
|
|
194
330
|
const INDENT_WIDTH = 2;
|
|
195
331
|
const PRINT_WIDTH = 80;
|
|
332
|
+
const SAFE_SINGLE_QUOTED_TEXT = /^[^'\\\p{Cc}]*$/u;
|
|
196
333
|
function quote(text) {
|
|
334
|
+
if (!SAFE_SINGLE_QUOTED_TEXT.test(text)) return JSON.stringify(text);
|
|
197
335
|
return `'${text}'`;
|
|
198
336
|
}
|
|
199
337
|
function buildArrayOptionLines(key, items) {
|
|
@@ -238,7 +376,6 @@ function buildKnipConfigContent(adonisjs) {
|
|
|
238
376
|
return buildPresetConfigFile(KNIP_IMPORT, toPresetOptions$1(adonisjs));
|
|
239
377
|
}
|
|
240
378
|
// src/cli/update_knip.ts
|
|
241
|
-
const KNIP_PACKAGES = ["knip", TOOLING_PACKAGE_NAME];
|
|
242
379
|
function warnAboutConflictingConfigs$1(cwd) {
|
|
243
380
|
const conflictingFileNames = KNIP_CONFIG_FILE_NAMES.filter((fileName) => fileName !== "knip.ts" && existsSync(join(cwd, fileName)));
|
|
244
381
|
for (const fileName of conflictingFileNames) log.warn(`${fileName} found: it will conflict with the generated ${KNIP_CONFIG_FILE_NAME}. Consider removing it.`);
|
|
@@ -253,10 +390,6 @@ async function updateKnip(result) {
|
|
|
253
390
|
const adonisjsOption = await detectAdonisjsOption(cwd, result);
|
|
254
391
|
warnAboutConflictingConfigs$1(cwd);
|
|
255
392
|
await writeGeneratedFile(join(cwd, KNIP_CONFIG_FILE_NAME), buildKnipConfigContent(adonisjsOption));
|
|
256
|
-
await installPackage(KNIP_PACKAGES, {
|
|
257
|
-
dev: true,
|
|
258
|
-
cwd
|
|
259
|
-
});
|
|
260
393
|
log.success("Knip configured");
|
|
261
394
|
}
|
|
262
395
|
// src/cli/oxc_config_content.ts
|
|
@@ -265,15 +398,19 @@ const OXLINT_PRESET_ORDER = [
|
|
|
265
398
|
"react",
|
|
266
399
|
"vitest"
|
|
267
400
|
];
|
|
401
|
+
const DISABLED_SUBPATH_IMPORTS_OPTION = {
|
|
402
|
+
key: "subpathImports",
|
|
403
|
+
value: "false"
|
|
404
|
+
};
|
|
268
405
|
function toPresetOptions(enabledNames) {
|
|
269
406
|
return enabledNames.map((name) => ({
|
|
270
407
|
key: name,
|
|
271
408
|
value: "true"
|
|
272
409
|
}));
|
|
273
410
|
}
|
|
274
|
-
function buildOxlintConfigContent(flags) {
|
|
275
|
-
const
|
|
276
|
-
return buildPresetConfigFile(OXC_LINT_IMPORT,
|
|
411
|
+
function buildOxlintConfigContent(flags, hasSubpathImports) {
|
|
412
|
+
const options = [...toPresetOptions(OXLINT_PRESET_ORDER.filter((name) => flags[name])), ...hasSubpathImports ? [] : [DISABLED_SUBPATH_IMPORTS_OPTION]];
|
|
413
|
+
return buildPresetConfigFile(OXC_LINT_IMPORT, options);
|
|
277
414
|
}
|
|
278
415
|
function buildOxfmtConfigContent(flags) {
|
|
279
416
|
const enabledNames = flags.adonisjs ? ["adonisjs"] : [];
|
|
@@ -300,12 +437,6 @@ async function updateVscodeSettings(cwd) {
|
|
|
300
437
|
log.success(".vscode/settings.json updated");
|
|
301
438
|
}
|
|
302
439
|
// src/cli/update_oxc.ts
|
|
303
|
-
const OXC_PACKAGES = [
|
|
304
|
-
"oxfmt",
|
|
305
|
-
"oxlint",
|
|
306
|
-
"oxlint-tsgolint",
|
|
307
|
-
TOOLING_PACKAGE_NAME
|
|
308
|
-
];
|
|
309
440
|
const OXLINT_CONFIG_FILE = "oxlint.config.ts";
|
|
310
441
|
const OXFMT_CONFIG_FILE = "oxfmt.config.ts";
|
|
311
442
|
const CONFLICTING_OXLINT_CONFIG_FILES = [".oxlintrc.json", ".oxlintrc.jsonc"];
|
|
@@ -317,14 +448,11 @@ function warnAboutConflictingConfigs(cwd) {
|
|
|
317
448
|
async function updateOxc(result) {
|
|
318
449
|
if (!result.tools.includes("oxc")) return;
|
|
319
450
|
const cwd = process.cwd();
|
|
451
|
+
const hasSubpathImports = await detectSubpathImports(cwd);
|
|
320
452
|
warnAboutConflictingConfigs(cwd);
|
|
321
|
-
await writeGeneratedFile(join(cwd, OXLINT_CONFIG_FILE), buildOxlintConfigContent(result.presetFlags));
|
|
453
|
+
await writeGeneratedFile(join(cwd, OXLINT_CONFIG_FILE), buildOxlintConfigContent(result.presetFlags, hasSubpathImports));
|
|
322
454
|
await writeGeneratedFile(join(cwd, OXFMT_CONFIG_FILE), buildOxfmtConfigContent(result.presetFlags));
|
|
323
455
|
if (result.tools.includes("vscode")) await updateVscodeSettings(cwd);
|
|
324
|
-
await installPackage(OXC_PACKAGES, {
|
|
325
|
-
dev: true,
|
|
326
|
-
cwd
|
|
327
|
-
});
|
|
328
456
|
log.success("OXC configured (oxlint + oxfmt)");
|
|
329
457
|
}
|
|
330
458
|
// src/cli/package_scripts.ts
|
|
@@ -401,68 +529,21 @@ async function updatePackageScripts(result) {
|
|
|
401
529
|
if (merge.skippedNames.length > 0) log.info(`package.json scripts already defined, kept: ${merge.skippedNames.join(", ")}`);
|
|
402
530
|
}
|
|
403
531
|
// src/cli/index.ts
|
|
404
|
-
const
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
"
|
|
408
|
-
|
|
409
|
-
];
|
|
410
|
-
function findGitRoot(startDirectory) {
|
|
411
|
-
let directory = startDirectory;
|
|
412
|
-
while (true) {
|
|
413
|
-
if (existsSync(join(directory, ".git"))) return directory;
|
|
414
|
-
const parent = dirname(directory);
|
|
415
|
-
if (parent === directory) return null;
|
|
416
|
-
directory = parent;
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
function existsAtAnyRoot(roots, entryNames) {
|
|
420
|
-
return roots.some((root) => entryNames.some((entryName) => existsSync(join(root, entryName))));
|
|
421
|
-
}
|
|
422
|
-
async function promptTools(cwd) {
|
|
423
|
-
const gitRoot = findGitRoot(cwd);
|
|
424
|
-
const roots = gitRoot && gitRoot !== cwd ? [cwd, gitRoot] : [cwd];
|
|
425
|
-
const hasEditorConfig = existsAtAnyRoot(roots, [".editorconfig"]);
|
|
426
|
-
const hasVscode = existsAtAnyRoot(roots, [".vscode"]);
|
|
427
|
-
const hasKnip = existsAtAnyRoot(roots, KNIP_CONFIG_FILE_NAMES);
|
|
428
|
-
const initialValues = DEFAULT_SELECTED_TOOLS.filter((tool) => {
|
|
429
|
-
if (tool === "editorconfig") return !hasEditorConfig;
|
|
430
|
-
if (tool === "vscode") return !hasVscode;
|
|
431
|
-
if (tool === "knip") return !hasKnip;
|
|
432
|
-
return true;
|
|
433
|
-
});
|
|
434
|
-
return exitWhenCancelled(await multiselect({
|
|
435
|
-
message: "Select tools to configure",
|
|
436
|
-
options: [
|
|
437
|
-
{
|
|
438
|
-
value: "editorconfig",
|
|
439
|
-
label: "EditorConfig",
|
|
440
|
-
...hasEditorConfig && { hint: "already exists" }
|
|
441
|
-
},
|
|
442
|
-
{
|
|
443
|
-
value: "oxc",
|
|
444
|
-
label: "OXC (oxlint + oxfmt)"
|
|
445
|
-
},
|
|
446
|
-
{
|
|
447
|
-
value: "knip",
|
|
448
|
-
label: "Knip (unused files, exports, dependencies)",
|
|
449
|
-
...hasKnip && { hint: "already exists" }
|
|
450
|
-
},
|
|
451
|
-
{
|
|
452
|
-
value: "vscode",
|
|
453
|
-
label: "VSCode settings (.vscode/settings.json)",
|
|
454
|
-
...hasVscode && { hint: "already exists" }
|
|
455
|
-
}
|
|
456
|
-
],
|
|
457
|
-
initialValues,
|
|
458
|
-
required: true
|
|
459
|
-
}));
|
|
532
|
+
const FAILURE_EXIT_CODE = 1;
|
|
533
|
+
function exitWhenNotInteractive() {
|
|
534
|
+
if (process.stdin.isTTY) return;
|
|
535
|
+
log.error("This setup asks questions and needs an interactive terminal. Run it again from a terminal.");
|
|
536
|
+
process.exit(FAILURE_EXIT_CODE);
|
|
460
537
|
}
|
|
461
538
|
async function main() {
|
|
539
|
+
exitWhenNotInteractive();
|
|
462
540
|
const cwd = process.cwd();
|
|
463
541
|
intro(color.blue(TOOLING_PACKAGE_NAME));
|
|
464
542
|
log.info(`You are about to configure ${TOOLING_PACKAGE_NAME} in the current directory: ${color.green(cwd)}`);
|
|
465
|
-
if (!exitWhenCancelled(await confirm({ message: "Continue
|
|
543
|
+
if (!exitWhenCancelled(await confirm({ message: "Continue?" }))) {
|
|
544
|
+
outro("Nothing was changed.");
|
|
545
|
+
return;
|
|
546
|
+
}
|
|
466
547
|
const tools = await promptTools(cwd);
|
|
467
548
|
const result = {
|
|
468
549
|
tools,
|
|
@@ -472,10 +553,12 @@ async function main() {
|
|
|
472
553
|
await updatePackageScripts(result);
|
|
473
554
|
await updateOxc(result);
|
|
474
555
|
await updateKnip(result);
|
|
556
|
+
await installDevPackages(listDevPackages(result), cwd);
|
|
475
557
|
log.success("All done.");
|
|
476
558
|
}
|
|
477
559
|
main().catch((error) => {
|
|
478
560
|
log.error(error instanceof Error ? error.message : String(error));
|
|
479
|
-
|
|
561
|
+
log.info("Files written before the error are kept.");
|
|
562
|
+
process.exit(FAILURE_EXIT_CODE);
|
|
480
563
|
});
|
|
481
564
|
export {};
|
package/dist/oxc/lint.d.mts
CHANGED
|
@@ -6,6 +6,8 @@ export interface MinimalstuffOxlintOptions extends OxlintConfig {
|
|
|
6
6
|
adonisjs?: boolean;
|
|
7
7
|
/** Enable the vitest plugin. */
|
|
8
8
|
vitest?: boolean;
|
|
9
|
+
/** Report relative imports so code uses Node subpath imports (`#folder/file.ts`). Defaults to true. */
|
|
10
|
+
subpathImports?: boolean;
|
|
9
11
|
}
|
|
10
12
|
/**
|
|
11
13
|
* Builds the root oxlint config: preset parts are placed in `extends` before the
|
package/dist/oxc/lint.mjs
CHANGED
|
@@ -2,12 +2,15 @@ import { n as COMMON_IGNORE_PATTERNS, t as ADONISJS_IGNORE_PATTERNS } from "../s
|
|
|
2
2
|
import { defineConfig } from "oxlint";
|
|
3
3
|
// src/oxc/lint.ts
|
|
4
4
|
const INERTIA_FRONTEND_FILES = ["**/inertia/**/*.{ts,tsx}"];
|
|
5
|
+
const TEST_FILES = ["**/*.{test,spec}.{ts,tsx,js,jsx}", "**/tests/**"];
|
|
6
|
+
const RELATIVE_IMPORT_MESSAGE = "Use a subpath import (#folder/file.ts) instead of a relative path.";
|
|
5
7
|
function createBasePreset() {
|
|
6
8
|
return defineConfig({
|
|
7
9
|
plugins: [
|
|
8
10
|
"typescript",
|
|
9
11
|
"unicorn",
|
|
10
|
-
"oxc"
|
|
12
|
+
"oxc",
|
|
13
|
+
"promise"
|
|
11
14
|
],
|
|
12
15
|
categories: { correctness: "error" },
|
|
13
16
|
options: {
|
|
@@ -15,6 +18,13 @@ function createBasePreset() {
|
|
|
15
18
|
typeCheck: true
|
|
16
19
|
},
|
|
17
20
|
rules: {
|
|
21
|
+
"no-await-in-loop": "warn",
|
|
22
|
+
"promise/param-names": "error",
|
|
23
|
+
"promise/no-return-in-finally": "error",
|
|
24
|
+
"promise/no-multiple-resolved": "error",
|
|
25
|
+
"promise/no-new-statics": "error",
|
|
26
|
+
"promise/valid-params": "error",
|
|
27
|
+
"promise/no-nesting": "warn",
|
|
18
28
|
"typescript/await-thenable": "error",
|
|
19
29
|
"typescript/no-floating-promises": "error",
|
|
20
30
|
"typescript/no-misused-promises": "error",
|
|
@@ -27,7 +37,11 @@ function createBasePreset() {
|
|
|
27
37
|
"typescript/prefer-promise-reject-errors": "error",
|
|
28
38
|
"typescript/consistent-type-imports": "error",
|
|
29
39
|
"typescript/no-deprecated": "warn"
|
|
30
|
-
}
|
|
40
|
+
},
|
|
41
|
+
overrides: [{
|
|
42
|
+
files: TEST_FILES,
|
|
43
|
+
rules: { "no-await-in-loop": "off" }
|
|
44
|
+
}]
|
|
31
45
|
});
|
|
32
46
|
}
|
|
33
47
|
function createReactPreset() {
|
|
@@ -74,6 +88,12 @@ function createAdonisjsPreset() {
|
|
|
74
88
|
}
|
|
75
89
|
});
|
|
76
90
|
}
|
|
91
|
+
function createSubpathImportsPreset() {
|
|
92
|
+
return defineConfig({ rules: { "no-restricted-imports": ["error", { patterns: [{
|
|
93
|
+
group: ["./*", "../*"],
|
|
94
|
+
message: RELATIVE_IMPORT_MESSAGE
|
|
95
|
+
}] }] } });
|
|
96
|
+
}
|
|
77
97
|
function createInertiaPreset() {
|
|
78
98
|
return defineConfig({ overrides: [{
|
|
79
99
|
files: INERTIA_FRONTEND_FILES,
|
|
@@ -90,6 +110,7 @@ function createPresets(options) {
|
|
|
90
110
|
if (options.vitest) presets.push(createVitestPreset());
|
|
91
111
|
if (options.adonisjs) presets.push(createAdonisjsPreset());
|
|
92
112
|
if (options.adonisjs && options.react) presets.push(createInertiaPreset());
|
|
113
|
+
if (options.subpathImports) presets.push(createSubpathImportsPreset());
|
|
93
114
|
return presets;
|
|
94
115
|
}
|
|
95
116
|
function createIgnorePatterns(isAdonisjsEnabled, userIgnorePatterns) {
|
|
@@ -106,13 +127,14 @@ function createIgnorePatterns(isAdonisjsEnabled, userIgnorePatterns) {
|
|
|
106
127
|
* root because oxlint does not inherit them through `extends`.
|
|
107
128
|
*/
|
|
108
129
|
function minimalstuffPreset(options = {}) {
|
|
109
|
-
const { react = false, adonisjs = false, vitest = false, extends: userExtends = [], ignorePatterns: userIgnorePatterns = [], ...userConfig } = options;
|
|
130
|
+
const { react = false, adonisjs = false, vitest = false, subpathImports = true, extends: userExtends = [], ignorePatterns: userIgnorePatterns = [], ...userConfig } = options;
|
|
110
131
|
return defineConfig({
|
|
111
132
|
...userConfig,
|
|
112
133
|
extends: [...createPresets({
|
|
113
134
|
react,
|
|
114
135
|
adonisjs,
|
|
115
|
-
vitest
|
|
136
|
+
vitest,
|
|
137
|
+
subpathImports
|
|
116
138
|
}), ...userExtends],
|
|
117
139
|
ignorePatterns: createIgnorePatterns(adonisjs, userIgnorePatterns)
|
|
118
140
|
});
|
package/package.json
CHANGED
|
@@ -1,115 +1,131 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
2
|
+
"name": "@minimalstuff/tooling",
|
|
3
|
+
"version": "0.8.0",
|
|
4
|
+
"description": "Shared tooling configs: EditorConfig, OXC (oxlint + oxfmt), Knip",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"editorconfig",
|
|
7
|
+
"knip",
|
|
8
|
+
"oxc",
|
|
9
|
+
"oxfmt",
|
|
10
|
+
"oxlint",
|
|
11
|
+
"react"
|
|
12
|
+
],
|
|
13
|
+
"homepage": "https://github.com/minimalstuff/tooling#readme",
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/minimalstuff/tooling/issues"
|
|
16
|
+
},
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"author": "Sonny93 <sonnyasdev@gmail.com>",
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "https://github.com/minimalstuff/tooling"
|
|
22
|
+
},
|
|
23
|
+
"bin": {
|
|
24
|
+
"tooling": "./dist/cli/index.mjs"
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"dist",
|
|
28
|
+
"preset"
|
|
29
|
+
],
|
|
30
|
+
"type": "module",
|
|
31
|
+
"imports": {
|
|
32
|
+
"#*": "./src/*"
|
|
33
|
+
},
|
|
34
|
+
"exports": {
|
|
35
|
+
"./editorconfig": "./preset/.editorconfig",
|
|
36
|
+
"./oxc/lint": "./dist/oxc/lint.mjs",
|
|
37
|
+
"./oxc/fmt": "./dist/oxc/fmt.mjs",
|
|
38
|
+
"./knip": "./dist/knip/knip.mjs"
|
|
39
|
+
},
|
|
40
|
+
"publishConfig": {
|
|
41
|
+
"access": "public",
|
|
42
|
+
"provenance": true
|
|
43
|
+
},
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"@antfu/install-pkg": "^2.1.0",
|
|
46
|
+
"@clack/prompts": "^1.8.1",
|
|
47
|
+
"jsonc-parser": "^3.3.1",
|
|
48
|
+
"picocolors": "^1.1.1"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@adonisjs/eslint-plugin": "^2.2.2",
|
|
52
|
+
"@release-it/keep-a-changelog": "^8.0.1",
|
|
53
|
+
"@types/node": "^26.6.6",
|
|
54
|
+
"knip": "6.44.1",
|
|
55
|
+
"oxfmt": "^0.75.0",
|
|
56
|
+
"oxlint": "^1.90.0",
|
|
57
|
+
"oxlint-tsgolint": "^7.0.2005",
|
|
58
|
+
"release-it": "^21.1.2",
|
|
59
|
+
"tsdown": "^0.23.4",
|
|
60
|
+
"typescript": "^7.0.2",
|
|
61
|
+
"vitest": "^5.0.5"
|
|
62
|
+
},
|
|
63
|
+
"peerDependencies": {
|
|
64
|
+
"@adonisjs/eslint-plugin": "^2.2.2",
|
|
65
|
+
"knip": ">=6.42.1",
|
|
66
|
+
"oxfmt": ">=0.74.0",
|
|
67
|
+
"oxlint": ">=1.89.0",
|
|
68
|
+
"oxlint-tsgolint": ">=7.0.2004"
|
|
69
|
+
},
|
|
70
|
+
"peerDependenciesMeta": {
|
|
71
|
+
"@adonisjs/eslint-plugin": {
|
|
72
|
+
"optional": true
|
|
73
|
+
},
|
|
74
|
+
"knip": {
|
|
75
|
+
"optional": true
|
|
76
|
+
},
|
|
77
|
+
"oxfmt": {
|
|
78
|
+
"optional": true
|
|
79
|
+
},
|
|
80
|
+
"oxlint": {
|
|
81
|
+
"optional": true
|
|
82
|
+
},
|
|
83
|
+
"oxlint-tsgolint": {
|
|
84
|
+
"optional": true
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
"engines": {
|
|
88
|
+
"node": ">=26"
|
|
89
|
+
},
|
|
90
|
+
"release-it": {
|
|
91
|
+
"hooks": {
|
|
92
|
+
"before:init": "pnpm checks"
|
|
93
|
+
},
|
|
94
|
+
"git": {
|
|
95
|
+
"requireCleanWorkingDir": true,
|
|
96
|
+
"requireUpstream": true,
|
|
97
|
+
"commitMessage": "chore(release): ${version}",
|
|
98
|
+
"tagAnnotation": "v${version}",
|
|
99
|
+
"push": true,
|
|
100
|
+
"tagName": "v${version}",
|
|
101
|
+
"tagExclude": "*.*.*-*"
|
|
102
|
+
},
|
|
103
|
+
"github": {
|
|
104
|
+
"release": true
|
|
105
|
+
},
|
|
106
|
+
"npm": {
|
|
107
|
+
"publish": false
|
|
108
|
+
},
|
|
109
|
+
"plugins": {
|
|
110
|
+
"@release-it/keep-a-changelog": {
|
|
111
|
+
"filename": "CHANGELOG.md",
|
|
112
|
+
"addUnreleased": true,
|
|
113
|
+
"addVersionUrl": true
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
"scripts": {
|
|
118
|
+
"knip": "knip",
|
|
119
|
+
"lint": "oxlint",
|
|
120
|
+
"lint:fix": "oxlint --fix",
|
|
121
|
+
"format": "oxfmt && oxlint --fix",
|
|
122
|
+
"format:check": "oxfmt --check",
|
|
123
|
+
"typecheck": "tsc --noEmit",
|
|
124
|
+
"test": "vitest run",
|
|
125
|
+
"test:package": "vitest run --config vitest.package.config.ts",
|
|
126
|
+
"build": "tsdown",
|
|
127
|
+
"checks": "pnpm typecheck && pnpm lint && pnpm format:check && pnpm knip && pnpm test && pnpm build",
|
|
128
|
+
"release": "release-it",
|
|
129
|
+
"release:next": "release-it --preRelease=next --plugins.@release-it/keep-a-changelog.keepUnreleased"
|
|
130
|
+
}
|
|
131
|
+
}
|