@starci/eslint-canon-be 3.4.27 → 3.4.29

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/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.4.29 - 2026-10-22
4
+ - Changed: the bundled canon pins select @starci/hfs 4.7.21 and @starci/cli 1.7.21.
5
+
6
+ ## 3.4.28 - 2026-10-22
7
+ - Fixed: Sonar way parity with the server: the injected-constructor-aware `max-params` (S107) replaces core `max-params`, and the ports that report what the server does not on the same source (S1481 `no-unused-vars`, S3403 `different-types-comparison`, S3782 `argument-type`, S3800 `function-return-type`, S6582 `prefer-optional-chain`) are left to the server; NIVO (0 issues on the server) lints at 0 instead of 205 under 1.7.19.
8
+ - Changed: the bundled canon-pins and failure-code copies follow the 1.7.20 cohort; lint behavior is unchanged.
9
+
3
10
  ## 3.4.27 - 2026-10-21
4
11
  - Changed: supersedes 3.4.26 (app lint broken: the canons' Sonar way block carries its own ignores, which `starci app lint` refused as an unsupported source scope, so it exited 2 without running ESLint and reported 0 findings); 3.4.26 is not used.
5
12
  - Changed: the bundled canon-pins copy follows the 1.7.19 cohort (cli 1.7.19, hfs 4.7.19); lint behavior is unchanged.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@starci/eslint-canon-be",
3
- "version": "3.4.27",
3
+ "version": "3.4.29",
4
4
  "description": "The StarCi back-end lint canon: every rule its laws publish, gathered as one flat-config plugin.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -29,14 +29,14 @@ pins:
29
29
  source: packages/grammar/package.json
30
30
  why: 'the grammar front ends read: the brand layer sets `--font-sans` and `--font-mono` and the grammar reads them; it carries the Input tel kind, the copyable and read-only Input, the IconButton disclosure props and count badge, ChatBubble, FillViewport, Textarea mentions and Enter-to-send, the leading PrimaryRailLayout rail, the plate-less Image, ListRow, the soft Alert, Progress steps, the floating primary IconButton, FlowGraph, the STATE-8 loading views and the bordered selectable TagGroup chips. The runtime source version wins for a @starci package.'
31
31
  '@starci/eslint-canon-be':
32
- version: 3.4.27
32
+ version: 3.4.29
33
33
  group: starci
34
34
  install: registry
35
35
  side: be
36
36
  source: packages/eslint/be/package.json
37
37
  why: 'the back-end ESLint canon: `loadHfs(import.meta.url)` of be/eslint.config.mjs finds the app-root hfs.json (kind app) and gives every linted file the view of the be side, and the project graph is built per side; its bundled runtime copies (slots, canon-pins, failure codes, the architecture machine) put .starcistacks and .sops.yaml at the app root; `starciBeConfig({ hfs: loadHfs(import.meta.url) })` is the typed factory and the BE-CONVENTION laws are its rules.'
38
38
  '@starci/eslint-canon-fe':
39
- version: 8.4.26
39
+ version: 8.4.28
40
40
  group: starci
41
41
  install: registry
42
42
  side: fe
@@ -50,7 +50,7 @@ pins:
50
50
  source: packages/stylelint/package.json
51
51
  why: 'the front-end stylelint canon: no-class-selector refuses a compound class selector (`div.card`); the brand layer accepts `--font-sans` and `--font-mono`; status-contrast measures the HeroUI soft pairs per theme; brand-layer-shape reads the shared :root,.light,.dark block and the info soft pair; appTokens come from loadAppTokens(import.meta.url) for the managed one-line stylelint.config.mjs.'
52
52
  '@starci/tsconfig':
53
- version: 2.0.4
53
+ version: 2.0.5
54
54
  group: starci
55
55
  install: registry
56
56
  side: both
@@ -76,14 +76,14 @@ pins:
76
76
  source: packages/test-world/package.json
77
77
  why: 'the shared e2e library of every back end (R47, R48), a devDependency of every back end: the warm stack behind toxiproxy, the network-edge fakes, the Nest boot, the typed useTestWorld handle, useSandbox for contract specs and the outage lock. Kafka is real own infra (the one digest-pinned apache/kafka KRaft image, a broker listener and proxy per slot, slot-prefixed topics, consumer groups and client ids) and Postgres is schema-per-context (a schema and a login role per context in a shared database). Each worker has its own data slot (<ns>_w<k>) with its own databases, Keycloak realm, leased Redis DB, bucket/collection/topic prefixes, fakes host, toxiproxy proxies and outage lock; a run provisions min(jest workers, workers cap, default 2) slots, and state file protocol 2 pairs exactly with @starci/jest-preset (TEST_WORLD_PAIR_MISMATCH otherwise). A modules world boots real peer apps beside its modules, world.apps.<name>.during(fn) is the outage of a peer app, w.keycloak.clientSecret(client) answers the run-generated secret of a confidential realm client, world.keycloak.events/sessions read the realm user events and live sessions, world.infra.postgresql.connection(name) takes one database connection down while the others serve, and world.resolve and scope.resolve take any Nest token. Every path a declaration names (`stack`, seeds, the realm, Dockerfiles) resolves from the app root (the directory of hfs.json); the globalSetup registers the path aliases as TypeScript resolves them. Its CLI main is exported at ./cli for starci app stack.'
78
78
  '@starci/cli':
79
- version: 1.7.19
79
+ version: 1.7.21
80
80
  group: starci
81
81
  install: registry
82
82
  side: both
83
83
  source: packages/cli/package.json
84
84
  why: 'the only StarCi command package; product repositories install it for starci app, while @starci/hfs remains its pinned transitive implementation.'
85
85
  '@starci/hfs':
86
- version: 4.7.19
86
+ version: 4.7.21
87
87
  group: starci
88
88
  install: registry
89
89
  side: both
@@ -3754,7 +3754,7 @@ rules:
3754
3754
  - {path: packages/eslint/be/sonar-parity-editions.spec.mjs, edition: full}
3755
3755
  - {path: packages/eslint/fe/sonar-parity-editions.spec.mjs, edition: lite}
3756
3756
  - {path: packages/eslint/fe/sonar-parity-editions.spec.mjs, edition: full}
3757
- law: "Code carries none of the smells SonarCloud measures that a lint rule can decide: no `await` inside a loop (S9382; an endless loop is spared), no `charCodeAt`/`fromCharCode` (S7758), no string that only escapes backslashes (S7780; a Next `matcher` is spared, it is read statically), no nested conditional expression (S3358), no `void` on anything but a call (S3735), no unused import (S1128), no import that is only handed on instead of `export ... from` (S7763), no prop of a component's props type the component never reads (S6767, front end), no `<video>` or `<audio>` without a captions track unless muted (S4084, front end), and, through typescript-eslint with type information, no deprecated API (S1874), no object turned into text (S6551) and no `async` function that never awaits and returns no promise (S7503). Every other rule of the Sonar way TypeScript profile with an ESLint equivalent (scripts/lib/sonar-way.mjs: eslint-plugin-sonarjs' Sonar way set, the core, typescript-eslint and unicorn rules it builds on) is on at error in both canons. The files a unit or an end-to-end spec names are outside the scan, so outside these rules."
3757
+ law: "Code carries none of the smells SonarCloud measures that a lint rule can decide: no `await` inside a loop (S9382; an endless loop is spared), no `charCodeAt`/`fromCharCode` (S7758), no string that only escapes backslashes (S7780; a Next `matcher` is spared, it is read statically), no nested conditional expression (S3358), no `void` on anything but a call (S3735), no unused import (S1128), no import that is only handed on instead of `export ... from` (S7763), no prop of a component's props type the component never reads (S6767, front end), no `<video>` or `<audio>` without a captions track unless muted (S4084, front end), and, through typescript-eslint with type information, no deprecated API (S1874), no object turned into text (S6551) and no `async` function that never awaits and returns no promise (S7503). No function takes more than seven parameters (S107), except the constructor of an injectable class, whose parameters are its injected dependencies. Every other rule of the Sonar way TypeScript profile with an ESLint equivalent that reports what the server reports on the same source (scripts/lib/sonar-way.mjs: eslint-plugin-sonarjs' Sonar way set and the core and unicorn rules it builds on) is on at error in both canons; a port that does not match the server is left to the server. The files a unit or an end-to-end spec names are outside the scan, so outside these rules."
3758
3758
  kinds: [lint, codemod]
3759
3759
  gates: [pre-commit, settle, land, ci]
3760
3760
  failureCodes: ["SCAN_SMELL"]
@@ -3775,6 +3775,8 @@ rules:
3775
3775
  - {kind: eslint-fe, id: prefer-export-from}
3776
3776
  - {kind: eslint-fe, id: no-unused-prop-types}
3777
3777
  - {kind: eslint-fe, id: media-has-caption}
3778
+ - {kind: eslint-be, id: max-params}
3779
+ - {kind: eslint-fe, id: max-params}
3778
3780
  - id: R236
3779
3781
  code: "RT_GATE_LOOSENING"
3780
3782
  editions: [lite, full]
@@ -40,7 +40,7 @@ export const pathsOverlap = (a, b) => sameOrUnder(a, b) || sameOrUnder(b, a);
40
40
  * `trim` blanks at the ends, `collapse` folds '//' runs to '/', `dot` drops a leading './',
41
41
  * `glob` strips a trailing glob ('star': '*'/'**' with their slash, 'double': a '/**' only),
42
42
  * `fold` lowercases. A trailing '/' always goes. Null reads as ''.
43
- * @param {unknown} p
43
+ * @param {string|number|null|undefined} p
44
44
  * @param {{trim?: boolean, collapse?: boolean, dot?: boolean, glob?: string|null, fold?: boolean}} [options]
45
45
  */
46
46
  export const normPath = (p, { trim = false, collapse = false, dot = false, glob = null, fold = false } = {}) => {
@@ -5,6 +5,8 @@
5
5
  // scan (`sonar.exclusions`), so it is outside these rules. The rules that need the type checker (S1874, S6551, S7503) are borrowed from
6
6
  // typescript-eslint by the canon factories; the one that needs a regex ambiguity analysis (S8786) runs in the runtime's own `sonar-rules` check.
7
7
 
8
+ import { MAX_PARAMETERS } from './sonar-way.mjs';
9
+
8
10
  const FUNCTIONS = new Set(['FunctionDeclaration', 'FunctionExpression', 'ArrowFunctionExpression']);
9
11
  const REPEATED = Object.freeze({
10
12
  ForStatement: ['body', 'test', 'update'],
@@ -206,6 +208,26 @@ const noUnusedPropTypes = {
206
208
  },
207
209
  };
208
210
 
211
+ /** The decorators of a class whose constructor parameters are injected (Sonar's S107 spares these constructors). */
212
+ const INJECTED = new Set(['Injectable', 'Component', 'Directive', 'Pipe']);
213
+ const decoratorName = (decorator) => {
214
+ const expression = decorator.expression.type === 'CallExpression' ? decorator.expression.callee : decorator.expression;
215
+ return expression.type === 'Identifier' ? expression.name : null;
216
+ };
217
+ const injectedConstructor = (node) => node.parent?.type === 'MethodDefinition' && node.parent.kind === 'constructor'
218
+ && (node.parent.parent?.parent?.decorators ?? []).some((decorator) => INJECTED.has(decoratorName(decorator)));
219
+
220
+ /** S107: a function takes at most MAX_PARAMETERS parameters; the constructor of an injectable class is a dependency list, not a call shape. */
221
+ const maxParams = {
222
+ meta: { type: 'suggestion', schema: [], messages: { many: 'S107: this function has {{count}} parameters; at most {{max}} are allowed. Pass an options object.' } },
223
+ create(context) {
224
+ const check = (node) => {
225
+ if (node.params.length > MAX_PARAMETERS && !injectedConstructor(node)) context.report({ node, messageId: 'many', data: { count: String(node.params.length), max: String(MAX_PARAMETERS) } });
226
+ };
227
+ return { FunctionDeclaration: check, FunctionExpression: check, ArrowFunctionExpression: check };
228
+ },
229
+ };
230
+
209
231
  /** S4084: a `<video>` or `<audio>` element plays captions: a `<track kind="captions">` child, or it is `muted`. */
210
232
  const MEDIA = new Set(['video', 'audio']);
211
233
  const jsxName = (node) => (node?.name?.type === 'JSXIdentifier' ? node.name.name : null);
@@ -243,4 +265,5 @@ export const SONAR_SYNTAX_RULES = Object.freeze({
243
265
  'prefer-export-from': scanned(preferExportFrom),
244
266
  'no-unused-prop-types': scanned(noUnusedPropTypes),
245
267
  'media-has-caption': scanned(mediaHasCaption),
268
+ 'max-params': scanned(maxParams),
246
269
  });
@@ -10,23 +10,30 @@
10
10
  export const COGNITIVE_COMPLEXITY_LIMIT = 15;
11
11
  export const MAX_PARAMETERS = 7;
12
12
 
13
- /** sonarjs rules of Sonar way another canon rule already reports: the owner that reports the same Sonar id. */
13
+ /**
14
+ * sonarjs rules of Sonar way the local lint does not run: another canon owner reports the same Sonar id, or the port does not match what the
15
+ * server reports on the same source and is left to the server. Parity is measured, not assumed: a product scan with 0 issues on the server
16
+ * (Sonar way, 2026-10-21) while these ports reported 130 findings on it; a rule that cannot match the server is not a lint error.
17
+ */
14
18
  const SONAR_WAY_OWNED = Object.freeze({
15
19
  'sonarjs/no-nested-conditional': 'S3358, the canon syntax rule no-nested-conditional',
16
20
  'sonarjs/unused-import': 'S1128, the canon syntax rule no-unused-import',
17
21
  'sonarjs/void-use': 'S3735, the canon syntax rule no-void-operator',
18
22
  'sonarjs/deprecation': 'S1874, the borrowed @typescript-eslint/no-deprecated',
23
+ 'sonarjs/no-unused-vars': 'S1481, the TypeScript compiler (noUnusedLocals in @starci/tsconfig); the port also reports a rest-sibling omit the server accepts',
24
+ 'sonarjs/different-types-comparison': 'S3403, the server: the port reads control-flow-narrowed types (`x !== null` after an aliased guard) the server does not report',
25
+ 'sonarjs/function-return-type': 'S3800, the server: the port reports nullable and union returns the server accepts',
26
+ 'sonarjs/argument-type': 'S3782, the server: the port reports optional arguments the server accepts',
19
27
  });
20
28
 
21
29
  /**
22
- * The Sonar way rules SonarSource implements on an ESLint rule outside eslint-plugin-sonarjs: `{ sonar, rule, options? }`. S4084 (a
23
- * `<video>`/`<audio>` without captions) is the front-end canon's syntax rule media-has-caption. S7785 (top-level await) is left out: an
24
- * app's TypeScript compiles to CommonJS (`module: nodenext` without `type: module`), where top-level await does not exist.
30
+ * The Sonar way rules SonarSource implements on an ESLint rule outside eslint-plugin-sonarjs: `{ sonar, rule, options? }`. The canon syntax
31
+ * rules carry S107 (`max-params`, which spares the constructor of an injectable class as the server does) and S4084 (`media-has-caption`,
32
+ * front end). Left out: S7785 (top-level await; an app's TypeScript compiles to CommonJS, `module: nodenext` without `type: module`) and
33
+ * S6582 (typescript-eslint's optional-chain rule reports guards whose optional chain would change the value's type, which the server accepts).
25
34
  */
26
35
  export const SONAR_WAY_EXTRA = Object.freeze([
27
- { sonar: 'S107', rule: 'max-params', options: [{ max: MAX_PARAMETERS }] },
28
36
  { sonar: 'S3863', rule: 'no-duplicate-imports', options: [{ allowSeparateTypeImports: true }] },
29
- { sonar: 'S6582', rule: '@typescript-eslint/prefer-optional-chain' },
30
37
  { sonar: 'S4138', rule: 'unicorn/no-for-loop' },
31
38
  { sonar: 'S7721', rule: 'unicorn/consistent-function-scoping', options: [{ checkArrowFunctions: false }] },
32
39
  { sonar: 'S7732', rule: 'unicorn/no-instanceof-builtins' },
package/sonar-parity.mjs CHANGED
@@ -11,7 +11,7 @@
11
11
  */
12
12
  import { SONAR_SYNTAX_RULES } from "./runtime/scripts/lib/sonar-syntax-rules.mjs"
13
13
 
14
- const NAMES = ["no-await-in-loop", "prefer-code-point", "prefer-string-raw", "no-nested-conditional", "no-void-operator", "no-unused-import", "prefer-export-from"]
14
+ const NAMES = ["no-await-in-loop", "prefer-code-point", "prefer-string-raw", "no-nested-conditional", "no-void-operator", "no-unused-import", "prefer-export-from", "max-params"]
15
15
 
16
16
  /** The rules this law contributes to the plugin. */
17
17
  export const rules = Object.fromEntries(NAMES.map((name) => [name, SONAR_SYNTAX_RULES[name]]))