@aditosoftware/eslint-config-adito-platform 2.0.4 → 2.2.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.
Files changed (3) hide show
  1. package/CHANGELOG.md +73 -5
  2. package/index.mjs +250 -4
  3. package/package.json +12 -5
package/CHANGELOG.md CHANGED
@@ -5,13 +5,81 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## 2.2.0
9
+
10
+ ### Added
11
+
12
+ - Enabled `no-duplicate-imports` (`warn`): each module may only be imported once, duplicated imports of the same module must be merged into a single import statement
13
+ - Enabled core rules (`warn`):
14
+ - `no-console` (with `allow: ["warn", "error"]`): catches forgotten debug logging, while `console.warn`/`console.error` stay legitimate
15
+ - `no-alert`: catches forgotten debugging dialogs
16
+ - `no-template-curly-in-string`: catches `"${x}"` inside plain strings (missing template literal)
17
+ - `no-self-compare`: catches `x === x`, which is almost always a typo
18
+ - `no-promise-executor-return`: the promise executor must call `resolve`/`reject`, returning a value is a mistake
19
+ - `no-constructor-return`: a `return` in a constructor has no effect
20
+ - `no-multi-str`: line continuations with `\` are error-prone, template literals should be used instead
21
+ - `no-new-wrappers`: `new String("x")` etc. instead of the primitive literal is a mistake
22
+ - `no-implicit-coercion`: forces readable conversions like `Boolean(x)`, `Number(x)`, `String(x)` instead of `!!x`, `+x`, `"" + x`
23
+ - `default-case-last`: the `default` clause must be the last case in a switch
24
+ - `no-else-return`: a `return` makes a following `else` redundant
25
+ - `object-shorthand`: `{ x: x }` can be shortened to `{ x }`
26
+
27
+ ### Changed
28
+
29
+ - Replaced the core rule `no-throw-literal` with `@typescript-eslint/only-throw-error` (`warn`): the TypeScript rule understands thrown class references (e.g. `new Error()`), which the core rule cannot
30
+
31
+ ## 2.1.0
32
+
33
+ ### Added
34
+
35
+ - Added `eslint-plugin-unicorn` for more rule checks
36
+ - `jsdoc/require-jsdoc` now requires a TSDoc block above every test method call: `suite`/`suiteSetup`/`suiteTeardown`/`test`/`setup`/`teardown`
37
+ - Enabled `@stylistic` rules (`warn`): `semi`, `eol-last`,
38
+ `lines-between-class-members`, `no-multi-spaces`,
39
+ `no-multiple-empty-lines`, `lines-around-comment`, `line-comment-position`. None of those rules conflicts with prettier formatting
40
+
41
+ ### Changed
42
+
43
+ - Also validated that types and interfaces will get TSDoc comments
44
+ - Bumped peer dependencies:
45
+ - eslint to 10.12.0
46
+ - eslint-plugin-jsdoc to 65.3.0
47
+ - `jsdoc/require-jsdoc` only requires JSDoc for type properties (interface
48
+ members, named type members) outside of function parameters: one-off inline
49
+ parameter shapes (`function f(x: { a: string })`) no longer require docs,
50
+ interfaces and named types still do
51
+ - `unicorn/no-non-function-verb-prefix` only checks the `get`, `set` and `is`
52
+ prefixes (configured via the rule's `verbs` option); the default verb list
53
+ (`unset`, `delete`, `add`, `remove`, `destroy`, `create`) is no longer enforced
54
+ - Disabled `jsdoc/require-throws-type`: the required `@throws {Type}` brace
55
+ syntax is JSDoc-only — the TSDoc parser rejects it (malformed inline tag)
56
+ and it renders poorly in the IDE hover. Throws are documented as `` `Type` ``
57
+ or `{@link Type}` instead
58
+ - Disabled `unicorn/prefer-iterator-to-array`: the suggested
59
+ `Iterator#toArray()` is ES2025 (iterator helpers) and not available with the
60
+ projects' ES2022/ES2023 target/lib
61
+ - `unicorn/filename-case` now ignores directory names: only the filename itself is checked against the allowed cases
62
+ - Disabled `unicorn/no-unsafe-property-key`: false positive for the required
63
+ Immer idiom `[immerable] = true` (and for `keyof` access on such classes) —
64
+ the rule's unique-symbol detection checks `TypeFlags.UniqueESSymbol`
65
+ (16384), but TypeScript reports the type of a unique symbol expression as
66
+ `ESSymbolLiteral` (8192), so the guard never matches; TS itself already
67
+ checks the key types
68
+ - Allowed `unicorn/no-top-level-assignment-in-function` in
69
+ `**/extension.ts`: the extension entry point keeps module-level state that
70
+ is assigned during `activate()` and by the exported test setters (the rule
71
+ has no options)
72
+ - Typed linting now uses `parserOptions.projectService: true` instead of the
73
+ legacy `project: true` auto-discovery option: same behavior (each file's
74
+ `tsconfig.json` is auto-detected) but with better caching and project-
75
+ reference support
76
+
8
77
  ## 2.0.4
9
78
 
10
79
  ### Changed
11
80
 
12
81
  - ci: used npm 11 for publishing with OIDC and used only supported node versions for pipelines by @rH4rtinger in #34
13
82
 
14
-
15
83
  - Upgraded dependencies:
16
84
  - chore(deps): bump flatted from 3.4.1 to 3.4.2 by @dependabot[bot] in #20
17
85
  - chore(deps): bump picomatch from 4.0.3 to 4.0.4 by @dependabot[bot] in #21
@@ -53,10 +121,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
53
121
  ### Changed
54
122
 
55
123
  - Upgraded dependencies:
56
- - @typescript-eslint/eslint-plugin to 8.46.1
57
- - @typescript-eslint/parser to 8.46.1
58
- - @stylistic/eslint-plugin to 5.4.0
59
- - eslint-plugin-jsdoc to 60.8.3
124
+ - @typescript-eslint/eslint-plugin to 8.46.1
125
+ - @typescript-eslint/parser to 8.46.1
126
+ - @stylistic/eslint-plugin to 5.4.0
127
+ - eslint-plugin-jsdoc to 60.8.3
60
128
 
61
129
  ## 2.0.1
62
130
 
package/index.mjs CHANGED
@@ -1,5 +1,6 @@
1
1
  import typescriptEslint from "@typescript-eslint/eslint-plugin";
2
2
  import tsdoc from "eslint-plugin-tsdoc";
3
+ import unicorn from "eslint-plugin-unicorn";
3
4
  import globals from "globals";
4
5
  import tsParser from "@typescript-eslint/parser";
5
6
  import path from "node:path";
@@ -25,6 +26,7 @@ export default [
25
26
  "**/build",
26
27
  "**/*.js",
27
28
  "**/*.mjs",
29
+ "**/*.json",
28
30
  ".vscode-test/**",
29
31
  ],
30
32
  },
@@ -36,13 +38,21 @@ export default [
36
38
  "plugin:chai-friendly/recommended",
37
39
  "plugin:chai-expect/recommended",
38
40
  // prettier needs to be the last line
39
- "plugin:prettier/recommended"
41
+ "plugin:prettier/recommended",
40
42
  ),
43
+ // unicorn v77+ ships flat configs: spread them directly instead of using FlatCompat
44
+ unicorn.configs.recommended,
41
45
  {
46
+ // scope the TS parser and typed linting to TS files only, so other file
47
+ // types (e.g. *.json) never hit the parser error for files that are not
48
+ // included in any `tsconfig.json` project
49
+ files: ["**/*.ts", "**/*.tsx"],
50
+
42
51
  plugins: {
43
52
  "@typescript-eslint": typescriptEslint,
44
53
  "@stylistic": stylistic,
45
54
  tsdoc,
55
+ unicorn,
46
56
  },
47
57
 
48
58
  languageOptions: {
@@ -52,11 +62,14 @@ export default [
52
62
  },
53
63
 
54
64
  parser: tsParser,
55
- ecmaVersion: 6,
65
+ ecmaVersion: "latest",
56
66
  sourceType: "module",
57
67
 
58
68
  parserOptions: {
59
- project: true,
69
+ // typed linting via the TS project service (recommended over the
70
+ // legacy `project` option): each file's `tsconfig.json` is
71
+ // auto-detected, with better caching and project-reference support
72
+ projectService: true,
60
73
  },
61
74
  },
62
75
 
@@ -73,6 +86,101 @@ export default [
73
86
 
74
87
  "prettier/prettier": "warn",
75
88
 
89
+ // conflicting with prettier formatting (prettier is the last word here)
90
+ "unicorn/empty-brace-spaces": "off",
91
+
92
+ // our documentation style keeps the asterisk prefix
93
+ "unicorn/no-asterisk-prefix-in-documentation-comments": "off",
94
+
95
+ "unicorn/consistent-boolean-name": "off",
96
+ "unicorn/explicit-length-check": "off",
97
+ // `null` is fine as long as the type checks (validate) pass
98
+ "unicorn/no-null": "off",
99
+ // only `get`/`set`/`is` prefixes must denote functions
100
+ "unicorn/no-non-function-verb-prefix": [
101
+ "error",
102
+ {
103
+ verbs: ["get", "set", "is"],
104
+ },
105
+ ],
106
+ // false positive for the required Immer idiom `[immerable] = true`
107
+ // (and for `keyof` access on such classes): the rule's unique-symbol
108
+ // detection checks TypeFlags.UniqueESSymbol (16384), but TS reports
109
+ // the type of a unique symbol expression as ESSymbolLiteral (8192),
110
+ // so the guard never matches and the generic property heuristic fires;
111
+ // TS itself already checks the key types
112
+ "unicorn/no-unsafe-property-key": "off",
113
+ "unicorn/no-useless-undefined": "off",
114
+ "unicorn/prefer-await": "off",
115
+ // `Iterator#toArray()` is ES2025 (iterator helpers) and not available with the
116
+ // projects' ES2022/ES2023 target/lib (nor in all VS Code extension hosts);
117
+ // spreading an iterator stays the portable way
118
+ "unicorn/prefer-iterator-to-array": "off",
119
+ "unicorn/prefer-module": "off",
120
+ "unicorn/prefer-ternary": "off",
121
+ "unicorn/prefer-default-parameters": "off",
122
+ "unicorn/prefer-includes-over-repeated-comparisons": "off",
123
+
124
+ // Allow one more nested call
125
+ "unicorn/max-nested-calls": [
126
+ "error",
127
+ {
128
+ max: 4,
129
+ },
130
+ ],
131
+
132
+ // we allow naming variables and files `config`/`util(s)`
133
+ "unicorn/name-replacements": [
134
+ "error",
135
+ {
136
+ replacements: {
137
+ configuration: false,
138
+ util: false,
139
+ utils: false,
140
+ db: false,
141
+ doc: false,
142
+ },
143
+ },
144
+ ],
145
+
146
+ // public methods should be written before private elements
147
+ "unicorn/consistent-class-member-order": [
148
+ "error",
149
+ {
150
+ order: [
151
+ "static-field",
152
+ "static-block",
153
+ "public-field",
154
+ "private-field",
155
+ "constructor",
156
+ "static-method",
157
+ "public-method",
158
+ "private-method",
159
+ ],
160
+ },
161
+ ],
162
+
163
+ // our file naming convention: camelCase (with acronyms) and PascalCase
164
+ "unicorn/filename-case": [
165
+ "error",
166
+ {
167
+ cases: {
168
+ kebabCase: true,
169
+ camelCase: true,
170
+ camelCaseWithAcronyms: true,
171
+ pascalCase: true,
172
+ },
173
+ // only the filename itself is checked for case; directory names
174
+ // within the file path are ignored (e.g. 01_webview, RMB)
175
+ checkDirectories: false,
176
+ // allow the fully uppercase acronym GUI in filenames
177
+ // (e.g. LiquibaseGUITestUtils.ts) — the case variants above only
178
+ // accept lowercase acronyms or a leading acronym, so matching
179
+ // files are skipped instead
180
+ ignore: [/GUI/],
181
+ },
182
+ ],
183
+
76
184
  "@typescript-eslint/no-deprecated": "error",
77
185
 
78
186
  "@typescript-eslint/no-floating-promises": "error",
@@ -94,9 +202,79 @@ export default [
94
202
  },
95
203
  ],
96
204
  "@stylistic/semi": "warn",
205
+ // Prettier always emits a trailing newline at EOF — no conflict
206
+ "@stylistic/eol-last": "warn",
207
+ // Prettier keeps but never adds the blank line between members
208
+ "@stylistic/lines-between-class-members": "warn",
209
+ // Prettier normalizes to single spaces as well
210
+ "@stylistic/no-multi-spaces": "warn",
211
+ // exactly what Prettier collapses multiple empty lines to
212
+ "@stylistic/no-multiple-empty-lines": [
213
+ "warn",
214
+ {
215
+ max: 1,
216
+ },
217
+ ],
218
+ "@stylistic/line-comment-position": [
219
+ "warn",
220
+ {
221
+ position: "above",
222
+ },
223
+ ],
224
+ // blank line before a standalone block comment; JSDoc blocks are
225
+ // attached documentation (excluded via ignorePattern) and
226
+ // block/class/module boundaries are exempt
227
+ "@stylistic/lines-around-comment": [
228
+ "warn",
229
+ {
230
+ beforeBlockComment: true,
231
+ allowBlockStart: true,
232
+ allowBlockEnd: true,
233
+ allowClassStart: false,
234
+ allowClassEnd: false,
235
+ allowModuleStart: true,
236
+ allowModuleEnd: false,
237
+ // JSDoc/TSDoc blocks are attached documentation (their token
238
+ // value starts with "*") — exclude them from the check
239
+ ignorePattern: "^\\*",
240
+ },
241
+ ],
97
242
  curly: "warn",
98
243
  eqeqeq: "warn",
99
- "no-throw-literal": "warn",
244
+ // each module may only be imported once (merge the specifiers instead)
245
+ "no-duplicate-imports": "warn",
246
+ // forgotten debug logging; warn/error are legitimate API error channels
247
+ "no-console": [
248
+ "warn",
249
+ {
250
+ allow: ["warn", "error"],
251
+ },
252
+ ],
253
+ // forgotten debugging dialogs (alert/confirm/prompt)
254
+ "no-alert": "warn",
255
+ // `"${x}"` in a plain string is almost always a missing template literal
256
+ "no-template-curly-in-string": "warn",
257
+ // `x === x` is almost always a typo for `x === y`
258
+ "no-self-compare": "warn",
259
+ // the executor must call resolve/reject, returning a value is a mistake
260
+ "no-promise-executor-return": "warn",
261
+ // a `return` in a constructor has no effect
262
+ "no-constructor-return": "warn",
263
+ // line continuations with `\` are error-prone; use template literals
264
+ "no-multi-str": "warn",
265
+ // `new String("x")` etc. instead of the primitive literal is a mistake
266
+ "no-new-wrappers": "warn",
267
+ // `!!x`, `+x`, `"" + x` are hard to read; use Boolean(), Number(), String()
268
+ "no-implicit-coercion": "warn",
269
+ // `default` must be the last case in a switch
270
+ "default-case-last": "warn",
271
+ // `return` makes `else` redundant and harder to read
272
+ "no-else-return": "warn",
273
+ // `{ x: x }` can be shortened to `{ x }`
274
+ "object-shorthand": "warn",
275
+ // the TS rule understands thrown class references (e.g. `new Error()`),
276
+ // which the core rule `no-throw-literal` cannot
277
+ "@typescript-eslint/only-throw-error": "warn",
100
278
  "tsdoc/syntax": "warn",
101
279
 
102
280
  "jsdoc/tag-lines": [
@@ -132,6 +310,15 @@ export default [
132
310
 
133
311
  "jsdoc/check-indentation": "warn",
134
312
  "jsdoc/check-line-alignment": "warn",
313
+ // each line of a multiline JSDoc block must start with an asterisk
314
+ // (fixes the un-asterisked output of unicorn/single-line-block-comment-style)
315
+ "jsdoc/require-asterisk-prefix": "warn",
316
+
317
+ // we document with TSDoc: a `@throws {Type}` brace type is JSDoc syntax
318
+ // that tsdoc/syntax rejects (malformed inline tag) and that renders
319
+ // poorly in the IDE hover. Throws are documented as `Type` (code span)
320
+ // or {@link Type} instead — the type requirement is therefore off
321
+ "jsdoc/require-throws-type": "off",
135
322
 
136
323
  "jsdoc/require-jsdoc": [
137
324
  "warn",
@@ -144,8 +331,67 @@ export default [
144
331
  ArrowFunctionExpression: false,
145
332
  FunctionExpression: false,
146
333
  },
334
+ // the rule's fixer inserts *empty* JSDoc blocks, which is not the
335
+ // goal (documentation should be written by hand); keep reporting,
336
+ // but never auto-fix
337
+ enableFixer: false,
338
+ contexts: [
339
+ "TSInterfaceDeclaration",
340
+ "TSMethodSignature",
341
+ // only outside function parameters: one-off inline parameter shapes
342
+ // stay out of scope, interfaces and named types still require docs.
343
+ // .params/.parameters are field selectors that match the parameter
344
+ // nodes themselves (elements of a function's params/parameters
345
+ // array) — @typescript-eslint 8.x has no TSParameter node type
346
+ // (parameters are plain Identifiers with a typeAnnotation)
347
+ "TSPropertySignature:not(.params TSPropertySignature, .parameters TSPropertySignature)",
348
+ "TSEnumMember",
349
+ // class attributes / fields
350
+ // (PropertyDefinition: current ESTree-aligned name, TSPropertyDefinition:
351
+ // older @typescript-eslint versions; the unused one simply never fires)
352
+ "PropertyDefinition",
353
+ "TSPropertyDefinition",
354
+ "TSAbstractPropertyDefinition",
355
+ // WebdriverIO/Mocha test elements: a TSDoc block is expected
356
+ // above every suite/test/setup/teardown call (only bare global
357
+ // calls match — member expressions like regex.test(…) are safe)
358
+ "CallExpression[callee.name='suite']",
359
+ "CallExpression[callee.name='suiteSetup']",
360
+ "CallExpression[callee.name='suiteTeardown']",
361
+ "CallExpression[callee.name='test']",
362
+ "CallExpression[callee.name='setup']",
363
+ "CallExpression[callee.name='teardown']",
364
+ ],
147
365
  },
148
366
  ],
149
367
  },
150
368
  },
369
+ {
370
+ // Config files (vite.config.ts, webpack.config.ts, …) and everything under a
371
+ // test/ directory (incl. test utilities like chai setup files) are entry
372
+ // points run by the tooling, not libraries imported by production code.
373
+ // Top-level side effects (defineConfig({…}), chai.use(…), before(…)) and
374
+ // Mocha's test-context `this` (this.timeout(), this.test) are expected
375
+ // there; unicorn has no options to exempt those contexts.
376
+ files: [
377
+ "**/*.config.*",
378
+ "**/test/**",
379
+ "**/e2e/**",
380
+ "**/*.test.ts",
381
+ "**/*.spec.ts",
382
+ ],
383
+ rules: {
384
+ "unicorn/no-top-level-side-effects": "off",
385
+ "unicorn/no-this-outside-of-class": "off",
386
+ },
387
+ },
388
+ {
389
+ // The extension entry point keeps module-level state that is assigned
390
+ // during activate() and re-assigned by the exported test setters; the
391
+ // rule has no options to exempt this intended pattern
392
+ files: ["**/extension.ts"],
393
+ rules: {
394
+ "unicorn/no-top-level-assignment-in-function": "off",
395
+ },
396
+ },
151
397
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aditosoftware/eslint-config-adito-platform",
3
- "version": "2.0.4",
3
+ "version": "2.2.0",
4
4
  "description": "eslint configuration for the platform team of ADITO",
5
5
  "main": "index.mjs",
6
6
  "license": "MIT",
@@ -8,17 +8,24 @@
8
8
  "type": "git",
9
9
  "url": "https://github.com/aditosoftware/eslint-config-adito-platform.git"
10
10
  },
11
+ "scripts": {
12
+ "validate": "node test/validate.mjs"
13
+ },
11
14
  "peerDependencies": {
15
+ "@eslint/eslintrc": "^3.3.7",
16
+ "@eslint/js": "^10.0.1",
17
+ "@stylistic/eslint-plugin": "^5.10.0",
12
18
  "@typescript-eslint/eslint-plugin": "^8.57.0",
13
19
  "@typescript-eslint/parser": "^8.57.0",
14
- "@stylistic/eslint-plugin": "^5.10.0",
15
- "eslint": "^9.37.0",
20
+ "eslint": "^10.12.0",
16
21
  "eslint-config-prettier": "^10.1.8",
17
22
  "eslint-plugin-chai-expect": "^4.0.0",
18
23
  "eslint-plugin-chai-friendly": "^1.1.0",
19
- "eslint-plugin-jsdoc": "^62.8.0",
24
+ "eslint-plugin-jsdoc": "^65.3.0",
20
25
  "eslint-plugin-prettier": "^5.5.5",
21
26
  "eslint-plugin-tsdoc": "^0.5.2",
27
+ "eslint-plugin-unicorn": "^77.0.0",
28
+ "globals": "^17.13.0",
22
29
  "prettier": "3.6.2"
23
30
  }
24
- }
31
+ }