@minimalstuff/tooling 0.6.0 → 0.7.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.
@@ -0,0 +1,70 @@
1
+ // src/knip/adonisjs_workspace.ts
2
+ const ADONISJS_WORKSPACE_CONFIG = {
3
+ entry: [
4
+ "adonisrc.ts",
5
+ "ace.js",
6
+ "bin/*.ts",
7
+ "start/**/*.ts",
8
+ "config/**/*.ts",
9
+ "providers/**/*.ts",
10
+ "commands/**/*.ts",
11
+ "database/migrations/**/*.ts",
12
+ "database/seeders/**/*.ts",
13
+ "database/factories/**/*.ts",
14
+ "tests/bootstrap.ts",
15
+ "tests/**/*.spec.{ts,js}",
16
+ "app/**/*.spec.{ts,js}",
17
+ "inertia/{app,ssr}.{ts,tsx}",
18
+ "inertia/app/{app,ssr}.{ts,tsx}",
19
+ "inertia/pages/**/*.{ts,tsx}"
20
+ ],
21
+ project: ["**/*.{ts,tsx,js}"],
22
+ ignore: [".adonisjs/**", "database/schema.ts"],
23
+ ignoreDependencies: [
24
+ "pg",
25
+ "mysql2",
26
+ "better-sqlite3",
27
+ "sqlite3",
28
+ "pino-pretty",
29
+ "hot-hook"
30
+ ]
31
+ };
32
+ // src/knip/knip.ts
33
+ function toArray(value) {
34
+ return Array.isArray(value) ? value : [value];
35
+ }
36
+ function mergeSettings(presetSettings, userSettings) {
37
+ const merged = { ...presetSettings };
38
+ for (const [key, userValue] of Object.entries(userSettings)) {
39
+ const presetValue = merged[key];
40
+ merged[key] = Array.isArray(presetValue) ? [...presetValue, ...toArray(userValue)] : userValue;
41
+ }
42
+ return merged;
43
+ }
44
+ function applyToRootWorkspace(userConfig) {
45
+ return mergeSettings(ADONISJS_WORKSPACE_CONFIG, userConfig);
46
+ }
47
+ function applyToWorkspaces(userConfig, workspacePaths) {
48
+ const workspaces = { ...userConfig.workspaces };
49
+ for (const workspacePath of workspacePaths) workspaces[workspacePath] = mergeSettings(ADONISJS_WORKSPACE_CONFIG, workspaces[workspacePath] ?? {});
50
+ return {
51
+ ...userConfig,
52
+ workspaces
53
+ };
54
+ }
55
+ function applyAdonisjs(userConfig, adonisjs) {
56
+ if (adonisjs === false) return userConfig;
57
+ if (adonisjs === true) return applyToRootWorkspace(userConfig);
58
+ return applyToWorkspaces(userConfig, adonisjs);
59
+ }
60
+ /**
61
+ * Builds the root knip config. With `adonisjs`, the AdonisJS conventions are
62
+ * merged into the targeted workspace(s): arrays (`entry`, `project`, `ignore`,
63
+ * `ignoreDependencies`, ...) are concatenated with yours, other keys of yours
64
+ * win.
65
+ */
66
+ function minimalstuffPreset(options = {}) {
67
+ const { adonisjs = false, ...userConfig } = options;
68
+ return applyAdonisjs(userConfig, adonisjs);
69
+ }
70
+ export { minimalstuffPreset };
@@ -1,9 +1,10 @@
1
- import { defineConfig } from "oxfmt";
2
-
3
- //#region src/oxc/fmt.d.ts
4
- declare const OXFMT_DEFAULT_IGNORE_PATTERNS: string[];
5
- declare const ADONISJS_DEFAULT_IGNORE_PATTERNS: string[];
6
- type OxfmtOptions = Partial<Parameters<typeof defineConfig>[0]>;
7
- declare function minimalstuffPreset(config?: OxfmtOptions): ReturnType<typeof defineConfig>;
8
- //#endregion
9
- export { ADONISJS_DEFAULT_IGNORE_PATTERNS, OXFMT_DEFAULT_IGNORE_PATTERNS, minimalstuffPreset };
1
+ import { OxfmtConfig } from "oxfmt";
2
+ export interface MinimalstuffOxfmtOptions extends OxfmtConfig {
3
+ /** Add AdonisJS ignore patterns. */
4
+ adonisjs?: boolean;
5
+ }
6
+ /**
7
+ * Builds the root oxfmt config. Options override the defaults, except
8
+ * `ignorePatterns` which are appended to the preset ones.
9
+ */
10
+ export declare function minimalstuffPreset(options?: MinimalstuffOxfmtOptions): OxfmtConfig;
package/dist/oxc/fmt.mjs CHANGED
@@ -1,13 +1,13 @@
1
- import { t as IGNORE_PATTERNS } from "../shared-CoSP_HvN.mjs";
1
+ import { n as COMMON_IGNORE_PATTERNS, r as FORMAT_ONLY_IGNORE_PATTERNS, t as ADONISJS_IGNORE_PATTERNS } from "../shared-B_NHkjil.mjs";
2
2
  import { defineConfig } from "oxfmt";
3
- //#region src/oxc/fmt.ts
4
- const OXFMT_DEFAULT_IGNORE_PATTERNS = [...IGNORE_PATTERNS];
5
- const ADONISJS_DEFAULT_IGNORE_PATTERNS = [
6
- ".adonisjs/**",
7
- "pnpm-*.yaml",
8
- "bin/*"
9
- ];
10
- function minimalstuffPreset(config = {}) {
3
+ // src/oxc/fmt.ts
4
+ const INTERNAL_IMPORT_PREFIXES = ["@/", "~/"];
5
+ /**
6
+ * Builds the root oxfmt config. Options override the defaults, except
7
+ * `ignorePatterns` which are appended to the preset ones.
8
+ */
9
+ function minimalstuffPreset(options = {}) {
10
+ const { adonisjs = false, ignorePatterns: userIgnorePatterns = [], ...userConfig } = options;
11
11
  return defineConfig({
12
12
  printWidth: 80,
13
13
  tabWidth: 2,
@@ -18,10 +18,30 @@ function minimalstuffPreset(config = {}) {
18
18
  bracketSpacing: true,
19
19
  arrowParens: "always",
20
20
  trailingComma: "es5",
21
- ignorePatterns: OXFMT_DEFAULT_IGNORE_PATTERNS,
22
21
  htmlWhitespaceSensitivity: "ignore",
23
- ...config
22
+ sortImports: {
23
+ internalPattern: INTERNAL_IMPORT_PREFIXES,
24
+ groups: [
25
+ ["side_effect", "side_effect_style"],
26
+ ["builtin", "external"],
27
+ [
28
+ "internal",
29
+ "subpath",
30
+ "parent",
31
+ "sibling",
32
+ "index",
33
+ "style",
34
+ "unknown"
35
+ ]
36
+ ]
37
+ },
38
+ ...userConfig,
39
+ ignorePatterns: [
40
+ ...COMMON_IGNORE_PATTERNS,
41
+ ...FORMAT_ONLY_IGNORE_PATTERNS,
42
+ ...adonisjs ? ADONISJS_IGNORE_PATTERNS : [],
43
+ ...userIgnorePatterns
44
+ ]
24
45
  });
25
46
  }
26
- //#endregion
27
- export { ADONISJS_DEFAULT_IGNORE_PATTERNS, OXFMT_DEFAULT_IGNORE_PATTERNS, minimalstuffPreset };
47
+ export { minimalstuffPreset };
@@ -1,15 +1,16 @@
1
1
  import { OxlintConfig } from "oxlint";
2
-
3
- //#region src/oxc/lint.d.ts
4
- declare const ADONISJS_DEFAULT_IGNORE_PATTERNS: string[];
5
- interface MinimalstuffOxlintConfig {
6
- adonisjs?: boolean;
7
- perfectionist?: boolean;
2
+ export interface MinimalstuffOxlintOptions extends OxlintConfig {
3
+ /** Enable React rules (hooks, fast refresh) and accessibility checks. */
8
4
  react?: boolean;
5
+ /** Enable AdonisJS rules and ignore patterns. */
6
+ adonisjs?: boolean;
7
+ /** Enable the vitest plugin. */
8
+ vitest?: boolean;
9
9
  }
10
- declare function minimalstuffPreset(config?: MinimalstuffOxlintConfig): {
11
- extends: OxlintConfig[];
12
- rules: {};
13
- };
14
- //#endregion
15
- export { ADONISJS_DEFAULT_IGNORE_PATTERNS, minimalstuffPreset };
10
+ /**
11
+ * Builds the root oxlint config: preset parts are placed in `extends` before the
12
+ * user's own `extends`, while the user's keys sit on top (rules override,
13
+ * overrides and plugins are appended). `ignorePatterns` are always merged at the
14
+ * root because oxlint does not inherit them through `extends`.
15
+ */
16
+ export declare function minimalstuffPreset(options?: MinimalstuffOxlintOptions): OxlintConfig;
package/dist/oxc/lint.mjs CHANGED
@@ -1,41 +1,55 @@
1
- import { t as IGNORE_PATTERNS } from "../shared-CoSP_HvN.mjs";
1
+ import { n as COMMON_IGNORE_PATTERNS, t as ADONISJS_IGNORE_PATTERNS } from "../shared-B_NHkjil.mjs";
2
2
  import { defineConfig } from "oxlint";
3
- //#region src/oxc/lint.ts
4
- const ADONISJS_DEFAULT_IGNORE_PATTERNS = [
5
- ".adonisjs/**",
6
- "pnpm-*.yaml",
7
- "bin/*"
8
- ];
9
- const STRICT_TYPE_AWARE_RULES = {
10
- "typescript/await-thenable": "error",
11
- "typescript/no-floating-promises": "error",
12
- "typescript/no-misused-promises": "error",
13
- "typescript/no-unnecessary-condition": "off",
14
- "typescript/no-unnecessary-type-assertion": "error",
15
- "typescript/no-unsafe-argument": "off",
16
- "typescript/no-unsafe-assignment": "off",
17
- "typescript/no-unsafe-call": "off",
18
- "typescript/no-unsafe-member-access": "off",
19
- "typescript/no-unsafe-return": "off",
20
- "typescript/prefer-nullish-coalescing": "error",
21
- "typescript/prefer-optional-chain": "error",
22
- "typescript/strict-boolean-expressions": "off",
23
- "typescript/switch-exhaustiveness-check": "off"
24
- };
25
- function reactPreset() {
3
+ // src/oxc/lint.ts
4
+ const INERTIA_FRONTEND_FILES = ["**/inertia/**/*.{ts,tsx}"];
5
+ function createBasePreset() {
26
6
  return defineConfig({
27
- plugins: ["react", "react-perf"],
28
- rules: {}
7
+ plugins: [
8
+ "typescript",
9
+ "unicorn",
10
+ "oxc"
11
+ ],
12
+ categories: { correctness: "error" },
13
+ options: {
14
+ typeAware: true,
15
+ typeCheck: true
16
+ },
17
+ rules: {
18
+ "typescript/await-thenable": "error",
19
+ "typescript/no-floating-promises": "error",
20
+ "typescript/no-misused-promises": "error",
21
+ "typescript/no-unnecessary-type-assertion": "error",
22
+ "typescript/prefer-nullish-coalescing": "error",
23
+ "typescript/prefer-optional-chain": "error",
24
+ "typescript/switch-exhaustiveness-check": "error",
25
+ "typescript/only-throw-error": "error",
26
+ "typescript/return-await": "error",
27
+ "typescript/prefer-promise-reject-errors": "error",
28
+ "typescript/consistent-type-imports": "error",
29
+ "typescript/no-deprecated": "warn"
30
+ }
31
+ });
32
+ }
33
+ function createReactPreset() {
34
+ return defineConfig({
35
+ plugins: ["react", "jsx-a11y"],
36
+ rules: {
37
+ "react/rules-of-hooks": "error",
38
+ "react/only-export-components": ["warn", { allowConstantExport: true }]
39
+ }
29
40
  });
30
41
  }
31
- function adonisjsPreset() {
42
+ function createVitestPreset() {
43
+ return defineConfig({ plugins: ["vitest"] });
44
+ }
45
+ function createAdonisjsPreset() {
32
46
  return defineConfig({
33
47
  jsPlugins: ["@adonisjs/eslint-plugin"],
34
48
  rules: {
35
49
  "@adonisjs/prefer-lazy-controller-import": "error",
36
50
  "@adonisjs/prefer-lazy-listener-import": "error",
37
51
  "typescript/triple-slash-reference": "off",
38
- "@typescript-eslint/no-floating-promises": ["error", { allowForKnownSafePromises: [{
52
+ "typescript/no-floating-promises": ["error", { allowForKnownSafePromises: [{
39
53
  from: "package",
40
54
  package: "@adonisjs/lucid",
41
55
  name: [
@@ -60,59 +74,47 @@ function adonisjsPreset() {
60
74
  }
61
75
  });
62
76
  }
63
- function perfectionistPreset() {
64
- return defineConfig({
65
- jsPlugins: ["eslint-plugin-perfectionist"],
66
- rules: { "perfectionist/sort-imports": ["error", {
67
- type: "line-length",
68
- order: "asc",
69
- internalPattern: ["^@/.*", "^~/.*"],
70
- groups: [
71
- ["side-effect", "side-effect-style"],
72
- ["builtin", "external"],
73
- [
74
- "internal",
75
- "subpath",
76
- "parent",
77
- "sibling",
78
- "index",
79
- "style",
80
- "unknown"
81
- ]
82
- ]
83
- }] }
84
- });
85
- }
86
- function defaultPreset() {
87
- return defineConfig({
88
- ignorePatterns: IGNORE_PATTERNS,
89
- plugins: [
90
- "typescript",
91
- "node",
92
- "eslint",
93
- "oxc"
94
- ],
95
- rules: { ...STRICT_TYPE_AWARE_RULES },
96
- options: {
97
- typeAware: true,
98
- typeCheck: true
77
+ function createInertiaPreset() {
78
+ return defineConfig({ overrides: [{
79
+ files: INERTIA_FRONTEND_FILES,
80
+ rules: {
81
+ "@adonisjs/no-backend-import-in-frontend": "error",
82
+ "@adonisjs/prefer-adonisjs-inertia-link": "error",
83
+ "@adonisjs/prefer-adonisjs-inertia-form": "error"
99
84
  }
100
- });
85
+ }] });
86
+ }
87
+ function createPresets(options) {
88
+ const presets = [createBasePreset()];
89
+ if (options.react) presets.push(createReactPreset());
90
+ if (options.vitest) presets.push(createVitestPreset());
91
+ if (options.adonisjs) presets.push(createAdonisjsPreset());
92
+ if (options.adonisjs && options.react) presets.push(createInertiaPreset());
93
+ return presets;
94
+ }
95
+ function createIgnorePatterns(isAdonisjsEnabled, userIgnorePatterns) {
96
+ return [
97
+ ...COMMON_IGNORE_PATTERNS,
98
+ ...isAdonisjsEnabled ? ADONISJS_IGNORE_PATTERNS : [],
99
+ ...userIgnorePatterns
100
+ ];
101
101
  }
102
- function minimalstuffPreset(config = {}) {
103
- const normalizedConfig = {
104
- perfectionist: true,
105
- ...config
106
- };
102
+ /**
103
+ * Builds the root oxlint config: preset parts are placed in `extends` before the
104
+ * user's own `extends`, while the user's keys sit on top (rules override,
105
+ * overrides and plugins are appended). `ignorePatterns` are always merged at the
106
+ * root because oxlint does not inherit them through `extends`.
107
+ */
108
+ function minimalstuffPreset(options = {}) {
109
+ const { react = false, adonisjs = false, vitest = false, extends: userExtends = [], ignorePatterns: userIgnorePatterns = [], ...userConfig } = options;
107
110
  return defineConfig({
108
- extends: [
109
- defaultPreset(),
110
- normalizedConfig.react ? reactPreset() : null,
111
- normalizedConfig.adonisjs ? adonisjsPreset() : null,
112
- normalizedConfig.perfectionist ? perfectionistPreset() : null
113
- ].filter(Boolean),
114
- rules: {}
111
+ ...userConfig,
112
+ extends: [...createPresets({
113
+ react,
114
+ adonisjs,
115
+ vitest
116
+ }), ...userExtends],
117
+ ignorePatterns: createIgnorePatterns(adonisjs, userIgnorePatterns)
115
118
  });
116
119
  }
117
- //#endregion
118
- export { ADONISJS_DEFAULT_IGNORE_PATTERNS, minimalstuffPreset };
120
+ export { minimalstuffPreset };
@@ -0,0 +1,16 @@
1
+ // src/oxc/shared.ts
2
+ const COMMON_IGNORE_PATTERNS = [
3
+ "**/node_modules/**",
4
+ "**/dist/**",
5
+ "**/build/**",
6
+ "**/routeTree.gen.ts",
7
+ "**/*.yml",
8
+ "**/*.yaml"
9
+ ];
10
+ const ADONISJS_IGNORE_PATTERNS = [
11
+ "**/.adonisjs/**",
12
+ "**/bin/*",
13
+ "**/database/schema.ts"
14
+ ];
15
+ const FORMAT_ONLY_IGNORE_PATTERNS = ["**/CHANGELOG.md"];
16
+ export { COMMON_IGNORE_PATTERNS as n, FORMAT_ONLY_IGNORE_PATTERNS as r, ADONISJS_IGNORE_PATTERNS as t };
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "@minimalstuff/tooling",
3
- "version": "0.6.0",
4
- "description": "Shared tooling configs: EditorConfig, OXC (oxlint + oxfmt)",
3
+ "version": "0.7.0",
4
+ "description": "Shared tooling configs: EditorConfig, OXC (oxlint + oxfmt), Knip",
5
5
  "keywords": [
6
6
  "editorconfig",
7
+ "knip",
7
8
  "oxc",
8
9
  "oxfmt",
9
10
  "oxlint",
@@ -24,45 +25,54 @@
24
25
  "exports": {
25
26
  "./editorconfig": "./preset/.editorconfig",
26
27
  "./oxc/lint": "./dist/oxc/lint.mjs",
27
- "./oxc/fmt": "./dist/oxc/fmt.mjs"
28
+ "./oxc/fmt": "./dist/oxc/fmt.mjs",
29
+ "./knip": "./dist/knip/knip.mjs"
28
30
  },
29
31
  "publishConfig": {
30
32
  "access": "public",
31
33
  "provenance": true
32
34
  },
33
35
  "scripts": {
34
- "lint": "oxlint --type-aware",
35
- "lint:fix": "oxlint --type-aware --fix",
36
- "format": "oxfmt --write . && oxlint --type-aware --fix",
37
- "build": "tsdown",
38
- "release": "release-it",
36
+ "knip": "knip",
37
+ "lint": "oxlint",
38
+ "lint:fix": "oxlint --fix",
39
+ "format": "oxfmt && oxlint --fix",
40
+ "format:check": "oxfmt --check",
39
41
  "typecheck": "tsc --noEmit",
40
- "checks": "pnpm typecheck && pnpm lint"
42
+ "test": "vitest run",
43
+ "build": "tsdown",
44
+ "checks": "pnpm typecheck && pnpm lint && pnpm format:check && pnpm knip && pnpm test && pnpm build",
45
+ "release": "release-it"
41
46
  },
42
47
  "dependencies": {
43
- "@adonisjs/eslint-plugin": "^2.2.1",
44
- "@antfu/install-pkg": "^1.1.0",
45
- "@clack/prompts": "^1.0.1",
46
- "eslint-plugin-perfectionist": "^5.5.0",
48
+ "@adonisjs/eslint-plugin": "^2.2.2",
49
+ "@antfu/install-pkg": "^2.1.0",
50
+ "@clack/prompts": "^1.8.1",
47
51
  "jsonc-parser": "^3.3.1",
48
52
  "picocolors": "^1.1.1"
49
53
  },
50
54
  "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
- "oxlint-tsgolint": "^0.20.0",
56
- "release-it": "^19.2.4",
57
- "tsdown": "^0.21.3",
58
- "typescript": "^5.9.3"
55
+ "@release-it/conventional-changelog": "^12.0.2",
56
+ "@types/node": "^26.6.5",
57
+ "knip": "6.42.1",
58
+ "oxfmt": "^0.74.0",
59
+ "oxlint": "^1.89.0",
60
+ "oxlint-tsgolint": "^7.0.2004",
61
+ "release-it": "^21.1.1",
62
+ "tsdown": "^0.23.1",
63
+ "typescript": "^7.0.2",
64
+ "vitest": "^5.0.5"
59
65
  },
60
66
  "peerDependencies": {
61
- "oxfmt": ">=0.40.0",
62
- "oxlint": ">=1.55.0",
63
- "oxlint-tsgolint": ">=0.20.0"
67
+ "knip": ">=6.42.1",
68
+ "oxfmt": ">=0.74.0",
69
+ "oxlint": ">=1.89.0",
70
+ "oxlint-tsgolint": ">=7.0.2004"
64
71
  },
65
72
  "peerDependenciesMeta": {
73
+ "knip": {
74
+ "optional": true
75
+ },
66
76
  "oxfmt": {
67
77
  "optional": true
68
78
  },
@@ -73,7 +83,10 @@
73
83
  "optional": true
74
84
  }
75
85
  },
76
- "packageManager": "pnpm@10.29.3",
86
+ "engines": {
87
+ "node": ">=26"
88
+ },
89
+ "packageManager": "pnpm@12.15.0",
77
90
  "release-it": {
78
91
  "git": {
79
92
  "requireCleanWorkingDir": true,
@@ -93,7 +106,8 @@
93
106
  "@release-it/conventional-changelog": {
94
107
  "infile": "CHANGELOG.md",
95
108
  "preset": {
96
- "name": "conventionalcommits"
109
+ "name": "conventionalcommits",
110
+ "preMajor": true
97
111
  }
98
112
  }
99
113
  }
@@ -19,3 +19,7 @@ insert_final_newline = unset
19
19
  indent_style = space
20
20
  indent_size = 2
21
21
  trim_trailing_whitespace = false
22
+
23
+ [*.{yml,yaml}]
24
+ indent_style = space
25
+ indent_size = 2
@@ -1,11 +0,0 @@
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 };