@sinemacula/coding-standards 1.12.3 → 1.14.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
@@ -195,6 +195,32 @@ package_filters = [
195
195
  ]
196
196
  ```
197
197
 
198
+ ### TypeScript (tsconfig)
199
+
200
+ The package ships a shared `tsconfig` base so every TypeScript repository checks its code to the same bar. Install the
201
+ package (as above) and extend the base from your `tsconfig.json`:
202
+
203
+ ```json
204
+ {
205
+ "extends": "@sinemacula/coding-standards/js/tsconfig.base.json",
206
+ "compilerOptions": {
207
+ "lib": ["ES2023", "DOM", "DOM.Iterable"],
208
+ "types": ["node"]
209
+ },
210
+ "include": ["src"]
211
+ }
212
+ ```
213
+
214
+ The base carries only the environment-independent options: the full strictness set and the module/resolution
215
+ discipline. Everything environment-specific stays in the consuming repo and layers on top - `lib` (DOM for the browser,
216
+ none for a Node service), `types`, Vue's `jsx`/`jsxImportSource`, `paths`, `noEmit`, and the `include`/`exclude` globs.
217
+ The `target` and `module` defaults suit bundler-built apps and libraries; a non-bundler project overrides them.
218
+
219
+ The base sets `noPropertyAccessFromIndexSignature`, so a property that comes from an index signature is accessed with
220
+ brackets (`config['key']`), not a dot. Biome cannot see types and so cannot tell that access apart from a normal one,
221
+ which is why its `useLiteralKeys` rule is off and the type-aware `@typescript-eslint/dot-notation` rule enforces dot
222
+ access for real properties instead. Load the type-checked ESLint layer to get it.
223
+
198
224
  ### Knip (JavaScript / TypeScript)
199
225
 
200
226
  ```json
package/js/biome.json CHANGED
@@ -38,7 +38,7 @@
38
38
  "noUselessTernary": "warn",
39
39
  "noUselessUndefinedInitialization": "warn",
40
40
  "useArrowFunction": "warn",
41
- "useLiteralKeys": "warn",
41
+ "useLiteralKeys": "off",
42
42
  "useNumericLiterals": "warn"
43
43
  },
44
44
  "correctness": {
@@ -92,7 +92,7 @@ export default [
92
92
  },
93
93
  },
94
94
  {
95
- files: ['**/*.{test,spec}.{ts,tsx,mts,cts,js,jsx,mjs,cjs}', '**/__tests__/**', '**/tests/**'],
95
+ files: ['**/*.{test,spec}.{ts,tsx,mts,cts,js,jsx,mjs,cjs}', '**/__tests__/**', '**/tests/**', '**/test-support/**'],
96
96
  rules: {
97
97
  'max-lines-per-function': 'off',
98
98
  'max-depth': 'off',
@@ -31,6 +31,9 @@ export default [
31
31
 
32
32
  '@typescript-eslint/await-thenable': 'error',
33
33
  '@typescript-eslint/consistent-type-imports': 'error',
34
+ // Type-aware replacement for Biome's useLiteralKeys: dot access for
35
+ // real properties, bracket access allowed on index signatures.
36
+ '@typescript-eslint/dot-notation': ['error', { allowIndexSignaturePropertyAccess: true }],
34
37
  '@typescript-eslint/explicit-module-boundary-types': 'error',
35
38
  '@typescript-eslint/no-floating-promises': 'error',
36
39
  '@typescript-eslint/no-misused-promises': 'error',
@@ -0,0 +1,27 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "display": "@sinemacula/coding-standards base",
4
+ "compilerOptions": {
5
+ "target": "ES2023",
6
+ "module": "Preserve",
7
+ "moduleResolution": "Bundler",
8
+ "moduleDetection": "force",
9
+ "verbatimModuleSyntax": true,
10
+ "isolatedModules": true,
11
+ "resolveJsonModule": true,
12
+ "esModuleInterop": true,
13
+ "strict": true,
14
+ "noUncheckedIndexedAccess": true,
15
+ "noPropertyAccessFromIndexSignature": true,
16
+ "exactOptionalPropertyTypes": true,
17
+ "noImplicitOverride": true,
18
+ "noFallthroughCasesInSwitch": true,
19
+ "noImplicitReturns": true,
20
+ "allowUnreachableCode": false,
21
+ "noUnusedLocals": true,
22
+ "noUnusedParameters": true,
23
+ "noUncheckedSideEffectImports": true,
24
+ "forceConsistentCasingInFileNames": true,
25
+ "skipLibCheck": true
26
+ }
27
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sinemacula/coding-standards",
3
- "version": "1.12.3",
3
+ "version": "1.14.0",
4
4
  "description": "Centralized coding standards, static analysis configurations, and code quality tooling for all Sine Macula repositories.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Ben Carey <bdmc@sinemacula.co.uk>",
@@ -16,6 +16,7 @@
16
16
  "biome",
17
17
  "knip",
18
18
  "eslint",
19
+ "typescript",
19
20
  "coding-standards",
20
21
  "linting",
21
22
  "config"
@@ -36,6 +37,7 @@
36
37
  "./js/eslint": "./js/eslint/index.js",
37
38
  "./js/eslint/type-checked": "./js/eslint/type-checked.js",
38
39
  "./js/eslint/vue": "./js/eslint/vue.js",
40
+ "./js/tsconfig.base.json": "./js/tsconfig.base.json",
39
41
  "./*": "./*"
40
42
  },
41
43
  "scripts": {