@dloizides/frontend-devtools 2.0.0 → 2.1.1
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 +170 -162
- package/dist/eslint/index.d.mts +4 -1
- package/dist/eslint/index.d.ts +4 -1
- package/dist/eslint/index.js +121 -6
- package/dist/eslint/index.js.map +1 -1
- package/dist/eslint/index.mjs +120 -7
- package/dist/eslint/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,162 +1,170 @@
|
|
|
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.
|
|
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
|
-
|
|
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
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
`
|
|
160
|
-
|
|
161
|
-
|
|
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
|
+
## [2.1.0] - 2026-10-20
|
|
9
|
+
|
|
10
|
+
QUAL-ADOPT-1 "Fail lint/arch tests when an app re-implements an existing package" (TS half).
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- `no-reimplemented-package`: flags app code that re-implements a shared package (hand-rolled analytics/Umami -> `@dloizides/analytics-web`, `X-BFF-Csrf` header or `bffCsrf` -> `@dloizides/bff-web-client`, `forgotPasswordRequest` -> `@dloizides/auth-web`, `utils/logger` -> `@dloizides/logging-web`). Pairs live in one registry, `src/rules/reimplemented-packages-registry.js`. Tests, e2e and package sources are exempt; `allow` adds path fragments.
|
|
14
|
+
- `reuseConfig` + `REUSE_RULE_NAMES` (opt-in, not part of `recommendedConfig`).
|
|
15
|
+
|
|
16
|
+
## [2.0.0] - 2026-10-20
|
|
17
|
+
|
|
18
|
+
D-PAT-15 "Move initI18n out of frontend-devtools so it is dev-only".
|
|
19
|
+
|
|
20
|
+
### Removed (BREAKING)
|
|
21
|
+
- `initI18n` and `InitI18nOptions`: import them from `@dloizides/i18n` (>= 1.1.0), same signature: `import { initI18n } from '@dloizides/i18n';`.
|
|
22
|
+
- The root entry (`@dloizides/frontend-devtools`): it exported only `initI18n`. Use the `/eslint` and `/test-results` subpaths.
|
|
23
|
+
- The `i18next` and `react-i18next` optional peer dependencies.
|
|
24
|
+
|
|
25
|
+
## [1.10.0] - 2026-10-19
|
|
26
|
+
|
|
27
|
+
PATTERN-1.12 "TS rule packs + house rules in frontend-devtools" (D-PAT-12 "Whole rule packs as warnings, one shared approach").
|
|
28
|
+
|
|
29
|
+
### Added
|
|
30
|
+
- `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.
|
|
31
|
+
- `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.
|
|
32
|
+
- `HOUSE_PATTERN_RULE_NAMES`.
|
|
33
|
+
|
|
34
|
+
## [1.9.0] - 2026-10-19
|
|
35
|
+
|
|
36
|
+
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.
|
|
37
|
+
|
|
38
|
+
### Changed
|
|
39
|
+
- `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`).
|
|
40
|
+
- `no-raw-backend-fetch` registers no visitors when the parsed AST is not an ESTree `Program` (non-JS languages under an unscoped `apiConfig`).
|
|
41
|
+
|
|
42
|
+
### Tests
|
|
43
|
+
- `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/`.
|
|
44
|
+
|
|
45
|
+
## [1.8.0] - 2026-10-19
|
|
46
|
+
|
|
47
|
+
PATTERN-1.4 "TypeScript pattern rules as ESLint rules", row PAT-API-1 "web apps call the backend through the shared client".
|
|
48
|
+
|
|
49
|
+
### Added
|
|
50
|
+
|
|
51
|
+
- `no-raw-backend-fetch`: reports `fetch(` / `window.fetch(` / `globalThis.fetch(` / `self.fetch(` and value imports of `axios`
|
|
52
|
+
(`import`, `require`, `import()`) in `src/**`. Exempt: `src/server/`, `src/http/`, `src/lib/http/`, `packages/*-client/`,
|
|
53
|
+
`/generated/`, service worker files, `app/+html.*`, tests, `data:`/`blob:` URLs, `import type` from axios. Option `{ allow: string[] }`.
|
|
54
|
+
- `apiConfig` flat-config preset (`API_RULE_NAMES`) at `error`; included in `recommendedConfig`.
|
|
55
|
+
|
|
56
|
+
## [1.7.0] - 2026-10-19
|
|
57
|
+
|
|
58
|
+
NAV-1 "Every game menu works with arrow keys and controller", phase 3.
|
|
59
|
+
|
|
60
|
+
### Added
|
|
61
|
+
|
|
62
|
+
- `game-menu-focusable`: reports a `click` / `pointerdown` / `pointerup` listener or `onclick =` on an element created as
|
|
63
|
+
`div` / `span` / `li` / `img` whose variable never gets `tabIndex` / `role` (property or `setAttribute`), and every
|
|
64
|
+
`stopPropagation()` inside a `keydown` / `onkeydown` handler (inline, named function or const). No options, no autofix.
|
|
65
|
+
- `gameConfig` flat-config preset (`GAME_RULE_NAMES`): enables `game-menu-focusable` at `error`. Not part of
|
|
66
|
+
`recommendedConfig`; game repos opt in.
|
|
67
|
+
|
|
68
|
+
### Changed
|
|
69
|
+
|
|
70
|
+
- `testdoc-results.v1.schema.json` copy synced to Dloizides.Testing 7fbf809 (adds the optional `features` array).
|
|
71
|
+
|
|
72
|
+
## [1.5.0] - 2026-10-07
|
|
73
|
+
|
|
74
|
+
KEFI-ACT-1 "Same attendee actions everywhere" (generalized: one row-action source per entity, every portal).
|
|
75
|
+
|
|
76
|
+
### Added
|
|
77
|
+
|
|
78
|
+
- `single-row-action-source`: reports `<RowActionGroup actions>` from `@dloizides/ui-buttons` built in the same file
|
|
79
|
+
(inline array, array-bound identifier, `useMemo` returning an array, local builder function, `RowActionSpec[]`
|
|
80
|
+
annotated local). Imported builders/sets and props pass. No options, no autofix.
|
|
81
|
+
- `rowActionsConfig` and `recommendedConfig` flat-config blocks (`recommendedConfig` = comments + row actions, all `error`).
|
|
82
|
+
|
|
83
|
+
## [1.4.0] - 2026-10-07
|
|
84
|
+
|
|
85
|
+
COMMENTS-1 "No code comments; only short doc comments on public members", decision D-CMT-4 "One-line summary, no call chains".
|
|
86
|
+
|
|
87
|
+
### Changed
|
|
88
|
+
|
|
89
|
+
- `doc-comment-max-lines`: the description (lines other than `@param` / `@returns`) is capped at ONE line
|
|
90
|
+
(`summaryMaxLines`, default 1), every doc line at 120 chars (`lineMaxChars`), and a line containing an arrow
|
|
91
|
+
(U+2192 or `->`) or starting `Flow:` is reported (`callChain`). Matches `.claude/hooks/review-violations.js` docBlock().
|
|
92
|
+
The 3-line total cap is unchanged. One report per block; banned tags take precedence.
|
|
93
|
+
|
|
94
|
+
## [1.3.0] - 2026-10-06
|
|
95
|
+
|
|
96
|
+
COMMENTS-1 "No code comments; only short doc comments on public members" (decisions D-CMT-1, D-CMT-3).
|
|
97
|
+
|
|
98
|
+
### Added
|
|
99
|
+
|
|
100
|
+
- `no-comments`: reports every comment that is not a `/**` doc block and not a tool directive
|
|
101
|
+
(`eslint-*`, `@ts-*`, `prettier-ignore`, `istanbul`/`c8`, `/// <reference>`, `#__PURE__`,
|
|
102
|
+
`webpackChunkName`, shebang). `allow: string[]` adds directive regexes. Suggestion only, no autofix.
|
|
103
|
+
- `doc-comment-public-only`: a doc block must sit on an exported declaration (incl. `export { x }`,
|
|
104
|
+
`export default x`, `module.exports`, ambient `declare module`) or a public member of one;
|
|
105
|
+
`private` / `protected` / `#` members and local declarations are reported.
|
|
106
|
+
- `doc-comment-max-lines`: doc body capped at `max` (default 3) content lines; block tags other than
|
|
107
|
+
`allowedTags` (default `@param`, `@returns`) are reported. JSDoc type-annotation blocks
|
|
108
|
+
(`@type`, `@typedef`, ...) are exempt from both doc rules.
|
|
109
|
+
- `commentsConfig` flat-config block (the three rules at `error`) and `COMMENT_RULE_NAMES`, exported
|
|
110
|
+
from `/eslint`. Not adopted by any app yet: each repo opts in as step 1 of its COMMENTS-CLEAN sweep.
|
|
111
|
+
|
|
112
|
+
## [1.1.0] - 2026-07-13
|
|
113
|
+
|
|
114
|
+
Both changes come out of the ES-04 (agora-web) build, which surfaced two ways the
|
|
115
|
+
rule pack misbehaved against a freshly scaffolded app.
|
|
116
|
+
|
|
117
|
+
### Fixed
|
|
118
|
+
|
|
119
|
+
- **`no-null-check`: the autofixer no longer corrupts files.** It rewrote
|
|
120
|
+
`x === undefined` → `!isValueDefined(x)` *without importing `isValueDefined`*,
|
|
121
|
+
so `eslint --fix` emitted source referencing an undeclared global. Running
|
|
122
|
+
`lint:fix` on agora-web rewrote ~20 files and produced 67 `no-unsafe-call` /
|
|
123
|
+
`strict-boolean-expressions` errors. A fixer that produces broken code is worse
|
|
124
|
+
than no fixer — `lint:fix` is the first thing anyone runs.
|
|
125
|
+
|
|
126
|
+
The fixer now inserts `import { isValueDefined } from '@dloizides/utils';` (the
|
|
127
|
+
path is configurable via the pre-existing but previously **unused**
|
|
128
|
+
`utilImportPath` option) when the file has no binding for the guard, and skips
|
|
129
|
+
the autofix entirely in the module that defines or re-exports it. Proven with
|
|
130
|
+
`Linter.verifyAndFix` multipass tests — the actual `--fix` code path.
|
|
131
|
+
|
|
132
|
+
⚠️ The package's own test suite had *codified* the bug: it asserted the
|
|
133
|
+
import-less output was correct. Those expectations were wrong and are updated.
|
|
134
|
+
|
|
135
|
+
### Changed
|
|
136
|
+
|
|
137
|
+
- **`smart-max-lines`: `functionWarn` is now opt-in (default: off).** ESLint has
|
|
138
|
+
no per-report severity, so a `functionWarn` report is emitted at the severity
|
|
139
|
+
the *rule* is configured with. Every app configured the rule as `'error'` and
|
|
140
|
+
passed `functionWarn: 30` — which made the real, enforced limit **30 lines**
|
|
141
|
+
while the docs promised **50**. The rule lied about its own threshold.
|
|
142
|
+
|
|
143
|
+
Out of the box the only enforced thresholds are now `componentMax` (200) and
|
|
144
|
+
`functionMax` (50) — exactly what the documentation has always promised.
|
|
145
|
+
`functionWarn` remains available as an explicit *stricter second threshold*,
|
|
146
|
+
and its schema/message now say plainly that it reports at the rule's severity
|
|
147
|
+
rather than as a warning.
|
|
148
|
+
|
|
149
|
+
Migration: drop `functionWarn: 30` from your ESLint config. This only relaxes
|
|
150
|
+
linting (30 → 50), so it cannot introduce new failures.
|
|
151
|
+
|
|
152
|
+
## [1.0.0] - 2026-06-14
|
|
153
|
+
|
|
154
|
+
### Added
|
|
155
|
+
|
|
156
|
+
- Initial extraction of the shared RN-web dev tooling duplicated across
|
|
157
|
+
erevna-web, katalogos-web, and kefi-web.
|
|
158
|
+
- **ESLint custom rule pack** (17 rules) exported as `plugin` / `rules` /
|
|
159
|
+
`legacyPlugins`, also available under the `@dloizides/frontend-devtools/eslint`
|
|
160
|
+
subpath. Rule names preserved byte-for-byte so existing config keys and
|
|
161
|
+
`eslint-disable-next-line <rule>` comments keep working:
|
|
162
|
+
`enforce-function-style`, `enforce-module-structure`, `enforce-route-preload`,
|
|
163
|
+
`enforce-test-colocation`, `enum-file-isolation`, `i18n-interpolation`,
|
|
164
|
+
`i18n-param-names`, `no-barrel-companion-file`, `no-duplicate-nav-prefix`,
|
|
165
|
+
`no-duplicate-shared-patterns`, `no-generated-models-barrel-value-import`,
|
|
166
|
+
`no-null-check`, `no-optional-undefined`, `no-product-imports-in-shared`,
|
|
167
|
+
`prefer-const-enum`, `require-stable-hook-args`, `smart-max-lines`.
|
|
168
|
+
- **`initI18n(options)`** — parameterized i18next + react-i18next init factory.
|
|
169
|
+
Carries the `import/no-named-as-default-member` disable so apps stop repeating
|
|
170
|
+
it. The app owns its `locales/*.json` strings and the active language.
|
package/dist/eslint/index.d.mts
CHANGED
|
@@ -90,7 +90,10 @@ declare const gameConfig: FlatConfig;
|
|
|
90
90
|
declare const API_RULE_NAMES: readonly string[];
|
|
91
91
|
/** PAT-API-1: the backend is called through the shared client or generated hooks, never raw fetch/axios. */
|
|
92
92
|
declare const apiConfig: FlatConfig;
|
|
93
|
+
declare const REUSE_RULE_NAMES: readonly string[];
|
|
94
|
+
/** QUAL-ADOPT-1: app code may not re-implement a capability a shared @dloizides package provides. Opt-in. */
|
|
95
|
+
declare const reuseConfig: FlatConfig;
|
|
93
96
|
/** The recommended flat-config block: every rule the pack enables by default, at error. */
|
|
94
97
|
declare const recommendedConfig: FlatConfig;
|
|
95
98
|
|
|
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 };
|
|
99
|
+
export { API_RULE_NAMES, COMMENT_RULE_NAMES, type CustomRule, type FlatConfig, type FlatConfigPlugin, GAME_RULE_NAMES, HOUSE_PATTERN_RULE_NAMES, REUSE_RULE_NAMES, ROW_ACTION_RULE_NAMES, type SingleRulePlugin, apiConfig, commentsConfig, gameConfig, legacyPlugins, patternPacksConfig, plugin, recommendedConfig, reuseConfig, rowActionsConfig, ruleNames, rules };
|
package/dist/eslint/index.d.ts
CHANGED
|
@@ -90,7 +90,10 @@ declare const gameConfig: FlatConfig;
|
|
|
90
90
|
declare const API_RULE_NAMES: readonly string[];
|
|
91
91
|
/** PAT-API-1: the backend is called through the shared client or generated hooks, never raw fetch/axios. */
|
|
92
92
|
declare const apiConfig: FlatConfig;
|
|
93
|
+
declare const REUSE_RULE_NAMES: readonly string[];
|
|
94
|
+
/** QUAL-ADOPT-1: app code may not re-implement a capability a shared @dloizides package provides. Opt-in. */
|
|
95
|
+
declare const reuseConfig: FlatConfig;
|
|
93
96
|
/** The recommended flat-config block: every rule the pack enables by default, at error. */
|
|
94
97
|
declare const recommendedConfig: FlatConfig;
|
|
95
98
|
|
|
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 };
|
|
99
|
+
export { API_RULE_NAMES, COMMENT_RULE_NAMES, type CustomRule, type FlatConfig, type FlatConfigPlugin, GAME_RULE_NAMES, HOUSE_PATTERN_RULE_NAMES, REUSE_RULE_NAMES, ROW_ACTION_RULE_NAMES, type SingleRulePlugin, apiConfig, commentsConfig, gameConfig, legacyPlugins, patternPacksConfig, plugin, recommendedConfig, reuseConfig, rowActionsConfig, ruleNames, rules };
|
package/dist/eslint/index.js
CHANGED
|
@@ -2143,6 +2143,111 @@ var no_raw_color_literal_default = {
|
|
|
2143
2143
|
}
|
|
2144
2144
|
};
|
|
2145
2145
|
|
|
2146
|
+
// src/rules/reimplemented-packages-registry.js
|
|
2147
|
+
var REIMPLEMENTED_PACKAGE_REGISTRY = [
|
|
2148
|
+
{
|
|
2149
|
+
id: "analytics",
|
|
2150
|
+
package: "@dloizides/analytics-web",
|
|
2151
|
+
use: "createAnalytics, track, createWebVitals",
|
|
2152
|
+
paths: [/\/src\/lib\/analytics\//, /\/UmamiClient\.[cm]?[jt]sx?$/, /\/MultiProviderClient\.[cm]?[jt]sx?$/, /\/useWebVitalsTracking\.[cm]?[jt]sx?$/],
|
|
2153
|
+
literals: []
|
|
2154
|
+
},
|
|
2155
|
+
{
|
|
2156
|
+
id: "bff-csrf",
|
|
2157
|
+
package: "@dloizides/bff-web-client",
|
|
2158
|
+
use: "createBffAxiosClient (default CSRF interceptor)",
|
|
2159
|
+
paths: [/\/bffCsrf\.[cm]?[jt]sx?$/],
|
|
2160
|
+
literals: [/^X-BFF-Csrf$/i]
|
|
2161
|
+
},
|
|
2162
|
+
{
|
|
2163
|
+
id: "forgot-password",
|
|
2164
|
+
package: "@dloizides/auth-web",
|
|
2165
|
+
use: "useBffForgotPassword, ForgotPasswordForm",
|
|
2166
|
+
paths: [/\/forgotPasswordRequest\.[cm]?[jt]sx?$/],
|
|
2167
|
+
literals: []
|
|
2168
|
+
},
|
|
2169
|
+
{
|
|
2170
|
+
id: "logger",
|
|
2171
|
+
package: "@dloizides/logging-web",
|
|
2172
|
+
use: "logger, LoggingService",
|
|
2173
|
+
paths: [/\/src\/(?:lib\/)?utils\/logger\.[cm]?[jt]sx?$/],
|
|
2174
|
+
literals: []
|
|
2175
|
+
}
|
|
2176
|
+
];
|
|
2177
|
+
|
|
2178
|
+
// src/rules/no-reimplemented-package.js
|
|
2179
|
+
var TEST_FILE2 = /(?:\.(?:test|spec)\.[cm]?[jt]sx?$)|(?:\/__tests__\/)|(?:\/e2e\/)/;
|
|
2180
|
+
var SHARED_SOURCE = /\/(?:NpmPackages\/packages|node_modules)\//;
|
|
2181
|
+
function normalisePath2(filename) {
|
|
2182
|
+
return typeof filename === "string" ? filename.split("\\").join("/") : "";
|
|
2183
|
+
}
|
|
2184
|
+
function isExemptFile2(path2, allow) {
|
|
2185
|
+
if (!path2.includes("/src/")) return true;
|
|
2186
|
+
if (TEST_FILE2.test(path2) || SHARED_SOURCE.test(path2)) return true;
|
|
2187
|
+
return allow.some((fragment) => path2.includes(fragment));
|
|
2188
|
+
}
|
|
2189
|
+
var MODULE_DECLARATIONS = /* @__PURE__ */ new Set(["ImportDeclaration", "ExportNamedDeclaration", "ExportAllDeclaration"]);
|
|
2190
|
+
function usesPackage(program, packageName) {
|
|
2191
|
+
return program.body.some((statement) => {
|
|
2192
|
+
if (!MODULE_DECLARATIONS.has(statement.type) || statement.source == null) return false;
|
|
2193
|
+
const source = statement.source.value;
|
|
2194
|
+
return source === packageName || typeof source === "string" && source.startsWith(`${packageName}/`);
|
|
2195
|
+
});
|
|
2196
|
+
}
|
|
2197
|
+
function literalText(node) {
|
|
2198
|
+
if (node.type === "Literal") return typeof node.value === "string" ? node.value : "";
|
|
2199
|
+
return node.quasis.length === 1 ? node.quasis[0].value.cooked ?? "" : "";
|
|
2200
|
+
}
|
|
2201
|
+
var noReimplementedPackageRule = {
|
|
2202
|
+
meta: {
|
|
2203
|
+
type: "problem",
|
|
2204
|
+
docs: {
|
|
2205
|
+
description: "Flag app code that re-implements a capability a shared @dloizides package already provides.",
|
|
2206
|
+
recommended: false
|
|
2207
|
+
},
|
|
2208
|
+
schema: [
|
|
2209
|
+
{
|
|
2210
|
+
type: "object",
|
|
2211
|
+
properties: { allow: { type: "array", items: { type: "string" } } },
|
|
2212
|
+
additionalProperties: false
|
|
2213
|
+
}
|
|
2214
|
+
],
|
|
2215
|
+
messages: {
|
|
2216
|
+
reimplemented: "This re-implements {{package}} ({{id}}). Use {{use}} from {{package}} instead (QUAL-ADOPT-1)."
|
|
2217
|
+
}
|
|
2218
|
+
},
|
|
2219
|
+
create(context) {
|
|
2220
|
+
const options = context.options[0] ?? {};
|
|
2221
|
+
const path2 = normalisePath2(context.filename ?? context.getFilename());
|
|
2222
|
+
if (isExemptFile2(path2, options.allow ?? [])) return {};
|
|
2223
|
+
const reported = /* @__PURE__ */ new Set();
|
|
2224
|
+
const report = (node, entry) => {
|
|
2225
|
+
if (reported.has(entry.id)) return;
|
|
2226
|
+
reported.add(entry.id);
|
|
2227
|
+
context.report({ node, messageId: "reimplemented", data: { id: entry.id, package: entry.package, use: entry.use } });
|
|
2228
|
+
};
|
|
2229
|
+
const checkLiteral = (node) => {
|
|
2230
|
+
const text = literalText(node);
|
|
2231
|
+
if (text === "") return;
|
|
2232
|
+
for (const entry of REIMPLEMENTED_PACKAGE_REGISTRY)
|
|
2233
|
+
if (entry.literals.some((pattern) => pattern.test(text))) report(node, entry);
|
|
2234
|
+
};
|
|
2235
|
+
return {
|
|
2236
|
+
Program(node) {
|
|
2237
|
+
for (const entry of REIMPLEMENTED_PACKAGE_REGISTRY)
|
|
2238
|
+
if (entry.paths.some((pattern) => pattern.test(path2)) && !usesPackage(node, entry.package)) report(node, entry);
|
|
2239
|
+
},
|
|
2240
|
+
Literal: checkLiteral,
|
|
2241
|
+
TemplateLiteral: checkLiteral
|
|
2242
|
+
};
|
|
2243
|
+
}
|
|
2244
|
+
};
|
|
2245
|
+
var no_reimplemented_package_default = {
|
|
2246
|
+
rules: {
|
|
2247
|
+
"no-reimplemented-package": noReimplementedPackageRule
|
|
2248
|
+
}
|
|
2249
|
+
};
|
|
2250
|
+
|
|
2146
2251
|
// src/rules/prefer-const-enum.js
|
|
2147
2252
|
function toPascalCase(value) {
|
|
2148
2253
|
const words = value.replace(/([a-z])([A-Z])/g, "$1 $2").split(/[-_\s]+/).filter((w) => w.length > 0);
|
|
@@ -2214,17 +2319,17 @@ var prefer_const_enum_default = {
|
|
|
2214
2319
|
|
|
2215
2320
|
// src/rules/query-key-factory.js
|
|
2216
2321
|
var QUERY_KEY = "queryKey";
|
|
2217
|
-
var
|
|
2322
|
+
var TEST_FILE3 = /(?:\.(?:test|spec)\.[cm]?[jt]sx?$)|(?:\/__tests__\/)/;
|
|
2218
2323
|
var FACTORY_FILE = /[kK]eys?(?:Factory)?\.[cm]?[jt]sx?$/;
|
|
2219
2324
|
var DEFAULT_ALLOWED_PATH_FRAGMENTS2 = ["/generated/", "/autoGeneratedHooks/"];
|
|
2220
2325
|
var INLINE_KEY_TYPES = /* @__PURE__ */ new Set(["ArrayExpression", "Literal", "TemplateLiteral"]);
|
|
2221
2326
|
var TYPE_WRAPPERS = /* @__PURE__ */ new Set(["TSAsExpression", "TSSatisfiesExpression", "TSNonNullExpression"]);
|
|
2222
|
-
function
|
|
2327
|
+
function normalisePath3(filename) {
|
|
2223
2328
|
return typeof filename === "string" ? filename.split("\\").join("/") : "";
|
|
2224
2329
|
}
|
|
2225
|
-
function
|
|
2226
|
-
const path2 =
|
|
2227
|
-
if (
|
|
2330
|
+
function isExemptFile3(filename, allow) {
|
|
2331
|
+
const path2 = normalisePath3(filename);
|
|
2332
|
+
if (TEST_FILE3.test(path2)) return true;
|
|
2228
2333
|
if (FACTORY_FILE.test(path2)) return true;
|
|
2229
2334
|
return [...DEFAULT_ALLOWED_PATH_FRAGMENTS2, ...allow].some((fragment) => path2.includes(fragment));
|
|
2230
2335
|
}
|
|
@@ -2259,7 +2364,7 @@ var rule4 = {
|
|
|
2259
2364
|
const options = context.options[0] ?? {};
|
|
2260
2365
|
const allow = Array.isArray(options.allow) ? options.allow : [];
|
|
2261
2366
|
const filename = context.filename ?? context.getFilename();
|
|
2262
|
-
if (
|
|
2367
|
+
if (isExemptFile3(filename, allow)) return {};
|
|
2263
2368
|
return {
|
|
2264
2369
|
Property(node) {
|
|
2265
2370
|
if (!isQueryKeyProperty(node)) return;
|
|
@@ -2953,6 +3058,7 @@ var ruleModules = [
|
|
|
2953
3058
|
no_product_imports_in_shared_default,
|
|
2954
3059
|
no_raw_backend_fetch_default,
|
|
2955
3060
|
no_raw_color_literal_default,
|
|
3061
|
+
no_reimplemented_package_default,
|
|
2956
3062
|
prefer_const_enum_default,
|
|
2957
3063
|
query_key_factory_default,
|
|
2958
3064
|
require_stable_hook_args_default,
|
|
@@ -3071,6 +3177,13 @@ var apiConfig = {
|
|
|
3071
3177
|
"@dloizides/no-raw-backend-fetch": "error"
|
|
3072
3178
|
}
|
|
3073
3179
|
};
|
|
3180
|
+
var REUSE_RULE_NAMES = ["no-reimplemented-package"];
|
|
3181
|
+
var reuseConfig = {
|
|
3182
|
+
plugins: commentsConfig.plugins,
|
|
3183
|
+
rules: {
|
|
3184
|
+
"@dloizides/no-reimplemented-package": "error"
|
|
3185
|
+
}
|
|
3186
|
+
};
|
|
3074
3187
|
var recommendedConfig = {
|
|
3075
3188
|
plugins: commentsConfig.plugins,
|
|
3076
3189
|
rules: { ...commentsConfig.rules, ...rowActionsConfig.rules, ...apiConfig.rules }
|
|
@@ -3080,6 +3193,7 @@ exports.API_RULE_NAMES = API_RULE_NAMES;
|
|
|
3080
3193
|
exports.COMMENT_RULE_NAMES = COMMENT_RULE_NAMES;
|
|
3081
3194
|
exports.GAME_RULE_NAMES = GAME_RULE_NAMES;
|
|
3082
3195
|
exports.HOUSE_PATTERN_RULE_NAMES = HOUSE_PATTERN_RULE_NAMES;
|
|
3196
|
+
exports.REUSE_RULE_NAMES = REUSE_RULE_NAMES;
|
|
3083
3197
|
exports.ROW_ACTION_RULE_NAMES = ROW_ACTION_RULE_NAMES;
|
|
3084
3198
|
exports.apiConfig = apiConfig;
|
|
3085
3199
|
exports.commentsConfig = commentsConfig;
|
|
@@ -3088,6 +3202,7 @@ exports.legacyPlugins = legacyPlugins;
|
|
|
3088
3202
|
exports.patternPacksConfig = patternPacksConfig;
|
|
3089
3203
|
exports.plugin = plugin;
|
|
3090
3204
|
exports.recommendedConfig = recommendedConfig;
|
|
3205
|
+
exports.reuseConfig = reuseConfig;
|
|
3091
3206
|
exports.rowActionsConfig = rowActionsConfig;
|
|
3092
3207
|
exports.ruleNames = ruleNames;
|
|
3093
3208
|
exports.rules = rules;
|