@minimalstuff/tooling 0.10.0 → 0.12.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
@@ -24,7 +24,7 @@ Run this command from the project root, in an interactive terminal:
24
24
  pnpm dlx @minimalstuff/tooling@latest
25
25
  ```
26
26
 
27
- The CLI asks which tools to set up (EditorConfig, OXC, Knip), offers VS Code settings when OXC is selected, and asks for presets (`react`, `adonisjs`, `vitest`) pre-selected from your dependencies. It asks before overwriting a file and only adds the `package.json` scripts that are missing. It then installs the packages once as devDependencies with the detected package manager. See the [CLI reference](docs/cli.md) for details.
27
+ The CLI asks which tools to set up (EditorConfig, OXC, Knip), offers VS Code settings when OXC is selected, and asks for presets (`react`, `adonisjs`, `vitest`, `lingui`) pre-selected from your dependencies. It asks before overwriting a file and only adds the `package.json` scripts that are missing. It then installs the packages once as devDependencies with the detected package manager. See the [CLI reference](docs/cli.md) for details.
28
28
 
29
29
  ### Block releases that ship a patched or linked `@minimalstuff/*` package
30
30
 
@@ -318,6 +318,7 @@ const REACT_PACKAGES = [
318
318
  "@types/react-dom"
319
319
  ];
320
320
  const VITEST_PACKAGES = ["vitest"];
321
+ const LINGUI_PACKAGES = ["@lingui/core", "@lingui/react"];
321
322
  const ADONISJS_SCOPE_PREFIX = "@adonisjs/";
322
323
  const SUBPATH_IMPORT_PREFIX = "#";
323
324
  function collectDependencyNames(manifests) {
@@ -335,6 +336,7 @@ function detectPresetFlags(manifests) {
335
336
  return {
336
337
  react: hasAnyOf(REACT_PACKAGES),
337
338
  vitest: hasAnyOf(VITEST_PACKAGES),
339
+ lingui: hasAnyOf(LINGUI_PACKAGES),
338
340
  adonisjs: [...names].some((name) => name.startsWith(ADONISJS_SCOPE_PREFIX))
339
341
  };
340
342
  }
@@ -348,7 +350,8 @@ function toPresetFlags(names) {
348
350
  return {
349
351
  react: names.includes("react"),
350
352
  adonisjs: names.includes("adonisjs"),
351
- vitest: names.includes("vitest")
353
+ vitest: names.includes("vitest"),
354
+ lingui: names.includes("lingui")
352
355
  };
353
356
  }
354
357
  async function listDirectoryManifestLocations(cwd, workspaceDirectory) {
@@ -412,6 +415,10 @@ async function promptPresets(cwd) {
412
415
  {
413
416
  value: "vitest",
414
417
  label: "Vitest"
418
+ },
419
+ {
420
+ value: "lingui",
421
+ label: "Lingui"
415
422
  }
416
423
  ],
417
424
  initialValues: toDetectedPresetNames(detectedPresets),
@@ -594,7 +601,8 @@ async function updateKnip(result) {
594
601
  const OXLINT_PRESET_ORDER = [
595
602
  "adonisjs",
596
603
  "react",
597
- "vitest"
604
+ "vitest",
605
+ "lingui"
598
606
  ];
599
607
  const DISABLED_SUBPATH_IMPORTS_OPTION = {
600
608
  key: "subpathImports",
@@ -1,4 +1,8 @@
1
1
  import { OxlintConfig } from "oxlint";
2
+ export interface MinimalstuffLinguiOptions {
3
+ /** Extra strings that never need translating (brand names...), added to the default allowlist. */
4
+ allowedStrings?: readonly string[];
5
+ }
2
6
  export interface MinimalstuffOxlintOptions extends OxlintConfig {
3
7
  /** Enable React rules (hooks, fast refresh) and accessibility checks. */
4
8
  react?: boolean;
@@ -6,6 +10,11 @@ export interface MinimalstuffOxlintOptions extends OxlintConfig {
6
10
  adonisjs?: boolean;
7
11
  /** Enable the vitest plugin. */
8
12
  vitest?: boolean;
13
+ /**
14
+ * Refuse visible JSX text and user-facing attribute strings that bypass
15
+ * Lingui. Defaults to false.
16
+ */
17
+ lingui?: boolean | MinimalstuffLinguiOptions;
9
18
  /** Report relative imports so code uses Node subpath imports (`#folder/file.ts`). Defaults to true. */
10
19
  subpathImports?: boolean;
11
20
  }
package/dist/oxc/lint.mjs CHANGED
@@ -13,6 +13,49 @@ const ADONISJS_INJECTION_FILES = [
13
13
  "**/providers/**"
14
14
  ];
15
15
  const TEST_FILES = ["**/*.{test,spec}.{ts,tsx,js,jsx}", "**/tests/**"];
16
+ /**
17
+ * Attributes whose string reaches the user: the native ones plus the text props
18
+ * of `@minimalstuff/ui` components. Any other attribute (className, type, id...)
19
+ * is not text.
20
+ */
21
+ const LINGUI_TEXT_ATTRIBUTES = [
22
+ "aria-label",
23
+ "aria-description",
24
+ "aria-roledescription",
25
+ "aria-valuetext",
26
+ "title",
27
+ "alt",
28
+ "placeholder",
29
+ "label",
30
+ "description",
31
+ "error",
32
+ "text",
33
+ "message",
34
+ "closeLabel",
35
+ "clearLabel",
36
+ "menuLabel",
37
+ "requiredLabel",
38
+ "noResultsText",
39
+ "searchPlaceholder"
40
+ ];
41
+ /**
42
+ * Strings identical in every locale: empty `alt` on decorative images,
43
+ * punctuation and separators.
44
+ */
45
+ const UNTRANSLATABLE_JSX_STRINGS = [
46
+ "",
47
+ "·",
48
+ "•",
49
+ "…",
50
+ "%",
51
+ "(",
52
+ ")",
53
+ ",",
54
+ "/",
55
+ ":",
56
+ "|",
57
+ "-"
58
+ ];
16
59
  const RELATIVE_IMPORT_MESSAGE = "Use a subpath import (#folder/file.ts) instead of a relative path.";
17
60
  function createBasePreset() {
18
61
  return defineConfig({
@@ -67,6 +110,33 @@ function createReactPreset() {
67
110
  }]
68
111
  });
69
112
  }
113
+ /**
114
+ * `Trans` children are the message and `Kbd` children are key names, so both
115
+ * are allowed. `noStrings` stays off because oxlint then flags every attribute
116
+ * literal (className...), so wrapped literals (`{'text'}`) are not caught.
117
+ */
118
+ function createLinguiPreset(extraAllowedStrings) {
119
+ return defineConfig({
120
+ plugins: ["react"],
121
+ rules: { "react/jsx-no-literals": ["error", {
122
+ restrictedAttributes: LINGUI_TEXT_ATTRIBUTES,
123
+ allowedStrings: [...UNTRANSLATABLE_JSX_STRINGS, ...extraAllowedStrings],
124
+ elementOverrides: {
125
+ Trans: { allowElement: true },
126
+ Kbd: { allowElement: true }
127
+ }
128
+ }] },
129
+ overrides: [{
130
+ files: TEST_FILES,
131
+ rules: { "react/jsx-no-literals": "off" }
132
+ }]
133
+ });
134
+ }
135
+ function toLinguiAllowedStrings(lingui) {
136
+ if (lingui === false) return void 0;
137
+ if (lingui === true) return [];
138
+ return lingui.allowedStrings ?? [];
139
+ }
70
140
  function createVitestPreset() {
71
141
  return defineConfig({ plugins: ["vitest"] });
72
142
  }
@@ -128,6 +198,7 @@ function createPresets(options) {
128
198
  if (options.vitest) presets.push(createVitestPreset());
129
199
  if (options.adonisjs) presets.push(createAdonisjsPreset());
130
200
  if (options.adonisjs && options.react) presets.push(createInertiaPreset());
201
+ if (options.linguiAllowedStrings) presets.push(createLinguiPreset(options.linguiAllowedStrings));
131
202
  if (options.subpathImports) presets.push(createSubpathImportsPreset());
132
203
  return presets;
133
204
  }
@@ -145,13 +216,14 @@ function createIgnorePatterns(isAdonisjsEnabled, userIgnorePatterns) {
145
216
  * root because oxlint does not inherit them through `extends`.
146
217
  */
147
218
  function minimalstuffPreset(options = {}) {
148
- const { react = false, adonisjs = false, vitest = false, subpathImports = true, extends: userExtends = [], ignorePatterns: userIgnorePatterns = [], ...userConfig } = options;
219
+ const { react = false, adonisjs = false, vitest = false, lingui = false, subpathImports = true, extends: userExtends = [], ignorePatterns: userIgnorePatterns = [], ...userConfig } = options;
149
220
  return defineConfig({
150
221
  ...userConfig,
151
222
  extends: [...createPresets({
152
223
  react,
153
224
  adonisjs,
154
225
  vitest,
226
+ linguiAllowedStrings: toLinguiAllowedStrings(lingui),
155
227
  subpathImports
156
228
  }), ...userExtends],
157
229
  ignorePatterns: createIgnorePatterns(adonisjs, userIgnorePatterns)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@minimalstuff/tooling",
3
- "version": "0.10.0",
3
+ "version": "0.12.0",
4
4
  "description": "Shared tooling configs: EditorConfig, OXC (oxlint + oxfmt), Knip",
5
5
  "keywords": [
6
6
  "editorconfig",
@@ -93,7 +93,6 @@
93
93
  "requireCleanWorkingDir": true,
94
94
  "requireUpstream": true,
95
95
  "commitMessage": "chore(release): ${version}",
96
- "tagAnnotation": "v${version}",
97
96
  "push": true,
98
97
  "tagName": "v${version}",
99
98
  "tagExclude": "*.*.*-*"