@minimalstuff/tooling 0.1.3 → 0.2.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/README.md +27 -27
- package/dist/cli/index.d.mts +1 -1
- package/dist/cli/index.mjs +16 -41
- package/dist/oxc/lint.mjs +25 -1
- package/package.json +12 -8
- package/dist/tsconfigs/tsconfig.base.json +0 -29
- package/dist/tsconfigs/tsconfig.node-next.json +0 -7
- package/dist/tsconfigs/tsconfig.node.json +0 -15
- package/dist/tsconfigs/tsconfig.react.json +0 -16
package/README.md
CHANGED
|
@@ -29,11 +29,11 @@ pnpm add -D oxlint oxfmt @minimalstuff/tooling
|
|
|
29
29
|
|
|
30
30
|
```ts
|
|
31
31
|
// oxlint.config.ts
|
|
32
|
-
import { defineConfig } from
|
|
33
|
-
import { minimalstuffPreset } from
|
|
32
|
+
import { defineConfig } from 'oxlint';
|
|
33
|
+
import { minimalstuffPreset } from '@minimalstuff/tooling/oxc/lint';
|
|
34
34
|
|
|
35
35
|
export default defineConfig({
|
|
36
|
-
|
|
36
|
+
extends: [minimalstuffPreset()],
|
|
37
37
|
});
|
|
38
38
|
```
|
|
39
39
|
|
|
@@ -47,9 +47,9 @@ Options:
|
|
|
47
47
|
|
|
48
48
|
```ts
|
|
49
49
|
export default defineConfig({
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
extends: [
|
|
51
|
+
minimalstuffPreset({ react: true, adonisjs: true, perfectionist: true }),
|
|
52
|
+
],
|
|
53
53
|
});
|
|
54
54
|
```
|
|
55
55
|
|
|
@@ -57,7 +57,7 @@ export default defineConfig({
|
|
|
57
57
|
|
|
58
58
|
```ts
|
|
59
59
|
// oxfmt.config.ts
|
|
60
|
-
import { minimalstuffPreset } from
|
|
60
|
+
import { minimalstuffPreset } from '@minimalstuff/tooling/oxc/fmt';
|
|
61
61
|
|
|
62
62
|
export default minimalstuffPreset();
|
|
63
63
|
```
|
|
@@ -74,11 +74,11 @@ Defaults: `printWidth: 100`, `semi: false`, `singleQuote: true`, `trailingComma:
|
|
|
74
74
|
|
|
75
75
|
```json
|
|
76
76
|
{
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
77
|
+
"scripts": {
|
|
78
|
+
"lint": "oxlint",
|
|
79
|
+
"lint:fix": "oxlint --fix",
|
|
80
|
+
"format": "oxfmt --write ."
|
|
81
|
+
}
|
|
82
82
|
}
|
|
83
83
|
```
|
|
84
84
|
|
|
@@ -88,11 +88,11 @@ Node (ESM):
|
|
|
88
88
|
|
|
89
89
|
```json
|
|
90
90
|
{
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
91
|
+
"extends": "@minimalstuff/tooling/tsconfigs/tsconfig.node",
|
|
92
|
+
"compilerOptions": {
|
|
93
|
+
"rootDir": "./",
|
|
94
|
+
"outDir": "./build"
|
|
95
|
+
}
|
|
96
96
|
}
|
|
97
97
|
```
|
|
98
98
|
|
|
@@ -100,11 +100,11 @@ Node Next (ESM + `ts` extensions):
|
|
|
100
100
|
|
|
101
101
|
```json
|
|
102
102
|
{
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
103
|
+
"extends": "@minimalstuff/tooling/tsconfigs/tsconfig.node-next",
|
|
104
|
+
"compilerOptions": {
|
|
105
|
+
"rootDir": "./",
|
|
106
|
+
"outDir": "./build"
|
|
107
|
+
}
|
|
108
108
|
}
|
|
109
109
|
```
|
|
110
110
|
|
|
@@ -112,11 +112,11 @@ React (TSX, bundler resolution):
|
|
|
112
112
|
|
|
113
113
|
```json
|
|
114
114
|
{
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
115
|
+
"extends": "@minimalstuff/tooling/tsconfigs/tsconfig.react",
|
|
116
|
+
"compilerOptions": {
|
|
117
|
+
"rootDir": "./",
|
|
118
|
+
"outDir": "./build"
|
|
119
|
+
}
|
|
120
120
|
}
|
|
121
121
|
```
|
|
122
122
|
|
package/dist/cli/index.d.mts
CHANGED
package/dist/cli/index.mjs
CHANGED
|
@@ -32,12 +32,13 @@ const vscodeSettings = {
|
|
|
32
32
|
};
|
|
33
33
|
const oxcScripts = {
|
|
34
34
|
format: "oxfmt --write .",
|
|
35
|
-
lint: "oxlint",
|
|
36
|
-
"lint:fix": "oxlint --fix"
|
|
35
|
+
lint: "oxlint --type-aware",
|
|
36
|
+
"lint:fix": "oxlint --type-aware --fix"
|
|
37
37
|
};
|
|
38
38
|
const oxcPackages = [
|
|
39
39
|
"oxfmt",
|
|
40
40
|
"oxlint",
|
|
41
|
+
"oxlint-tsgolint",
|
|
41
42
|
TOOLING_PACKAGE_NAME
|
|
42
43
|
];
|
|
43
44
|
async function updateOxc(result) {
|
|
@@ -67,41 +68,27 @@ async function updateVscodeSettings(cwd) {
|
|
|
67
68
|
}
|
|
68
69
|
async function addScriptsToPackageJson(cwd) {
|
|
69
70
|
const pkgPath = join(cwd, "package.json");
|
|
70
|
-
const
|
|
71
|
+
const raw = await readFile(pkgPath, "utf-8");
|
|
72
|
+
const pkg = JSON.parse(raw);
|
|
71
73
|
pkg.scripts ??= {};
|
|
72
74
|
for (const [key, value] of Object.entries(oxcScripts)) pkg.scripts[key] = value;
|
|
73
75
|
await writeFile(pkgPath, JSON.stringify(pkg, null, 2));
|
|
74
76
|
}
|
|
75
77
|
//#endregion
|
|
76
78
|
//#region package.json
|
|
77
|
-
var version = "0.
|
|
79
|
+
var version = "0.2.0";
|
|
78
80
|
//#endregion
|
|
79
81
|
//#region src/cli/update_pkg.json.ts
|
|
80
82
|
async function updatePkgJson(_) {
|
|
81
83
|
const pathPackageJSON = join(process.cwd(), "package.json");
|
|
82
|
-
const
|
|
84
|
+
const raw = await readFile(pathPackageJSON, "utf-8");
|
|
85
|
+
const userPkgJson = JSON.parse(raw);
|
|
83
86
|
userPkgJson.devDependencies ??= {};
|
|
84
87
|
userPkgJson.devDependencies[TOOLING_PACKAGE_NAME] = `^${version}`;
|
|
85
88
|
await writeFile(pathPackageJSON, JSON.stringify(userPkgJson, null, 2));
|
|
86
89
|
p.log.success("Package.json updated 🤠");
|
|
87
90
|
}
|
|
88
91
|
//#endregion
|
|
89
|
-
//#region src/cli/update_tsconfig.ts
|
|
90
|
-
const tsConfigContent = `
|
|
91
|
-
{
|
|
92
|
-
"extends": "${TOOLING_PACKAGE_NAME}/tsconfigs/tsconfig.node",
|
|
93
|
-
"compilerOptions": {
|
|
94
|
-
"rootDir": "./",
|
|
95
|
-
"outDir": "./build"
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
`;
|
|
99
|
-
async function updateTsconfig(result) {
|
|
100
|
-
if (!result.tools.includes("tsconfig")) return;
|
|
101
|
-
await writeFile(join(process.cwd(), "tsconfig.json"), tsConfigContent);
|
|
102
|
-
p.log.success("Typescript configured 👹");
|
|
103
|
-
}
|
|
104
|
-
//#endregion
|
|
105
92
|
//#region src/cli/update_editorconfig.ts
|
|
106
93
|
const presetPath = fileURLToPath(new URL("../../preset/.editorconfig", import.meta.url));
|
|
107
94
|
async function updateEditorConfig(result) {
|
|
@@ -113,11 +100,7 @@ async function updateEditorConfig(result) {
|
|
|
113
100
|
}
|
|
114
101
|
//#endregion
|
|
115
102
|
//#region src/cli/index.ts
|
|
116
|
-
const DEFAULT_SELECTED_TOOLS = [
|
|
117
|
-
"editorconfig",
|
|
118
|
-
"tsconfig",
|
|
119
|
-
"oxc"
|
|
120
|
-
];
|
|
103
|
+
const DEFAULT_SELECTED_TOOLS = ["editorconfig", "oxc"];
|
|
121
104
|
function exit() {
|
|
122
105
|
cancel("Cancelled");
|
|
123
106
|
return process.exit(0);
|
|
@@ -129,27 +112,19 @@ async function main() {
|
|
|
129
112
|
if (isCancel(await confirm({ message: `Continue ?` }))) return exit();
|
|
130
113
|
const tools = await multiselect({
|
|
131
114
|
message: "Select tools to configure",
|
|
132
|
-
options: [
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
label: "TypeScript"
|
|
140
|
-
},
|
|
141
|
-
{
|
|
142
|
-
value: "oxc",
|
|
143
|
-
label: "OXC (oxlint + oxfmt)"
|
|
144
|
-
}
|
|
145
|
-
],
|
|
115
|
+
options: [{
|
|
116
|
+
value: "editorconfig",
|
|
117
|
+
label: "EditorConfig"
|
|
118
|
+
}, {
|
|
119
|
+
value: "oxc",
|
|
120
|
+
label: "OXC (oxlint + oxfmt)"
|
|
121
|
+
}],
|
|
146
122
|
initialValues: DEFAULT_SELECTED_TOOLS,
|
|
147
123
|
required: true
|
|
148
124
|
});
|
|
149
125
|
if (isCancel(tools)) return exit();
|
|
150
126
|
await updatePkgJson({ tools });
|
|
151
127
|
await updateEditorConfig({ tools });
|
|
152
|
-
await updateTsconfig({ tools });
|
|
153
128
|
await updateOxc({ tools });
|
|
154
129
|
log.success("All done. Make sure to install the dependencies with `pnpm install`.");
|
|
155
130
|
}
|
package/dist/oxc/lint.mjs
CHANGED
|
@@ -1,6 +1,26 @@
|
|
|
1
1
|
import { t as IGNORE_PATTERNS } from "../shared-CoSP_HvN.mjs";
|
|
2
2
|
import { defineConfig } from "oxlint";
|
|
3
3
|
//#region src/oxc/lint.ts
|
|
4
|
+
const STRICT_TYPE_AWARE_RULES = {
|
|
5
|
+
"typescript/await-thenable": "error",
|
|
6
|
+
"typescript/no-floating-promises": "error",
|
|
7
|
+
"typescript/no-misused-promises": "error",
|
|
8
|
+
"typescript/no-unnecessary-condition": "error",
|
|
9
|
+
"typescript/no-unnecessary-type-assertion": "error",
|
|
10
|
+
"typescript/no-unsafe-argument": "error",
|
|
11
|
+
"typescript/no-unsafe-assignment": "error",
|
|
12
|
+
"typescript/no-unsafe-call": "error",
|
|
13
|
+
"typescript/no-unsafe-member-access": "error",
|
|
14
|
+
"typescript/no-unsafe-return": "error",
|
|
15
|
+
"typescript/prefer-nullish-coalescing": "error",
|
|
16
|
+
"typescript/prefer-optional-chain": "error",
|
|
17
|
+
"typescript/strict-boolean-expressions": ["error", {
|
|
18
|
+
allowNullableBoolean: true,
|
|
19
|
+
allowNullableObject: true,
|
|
20
|
+
allowNullableString: true
|
|
21
|
+
}],
|
|
22
|
+
"typescript/switch-exhaustiveness-check": "error"
|
|
23
|
+
};
|
|
4
24
|
function reactPreset() {
|
|
5
25
|
return defineConfig({
|
|
6
26
|
plugins: ["react", "react-perf"],
|
|
@@ -71,7 +91,11 @@ function defaultPreset() {
|
|
|
71
91
|
"eslint",
|
|
72
92
|
"oxc"
|
|
73
93
|
],
|
|
74
|
-
rules: {}
|
|
94
|
+
rules: { ...STRICT_TYPE_AWARE_RULES },
|
|
95
|
+
options: {
|
|
96
|
+
typeAware: true,
|
|
97
|
+
typeCheck: true
|
|
98
|
+
}
|
|
75
99
|
});
|
|
76
100
|
}
|
|
77
101
|
function minimalstuffPreset(config = {}) {
|
package/package.json
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@minimalstuff/tooling",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Shared tooling configs: EditorConfig,
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Shared tooling configs: EditorConfig, OXC (oxlint + oxfmt)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"editorconfig",
|
|
7
7
|
"oxc",
|
|
8
8
|
"oxfmt",
|
|
9
9
|
"oxlint",
|
|
10
|
-
"react"
|
|
11
|
-
"tsconfig"
|
|
10
|
+
"react"
|
|
12
11
|
],
|
|
13
12
|
"license": "MIT",
|
|
14
13
|
"author": "Sonny93 <sonnyasdev@gmail.com>",
|
|
@@ -24,7 +23,6 @@
|
|
|
24
23
|
"type": "module",
|
|
25
24
|
"exports": {
|
|
26
25
|
"./editorconfig": "./preset/.editorconfig",
|
|
27
|
-
"./tsconfigs/*": "./dist/tsconfigs/*.json",
|
|
28
26
|
"./oxc/lint": "./dist/oxc/lint.mjs",
|
|
29
27
|
"./oxc/fmt": "./dist/oxc/fmt.mjs"
|
|
30
28
|
},
|
|
@@ -33,8 +31,9 @@
|
|
|
33
31
|
"provenance": true
|
|
34
32
|
},
|
|
35
33
|
"scripts": {
|
|
36
|
-
"lint": "oxlint",
|
|
37
|
-
"
|
|
34
|
+
"lint": "oxlint --type-aware",
|
|
35
|
+
"lint:fix": "oxlint --type-aware --fix",
|
|
36
|
+
"format": "oxfmt --write . && oxlint --type-aware --fix",
|
|
38
37
|
"build": "tsdown",
|
|
39
38
|
"release": "release-it",
|
|
40
39
|
"typecheck": "tsc --noEmit",
|
|
@@ -52,13 +51,15 @@
|
|
|
52
51
|
"@types/node": "^25.2.3",
|
|
53
52
|
"oxfmt": "^0.40.0",
|
|
54
53
|
"oxlint": "^1.55.0",
|
|
54
|
+
"oxlint-tsgolint": "^0.20.0",
|
|
55
55
|
"release-it": "^19.2.4",
|
|
56
56
|
"tsdown": "^0.21.3",
|
|
57
57
|
"typescript": "^5.9.3"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
60
|
"oxfmt": ">=0.40.0",
|
|
61
|
-
"oxlint": ">=1.55.0"
|
|
61
|
+
"oxlint": ">=1.55.0",
|
|
62
|
+
"oxlint-tsgolint": ">=0.20.0"
|
|
62
63
|
},
|
|
63
64
|
"peerDependenciesMeta": {
|
|
64
65
|
"oxfmt": {
|
|
@@ -66,6 +67,9 @@
|
|
|
66
67
|
},
|
|
67
68
|
"oxlint": {
|
|
68
69
|
"optional": true
|
|
70
|
+
},
|
|
71
|
+
"oxlint-tsgolint": {
|
|
72
|
+
"optional": true
|
|
69
73
|
}
|
|
70
74
|
},
|
|
71
75
|
"packageManager": "pnpm@10.29.3",
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"experimentalDecorators": true,
|
|
4
|
-
"checkJs": true,
|
|
5
|
-
"strict": true,
|
|
6
|
-
"allowUnreachableCode": false,
|
|
7
|
-
"allowUnusedLabels": false,
|
|
8
|
-
"exactOptionalPropertyTypes": true,
|
|
9
|
-
"noFallthroughCasesInSwitch": true,
|
|
10
|
-
"noImplicitAny": true,
|
|
11
|
-
"noImplicitOverride": true,
|
|
12
|
-
"noImplicitReturns": true,
|
|
13
|
-
"noImplicitThis": true,
|
|
14
|
-
"noUnusedLocals": true,
|
|
15
|
-
"noUnusedParameters": true,
|
|
16
|
-
"allowImportingTsExtensions": true,
|
|
17
|
-
"rewriteRelativeImportExtensions": true,
|
|
18
|
-
"useUnknownInCatchVariables": true,
|
|
19
|
-
"allowSyntheticDefaultImports": true,
|
|
20
|
-
"esModuleInterop": true,
|
|
21
|
-
"forceConsistentCasingInFileNames": true,
|
|
22
|
-
"isolatedModules": true,
|
|
23
|
-
"verbatimModuleSyntax": true,
|
|
24
|
-
"skipLibCheck": true
|
|
25
|
-
},
|
|
26
|
-
"ts-node": {
|
|
27
|
-
"swc": true
|
|
28
|
-
}
|
|
29
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
-
"extends": "./tsconfig.base.json",
|
|
4
|
-
"compilerOptions": {
|
|
5
|
-
"target": "ESNext",
|
|
6
|
-
"lib": ["ESNext"],
|
|
7
|
-
"emitDecoratorMetadata": true,
|
|
8
|
-
"experimentalDecorators": true,
|
|
9
|
-
"module": "NodeNext",
|
|
10
|
-
"moduleResolution": "NodeNext",
|
|
11
|
-
"resolveJsonModule": true,
|
|
12
|
-
"sourceMap": true,
|
|
13
|
-
"allowSyntheticDefaultImports": true
|
|
14
|
-
}
|
|
15
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
-
"extends": "./tsconfig.base.json",
|
|
4
|
-
"compilerOptions": {
|
|
5
|
-
"target": "ESNext",
|
|
6
|
-
"lib": ["DOM", "DOM.Iterable", "ESNext", "ES2020"],
|
|
7
|
-
"jsx": "react-jsx",
|
|
8
|
-
"useDefineForClassFields": true,
|
|
9
|
-
"module": "NodeNext",
|
|
10
|
-
"moduleResolution": "Bundler",
|
|
11
|
-
"resolveJsonModule": true,
|
|
12
|
-
"allowSyntheticDefaultImports": true,
|
|
13
|
-
"esModuleInterop": true,
|
|
14
|
-
"verbatimModuleSyntax": true
|
|
15
|
-
}
|
|
16
|
-
}
|