@minimalstuff/tooling 0.3.0 → 0.5.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 CHANGED
@@ -43,13 +43,22 @@ Options:
43
43
  | --------------- | --------- | ------- | --------------------------------------- |
44
44
  | `react` | `boolean` | `false` | Enable React-specific oxlint plugins |
45
45
  | `adonisjs` | `boolean` | `false` | Enable AdonisJS-specific rules |
46
- | `perfectionist` | `boolean` | `false` | Enable import sorting via perfectionist |
46
+ | `perfectionist` | `boolean` | `true` | Enable import sorting via perfectionist |
47
47
 
48
48
  ```ts
49
+ import {
50
+ ADONISJS_DEFAULT_IGNORE_PATTERNS,
51
+ minimalstuffPreset,
52
+ } from '@minimalstuff/tooling/oxc/lint';
53
+
49
54
  export default defineConfig({
55
+ ignorePatterns: [...ADONISJS_DEFAULT_IGNORE_PATTERNS, 'tmp/**'],
50
56
  extends: [
51
57
  minimalstuffPreset({ react: true, adonisjs: true, perfectionist: true }),
52
58
  ],
59
+ rules: {
60
+ 'no-unused-vars': 'error',
61
+ },
53
62
  });
54
63
  ```
55
64
 
@@ -68,6 +77,23 @@ You can override any option:
68
77
  export default minimalstuffPreset({ printWidth: 120, semi: true });
69
78
  ```
70
79
 
80
+ For Adonis projects, you can extend ignore patterns:
81
+
82
+ ```ts
83
+ import {
84
+ ADONISJS_DEFAULT_IGNORE_PATTERNS,
85
+ minimalstuffPreset,
86
+ OXFMT_DEFAULT_IGNORE_PATTERNS,
87
+ } from '@minimalstuff/tooling/oxc/fmt';
88
+
89
+ export default minimalstuffPreset({
90
+ ignorePatterns: [
91
+ ...OXFMT_DEFAULT_IGNORE_PATTERNS,
92
+ ...ADONISJS_DEFAULT_IGNORE_PATTERNS,
93
+ ],
94
+ });
95
+ ```
96
+
71
97
  Defaults: `printWidth: 100`, `semi: false`, `singleQuote: true`, `trailingComma: 'all'`, `arrowParens: 'avoid'`.
72
98
 
73
99
  #### Scripts
@@ -15,26 +15,58 @@ const OXC_FMT_IMPORT = `${TOOLING_PACKAGE_NAME}/oxc/fmt`;
15
15
  `${TOOLING_PACKAGE_NAME}`;
16
16
  //#endregion
17
17
  //#region src/cli/update_oxc.ts
18
- const oxlintConfigContent = `import { defineConfig } from 'oxlint'
18
+ function buildOxlintConfigContent(options) {
19
+ const presetOptions = [];
20
+ if (options.adonisjs) presetOptions.push("adonisjs: true");
21
+ if (options.react) presetOptions.push("react: true");
22
+ const presetCall = presetOptions.length > 0 ? `minimalstuffPreset({ ${presetOptions.join(", ")} })` : "minimalstuffPreset()";
23
+ if (!options.adonisjs) return `import { defineConfig } from 'oxlint'
19
24
  import { minimalstuffPreset } from '${OXC_LINT_IMPORT}'
20
25
 
21
26
  export default defineConfig({
22
- extends: [minimalstuffPreset()],
27
+ extends: [${presetCall}],
23
28
  })
24
29
  `;
30
+ return `import { defineConfig } from 'oxlint'
31
+ import {
32
+ ADONISJS_DEFAULT_IGNORE_PATTERNS,
33
+ minimalstuffPreset,
34
+ } from '${OXC_LINT_IMPORT}'
35
+
36
+ export default defineConfig({
37
+ ignorePatterns: [...ADONISJS_DEFAULT_IGNORE_PATTERNS],
38
+ extends: [${presetCall}],
39
+ })
40
+ `;
41
+ }
25
42
  const oxfmtConfigContent = `import { minimalstuffPreset } from '${OXC_FMT_IMPORT}'
26
43
 
27
44
  export default minimalstuffPreset()
28
45
  `;
46
+ const oxfmtAdonisConfigContent = `import {
47
+ ADONISJS_DEFAULT_IGNORE_PATTERNS,
48
+ minimalstuffPreset,
49
+ OXFMT_DEFAULT_IGNORE_PATTERNS,
50
+ } from '${OXC_FMT_IMPORT}'
51
+
52
+ export default minimalstuffPreset({
53
+ ignorePatterns: [
54
+ ...OXFMT_DEFAULT_IGNORE_PATTERNS,
55
+ ...ADONISJS_DEFAULT_IGNORE_PATTERNS,
56
+ ],
57
+ })
58
+ `;
29
59
  const vscodeSettings = {
30
60
  "oxc.typeAware": true,
31
- "oxc.fmt.experimental": true,
32
61
  "editor.defaultFormatter": "oxc.oxc-vscode"
33
62
  };
34
63
  const oxcScripts = {
35
- format: "oxfmt --write .",
36
- lint: "oxlint --type-aware",
37
- "lint:fix": "oxlint --type-aware --fix"
64
+ lint: "oxlint .",
65
+ "lint:fix": "oxlint . --fix --fix-suggestions --fix-dangerously",
66
+ format: "pnpm lint:fix; oxfmt .",
67
+ "format:check": "oxfmt . --check",
68
+ typecheck: "tsc --noEmit",
69
+ check: "pnpm run lint && pnpm run format:check && pnpm run typecheck"
38
70
  };
39
71
  const oxcPackages = [
40
72
  "oxfmt",
@@ -45,8 +77,9 @@ const oxcPackages = [
45
77
  async function updateOxc(result) {
46
78
  if (!result.tools.includes("oxc")) return;
47
79
  const cwd = process.cwd();
48
- await writeFile(join(cwd, "oxlint.config.ts"), oxlintConfigContent);
49
- await writeFile(join(cwd, "oxfmt.config.ts"), oxfmtConfigContent);
80
+ const projectType = await getProjectType(cwd);
81
+ await writeFile(join(cwd, "oxlint.config.ts"), buildOxlintConfigContent(projectType));
82
+ await writeFile(join(cwd, "oxfmt.config.ts"), projectType.adonisjs ? oxfmtAdonisConfigContent : oxfmtConfigContent);
50
83
  await updateVscodeSettings(cwd);
51
84
  await addScriptsToPackageJson(cwd);
52
85
  await installPackage(oxcPackages, {
@@ -55,6 +88,22 @@ async function updateOxc(result) {
55
88
  });
56
89
  p.log.success("OXC configured (oxlint + oxfmt) 🦀");
57
90
  }
91
+ function hasAdonisDependency(deps) {
92
+ if (!deps) return false;
93
+ return Object.keys(deps).some((name) => name.startsWith("@adonisjs/"));
94
+ }
95
+ function hasReactDependency(deps) {
96
+ if (!deps) return false;
97
+ return "react" in deps || "react-dom" in deps || "@types/react" in deps || "@types/react-dom" in deps;
98
+ }
99
+ async function getProjectType(cwd) {
100
+ const raw = await readFile(join(cwd, "package.json"), "utf-8");
101
+ const pkg = JSON.parse(raw);
102
+ return {
103
+ adonisjs: hasAdonisDependency(pkg.dependencies) || hasAdonisDependency(pkg.devDependencies) || hasAdonisDependency(pkg.peerDependencies),
104
+ react: hasReactDependency(pkg.dependencies) || hasReactDependency(pkg.devDependencies) || hasReactDependency(pkg.peerDependencies)
105
+ };
106
+ }
58
107
  async function updateVscodeSettings(cwd) {
59
108
  const vscodePath = join(cwd, ".vscode");
60
109
  const settingsPath = join(vscodePath, "settings.json");
@@ -86,7 +135,7 @@ async function addScriptsToPackageJson(cwd) {
86
135
  }
87
136
  //#endregion
88
137
  //#region package.json
89
- var version = "0.3.0";
138
+ var version = "0.5.0";
90
139
  //#endregion
91
140
  //#region src/cli/update_pkg.json.ts
92
141
  async function updatePkgJson(_) {
@@ -95,6 +144,13 @@ async function updatePkgJson(_) {
95
144
  const userPkgJson = JSON.parse(raw);
96
145
  userPkgJson.devDependencies ??= {};
97
146
  userPkgJson.devDependencies[TOOLING_PACKAGE_NAME] = `^${version}`;
147
+ userPkgJson.scripts ??= {};
148
+ userPkgJson.scripts.lint = "oxlint .";
149
+ userPkgJson.scripts["lint:fix"] = "oxlint . --fix --fix-suggestions --fix-dangerously";
150
+ userPkgJson.scripts.format = "pnpm lint:fix; oxfmt .";
151
+ userPkgJson.scripts["format:check"] = "oxfmt . --check";
152
+ userPkgJson.scripts.typecheck = "tsc --noEmit";
153
+ userPkgJson.scripts.check = "pnpm run lint && pnpm run format:check && pnpm run typecheck";
98
154
  await writeFile(pathPackageJSON, JSON.stringify(userPkgJson, null, 2));
99
155
  p.log.success("Package.json updated 🤠");
100
156
  }
@@ -1,7 +1,9 @@
1
1
  import { defineConfig } from "oxfmt";
2
2
 
3
3
  //#region src/oxc/fmt.d.ts
4
+ declare const OXFMT_DEFAULT_IGNORE_PATTERNS: string[];
5
+ declare const ADONISJS_DEFAULT_IGNORE_PATTERNS: string[];
4
6
  type OxfmtOptions = Partial<Parameters<typeof defineConfig>[0]>;
5
7
  declare function minimalstuffPreset(config?: OxfmtOptions): ReturnType<typeof defineConfig>;
6
8
  //#endregion
7
- export { minimalstuffPreset };
9
+ export { ADONISJS_DEFAULT_IGNORE_PATTERNS, OXFMT_DEFAULT_IGNORE_PATTERNS, minimalstuffPreset };
package/dist/oxc/fmt.mjs CHANGED
@@ -1,6 +1,12 @@
1
1
  import { t as IGNORE_PATTERNS } from "../shared-CoSP_HvN.mjs";
2
2
  import { defineConfig } from "oxfmt";
3
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
+ ];
4
10
  function minimalstuffPreset(config = {}) {
5
11
  return defineConfig({
6
12
  printWidth: 80,
@@ -12,10 +18,10 @@ function minimalstuffPreset(config = {}) {
12
18
  bracketSpacing: true,
13
19
  arrowParens: "always",
14
20
  trailingComma: "es5",
15
- ignorePatterns: IGNORE_PATTERNS,
21
+ ignorePatterns: OXFMT_DEFAULT_IGNORE_PATTERNS,
16
22
  htmlWhitespaceSensitivity: "ignore",
17
23
  ...config
18
24
  });
19
25
  }
20
26
  //#endregion
21
- export { minimalstuffPreset };
27
+ export { ADONISJS_DEFAULT_IGNORE_PATTERNS, OXFMT_DEFAULT_IGNORE_PATTERNS, minimalstuffPreset };
@@ -1,6 +1,7 @@
1
1
  import { OxlintConfig } from "oxlint";
2
2
 
3
3
  //#region src/oxc/lint.d.ts
4
+ declare const ADONISJS_DEFAULT_IGNORE_PATTERNS: string[];
4
5
  interface MinimalstuffOxlintConfig {
5
6
  adonisjs?: boolean;
6
7
  perfectionist?: boolean;
@@ -11,4 +12,4 @@ declare function minimalstuffPreset(config?: MinimalstuffOxlintConfig): {
11
12
  rules: {};
12
13
  };
13
14
  //#endregion
14
- export { minimalstuffPreset };
15
+ export { ADONISJS_DEFAULT_IGNORE_PATTERNS, minimalstuffPreset };
package/dist/oxc/lint.mjs CHANGED
@@ -1,6 +1,11 @@
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 ADONISJS_DEFAULT_IGNORE_PATTERNS = [
5
+ ".adonisjs/**",
6
+ "pnpm-*.yaml",
7
+ "bin/*"
8
+ ];
4
9
  const STRICT_TYPE_AWARE_RULES = {
5
10
  "typescript/await-thenable": "error",
6
11
  "typescript/no-floating-promises": "error",
@@ -95,15 +100,19 @@ function defaultPreset() {
95
100
  });
96
101
  }
97
102
  function minimalstuffPreset(config = {}) {
103
+ const normalizedConfig = {
104
+ perfectionist: true,
105
+ ...config
106
+ };
98
107
  return defineConfig({
99
108
  extends: [
100
109
  defaultPreset(),
101
- config.react ? reactPreset() : null,
102
- config.adonisjs ? adonisjsPreset() : null,
103
- config.perfectionist ? perfectionistPreset() : null
110
+ normalizedConfig.react ? reactPreset() : null,
111
+ normalizedConfig.adonisjs ? adonisjsPreset() : null,
112
+ normalizedConfig.perfectionist ? perfectionistPreset() : null
104
113
  ].filter(Boolean),
105
114
  rules: {}
106
115
  });
107
116
  }
108
117
  //#endregion
109
- export { minimalstuffPreset };
118
+ export { ADONISJS_DEFAULT_IGNORE_PATTERNS, minimalstuffPreset };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@minimalstuff/tooling",
3
- "version": "0.3.0",
3
+ "version": "0.5.0",
4
4
  "description": "Shared tooling configs: EditorConfig, OXC (oxlint + oxfmt)",
5
5
  "keywords": [
6
6
  "editorconfig",