@minimalstuff/tooling 0.2.1 → 0.4.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
@@ -46,10 +46,19 @@ Options:
46
46
  | `perfectionist` | `boolean` | `false` | 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
@@ -6,6 +6,7 @@ import { join } from "node:path";
6
6
  import { existsSync } from "node:fs";
7
7
  import { installPackage } from "@antfu/install-pkg";
8
8
  import { mkdir, readFile, writeFile } from "node:fs/promises";
9
+ import { parse, printParseErrorCode } from "jsonc-parser";
9
10
  import { fileURLToPath } from "node:url";
10
11
  //#region src/constants.ts
11
12
  const TOOLING_PACKAGE_NAME = "@minimalstuff/tooling";
@@ -27,7 +28,6 @@ export default minimalstuffPreset()
27
28
  `;
28
29
  const vscodeSettings = {
29
30
  "oxc.typeAware": true,
30
- "oxc.fmt.experimental": true,
31
31
  "editor.defaultFormatter": "oxc.oxc-vscode"
32
32
  };
33
33
  const oxcScripts = {
@@ -61,7 +61,16 @@ async function updateVscodeSettings(cwd) {
61
61
  let settings = {};
62
62
  if (existsSync(settingsPath)) {
63
63
  const content = await readFile(settingsPath, "utf-8");
64
- settings = JSON.parse(content);
64
+ const parseErrors = [];
65
+ const parsed = parse(content, parseErrors, {
66
+ allowTrailingComma: true,
67
+ allowEmptyContent: true
68
+ });
69
+ if (parseErrors.length > 0) {
70
+ const detail = parseErrors.map((e) => `${printParseErrorCode(e.error)} @${e.offset}`).join(", ");
71
+ throw new SyntaxError(`Invalid JSONC in ${settingsPath}: ${detail}`);
72
+ }
73
+ if (parsed !== null && parsed !== void 0 && typeof parsed === "object" && !Array.isArray(parsed)) settings = parsed;
65
74
  }
66
75
  for (const [key, value] of Object.entries(vscodeSettings)) if (!(key in settings)) settings[key] = value;
67
76
  await writeFile(settingsPath, JSON.stringify(settings, null, 2));
@@ -76,7 +85,7 @@ async function addScriptsToPackageJson(cwd) {
76
85
  }
77
86
  //#endregion
78
87
  //#region package.json
79
- var version = "0.2.1";
88
+ var version = "0.4.0";
80
89
  //#endregion
81
90
  //#region src/cli/update_pkg.json.ts
82
91
  async function updatePkgJson(_) {
@@ -85,6 +94,13 @@ async function updatePkgJson(_) {
85
94
  const userPkgJson = JSON.parse(raw);
86
95
  userPkgJson.devDependencies ??= {};
87
96
  userPkgJson.devDependencies[TOOLING_PACKAGE_NAME] = `^${version}`;
97
+ userPkgJson.scripts ??= {};
98
+ userPkgJson.scripts.lint = "oxlint .";
99
+ userPkgJson.scripts["lint:fix"] = "oxlint . --fix --fix-suggestions --fix-dangerously";
100
+ userPkgJson.scripts.format = "pnpm lint:fix; oxfmt .";
101
+ userPkgJson.scripts["format:check"] = "oxfmt . --check";
102
+ userPkgJson.scripts.typecheck = "tsc --noEmit";
103
+ userPkgJson.scripts.check = "pnpm run lint && pnpm run format:check && pnpm run typecheck";
88
104
  await writeFile(pathPackageJSON, JSON.stringify(userPkgJson, null, 2));
89
105
  p.log.success("Package.json updated 🤠");
90
106
  }
@@ -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",
@@ -106,4 +111,4 @@ function minimalstuffPreset(config = {}) {
106
111
  });
107
112
  }
108
113
  //#endregion
109
- export { minimalstuffPreset };
114
+ export { ADONISJS_DEFAULT_IGNORE_PATTERNS, minimalstuffPreset };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@minimalstuff/tooling",
3
- "version": "0.2.1",
3
+ "version": "0.4.0",
4
4
  "description": "Shared tooling configs: EditorConfig, OXC (oxlint + oxfmt)",
5
5
  "keywords": [
6
6
  "editorconfig",
@@ -44,6 +44,7 @@
44
44
  "@antfu/install-pkg": "^1.1.0",
45
45
  "@clack/prompts": "^1.0.1",
46
46
  "eslint-plugin-perfectionist": "^5.5.0",
47
+ "jsonc-parser": "^3.3.1",
47
48
  "picocolors": "^1.1.1"
48
49
  },
49
50
  "devDependencies": {