@dloizides/frontend-devtools 1.9.0 → 2.0.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/CHANGELOG.md +162 -144
- package/README.md +10 -35
- package/dist/eslint/index.d.mts +5 -1
- package/dist/eslint/index.d.ts +5 -1
- package/dist/eslint/index.js +117 -6
- package/dist/eslint/index.js.map +1 -1
- package/dist/eslint/index.mjs +112 -7
- package/dist/eslint/index.mjs.map +1 -1
- package/package.json +10 -29
- package/dist/index.d.mts +0 -69
- package/dist/index.d.ts +0 -69
- package/dist/index.js +0 -37
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -31
- package/dist/index.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,144 +1,162 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
All notable changes to `@dloizides/frontend-devtools` are documented here.
|
|
4
|
-
|
|
5
|
-
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
-
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
-
|
|
8
|
-
## [
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
###
|
|
13
|
-
- `
|
|
14
|
-
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
- `
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
###
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
(
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
## [1.
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
`
|
|
95
|
-
|
|
96
|
-
`
|
|
97
|
-
`
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
###
|
|
110
|
-
|
|
111
|
-
- **`
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
`
|
|
137
|
-
`
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
`
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `@dloizides/frontend-devtools` are documented here.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [2.0.0] - 2026-10-20
|
|
9
|
+
|
|
10
|
+
D-PAT-15 "Move initI18n out of frontend-devtools so it is dev-only".
|
|
11
|
+
|
|
12
|
+
### Removed (BREAKING)
|
|
13
|
+
- `initI18n` and `InitI18nOptions`: import them from `@dloizides/i18n` (>= 1.1.0), same signature: `import { initI18n } from '@dloizides/i18n';`.
|
|
14
|
+
- The root entry (`@dloizides/frontend-devtools`): it exported only `initI18n`. Use the `/eslint` and `/test-results` subpaths.
|
|
15
|
+
- The `i18next` and `react-i18next` optional peer dependencies.
|
|
16
|
+
|
|
17
|
+
## [1.10.0] - 2026-10-19
|
|
18
|
+
|
|
19
|
+
PATTERN-1.12 "TS rule packs + house rules in frontend-devtools" (D-PAT-12 "Whole rule packs as warnings, one shared approach").
|
|
20
|
+
|
|
21
|
+
### Added
|
|
22
|
+
- `patternPacksConfig`: the recommended rules of `@tanstack/eslint-plugin-query`, `eslint-plugin-react-you-might-not-need-an-effect`, `eslint-plugin-boundaries` and `eslint-plugin-sonarjs`, every rule at `warn`, plus the house rules.
|
|
23
|
+
- `query-key-factory` (PAT-QUERY-KEY-1 "queryKey only from a key factory"): flags an inline array/string/template `queryKey`; key-factory files (`*Keys.ts`), tests and generated code are exempt; `allow` adds path fragments.
|
|
24
|
+
- `HOUSE_PATTERN_RULE_NAMES`.
|
|
25
|
+
|
|
26
|
+
## [1.9.0] - 2026-10-19
|
|
27
|
+
|
|
28
|
+
PATTERN-1.4 "TypeScript pattern rules as ESLint rules", `no-raw-backend-fetch` (PAT-API-1 "web apps call the backend through the shared client") hardening.
|
|
29
|
+
|
|
30
|
+
### Changed
|
|
31
|
+
- `no-raw-backend-fetch` no longer reports `fetch` of a literal absolute `http(s)://host/...` URL (third-party), or of a value produced by `URL.createObjectURL(...)` / `new FileReader().result` (direct, or via a single `const`).
|
|
32
|
+
- `no-raw-backend-fetch` registers no visitors when the parsed AST is not an ESTree `Program` (non-JS languages under an unscoped `apiConfig`).
|
|
33
|
+
|
|
34
|
+
### Tests
|
|
35
|
+
- `apiConfigUnscoped.test.ts`: `apiConfig` without `files` lints `.js`/`.mjs`/`.cjs`, build output and a 2000-deep nested file without throwing, and still reports under `src/`.
|
|
36
|
+
|
|
37
|
+
## [1.8.0] - 2026-10-19
|
|
38
|
+
|
|
39
|
+
PATTERN-1.4 "TypeScript pattern rules as ESLint rules", row PAT-API-1 "web apps call the backend through the shared client".
|
|
40
|
+
|
|
41
|
+
### Added
|
|
42
|
+
|
|
43
|
+
- `no-raw-backend-fetch`: reports `fetch(` / `window.fetch(` / `globalThis.fetch(` / `self.fetch(` and value imports of `axios`
|
|
44
|
+
(`import`, `require`, `import()`) in `src/**`. Exempt: `src/server/`, `src/http/`, `src/lib/http/`, `packages/*-client/`,
|
|
45
|
+
`/generated/`, service worker files, `app/+html.*`, tests, `data:`/`blob:` URLs, `import type` from axios. Option `{ allow: string[] }`.
|
|
46
|
+
- `apiConfig` flat-config preset (`API_RULE_NAMES`) at `error`; included in `recommendedConfig`.
|
|
47
|
+
|
|
48
|
+
## [1.7.0] - 2026-10-19
|
|
49
|
+
|
|
50
|
+
NAV-1 "Every game menu works with arrow keys and controller", phase 3.
|
|
51
|
+
|
|
52
|
+
### Added
|
|
53
|
+
|
|
54
|
+
- `game-menu-focusable`: reports a `click` / `pointerdown` / `pointerup` listener or `onclick =` on an element created as
|
|
55
|
+
`div` / `span` / `li` / `img` whose variable never gets `tabIndex` / `role` (property or `setAttribute`), and every
|
|
56
|
+
`stopPropagation()` inside a `keydown` / `onkeydown` handler (inline, named function or const). No options, no autofix.
|
|
57
|
+
- `gameConfig` flat-config preset (`GAME_RULE_NAMES`): enables `game-menu-focusable` at `error`. Not part of
|
|
58
|
+
`recommendedConfig`; game repos opt in.
|
|
59
|
+
|
|
60
|
+
### Changed
|
|
61
|
+
|
|
62
|
+
- `testdoc-results.v1.schema.json` copy synced to Dloizides.Testing 7fbf809 (adds the optional `features` array).
|
|
63
|
+
|
|
64
|
+
## [1.5.0] - 2026-10-07
|
|
65
|
+
|
|
66
|
+
KEFI-ACT-1 "Same attendee actions everywhere" (generalized: one row-action source per entity, every portal).
|
|
67
|
+
|
|
68
|
+
### Added
|
|
69
|
+
|
|
70
|
+
- `single-row-action-source`: reports `<RowActionGroup actions>` from `@dloizides/ui-buttons` built in the same file
|
|
71
|
+
(inline array, array-bound identifier, `useMemo` returning an array, local builder function, `RowActionSpec[]`
|
|
72
|
+
annotated local). Imported builders/sets and props pass. No options, no autofix.
|
|
73
|
+
- `rowActionsConfig` and `recommendedConfig` flat-config blocks (`recommendedConfig` = comments + row actions, all `error`).
|
|
74
|
+
|
|
75
|
+
## [1.4.0] - 2026-10-07
|
|
76
|
+
|
|
77
|
+
COMMENTS-1 "No code comments; only short doc comments on public members", decision D-CMT-4 "One-line summary, no call chains".
|
|
78
|
+
|
|
79
|
+
### Changed
|
|
80
|
+
|
|
81
|
+
- `doc-comment-max-lines`: the description (lines other than `@param` / `@returns`) is capped at ONE line
|
|
82
|
+
(`summaryMaxLines`, default 1), every doc line at 120 chars (`lineMaxChars`), and a line containing an arrow
|
|
83
|
+
(U+2192 or `->`) or starting `Flow:` is reported (`callChain`). Matches `.claude/hooks/review-violations.js` docBlock().
|
|
84
|
+
The 3-line total cap is unchanged. One report per block; banned tags take precedence.
|
|
85
|
+
|
|
86
|
+
## [1.3.0] - 2026-10-06
|
|
87
|
+
|
|
88
|
+
COMMENTS-1 "No code comments; only short doc comments on public members" (decisions D-CMT-1, D-CMT-3).
|
|
89
|
+
|
|
90
|
+
### Added
|
|
91
|
+
|
|
92
|
+
- `no-comments`: reports every comment that is not a `/**` doc block and not a tool directive
|
|
93
|
+
(`eslint-*`, `@ts-*`, `prettier-ignore`, `istanbul`/`c8`, `/// <reference>`, `#__PURE__`,
|
|
94
|
+
`webpackChunkName`, shebang). `allow: string[]` adds directive regexes. Suggestion only, no autofix.
|
|
95
|
+
- `doc-comment-public-only`: a doc block must sit on an exported declaration (incl. `export { x }`,
|
|
96
|
+
`export default x`, `module.exports`, ambient `declare module`) or a public member of one;
|
|
97
|
+
`private` / `protected` / `#` members and local declarations are reported.
|
|
98
|
+
- `doc-comment-max-lines`: doc body capped at `max` (default 3) content lines; block tags other than
|
|
99
|
+
`allowedTags` (default `@param`, `@returns`) are reported. JSDoc type-annotation blocks
|
|
100
|
+
(`@type`, `@typedef`, ...) are exempt from both doc rules.
|
|
101
|
+
- `commentsConfig` flat-config block (the three rules at `error`) and `COMMENT_RULE_NAMES`, exported
|
|
102
|
+
from `/eslint`. Not adopted by any app yet: each repo opts in as step 1 of its COMMENTS-CLEAN sweep.
|
|
103
|
+
|
|
104
|
+
## [1.1.0] - 2026-07-13
|
|
105
|
+
|
|
106
|
+
Both changes come out of the ES-04 (agora-web) build, which surfaced two ways the
|
|
107
|
+
rule pack misbehaved against a freshly scaffolded app.
|
|
108
|
+
|
|
109
|
+
### Fixed
|
|
110
|
+
|
|
111
|
+
- **`no-null-check`: the autofixer no longer corrupts files.** It rewrote
|
|
112
|
+
`x === undefined` → `!isValueDefined(x)` *without importing `isValueDefined`*,
|
|
113
|
+
so `eslint --fix` emitted source referencing an undeclared global. Running
|
|
114
|
+
`lint:fix` on agora-web rewrote ~20 files and produced 67 `no-unsafe-call` /
|
|
115
|
+
`strict-boolean-expressions` errors. A fixer that produces broken code is worse
|
|
116
|
+
than no fixer — `lint:fix` is the first thing anyone runs.
|
|
117
|
+
|
|
118
|
+
The fixer now inserts `import { isValueDefined } from '@dloizides/utils';` (the
|
|
119
|
+
path is configurable via the pre-existing but previously **unused**
|
|
120
|
+
`utilImportPath` option) when the file has no binding for the guard, and skips
|
|
121
|
+
the autofix entirely in the module that defines or re-exports it. Proven with
|
|
122
|
+
`Linter.verifyAndFix` multipass tests — the actual `--fix` code path.
|
|
123
|
+
|
|
124
|
+
⚠️ The package's own test suite had *codified* the bug: it asserted the
|
|
125
|
+
import-less output was correct. Those expectations were wrong and are updated.
|
|
126
|
+
|
|
127
|
+
### Changed
|
|
128
|
+
|
|
129
|
+
- **`smart-max-lines`: `functionWarn` is now opt-in (default: off).** ESLint has
|
|
130
|
+
no per-report severity, so a `functionWarn` report is emitted at the severity
|
|
131
|
+
the *rule* is configured with. Every app configured the rule as `'error'` and
|
|
132
|
+
passed `functionWarn: 30` — which made the real, enforced limit **30 lines**
|
|
133
|
+
while the docs promised **50**. The rule lied about its own threshold.
|
|
134
|
+
|
|
135
|
+
Out of the box the only enforced thresholds are now `componentMax` (200) and
|
|
136
|
+
`functionMax` (50) — exactly what the documentation has always promised.
|
|
137
|
+
`functionWarn` remains available as an explicit *stricter second threshold*,
|
|
138
|
+
and its schema/message now say plainly that it reports at the rule's severity
|
|
139
|
+
rather than as a warning.
|
|
140
|
+
|
|
141
|
+
Migration: drop `functionWarn: 30` from your ESLint config. This only relaxes
|
|
142
|
+
linting (30 → 50), so it cannot introduce new failures.
|
|
143
|
+
|
|
144
|
+
## [1.0.0] - 2026-06-14
|
|
145
|
+
|
|
146
|
+
### Added
|
|
147
|
+
|
|
148
|
+
- Initial extraction of the shared RN-web dev tooling duplicated across
|
|
149
|
+
erevna-web, katalogos-web, and kefi-web.
|
|
150
|
+
- **ESLint custom rule pack** (17 rules) exported as `plugin` / `rules` /
|
|
151
|
+
`legacyPlugins`, also available under the `@dloizides/frontend-devtools/eslint`
|
|
152
|
+
subpath. Rule names preserved byte-for-byte so existing config keys and
|
|
153
|
+
`eslint-disable-next-line <rule>` comments keep working:
|
|
154
|
+
`enforce-function-style`, `enforce-module-structure`, `enforce-route-preload`,
|
|
155
|
+
`enforce-test-colocation`, `enum-file-isolation`, `i18n-interpolation`,
|
|
156
|
+
`i18n-param-names`, `no-barrel-companion-file`, `no-duplicate-nav-prefix`,
|
|
157
|
+
`no-duplicate-shared-patterns`, `no-generated-models-barrel-value-import`,
|
|
158
|
+
`no-null-check`, `no-optional-undefined`, `no-product-imports-in-shared`,
|
|
159
|
+
`prefer-const-enum`, `require-stable-hook-args`, `smart-max-lines`.
|
|
160
|
+
- **`initI18n(options)`** — parameterized i18next + react-i18next init factory.
|
|
161
|
+
Carries the `import/no-named-as-default-member` disable so apps stop repeating
|
|
162
|
+
it. The app owns its `locales/*.json` strings and the active language.
|
package/README.md
CHANGED
|
@@ -6,11 +6,10 @@ product-agnostic concerns that were duplicated byte-for-byte across
|
|
|
6
6
|
|
|
7
7
|
1. The **custom ESLint rule pack** (17 rules) — previously 17 identical
|
|
8
8
|
`eslint-plugins/*.mjs` files in each app.
|
|
9
|
-
2. **`initI18n()
|
|
10
|
-
|
|
9
|
+
2. **`initI18n()` moved to `@dloizides/i18n` in 2.0.0** — this package is dev-only:
|
|
10
|
+
`import { initI18n } from '@dloizides/i18n';` (same signature).
|
|
11
11
|
|
|
12
|
-
> **Decoupling:** the package owns the *logic* (rule implementations
|
|
13
|
-
> i18next `.use().init()` chain). Each app owns its *config* — which rules it
|
|
12
|
+
> **Decoupling:** the package owns the *logic* (rule implementations). Each app owns its *config* — which rules it
|
|
14
13
|
> enables and with what options, plus its own `locales/*.json` strings.
|
|
15
14
|
> This package **never imports a product**.
|
|
16
15
|
|
|
@@ -20,12 +19,12 @@ product-agnostic concerns that were duplicated byte-for-byte across
|
|
|
20
19
|
npm install -D @dloizides/frontend-devtools
|
|
21
20
|
```
|
|
22
21
|
|
|
23
|
-
`eslint
|
|
24
|
-
|
|
22
|
+
`eslint` is an optional peer dependency. There is no root entry since 2.0.0: import from
|
|
23
|
+
`@dloizides/frontend-devtools/eslint` or `@dloizides/frontend-devtools/test-results`.
|
|
25
24
|
|
|
26
25
|
## ESLint rule pack
|
|
27
26
|
|
|
28
|
-
Import from the
|
|
27
|
+
Import from the `/eslint` subpath. Three shapes are exported:
|
|
29
28
|
|
|
30
29
|
| Export | Use when |
|
|
31
30
|
| --- | --- |
|
|
@@ -136,38 +135,14 @@ by `recommendedConfig` and `rowActionsConfig`.
|
|
|
136
135
|
`ruleNames` exports the sorted list for migration assertions (prove no rule was
|
|
137
136
|
dropped).
|
|
138
137
|
|
|
139
|
-
## i18n init factory
|
|
138
|
+
## i18n init factory — moved
|
|
140
139
|
|
|
141
|
-
|
|
142
|
-
// src/localization/i18n.ts
|
|
143
|
-
import { initI18n } from '@dloizides/frontend-devtools';
|
|
144
|
-
import * as Localization from 'expo-localization';
|
|
145
|
-
import en from './locales/en.json';
|
|
146
|
-
|
|
147
|
-
const i18n = initI18n({
|
|
148
|
-
resources: { en: { translation: en } },
|
|
149
|
-
lng: Localization.getLocales()[0]?.languageCode, // optional; defaults to fallback
|
|
150
|
-
});
|
|
140
|
+
`initI18n` and `InitI18nOptions` live in `@dloizides/i18n` (>= 1.1.0) since 2.0.0:
|
|
151
141
|
|
|
152
|
-
|
|
142
|
+
```ts
|
|
143
|
+
import { initI18n } from '@dloizides/i18n';
|
|
153
144
|
```
|
|
154
145
|
|
|
155
|
-
### `InitI18nOptions`
|
|
156
|
-
|
|
157
|
-
| Field | Type | Default | Notes |
|
|
158
|
-
| --- | --- | --- | --- |
|
|
159
|
-
| `resources` | `Resource` | — (required) | App-owned strings bundle. |
|
|
160
|
-
| `lng` | `string` | `fallbackLng` | Active language. |
|
|
161
|
-
| `fallbackLng` | `string` | `'en'` | Fallback for missing keys. |
|
|
162
|
-
| `escapeValue` | `boolean` | `false` | React already escapes output. |
|
|
163
|
-
| `defaultNS` | `string \| string[]` | i18next default | Optional. |
|
|
164
|
-
| `ns` | `string \| string[]` | — | Optional; for multi-namespace apps. |
|
|
165
|
-
|
|
166
|
-
The factory wires `react-i18next` into the i18next singleton, runs `.init()`,
|
|
167
|
-
swallows the (synchronous-for-in-memory) init rejection, and returns the
|
|
168
|
-
singleton. The `FM()` / `FD()` helpers + `locales/*.json` stay **app-owned**
|
|
169
|
-
(per the SaaS code standards).
|
|
170
|
-
|
|
171
146
|
## Scripts
|
|
172
147
|
|
|
173
148
|
| Script | What |
|
package/dist/eslint/index.d.mts
CHANGED
|
@@ -74,6 +74,10 @@ declare const ruleNames: readonly string[];
|
|
|
74
74
|
*/
|
|
75
75
|
declare const legacyPlugins: Record<string, FlatConfigPlugin>;
|
|
76
76
|
|
|
77
|
+
declare const HOUSE_PATTERN_RULE_NAMES: readonly string[];
|
|
78
|
+
/** D-PAT-12 preset: four community rule packs plus the house pattern rules, every rule at warn. */
|
|
79
|
+
declare const patternPacksConfig: FlatConfig;
|
|
80
|
+
|
|
77
81
|
declare const COMMENT_RULE_NAMES: readonly string[];
|
|
78
82
|
/** Flat-config block for COMMENTS-1: no code comments, short doc comments on public members only. */
|
|
79
83
|
declare const commentsConfig: FlatConfig;
|
|
@@ -89,4 +93,4 @@ declare const apiConfig: FlatConfig;
|
|
|
89
93
|
/** The recommended flat-config block: every rule the pack enables by default, at error. */
|
|
90
94
|
declare const recommendedConfig: FlatConfig;
|
|
91
95
|
|
|
92
|
-
export { API_RULE_NAMES, COMMENT_RULE_NAMES, type CustomRule, type FlatConfig, type FlatConfigPlugin, GAME_RULE_NAMES, ROW_ACTION_RULE_NAMES, type SingleRulePlugin, apiConfig, commentsConfig, gameConfig, legacyPlugins, plugin, recommendedConfig, rowActionsConfig, ruleNames, rules };
|
|
96
|
+
export { API_RULE_NAMES, COMMENT_RULE_NAMES, type CustomRule, type FlatConfig, type FlatConfigPlugin, GAME_RULE_NAMES, HOUSE_PATTERN_RULE_NAMES, ROW_ACTION_RULE_NAMES, type SingleRulePlugin, apiConfig, commentsConfig, gameConfig, legacyPlugins, patternPacksConfig, plugin, recommendedConfig, rowActionsConfig, ruleNames, rules };
|
package/dist/eslint/index.d.ts
CHANGED
|
@@ -74,6 +74,10 @@ declare const ruleNames: readonly string[];
|
|
|
74
74
|
*/
|
|
75
75
|
declare const legacyPlugins: Record<string, FlatConfigPlugin>;
|
|
76
76
|
|
|
77
|
+
declare const HOUSE_PATTERN_RULE_NAMES: readonly string[];
|
|
78
|
+
/** D-PAT-12 preset: four community rule packs plus the house pattern rules, every rule at warn. */
|
|
79
|
+
declare const patternPacksConfig: FlatConfig;
|
|
80
|
+
|
|
77
81
|
declare const COMMENT_RULE_NAMES: readonly string[];
|
|
78
82
|
/** Flat-config block for COMMENTS-1: no code comments, short doc comments on public members only. */
|
|
79
83
|
declare const commentsConfig: FlatConfig;
|
|
@@ -89,4 +93,4 @@ declare const apiConfig: FlatConfig;
|
|
|
89
93
|
/** The recommended flat-config block: every rule the pack enables by default, at error. */
|
|
90
94
|
declare const recommendedConfig: FlatConfig;
|
|
91
95
|
|
|
92
|
-
export { API_RULE_NAMES, COMMENT_RULE_NAMES, type CustomRule, type FlatConfig, type FlatConfigPlugin, GAME_RULE_NAMES, ROW_ACTION_RULE_NAMES, type SingleRulePlugin, apiConfig, commentsConfig, gameConfig, legacyPlugins, plugin, recommendedConfig, rowActionsConfig, ruleNames, rules };
|
|
96
|
+
export { API_RULE_NAMES, COMMENT_RULE_NAMES, type CustomRule, type FlatConfig, type FlatConfigPlugin, GAME_RULE_NAMES, HOUSE_PATTERN_RULE_NAMES, ROW_ACTION_RULE_NAMES, type SingleRulePlugin, apiConfig, commentsConfig, gameConfig, legacyPlugins, patternPacksConfig, plugin, recommendedConfig, rowActionsConfig, ruleNames, rules };
|
package/dist/eslint/index.js
CHANGED
|
@@ -2,11 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
var fs = require('fs');
|
|
4
4
|
var path = require('path');
|
|
5
|
+
var tanstackQueryPlugin = require('@tanstack/eslint-plugin-query');
|
|
6
|
+
var boundariesPlugin = require('eslint-plugin-boundaries');
|
|
7
|
+
var effectPlugin = require('eslint-plugin-react-you-might-not-need-an-effect');
|
|
8
|
+
var sonarjsPlugin = require('eslint-plugin-sonarjs');
|
|
5
9
|
|
|
6
10
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
7
11
|
|
|
8
12
|
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
9
13
|
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
14
|
+
var tanstackQueryPlugin__default = /*#__PURE__*/_interopDefault(tanstackQueryPlugin);
|
|
15
|
+
var boundariesPlugin__default = /*#__PURE__*/_interopDefault(boundariesPlugin);
|
|
16
|
+
var effectPlugin__default = /*#__PURE__*/_interopDefault(effectPlugin);
|
|
17
|
+
var sonarjsPlugin__default = /*#__PURE__*/_interopDefault(sonarjsPlugin);
|
|
10
18
|
|
|
11
19
|
// src/rules/comment-utils.js
|
|
12
20
|
var DIRECTIVE_PATTERNS = [
|
|
@@ -2204,6 +2212,65 @@ var prefer_const_enum_default = {
|
|
|
2204
2212
|
}
|
|
2205
2213
|
};
|
|
2206
2214
|
|
|
2215
|
+
// src/rules/query-key-factory.js
|
|
2216
|
+
var QUERY_KEY = "queryKey";
|
|
2217
|
+
var TEST_FILE2 = /(?:\.(?:test|spec)\.[cm]?[jt]sx?$)|(?:\/__tests__\/)/;
|
|
2218
|
+
var FACTORY_FILE = /[kK]eys?(?:Factory)?\.[cm]?[jt]sx?$/;
|
|
2219
|
+
var DEFAULT_ALLOWED_PATH_FRAGMENTS2 = ["/generated/", "/autoGeneratedHooks/"];
|
|
2220
|
+
var INLINE_KEY_TYPES = /* @__PURE__ */ new Set(["ArrayExpression", "Literal", "TemplateLiteral"]);
|
|
2221
|
+
var TYPE_WRAPPERS = /* @__PURE__ */ new Set(["TSAsExpression", "TSSatisfiesExpression", "TSNonNullExpression"]);
|
|
2222
|
+
function normalisePath2(filename) {
|
|
2223
|
+
return typeof filename === "string" ? filename.split("\\").join("/") : "";
|
|
2224
|
+
}
|
|
2225
|
+
function isExemptFile2(filename, allow) {
|
|
2226
|
+
const path2 = normalisePath2(filename);
|
|
2227
|
+
if (TEST_FILE2.test(path2)) return true;
|
|
2228
|
+
if (FACTORY_FILE.test(path2)) return true;
|
|
2229
|
+
return [...DEFAULT_ALLOWED_PATH_FRAGMENTS2, ...allow].some((fragment) => path2.includes(fragment));
|
|
2230
|
+
}
|
|
2231
|
+
function unwrap2(node) {
|
|
2232
|
+
let current = node;
|
|
2233
|
+
while (current && TYPE_WRAPPERS.has(current.type)) current = current.expression;
|
|
2234
|
+
return current;
|
|
2235
|
+
}
|
|
2236
|
+
function isQueryKeyProperty(node) {
|
|
2237
|
+
if (node.computed) return false;
|
|
2238
|
+
if (node.key.type === "Identifier") return node.key.name === QUERY_KEY;
|
|
2239
|
+
return node.key.type === "Literal" && node.key.value === QUERY_KEY;
|
|
2240
|
+
}
|
|
2241
|
+
var rule4 = {
|
|
2242
|
+
meta: {
|
|
2243
|
+
type: "suggestion",
|
|
2244
|
+
docs: {
|
|
2245
|
+
description: "PAT-QUERY-KEY-1: a React Query queryKey comes from a key factory, never an inline literal."
|
|
2246
|
+
},
|
|
2247
|
+
schema: [
|
|
2248
|
+
{
|
|
2249
|
+
type: "object",
|
|
2250
|
+
properties: { allow: { type: "array", items: { type: "string" } } },
|
|
2251
|
+
additionalProperties: false
|
|
2252
|
+
}
|
|
2253
|
+
],
|
|
2254
|
+
messages: {
|
|
2255
|
+
inlineKey: "Inline queryKey literal. Build it with a key factory (e.g. clientKeys.detail(id) from clientKeys.ts) so the query and its invalidation share one key."
|
|
2256
|
+
}
|
|
2257
|
+
},
|
|
2258
|
+
create(context) {
|
|
2259
|
+
const options = context.options[0] ?? {};
|
|
2260
|
+
const allow = Array.isArray(options.allow) ? options.allow : [];
|
|
2261
|
+
const filename = context.filename ?? context.getFilename();
|
|
2262
|
+
if (isExemptFile2(filename, allow)) return {};
|
|
2263
|
+
return {
|
|
2264
|
+
Property(node) {
|
|
2265
|
+
if (!isQueryKeyProperty(node)) return;
|
|
2266
|
+
const value = unwrap2(node.value);
|
|
2267
|
+
if (value && INLINE_KEY_TYPES.has(value.type)) context.report({ node: node.value, messageId: "inlineKey" });
|
|
2268
|
+
}
|
|
2269
|
+
};
|
|
2270
|
+
}
|
|
2271
|
+
};
|
|
2272
|
+
var query_key_factory_default = { rules: { "query-key-factory": rule4 } };
|
|
2273
|
+
|
|
2207
2274
|
// src/rules/require-stable-hook-args.js
|
|
2208
2275
|
var STABLE_INIT_CALLS = /* @__PURE__ */ new Set([
|
|
2209
2276
|
"useCallback",
|
|
@@ -2887,6 +2954,7 @@ var ruleModules = [
|
|
|
2887
2954
|
no_raw_backend_fetch_default,
|
|
2888
2955
|
no_raw_color_literal_default,
|
|
2889
2956
|
prefer_const_enum_default,
|
|
2957
|
+
query_key_factory_default,
|
|
2890
2958
|
require_stable_hook_args_default,
|
|
2891
2959
|
single_row_action_source_default,
|
|
2892
2960
|
smart_max_lines_default
|
|
@@ -2894,11 +2962,11 @@ var ruleModules = [
|
|
|
2894
2962
|
function mergeRules(modules) {
|
|
2895
2963
|
const merged = {};
|
|
2896
2964
|
for (const mod of modules) {
|
|
2897
|
-
for (const [name,
|
|
2965
|
+
for (const [name, rule5] of Object.entries(mod.rules)) {
|
|
2898
2966
|
if (merged[name] !== void 0) {
|
|
2899
2967
|
throw new Error(`Duplicate ESLint rule name: "${name}"`);
|
|
2900
2968
|
}
|
|
2901
|
-
merged[name] =
|
|
2969
|
+
merged[name] = rule5;
|
|
2902
2970
|
}
|
|
2903
2971
|
}
|
|
2904
2972
|
return merged;
|
|
@@ -2914,17 +2982,58 @@ var ruleNames = Object.keys(plugin.rules).sort();
|
|
|
2914
2982
|
var legacyPlugins = buildLegacyPlugins();
|
|
2915
2983
|
function buildLegacyPlugins() {
|
|
2916
2984
|
const out = {};
|
|
2917
|
-
for (const [name,
|
|
2918
|
-
out[name] = oneRulePlugin(name,
|
|
2985
|
+
for (const [name, rule5] of Object.entries(rules)) {
|
|
2986
|
+
out[name] = oneRulePlugin(name, rule5);
|
|
2919
2987
|
}
|
|
2920
2988
|
return out;
|
|
2921
2989
|
}
|
|
2922
|
-
function oneRulePlugin(name,
|
|
2990
|
+
function oneRulePlugin(name, rule5) {
|
|
2923
2991
|
return {
|
|
2924
2992
|
meta: { name, version: "1.0.0" },
|
|
2925
|
-
rules: { [name]:
|
|
2993
|
+
rules: { [name]: rule5 }
|
|
2926
2994
|
};
|
|
2927
2995
|
}
|
|
2996
|
+
var OFF_LEVELS = ["off", 0];
|
|
2997
|
+
function pluginOf(mod) {
|
|
2998
|
+
const candidate = mod;
|
|
2999
|
+
const inner = candidate.default;
|
|
3000
|
+
return inner?.rules !== void 0 ? inner : candidate;
|
|
3001
|
+
}
|
|
3002
|
+
function rulesOf(config) {
|
|
3003
|
+
const blocks = Array.isArray(config) ? config : [config ?? {}];
|
|
3004
|
+
return Object.assign({}, ...blocks.map((block) => block.rules ?? {}));
|
|
3005
|
+
}
|
|
3006
|
+
function toWarn(entry) {
|
|
3007
|
+
const level = Array.isArray(entry) ? entry[0] : entry;
|
|
3008
|
+
if (OFF_LEVELS.includes(level)) {
|
|
3009
|
+
return entry;
|
|
3010
|
+
}
|
|
3011
|
+
return Array.isArray(entry) ? ["warn", ...entry.slice(1)] : "warn";
|
|
3012
|
+
}
|
|
3013
|
+
function warnAll(rules2) {
|
|
3014
|
+
return Object.fromEntries(Object.entries(rules2).map(([name, entry]) => [name, toWarn(entry)]));
|
|
3015
|
+
}
|
|
3016
|
+
var tanstackQuery = pluginOf(tanstackQueryPlugin__default.default);
|
|
3017
|
+
var effect = pluginOf(effectPlugin__default.default);
|
|
3018
|
+
var boundaries = pluginOf(boundariesPlugin__default.default);
|
|
3019
|
+
var sonarjs = pluginOf(sonarjsPlugin__default.default);
|
|
3020
|
+
var HOUSE_PATTERN_RULE_NAMES = ["query-key-factory"];
|
|
3021
|
+
var patternPacksConfig = {
|
|
3022
|
+
plugins: {
|
|
3023
|
+
"@tanstack/query": tanstackQuery,
|
|
3024
|
+
"react-you-might-not-need-an-effect": effect,
|
|
3025
|
+
boundaries,
|
|
3026
|
+
sonarjs,
|
|
3027
|
+
"@dloizides": plugin
|
|
3028
|
+
},
|
|
3029
|
+
rules: warnAll({
|
|
3030
|
+
...rulesOf(tanstackQuery.configs?.["flat/recommended"]),
|
|
3031
|
+
...rulesOf(effect.configs?.recommended),
|
|
3032
|
+
...rulesOf(boundaries.configs?.recommended),
|
|
3033
|
+
...rulesOf(sonarjs.configs?.recommended),
|
|
3034
|
+
"@dloizides/query-key-factory": "warn"
|
|
3035
|
+
})
|
|
3036
|
+
};
|
|
2928
3037
|
|
|
2929
3038
|
// src/eslint/configs.ts
|
|
2930
3039
|
var DOC_COMMENT_MAX_LINES = 3;
|
|
@@ -2970,11 +3079,13 @@ var recommendedConfig = {
|
|
|
2970
3079
|
exports.API_RULE_NAMES = API_RULE_NAMES;
|
|
2971
3080
|
exports.COMMENT_RULE_NAMES = COMMENT_RULE_NAMES;
|
|
2972
3081
|
exports.GAME_RULE_NAMES = GAME_RULE_NAMES;
|
|
3082
|
+
exports.HOUSE_PATTERN_RULE_NAMES = HOUSE_PATTERN_RULE_NAMES;
|
|
2973
3083
|
exports.ROW_ACTION_RULE_NAMES = ROW_ACTION_RULE_NAMES;
|
|
2974
3084
|
exports.apiConfig = apiConfig;
|
|
2975
3085
|
exports.commentsConfig = commentsConfig;
|
|
2976
3086
|
exports.gameConfig = gameConfig;
|
|
2977
3087
|
exports.legacyPlugins = legacyPlugins;
|
|
3088
|
+
exports.patternPacksConfig = patternPacksConfig;
|
|
2978
3089
|
exports.plugin = plugin;
|
|
2979
3090
|
exports.recommendedConfig = recommendedConfig;
|
|
2980
3091
|
exports.rowActionsConfig = rowActionsConfig;
|