@minimalstuff/tooling 0.1.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 ADDED
@@ -0,0 +1,133 @@
1
+ ## Features
2
+
3
+ - Shared presets for [OXC](https://oxc.rs/) tools (oxlint + oxfmt)
4
+ - TypeScript configuration presets
5
+ - CLI for quick project setup
6
+
7
+ ## Usage
8
+
9
+ > [!IMPORTANT]
10
+ > New/updated rules will not be considered as breaking changes. Only API changes will be considered as breaking changes.
11
+
12
+ ### CLI installation
13
+
14
+ Just run this command in your project root directory:
15
+
16
+ ```bash
17
+ pnpm dlx @minimalstuff/tooling@latest
18
+ ```
19
+
20
+ ### Manual install
21
+
22
+ ```bash
23
+ pnpm add -D oxlint oxfmt @minimalstuff/tooling
24
+ ```
25
+
26
+ ### OXC (oxlint + oxfmt)
27
+
28
+ #### oxlint
29
+
30
+ ```ts
31
+ // oxlint.config.ts
32
+ import { defineConfig } from "oxlint";
33
+ import { minimalstuffPreset } from "@minimalstuff/tooling/oxc/lint";
34
+
35
+ export default defineConfig({
36
+ extends: [minimalstuffPreset()],
37
+ });
38
+ ```
39
+
40
+ Options:
41
+
42
+ | Option | Type | Default | Description |
43
+ | --------------- | --------- | ------- | --------------------------------------- |
44
+ | `react` | `boolean` | `false` | Enable React-specific oxlint plugins |
45
+ | `adonisjs` | `boolean` | `false` | Enable AdonisJS-specific rules |
46
+ | `perfectionist` | `boolean` | `false` | Enable import sorting via perfectionist |
47
+
48
+ ```ts
49
+ export default defineConfig({
50
+ extends: [
51
+ minimalstuffPreset({ react: true, adonisjs: true, perfectionist: true }),
52
+ ],
53
+ });
54
+ ```
55
+
56
+ #### oxfmt
57
+
58
+ ```ts
59
+ // oxfmt.config.ts
60
+ import { minimalstuffPreset } from "@minimalstuff/tooling/oxc/fmt";
61
+
62
+ export default minimalstuffPreset();
63
+ ```
64
+
65
+ You can override any option:
66
+
67
+ ```ts
68
+ export default minimalstuffPreset({ printWidth: 120, semi: true });
69
+ ```
70
+
71
+ Defaults: `printWidth: 100`, `semi: false`, `singleQuote: true`, `trailingComma: 'all'`, `arrowParens: 'avoid'`.
72
+
73
+ #### Scripts
74
+
75
+ ```json
76
+ {
77
+ "scripts": {
78
+ "lint": "oxlint",
79
+ "lint:fix": "oxlint --fix",
80
+ "format": "oxfmt --write ."
81
+ }
82
+ }
83
+ ```
84
+
85
+ ### Tsconfig
86
+
87
+ Node (ESM):
88
+
89
+ ```json
90
+ {
91
+ "extends": "@minimalstuff/tooling/tsconfigs/tsconfig.node",
92
+ "compilerOptions": {
93
+ "rootDir": "./",
94
+ "outDir": "./build"
95
+ }
96
+ }
97
+ ```
98
+
99
+ Node Next (ESM + `ts` extensions):
100
+
101
+ ```json
102
+ {
103
+ "extends": "@minimalstuff/tooling/tsconfigs/tsconfig.node-next",
104
+ "compilerOptions": {
105
+ "rootDir": "./",
106
+ "outDir": "./build"
107
+ }
108
+ }
109
+ ```
110
+
111
+ React (TSX, bundler resolution):
112
+
113
+ ```json
114
+ {
115
+ "extends": "@minimalstuff/tooling/tsconfigs/tsconfig.react",
116
+ "compilerOptions": {
117
+ "rootDir": "./",
118
+ "outDir": "./build"
119
+ }
120
+ }
121
+ ```
122
+
123
+ ### Prerequisites
124
+
125
+ 1. **NPM token**
126
+ Create an automation token at [npmjs.com/access-tokens](https://www.npmjs.com/access-tokens) (scope: package publish for `@minimalstuff/ui`).
127
+
128
+ 2. **Repository secret**
129
+ In the repo: **Settings → Secrets and variables → Actions**. Add a secret named `NPM_TOKEN` with the token value.
130
+
131
+ ---
132
+
133
+ > source: https://github.com/Julien-R44/tooling
@@ -0,0 +1,8 @@
1
+ //#region src/cli/index.d.ts
2
+ type ConfigTool = 'editorconfig' | 'tsconfig' | 'oxc';
3
+ declare const DEFAULT_SELECTED_TOOLS: ConfigTool[];
4
+ interface PromptResult {
5
+ tools: ConfigTool[];
6
+ }
7
+ //#endregion
8
+ export { ConfigTool, DEFAULT_SELECTED_TOOLS, PromptResult };
@@ -0,0 +1,158 @@
1
+ #!/usr/bin/env node
2
+ import color from "picocolors";
3
+ import * as p from "@clack/prompts";
4
+ import { cancel, confirm, intro, isCancel, log, multiselect } from "@clack/prompts";
5
+ import { join } from "node:path";
6
+ import { existsSync } from "node:fs";
7
+ import { installPackage } from "@antfu/install-pkg";
8
+ import { mkdir, readFile, writeFile } from "node:fs/promises";
9
+ import { fileURLToPath } from "node:url";
10
+ //#region src/constants.ts
11
+ const TOOLING_PACKAGE_NAME = "@minimalstuff/tooling";
12
+ const OXC_LINT_IMPORT = `${TOOLING_PACKAGE_NAME}/oxc/lint`;
13
+ const OXC_FMT_IMPORT = `${TOOLING_PACKAGE_NAME}/oxc/fmt`;
14
+ `${TOOLING_PACKAGE_NAME}`;
15
+ //#endregion
16
+ //#region src/cli/update_oxc.ts
17
+ const oxlintConfigContent = `import { defineConfig } from 'oxlint'
18
+ import { minimalstuffPreset } from '${OXC_LINT_IMPORT}'
19
+
20
+ export default defineConfig({
21
+ extends: [minimalstuffPreset()],
22
+ })
23
+ `;
24
+ const oxfmtConfigContent = `import { minimalstuffPreset } from '${OXC_FMT_IMPORT}'
25
+
26
+ export default minimalstuffPreset()
27
+ `;
28
+ const vscodeSettings = {
29
+ "oxc.typeAware": true,
30
+ "oxc.fmt.experimental": true,
31
+ "editor.defaultFormatter": "oxc.oxc-vscode"
32
+ };
33
+ const oxcScripts = {
34
+ format: "oxfmt --write .",
35
+ lint: "oxlint",
36
+ "lint:fix": "oxlint --fix"
37
+ };
38
+ const oxcPackages = [
39
+ "oxfmt",
40
+ "oxlint",
41
+ TOOLING_PACKAGE_NAME
42
+ ];
43
+ async function updateOxc(result) {
44
+ if (!result.tools.includes("oxc")) return;
45
+ const cwd = process.cwd();
46
+ await writeFile(join(cwd, "oxlint.config.ts"), oxlintConfigContent);
47
+ await writeFile(join(cwd, "oxfmt.config.ts"), oxfmtConfigContent);
48
+ await updateVscodeSettings(cwd);
49
+ await addScriptsToPackageJson(cwd);
50
+ await installPackage(oxcPackages, {
51
+ dev: true,
52
+ cwd
53
+ });
54
+ p.log.success("OXC configured (oxlint + oxfmt) 🦀");
55
+ }
56
+ async function updateVscodeSettings(cwd) {
57
+ const vscodePath = join(cwd, ".vscode");
58
+ const settingsPath = join(vscodePath, "settings.json");
59
+ if (!existsSync(vscodePath)) await mkdir(vscodePath);
60
+ let settings = {};
61
+ if (existsSync(settingsPath)) {
62
+ const content = await readFile(settingsPath, "utf-8");
63
+ settings = JSON.parse(content);
64
+ }
65
+ for (const [key, value] of Object.entries(vscodeSettings)) if (!(key in settings)) settings[key] = value;
66
+ await writeFile(settingsPath, JSON.stringify(settings, null, 2));
67
+ }
68
+ async function addScriptsToPackageJson(cwd) {
69
+ const pkgPath = join(cwd, "package.json");
70
+ const pkg = JSON.parse(await readFile(pkgPath, "utf-8"));
71
+ pkg.scripts ??= {};
72
+ for (const [key, value] of Object.entries(oxcScripts)) pkg.scripts[key] = value;
73
+ await writeFile(pkgPath, JSON.stringify(pkg, null, 2));
74
+ }
75
+ //#endregion
76
+ //#region package.json
77
+ var version = "0.1.2";
78
+ //#endregion
79
+ //#region src/cli/update_pkg.json.ts
80
+ async function updatePkgJson(_) {
81
+ const pathPackageJSON = join(process.cwd(), "package.json");
82
+ const userPkgJson = JSON.parse(await readFile(pathPackageJSON, "utf-8"));
83
+ userPkgJson.devDependencies ??= {};
84
+ userPkgJson.devDependencies[TOOLING_PACKAGE_NAME] = `^${version}`;
85
+ await writeFile(pathPackageJSON, JSON.stringify(userPkgJson, null, 2));
86
+ p.log.success("Package.json updated 🤠");
87
+ }
88
+ //#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
+ //#region src/cli/update_editorconfig.ts
106
+ const presetPath = fileURLToPath(new URL("../../preset/.editorconfig", import.meta.url));
107
+ async function updateEditorConfig(result) {
108
+ if (!result.tools.includes("editorconfig")) return;
109
+ const cwd = process.cwd();
110
+ const content = await readFile(presetPath, "utf-8");
111
+ await writeFile(join(cwd, ".editorconfig"), content, "utf-8");
112
+ p.log.success(".editorconfig updated");
113
+ }
114
+ //#endregion
115
+ //#region src/cli/index.ts
116
+ const DEFAULT_SELECTED_TOOLS = [
117
+ "editorconfig",
118
+ "tsconfig",
119
+ "oxc"
120
+ ];
121
+ function exit() {
122
+ cancel("Cancelled");
123
+ return process.exit(0);
124
+ }
125
+ async function main() {
126
+ const cwd = process.cwd();
127
+ intro(color.blue(TOOLING_PACKAGE_NAME));
128
+ log.info(`You are about to configure ${TOOLING_PACKAGE_NAME} in the current directory: ${color.green(cwd)}`);
129
+ if (isCancel(await confirm({ message: `Continue ?` }))) return exit();
130
+ const tools = await multiselect({
131
+ message: "Select tools to configure",
132
+ options: [
133
+ {
134
+ value: "editorconfig",
135
+ label: "EditorConfig"
136
+ },
137
+ {
138
+ value: "tsconfig",
139
+ label: "TypeScript"
140
+ },
141
+ {
142
+ value: "oxc",
143
+ label: "OXC (oxlint + oxfmt)"
144
+ }
145
+ ],
146
+ initialValues: DEFAULT_SELECTED_TOOLS,
147
+ required: true
148
+ });
149
+ if (isCancel(tools)) return exit();
150
+ await updatePkgJson({ tools });
151
+ await updateEditorConfig({ tools });
152
+ await updateTsconfig({ tools });
153
+ await updateOxc({ tools });
154
+ log.success("All done. Make sure to install the dependencies with `pnpm install`.");
155
+ }
156
+ main();
157
+ //#endregion
158
+ export { DEFAULT_SELECTED_TOOLS };
@@ -0,0 +1,7 @@
1
+ import { defineConfig } from "oxfmt";
2
+
3
+ //#region src/oxc/fmt.d.ts
4
+ type OxfmtOptions = Partial<Parameters<typeof defineConfig>[0]>;
5
+ declare function minimalstuffPreset(config?: OxfmtOptions): ReturnType<typeof defineConfig>;
6
+ //#endregion
7
+ export { minimalstuffPreset };
@@ -0,0 +1,21 @@
1
+ import { t as IGNORE_PATTERNS } from "../shared-CoSP_HvN.mjs";
2
+ import { defineConfig } from "oxfmt";
3
+ //#region src/oxc/fmt.ts
4
+ function minimalstuffPreset(config = {}) {
5
+ return defineConfig({
6
+ printWidth: 80,
7
+ tabWidth: 2,
8
+ useTabs: true,
9
+ semi: true,
10
+ singleQuote: true,
11
+ quoteProps: "as-needed",
12
+ bracketSpacing: true,
13
+ arrowParens: "always",
14
+ trailingComma: "es5",
15
+ ignorePatterns: IGNORE_PATTERNS,
16
+ htmlWhitespaceSensitivity: "ignore",
17
+ ...config
18
+ });
19
+ }
20
+ //#endregion
21
+ export { minimalstuffPreset };
@@ -0,0 +1,14 @@
1
+ import { OxlintConfig } from "oxlint";
2
+
3
+ //#region src/oxc/lint.d.ts
4
+ interface MinimalstuffOxlintConfig {
5
+ adonisjs?: boolean;
6
+ perfectionist?: boolean;
7
+ react?: boolean;
8
+ }
9
+ declare function minimalstuffPreset(config?: MinimalstuffOxlintConfig): {
10
+ extends: OxlintConfig[];
11
+ rules: {};
12
+ };
13
+ //#endregion
14
+ export { minimalstuffPreset };
@@ -0,0 +1,89 @@
1
+ import { t as IGNORE_PATTERNS } from "../shared-CoSP_HvN.mjs";
2
+ import { defineConfig } from "oxlint";
3
+ //#region src/oxc/lint.ts
4
+ function reactPreset() {
5
+ return defineConfig({
6
+ plugins: ["react", "react-perf"],
7
+ rules: {}
8
+ });
9
+ }
10
+ function adonisjsPreset() {
11
+ return defineConfig({
12
+ jsPlugins: ["@adonisjs/eslint-plugin"],
13
+ rules: {
14
+ "@adonisjs/prefer-lazy-controller-import": "error",
15
+ "@adonisjs/prefer-lazy-listener-import": "error",
16
+ "typescript/triple-slash-reference": "off",
17
+ "@typescript-eslint/no-floating-promises": ["error", { allowForKnownSafePromises: [{
18
+ from: "package",
19
+ package: "@adonisjs/lucid",
20
+ name: [
21
+ "ExcutableQueryBuilderContract",
22
+ "ModelQueryBuilderContract",
23
+ "DatabaseQueryBuilderContract",
24
+ "InsertQueryBuilderContract",
25
+ "RawQueryBuilderContract",
26
+ "ChainableContract",
27
+ "RelationQueryBuilderContract",
28
+ "RelationSubQueryBuilderContract",
29
+ "HasManyQueryBuilderContract",
30
+ "HasManyThroughQueryBuilderContract",
31
+ "ManyToManyQueryBuilderContract",
32
+ "ManyToManySubQueryBuilderContract"
33
+ ]
34
+ }, {
35
+ from: "package",
36
+ package: "knex",
37
+ name: "QueryBuilder"
38
+ }] }]
39
+ }
40
+ });
41
+ }
42
+ function perfectionistPreset() {
43
+ return defineConfig({
44
+ jsPlugins: ["eslint-plugin-perfectionist"],
45
+ rules: { "perfectionist/sort-imports": ["error", {
46
+ type: "line-length",
47
+ order: "asc",
48
+ internalPattern: ["^@/.*", "^~/.*"],
49
+ groups: [
50
+ ["side-effect", "side-effect-style"],
51
+ ["builtin", "external"],
52
+ [
53
+ "internal",
54
+ "subpath",
55
+ "parent",
56
+ "sibling",
57
+ "index",
58
+ "style",
59
+ "unknown"
60
+ ]
61
+ ]
62
+ }] }
63
+ });
64
+ }
65
+ function defaultPreset() {
66
+ return defineConfig({
67
+ ignorePatterns: IGNORE_PATTERNS,
68
+ plugins: [
69
+ "typescript",
70
+ "node",
71
+ "eslint",
72
+ "oxc"
73
+ ],
74
+ rules: {}
75
+ });
76
+ }
77
+ function minimalstuffPreset(config = {}) {
78
+ return defineConfig({
79
+ extends: [
80
+ defaultPreset(),
81
+ config.react ? reactPreset() : null,
82
+ config.adonisjs ? adonisjsPreset() : null,
83
+ config.perfectionist ? perfectionistPreset() : null
84
+ ].filter(Boolean),
85
+ rules: {}
86
+ });
87
+ }
88
+ //#endregion
89
+ export { minimalstuffPreset };
@@ -0,0 +1,11 @@
1
+ //#region src/oxc/shared.ts
2
+ const IGNORE_PATTERNS = [
3
+ "**/.adonisjs/**",
4
+ "routeTree.gen.ts",
5
+ "node_modules/**",
6
+ "dist/**",
7
+ "build/**",
8
+ "*.yml"
9
+ ];
10
+ //#endregion
11
+ export { IGNORE_PATTERNS as t };
@@ -0,0 +1,29 @@
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
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "extends": "./tsconfig.node.json",
4
+ "compilerOptions": {
5
+ "rewriteRelativeImportExtensions": true
6
+ }
7
+ }
@@ -0,0 +1,15 @@
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
+ }
@@ -0,0 +1,16 @@
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
+ }
package/package.json ADDED
@@ -0,0 +1,96 @@
1
+ {
2
+ "name": "@minimalstuff/tooling",
3
+ "version": "0.1.2",
4
+ "description": "Shared tooling configs: EditorConfig, TSConfig, OXC (oxlint + oxfmt)",
5
+ "keywords": [
6
+ "editorconfig",
7
+ "oxc",
8
+ "oxfmt",
9
+ "oxlint",
10
+ "react",
11
+ "tsconfig"
12
+ ],
13
+ "license": "MIT",
14
+ "author": "Sonny93 <sonnyasdev@gmail.com>",
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "https://github.com/minimalstuff/tooling"
18
+ },
19
+ "bin": "./dist/cli/index.mjs",
20
+ "files": [
21
+ "dist",
22
+ "preset"
23
+ ],
24
+ "type": "module",
25
+ "exports": {
26
+ "./editorconfig": "./preset/.editorconfig",
27
+ "./tsconfigs/*": "./dist/tsconfigs/*.json",
28
+ "./oxc/lint": "./dist/oxc/lint.mjs",
29
+ "./oxc/fmt": "./dist/oxc/fmt.mjs"
30
+ },
31
+ "publishConfig": {
32
+ "access": "public",
33
+ "provenance": true
34
+ },
35
+ "scripts": {
36
+ "lint": "oxlint",
37
+ "format": "oxfmt --write .",
38
+ "build": "tsdown",
39
+ "release": "release-it",
40
+ "typecheck": "tsc --noEmit",
41
+ "checks": "pnpm typecheck && pnpm lint"
42
+ },
43
+ "dependencies": {
44
+ "@adonisjs/eslint-plugin": "^2.2.1",
45
+ "@antfu/install-pkg": "^1.1.0",
46
+ "@clack/prompts": "^1.0.1",
47
+ "eslint-plugin-perfectionist": "^5.5.0",
48
+ "picocolors": "^1.1.1"
49
+ },
50
+ "devDependencies": {
51
+ "@release-it/conventional-changelog": "^10.0.6",
52
+ "@types/node": "^25.2.3",
53
+ "oxfmt": "^0.40.0",
54
+ "oxlint": "^1.55.0",
55
+ "release-it": "^19.2.4",
56
+ "tsdown": "^0.21.3",
57
+ "typescript": "^5.9.3"
58
+ },
59
+ "peerDependencies": {
60
+ "oxfmt": ">=0.40.0",
61
+ "oxlint": ">=1.55.0"
62
+ },
63
+ "peerDependenciesMeta": {
64
+ "oxfmt": {
65
+ "optional": true
66
+ },
67
+ "oxlint": {
68
+ "optional": true
69
+ }
70
+ },
71
+ "packageManager": "pnpm@10.29.3",
72
+ "release-it": {
73
+ "git": {
74
+ "requireCleanWorkingDir": true,
75
+ "requireUpstream": true,
76
+ "commitMessage": "chore(release): ${version}",
77
+ "tagAnnotation": "v${version}",
78
+ "push": true,
79
+ "tagName": "v${version}"
80
+ },
81
+ "github": {
82
+ "release": true
83
+ },
84
+ "npm": {
85
+ "publish": false
86
+ },
87
+ "plugins": {
88
+ "@release-it/conventional-changelog": {
89
+ "infile": "CHANGELOG.md",
90
+ "preset": {
91
+ "name": "conventionalcommits"
92
+ }
93
+ }
94
+ }
95
+ }
96
+ }
@@ -0,0 +1,19 @@
1
+ # http://editorconfig.org
2
+
3
+ [*]
4
+ indent_style = tab
5
+ indent_size = 2
6
+ end_of_line = lf
7
+ charset = utf-8
8
+ trim_trailing_whitespace = true
9
+ insert_final_newline = true
10
+
11
+ [*.json]
12
+ insert_final_newline = unset
13
+
14
+ [**.min.js]
15
+ indent_style = unset
16
+ insert_final_newline = unset
17
+
18
+ [*.md]
19
+ trim_trailing_whitespace = false