@venizia/dev-configs 0.5.0-8 → 0.5.0-9

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 (165) hide show
  1. package/README.md +15 -11
  2. package/dist/checks/purity/manifest.js +11 -3
  3. package/dist/checks/purity/manifest.js.map +1 -1
  4. package/dist/checks/purity/probe.js +19 -2
  5. package/dist/checks/purity/probe.js.map +1 -1
  6. package/dist/checks/split-report.js +2 -1
  7. package/dist/checks/split-report.js.map +1 -1
  8. package/dist/checks/test-controls.d.ts +9 -1
  9. package/dist/checks/test-controls.js +9 -3
  10. package/dist/checks/test-controls.js.map +1 -1
  11. package/dist/checks/test-dead-code.d.ts +9 -1
  12. package/dist/checks/test-dead-code.js +13 -2
  13. package/dist/checks/test-dead-code.js.map +1 -1
  14. package/dist/checks/test-mutate.d.ts +9 -1
  15. package/dist/checks/test-mutate.js +12 -6
  16. package/dist/checks/test-mutate.js.map +1 -1
  17. package/dist/cli/check.d.ts +0 -1
  18. package/dist/cli/check.js +41 -67
  19. package/dist/cli/check.js.map +1 -1
  20. package/dist/cli/clean.js +3 -2
  21. package/dist/cli/clean.js.map +1 -1
  22. package/dist/cli/codemod/any-aliases.js +13 -12
  23. package/dist/cli/codemod/any-aliases.js.map +1 -1
  24. package/dist/cli/codemod/async-style.d.ts +1 -1
  25. package/dist/cli/codemod/async-style.js +17 -16
  26. package/dist/cli/codemod/async-style.js.map +1 -1
  27. package/dist/cli/codemod/binding-keys.js +14 -13
  28. package/dist/cli/codemod/binding-keys.js.map +1 -1
  29. package/dist/cli/codemod/class-renames.d.ts +1 -1
  30. package/dist/cli/codemod/class-renames.js +30 -11
  31. package/dist/cli/codemod/class-renames.js.map +1 -1
  32. package/dist/cli/codemod/connector-imports.js +12 -11
  33. package/dist/cli/codemod/connector-imports.js.map +1 -1
  34. package/dist/cli/codemod/const-classes.d.ts +1 -1
  35. package/dist/cli/codemod/const-classes.js +21 -20
  36. package/dist/cli/codemod/const-classes.js.map +1 -1
  37. package/dist/cli/codemod/drop-redundant-casts.d.ts +6 -1
  38. package/dist/cli/codemod/drop-redundant-casts.js +27 -19
  39. package/dist/cli/codemod/drop-redundant-casts.js.map +1 -1
  40. package/dist/cli/codemod/env-get.d.ts +3 -3
  41. package/dist/cli/codemod/env-get.js +18 -17
  42. package/dist/cli/codemod/env-get.js.map +1 -1
  43. package/dist/cli/codemod/files.js +2 -2
  44. package/dist/cli/codemod/files.js.map +1 -1
  45. package/dist/cli/codemod/function-to-arrow.d.ts +76 -0
  46. package/dist/cli/codemod/function-to-arrow.js +357 -0
  47. package/dist/cli/codemod/function-to-arrow.js.map +1 -0
  48. package/dist/cli/codemod/index.js +19 -4
  49. package/dist/cli/codemod/index.js.map +1 -1
  50. package/dist/cli/codemod/namespace-functions/index.js +13 -12
  51. package/dist/cli/codemod/namespace-functions/index.js.map +1 -1
  52. package/dist/cli/codemod/typed-route-context.d.ts +27 -0
  53. package/dist/cli/codemod/typed-route-context.js +570 -0
  54. package/dist/cli/codemod/typed-route-context.js.map +1 -0
  55. package/dist/cli/index.js +5 -5
  56. package/dist/cli/index.js.map +1 -1
  57. package/dist/common/cli-output.d.ts +16 -0
  58. package/dist/common/cli-output.js +49 -0
  59. package/dist/common/cli-output.js.map +1 -0
  60. package/dist/compilers/bun.js +1 -1
  61. package/dist/compilers/bun.js.map +1 -1
  62. package/dist/linters/eslint.js +1 -1
  63. package/dist/linters/eslint.js.map +1 -1
  64. package/dist/linters/house/browser-api-patterns.d.ts +1 -3
  65. package/dist/linters/house/browser-api-patterns.js +1 -3
  66. package/dist/linters/house/browser-api-patterns.js.map +1 -1
  67. package/dist/linters/house/common.d.ts +8 -2
  68. package/dist/linters/house/common.js +8 -2
  69. package/dist/linters/house/common.js.map +1 -1
  70. package/dist/linters/house/configs.js +8 -6
  71. package/dist/linters/house/configs.js.map +1 -1
  72. package/dist/linters/house/const-class-values.rule.d.ts +2 -2
  73. package/dist/linters/house/const-class-values.rule.js +14 -5
  74. package/dist/linters/house/const-class-values.rule.js.map +1 -1
  75. package/dist/linters/house/effect-cleanup-consistency.rule.d.ts +2 -2
  76. package/dist/linters/house/effect-cleanup-consistency.rule.js +1 -1
  77. package/dist/linters/house/effect-cleanup-consistency.rule.js.map +1 -1
  78. package/dist/linters/house/framework-api-patterns.d.ts +54 -0
  79. package/dist/linters/house/framework-api-patterns.js +62 -0
  80. package/dist/linters/house/framework-api-patterns.js.map +1 -0
  81. package/dist/linters/house/framework-exports.js +3 -3
  82. package/dist/linters/house/framework-exports.js.map +1 -1
  83. package/dist/linters/house/index.d.ts +3 -4
  84. package/dist/linters/house/index.js +4 -6
  85. package/dist/linters/house/index.js.map +1 -1
  86. package/dist/linters/house/max-params-own.rule.d.ts +2 -2
  87. package/dist/linters/house/max-params-own.rule.js +1 -1
  88. package/dist/linters/house/max-params-own.rule.js.map +1 -1
  89. package/dist/linters/house/no-async-hook-callback.rule.d.ts +2 -2
  90. package/dist/linters/house/no-async-hook-callback.rule.js +1 -1
  91. package/dist/linters/house/no-async-hook-callback.rule.js.map +1 -1
  92. package/dist/linters/house/no-await-new-chain.rule.d.ts +2 -2
  93. package/dist/linters/house/no-await-new-chain.rule.js +1 -1
  94. package/dist/linters/house/no-await-new-chain.rule.js.map +1 -1
  95. package/dist/linters/house/no-await-promise-chain.rule.d.ts +2 -2
  96. package/dist/linters/house/no-await-promise-chain.rule.js +1 -1
  97. package/dist/linters/house/no-await-promise-chain.rule.js.map +1 -1
  98. package/dist/linters/house/no-inline-await.rule.d.ts +2 -2
  99. package/dist/linters/house/no-inline-await.rule.js +1 -1
  100. package/dist/linters/house/no-inline-await.rule.js.map +1 -1
  101. package/dist/linters/house/no-leaked-render.rule.d.ts +2 -2
  102. package/dist/linters/house/no-leaked-render.rule.js +1 -1
  103. package/dist/linters/house/no-leaked-render.rule.js.map +1 -1
  104. package/dist/linters/house/no-new-error.rule.d.ts +2 -2
  105. package/dist/linters/house/no-new-error.rule.js +2 -2
  106. package/dist/linters/house/no-new-error.rule.js.map +1 -1
  107. package/dist/linters/house/no-parent-import.rule.d.ts +5 -2
  108. package/dist/linters/house/no-parent-import.rule.js +5 -2
  109. package/dist/linters/house/no-parent-import.rule.js.map +1 -1
  110. package/dist/linters/house/no-return-await.rule.d.ts +2 -2
  111. package/dist/linters/house/no-return-await.rule.js +1 -1
  112. package/dist/linters/house/no-return-await.rule.js.map +1 -1
  113. package/dist/linters/house/no-shadow-framework-type.rule.d.ts +2 -2
  114. package/dist/linters/house/no-shadow-framework-type.rule.js +2 -2
  115. package/dist/linters/house/no-shadow-framework-type.rule.js.map +1 -1
  116. package/dist/linters/house/no-silent-catch.rule.d.ts +2 -2
  117. package/dist/linters/house/no-silent-catch.rule.js +3 -3
  118. package/dist/linters/house/no-silent-catch.rule.js.map +1 -1
  119. package/dist/linters/house/no-unbraced-case.rule.d.ts +2 -2
  120. package/dist/linters/house/no-unbraced-case.rule.js +1 -1
  121. package/dist/linters/house/no-unbraced-case.rule.js.map +1 -1
  122. package/dist/linters/house/plugin.d.ts +1 -1
  123. package/dist/linters/house/plugin.js +6 -5
  124. package/dist/linters/house/plugin.js.map +1 -1
  125. package/dist/linters/house/prefer-framework-api.rule.d.ts +39 -7
  126. package/dist/linters/house/prefer-framework-api.rule.js +285 -12
  127. package/dist/linters/house/prefer-framework-api.rule.js.map +1 -1
  128. package/dist/linters/house/prefer-promise-sleep.rule.d.ts +2 -2
  129. package/dist/linters/house/prefer-promise-sleep.rule.js +3 -2
  130. package/dist/linters/house/prefer-promise-sleep.rule.js.map +1 -1
  131. package/dist/linters/house/prefer-tnullable.rule.d.ts +2 -2
  132. package/dist/linters/house/prefer-tnullable.rule.js +2 -2
  133. package/dist/linters/house/prefer-tnullable.rule.js.map +1 -1
  134. package/dist/linters/house/typed-route-context.rule.d.ts +19 -0
  135. package/dist/linters/house/typed-route-context.rule.js +322 -0
  136. package/dist/linters/house/typed-route-context.rule.js.map +1 -0
  137. package/dist/linters/house/zod-schema-convention.rule.d.ts +82 -0
  138. package/dist/linters/house/zod-schema-convention.rule.js +477 -0
  139. package/dist/linters/house/zod-schema-convention.rule.js.map +1 -0
  140. package/dist/linters/oxlint.js +11 -1
  141. package/dist/linters/oxlint.js.map +1 -1
  142. package/dist/linters/react-eslint.js.map +1 -1
  143. package/dist/linters/rules/naming-convention.rule.d.ts +4 -1
  144. package/dist/linters/rules/naming-convention.rule.js +30 -1
  145. package/dist/linters/rules/naming-convention.rule.js.map +1 -1
  146. package/dist/linters/rules/no-restricted-properties.rule.js +1 -1
  147. package/dist/linters/rules/no-restricted-properties.rule.js.map +1 -1
  148. package/dist/testing/spawn.utility.js +1 -1
  149. package/dist/testing/spawn.utility.js.map +1 -1
  150. package/package.json +5 -5
  151. package/dist/checks/use-when-baseline.d.ts +0 -25
  152. package/dist/checks/use-when-baseline.js +0 -38
  153. package/dist/checks/use-when-baseline.js.map +0 -1
  154. package/dist/linters/house/framework-rule-apis.d.ts +0 -24
  155. package/dist/linters/house/framework-rule-apis.js +0 -48
  156. package/dist/linters/house/framework-rule-apis.js.map +0 -1
  157. package/dist/linters/house/public-surface.d.ts +0 -57
  158. package/dist/linters/house/public-surface.js +0 -174
  159. package/dist/linters/house/public-surface.js.map +0 -1
  160. package/dist/linters/house/published-package-configs.d.ts +0 -23
  161. package/dist/linters/house/published-package-configs.js +0 -42
  162. package/dist/linters/house/published-package-configs.js.map +0 -1
  163. package/dist/linters/house/require-use-when.rule.d.ts +0 -42
  164. package/dist/linters/house/require-use-when.rule.js +0 -175
  165. package/dist/linters/house/require-use-when.rule.js.map +0 -1
@@ -1,25 +1,29 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PreferFrameworkApiRule = void 0;
4
+ const node_path_1 = require("node:path");
4
5
  const browser_api_patterns_1 = require("./browser-api-patterns");
5
6
  const common_1 = require("./common");
7
+ const framework_api_patterns_1 = require("./framework-api-patterns");
8
+ const framework_exports_1 = require("./framework-exports");
6
9
  /** The objects a global event listener is added to. */
7
10
  const GLOBAL_TARGETS = ['window', 'document', 'self', 'globalThis'];
8
11
  /** The names that stand for the global object. */
9
12
  const GLOBAL_OBJECTS = ['window', 'globalThis', 'self'];
10
13
  /**
11
- * `venizia/prefer-framework-api`. A browser API that `@venizia/ardor-react` wraps in a hook (`window.matchMedia`, a
14
+ * `@venizia/prefer-framework-api`. A browser API that `@venizia/ardor-react` wraps in a hook (`window.matchMedia`, a
12
15
  * `ResizeObserver`, `navigator.onLine`, a `beforeunload` listener, `navigator.clipboard.writeText`, `window.confirm`...) is
13
16
  * used through the hook, which owns the subscribe and cleanup. The rows are `BrowserApiPatterns.TABLE`; the message names
14
- * the hook. The rule is for apps: ardor-react's own source, where the hooks are written, turns it off.
17
+ * the hook. The rule is for apps: the package that ships the hooks (the nearest `package.json` is named
18
+ * `@venizia/ardor-react`) is not reported.
15
19
  *
16
- * Only a reference to the global is reported: a `window`, `navigator` or `document` the file binds itself is not. And only
20
+ * The rows of `FrameworkApiPatterns.TABLE` and of the `extra` option are not about React: they report anywhere in a file,
21
+ * with their own message, in a package their `dependsOn` and `owner` allow.
22
+ *
23
+ * For the hook rows, only a reference to the global is reported: a `window`, `navigator` or `document` the file binds itself is not. And only
17
24
  * where a hook can be called: in a component (a PascalCase function that draws JSX) or a hook (`useX`), see `isInReact`. A
18
25
  * module function, a class and an event handler making a one-off call are left alone. Hooks the author wants to bypass on
19
26
  * purpose take an `eslint-disable-next-line` with the reason, or `ignore` lists pattern ids.
20
- *
21
- * @useWhen a React app should reach the browser (media queries, sizes, observers, online status, visibility, unload, clipboard, confirm) through the ardor-react hooks
22
- * @insteadOf window.matchMedia, new ResizeObserver, navigator.onLine and the other browser APIs written by hand
23
27
  */
24
28
  class PreferFrameworkApiRule {
25
29
  static { this.NAME = `${common_1.HOUSE_PLUGIN_NAMESPACE}/prefer-framework-api`; }
@@ -160,25 +164,271 @@ class PreferFrameworkApiRule {
160
164
  }
161
165
  return false;
162
166
  }
167
+ /** The rows that apply in a file of this package: the table and `extra`, less the ignored ones. */
168
+ static rowsFor(opts) {
169
+ const { manifest, extra, ignore } = opts;
170
+ return [...framework_api_patterns_1.FrameworkApiPatterns.TABLE, ...extra].filter((row) => {
171
+ const { id, dependsOn, owner } = row;
172
+ if (ignore.has(id) || (owner !== undefined && manifest?.name === owner)) {
173
+ return false;
174
+ }
175
+ return (dependsOn === undefined ||
176
+ (manifest?.dependencies.some((entry) => entry.startsWith(dependsOn)) ?? false));
177
+ });
178
+ }
179
+ /** The listeners the rows outside React need, by node type or selector. */
180
+ static rowListeners(opts) {
181
+ const { context, rows } = opts;
182
+ const listeners = [];
183
+ for (const { match, message } of rows) {
184
+ const report = (node) => {
185
+ context.report({ node, message });
186
+ };
187
+ /** Reports a global written as a member path, when `accepts` takes it. */
188
+ const onPath = (given) => {
189
+ listeners.push([
190
+ common_1.AstNodeTypes.MEMBER_EXPRESSION,
191
+ (node) => {
192
+ const path = PreferFrameworkApiRule.pathOf({
193
+ node: given.key === '' ? node : common_1.AstNode.readField({ node, key: given.key }),
194
+ });
195
+ if (path !== undefined &&
196
+ !(given.isReadOnly === true && PreferFrameworkApiRule.isWritten({ node })) &&
197
+ (given.property === undefined ||
198
+ given.property.test(PreferFrameworkApiRule.memberName({ node }))) &&
199
+ given.accepts(PreferFrameworkApiRule.withoutGlobalRoot({ path })) &&
200
+ PreferFrameworkApiRule.isGlobal({ context, node, path })) {
201
+ report(node);
202
+ }
203
+ },
204
+ ]);
205
+ };
206
+ switch (match.type) {
207
+ case 'path': {
208
+ onPath({ key: '', accepts: (bare) => match.paths.includes(bare) });
209
+ break;
210
+ }
211
+ case 'member': {
212
+ onPath({
213
+ key: 'object',
214
+ accepts: (bare) => match.objects.includes(bare),
215
+ property: match.property === undefined ? undefined : new RegExp(match.property),
216
+ isReadOnly: match.isReadOnly,
217
+ });
218
+ break;
219
+ }
220
+ case 'selector': {
221
+ listeners.push([match.selector, report]);
222
+ break;
223
+ }
224
+ case 'literal': {
225
+ const pattern = new RegExp(match.pattern);
226
+ const check = (node, text) => {
227
+ const isWanted = match.isFallbackOnly !== true || PreferFrameworkApiRule.isFallback({ node });
228
+ if (typeof text === 'string' && isWanted && pattern.test(text)) {
229
+ report(node);
230
+ }
231
+ };
232
+ listeners.push([
233
+ common_1.AstNodeTypes.LITERAL,
234
+ (node) => check(node, common_1.AstNode.readField({ node, key: 'value' })),
235
+ ]);
236
+ listeners.push([
237
+ common_1.AstNodeTypes.TEMPLATE_ELEMENT,
238
+ (node) => {
239
+ const value = common_1.AstNode.readField({ node, key: 'value' });
240
+ const template = common_1.AstNode.readField({ node, key: 'parent' });
241
+ const parts = common_1.AstNode.readField({ node: template, key: 'quasis' });
242
+ // The first part is where a URL starts, and the template is what stands in a position.
243
+ if (common_1.AstNode.isNode(template) && Array.isArray(parts) && parts[0] === node) {
244
+ check(template, common_1.AstNode.readField({ node: value, key: 'cooked' }));
245
+ }
246
+ },
247
+ ]);
248
+ break;
249
+ }
250
+ case 'import': {
251
+ const check = (node) => {
252
+ const source = common_1.AstNode.readField({ node, key: 'source' });
253
+ const name = common_1.AstNode.readField({ node: source, key: 'value' });
254
+ if (typeof name === 'string' &&
255
+ match.sources.includes(name) &&
256
+ !PreferFrameworkApiRule.isTypeOnly({ node })) {
257
+ report(node);
258
+ }
259
+ };
260
+ listeners.push([common_1.AstNodeTypes.IMPORT_DECLARATION, check]);
261
+ listeners.push([common_1.AstNodeTypes.IMPORT_EXPRESSION, check]);
262
+ break;
263
+ }
264
+ default: {
265
+ // The other types are hook rows of `BrowserApiPatterns`; as an `extra` row they match nothing here.
266
+ break;
267
+ }
268
+ }
269
+ }
270
+ return listeners;
271
+ }
272
+ /** The name of `a.name` or `a['name']`; empty for `a[name]`, whose name the file does not state. */
273
+ static memberName(opts) {
274
+ const property = common_1.AstNode.readField({ node: opts.node, key: 'property' });
275
+ const computed = common_1.AstNode.readField({ node: opts.node, key: 'computed' }) === true;
276
+ const name = common_1.AstNode.readField({ node: property, key: computed ? 'value' : 'name' });
277
+ return typeof name === 'string' ? name : '';
278
+ }
279
+ /** The field each type of an `extra` row cannot do without. */
280
+ static { this.ROW_FIELDS = new Map([
281
+ ['path', 'paths'],
282
+ ['member', 'objects'],
283
+ ['selector', 'selector'],
284
+ ['literal', 'pattern'],
285
+ ['import', 'sources'],
286
+ ]); }
287
+ /** Whether an `extra` entry is a row this rule can run. The option schema refuses the others before it gets here. */
288
+ static isRow(value) {
289
+ const match = common_1.AstNode.readField({ node: value, key: 'match' });
290
+ const field = PreferFrameworkApiRule.ROW_FIELDS.get(common_1.AstNode.getType({ node: match }));
291
+ return (typeof common_1.AstNode.readField({ node: value, key: 'id' }) === 'string' &&
292
+ typeof common_1.AstNode.readField({ node: value, key: 'message' }) === 'string' &&
293
+ field !== undefined &&
294
+ common_1.AstNode.readField({ node: match, key: field }) !== undefined);
295
+ }
296
+ /** The schema of the `match` of an `extra` row: one shape per type, each with its own field required. */
297
+ static matchSchema() {
298
+ const text = { type: 'string' };
299
+ const list = { type: 'array', items: text };
300
+ const flag = { type: 'boolean' };
301
+ const shapes = [
302
+ { type: 'path' },
303
+ { type: 'member', more: { property: text, isReadOnly: flag } },
304
+ { type: 'selector' },
305
+ { type: 'literal', more: { isFallbackOnly: flag } },
306
+ { type: 'import' },
307
+ ];
308
+ return {
309
+ oneOf: shapes.map(({ type, more }) => {
310
+ const field = PreferFrameworkApiRule.ROW_FIELDS.get(type) ?? type;
311
+ const isText = type === 'selector' || type === 'literal';
312
+ return {
313
+ type: 'object',
314
+ properties: { type: { enum: [type] }, [field]: isText ? text : list, ...more },
315
+ required: ['type', field],
316
+ additionalProperties: false,
317
+ };
318
+ }),
319
+ };
320
+ }
321
+ /**
322
+ * Whether `node` is assigned to or deleted, rather than read. A member that a destructuring pattern writes
323
+ * (`[process.env.APP_ENV_A] = values`) counts as a read and is reported.
324
+ */
325
+ static isWritten(opts) {
326
+ const { node } = opts;
327
+ const parent = common_1.AstNode.readField({ node, key: 'parent' });
328
+ const type = common_1.AstNode.getType({ node: parent });
329
+ if (type === common_1.AstNodeTypes.ASSIGNMENT_EXPRESSION) {
330
+ return common_1.AstNode.readField({ node: parent, key: 'left' }) === node;
331
+ }
332
+ return (type === common_1.AstNodeTypes.UNARY_EXPRESSION &&
333
+ common_1.AstNode.readField({ node: parent, key: 'operator' }) === 'delete');
334
+ }
335
+ static { this.FALLBACK_KEYS = new Set(['default', 'defaultValue', 'fallback']); }
336
+ /** Whether `node` is the value used when another is missing. */
337
+ static isFallback(opts) {
338
+ const { node } = opts;
339
+ const parent = common_1.AstNode.readField({ node, key: 'parent' });
340
+ const type = common_1.AstNode.getType({ node: parent });
341
+ const isRight = common_1.AstNode.readField({ node: parent, key: 'right' }) === node;
342
+ if (type === common_1.AstNodeTypes.LOGICAL_EXPRESSION) {
343
+ return isRight && common_1.AstNode.readField({ node: parent, key: 'operator' }) !== '&&';
344
+ }
345
+ if (type === common_1.AstNodeTypes.ASSIGNMENT_PATTERN) {
346
+ return isRight;
347
+ }
348
+ if (type === common_1.AstNodeTypes.ASSIGNMENT_EXPRESSION) {
349
+ const operator = common_1.AstNode.readField({ node: parent, key: 'operator' });
350
+ return isRight && (operator === '??=' || operator === '||=');
351
+ }
352
+ return (type === common_1.AstNodeTypes.PROPERTY &&
353
+ common_1.AstNode.readField({ node: parent, key: 'value' }) === node &&
354
+ PreferFrameworkApiRule.FALLBACK_KEYS.has(common_1.AstNode.readField({
355
+ node: common_1.AstNode.readField({ node: parent, key: 'key' }),
356
+ key: 'name',
357
+ })));
358
+ }
359
+ /** Whether an import declaration brings in types only. */
360
+ static isTypeOnly(opts) {
361
+ const { node } = opts;
362
+ const specifiers = common_1.AstNode.readField({ node, key: 'specifiers' });
363
+ const isType = (item) => common_1.AstNode.readField({ node: item, key: 'importKind' }) === 'type';
364
+ return (isType(node) ||
365
+ (Array.isArray(specifiers) && specifiers.length > 0 && specifiers.every(isType)));
366
+ }
367
+ /** One listener object: two rows that visit the same node both run. */
368
+ static merge(opts) {
369
+ const byKey = new Map();
370
+ for (const [key, listener] of opts.listeners) {
371
+ byKey.set(key, [...(byKey.get(key) ?? []), listener]);
372
+ }
373
+ return Object.fromEntries([...byKey].map(([key, all]) => [
374
+ key,
375
+ (node) => {
376
+ for (const listener of all) {
377
+ listener(node);
378
+ }
379
+ },
380
+ ]));
381
+ }
163
382
  static { this.RULE = {
164
383
  meta: {
165
384
  type: 'suggestion',
166
385
  schema: [
167
386
  {
168
387
  type: 'object',
169
- properties: { ignore: { type: 'array', items: { type: 'string' } } },
388
+ properties: {
389
+ hooks: { type: 'boolean' },
390
+ ignore: { type: 'array', items: { type: 'string' } },
391
+ extra: {
392
+ type: 'array',
393
+ items: {
394
+ type: 'object',
395
+ properties: {
396
+ id: { type: 'string' },
397
+ message: { type: 'string' },
398
+ dependsOn: { type: 'string' },
399
+ owner: { type: 'string' },
400
+ match: PreferFrameworkApiRule.matchSchema(),
401
+ },
402
+ required: ['id', 'match', 'message'],
403
+ additionalProperties: false,
404
+ },
405
+ },
406
+ },
170
407
  additionalProperties: false,
171
408
  },
172
409
  ],
173
410
  messages: {
174
- framework: 'Use {{hooks}} from {{package}} instead of {{written}}: the hook owns the subscribe and the cleanup.',
411
+ framework: "Use {{hooks}} instead of {{written}}, the hook owns the subscribe and the cleanup: `import { {{name}} } from '{{package}}';`",
175
412
  },
176
413
  },
177
414
  create: (context) => {
415
+ const manifest = framework_exports_1.FrameworkExports.manifestFor({ directory: (0, node_path_1.dirname)(context.filename) });
178
416
  const options = context.options[0];
179
417
  const ignored = common_1.AstNode.readField({ node: options, key: 'ignore' });
180
418
  const ignore = new Set(Array.isArray(ignored) ? ignored : []);
181
- const patterns = browser_api_patterns_1.BrowserApiPatterns.TABLE.filter((pattern) => !ignore.has(pattern.id));
419
+ const added = common_1.AstNode.readField({ node: options, key: 'extra' });
420
+ const rows = PreferFrameworkApiRule.rowsFor({
421
+ manifest,
422
+ extra: Array.isArray(added)
423
+ ? added.filter((row) => PreferFrameworkApiRule.isRow(row))
424
+ : [],
425
+ ignore,
426
+ });
427
+ // The package that ships the hooks writes them with the browser APIs they wrap.
428
+ const patterns = common_1.AstNode.readField({ node: options, key: 'hooks' }) === false ||
429
+ manifest?.name === browser_api_patterns_1.BrowserApiPatterns.PACKAGE
430
+ ? []
431
+ : browser_api_patterns_1.BrowserApiPatterns.TABLE.filter((pattern) => !ignore.has(pattern.id));
182
432
  const report = (opts) => {
183
433
  const { node, pattern } = opts;
184
434
  const subscribes = pattern.match.type === 'listener' || pattern.match.type === 'new';
@@ -190,12 +440,14 @@ class PreferFrameworkApiRule {
190
440
  messageId: 'framework',
191
441
  data: {
192
442
  hooks: pattern.hooks,
443
+ // One import line, for the first hook the row suggests (the `useX` words are in backticks).
444
+ name: /`(use\w+)`/.exec(pattern.hooks)?.[1],
193
445
  package: browser_api_patterns_1.BrowserApiPatterns.PACKAGE,
194
446
  written: pattern.written,
195
447
  },
196
448
  });
197
449
  };
198
- return {
450
+ const hooks = {
199
451
  // `window.matchMedia`, `window.innerWidth`, `navigator.onLine`, `navigator.clipboard.writeText`...
200
452
  [common_1.AstNodeTypes.MEMBER_EXPRESSION]: (node) => {
201
453
  const path = PreferFrameworkApiRule.pathOf({ node });
@@ -271,11 +523,32 @@ class PreferFrameworkApiRule {
271
523
  }
272
524
  },
273
525
  };
526
+ return PreferFrameworkApiRule.merge({
527
+ listeners: [
528
+ ...Object.entries(hooks),
529
+ ...PreferFrameworkApiRule.rowListeners({ context, rows }),
530
+ ],
531
+ });
274
532
  },
275
533
  }; }
534
+ /**
535
+ * `hooks: false` leaves out the rows of `BrowserApiPatterns`, for code that is not React: a `use...` function of another
536
+ * library reads as a hook. An entry that sets options replaces the earlier ones, so it states `hooks` again.
537
+ */
276
538
  static build(opts = {}) {
277
- const { severity = 'error', ignore } = opts;
278
- return ignore === undefined ? [severity] : [severity, { ignore: [...ignore] }];
539
+ const { severity = 'error', hooks, ignore, extra } = opts;
540
+ // Only what was given: the option schema refuses a key whose value is `undefined`.
541
+ const options = {};
542
+ if (hooks !== undefined) {
543
+ options.hooks = hooks;
544
+ }
545
+ if (ignore !== undefined) {
546
+ options.ignore = [...ignore];
547
+ }
548
+ if (extra !== undefined) {
549
+ options.extra = [...extra];
550
+ }
551
+ return Object.keys(options).length === 0 ? [severity] : [severity, options];
279
552
  }
280
553
  }
281
554
  exports.PreferFrameworkApiRule = PreferFrameworkApiRule;
@@ -1 +1 @@
1
- {"version":3,"file":"prefer-framework-api.rule.js","sourceRoot":"","sources":["../../../src/linters/house/prefer-framework-api.rule.ts"],"names":[],"mappings":";;;AAGA,iEAA4D;AAC5D,qCAAyE;AAEzE,uDAAuD;AACvD,MAAM,cAAc,GAA0B,CAAC,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC;AAE3F,kDAAkD;AAClD,MAAM,cAAc,GAA0B,CAAC,QAAQ,EAAE,YAAY,EAAE,MAAM,CAAC,CAAC;AAE/E;;;;;;;;;;;;;GAaG;AACH,MAAa,sBAAsB;aACjB,SAAI,GAAG,GAAG,+BAAsB,uBAAuB,CAAC;IAExE,uFAAuF;IAC/E,MAAM,CAAC,MAAM,CAAC,IAAuB;QAC3C,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;QAEtB,IAAI,gBAAO,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,CAAC,KAAK,qBAAY,CAAC,UAAU,EAAE,CAAC;YAC1D,MAAM,IAAI,GAAG,gBAAO,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,CAAC;YAEtD,OAAO,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;QACrD,CAAC;QAED,IAAI,gBAAO,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,CAAC,KAAK,qBAAY,CAAC,iBAAiB,EAAE,CAAC;YACjE,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,MAAM,QAAQ,GAAG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AE,EAAE;oBACjD,MAAM,IAAI,GAAG,sBAAsB,CAAC,MAAM,CAAC;wBACzC,IAAI,EAAE,gBAAO,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC;qBACjD,CAAC,CAAC;oBAEH,IAAI,IAAI,KAAK,SAAS,IAAI,CAAC,sBAAsB,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;wBACpF,OAAO;oBACT,CAAC;oBAED,MAAM,IAAI,GAAG,sBAAsB,CAAC,iBAAiB,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;oBAEhE,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;wBAC/B,IAAI,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,KAAK,IAAI,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;4BACzE,MAAM,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;wBAC5B,CAAC;oBACH,CAAC;gBACH,CAAC;aACF,CAAC;QACJ,CAAC;KACF,CAAC;IAEF,MAAM,CAAC,KAAK,CACV,OAAqE,EAAE;QAEvE,MAAM,EAAE,QAAQ,GAAG,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;QAE5C,OAAO,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,EAAE,MAAM,EAAE,CAAC,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC;IACjF,CAAC;;AAvVH,wDAwVC","sourcesContent":["import type { Linter, Rule, Scope } from 'eslint';\nimport type { TRuleSeverity } from '../rules/common';\nimport type { IBrowserApiPattern } from './browser-api-patterns';\nimport { BrowserApiPatterns } from './browser-api-patterns';\nimport { AstNode, AstNodeTypes, HOUSE_PLUGIN_NAMESPACE } from './common';\n\n/** The objects a global event listener is added to. */\nconst GLOBAL_TARGETS: ReadonlyArray<string> = ['window', 'document', 'self', 'globalThis'];\n\n/** The names that stand for the global object. */\nconst GLOBAL_OBJECTS: ReadonlyArray<string> = ['window', 'globalThis', 'self'];\n\n/**\n * `venizia/prefer-framework-api`. A browser API that `@venizia/ardor-react` wraps in a hook (`window.matchMedia`, a\n * `ResizeObserver`, `navigator.onLine`, a `beforeunload` listener, `navigator.clipboard.writeText`, `window.confirm`...) is\n * used through the hook, which owns the subscribe and cleanup. The rows are `BrowserApiPatterns.TABLE`; the message names\n * the hook. The rule is for apps: ardor-react's own source, where the hooks are written, turns it off.\n *\n * Only a reference to the global is reported: a `window`, `navigator` or `document` the file binds itself is not. And only\n * where a hook can be called: in a component (a PascalCase function that draws JSX) or a hook (`useX`), see `isInReact`. A\n * module function, a class and an event handler making a one-off call are left alone. Hooks the author wants to bypass on\n * purpose take an `eslint-disable-next-line` with the reason, or `ignore` lists pattern ids.\n *\n * @useWhen a React app should reach the browser (media queries, sizes, observers, online status, visibility, unload, clipboard, confirm) through the ardor-react hooks\n * @insteadOf window.matchMedia, new ResizeObserver, navigator.onLine and the other browser APIs written by hand\n */\nexport class PreferFrameworkApiRule {\n static readonly NAME = `${HOUSE_PLUGIN_NAMESPACE}/prefer-framework-api`;\n\n /** The dotted text of `a.b.c` (identifiers only), or `undefined` for anything else. */\n private static pathOf(opts: { node: unknown }): string | undefined {\n const { node } = opts;\n\n if (AstNode.getType({ node }) === AstNodeTypes.IDENTIFIER) {\n const name = AstNode.readField({ node, key: 'name' });\n\n return typeof name === 'string' ? name : undefined;\n }\n\n if (AstNode.getType({ node }) !== AstNodeTypes.MEMBER_EXPRESSION) {\n return undefined;\n }\n\n const property = AstNode.readField({ node, key: 'property' });\n const name = AstNode.readField({ node: property, key: 'name' });\n const head = PreferFrameworkApiRule.pathOf({\n node: AstNode.readField({ node, key: 'object' }),\n });\n\n return head !== undefined &&\n typeof name === 'string' &&\n AstNode.readField({ node, key: 'computed' }) !== true\n ? `${head}.${name}`\n : undefined;\n }\n\n /** `window.navigator.onLine` is `navigator.onLine`. */\n private static withoutGlobalRoot(opts: { path: string }): string {\n const [first, ...rest] = opts.path.split('.');\n\n return GLOBAL_OBJECTS.includes(first ?? '') && rest.length > 0 ? rest.join('.') : opts.path;\n }\n\n /** Whether the root identifier of `path` is the global one: no scope of the file binds it. */\n private static isGlobal(opts: {\n context: Rule.RuleContext;\n node: Rule.Node;\n path: string;\n }): boolean {\n const { context, node, path } = opts;\n const root = path.split('.')[0] ?? '';\n let scope: Scope.Scope | null = context.sourceCode.getScope(node);\n\n while (scope) {\n if ((scope.set.get(root)?.defs.length ?? 0) > 0) {\n return false;\n }\n\n scope = scope.upper;\n }\n\n return true;\n }\n\n private static readonly FUNCTIONS = new Set<string>([\n AstNodeTypes.FUNCTION_DECLARATION,\n AstNodeTypes.FUNCTION_EXPRESSION,\n AstNodeTypes.ARROW_FUNCTION_EXPRESSION,\n ]);\n\n /** Whether a function has JSX anywhere in it: with a PascalCase name, that is a component. */\n private static readonly jsxCache = new WeakMap<object, boolean>();\n\n private static containsJsx(opts: { context: Rule.RuleContext; node: unknown }): boolean {\n const { context, node } = opts;\n\n if (typeof node !== 'object' || node === null) {\n return false;\n }\n\n const cached = PreferFrameworkApiRule.jsxCache.get(node);\n\n if (cached !== undefined) {\n return cached;\n }\n\n const type = AstNode.getType({ node });\n let found = type === AstNodeTypes.JSX_ELEMENT || type === AstNodeTypes.JSX_FRAGMENT;\n\n for (const key of type === undefined ? [] : (context.sourceCode.visitorKeys[type] ?? [])) {\n const child = AstNode.readField({ node, key });\n\n for (const entry of Array.isArray(child) ? child : [child]) {\n found = found || PreferFrameworkApiRule.containsJsx({ context, node: entry });\n }\n }\n\n PreferFrameworkApiRule.jsxCache.set(node, found);\n\n return found;\n }\n\n /** The name a function is known by: its own, or the variable it is assigned to (through one `memo(...)` / `forwardRef(...)`). */\n private static nameOf(opts: { fn: Rule.Node }): string | undefined {\n const { fn } = opts;\n const own = AstNode.readField({\n node: AstNode.readField({ node: fn, key: 'id' }),\n key: 'name',\n });\n\n if (typeof own === 'string') {\n return own;\n }\n\n let parent: unknown = AstNode.readField({ node: fn, key: 'parent' });\n\n if (AstNode.getType({ node: parent }) === AstNodeTypes.CALL_EXPRESSION) {\n parent = AstNode.readField({ node: parent, key: 'parent' });\n }\n\n const name = AstNode.readField({\n node: AstNode.readField({ node: parent, key: 'id' }),\n key: 'name',\n });\n\n return AstNode.getType({ node: parent }) === AstNodeTypes.VARIABLE_DECLARATOR &&\n typeof name === 'string'\n ? name\n : undefined;\n }\n\n /** A hook (`useX`), or a component: a PascalCase function that draws JSX. */\n private static isReactFunction(opts: { context: Rule.RuleContext; fn: Rule.Node }): boolean {\n const name = PreferFrameworkApiRule.nameOf({ fn: opts.fn });\n\n if (name === undefined) {\n return false;\n }\n\n return (\n /^use[A-Z0-9]/.test(name) ||\n (/^[A-Z]/.test(name) &&\n PreferFrameworkApiRule.containsJsx({ context: opts.context, node: opts.fn }))\n );\n }\n\n /** Whether `fn` is an argument of a hook call (`useEffect(() => ...)`): the callback runs for the component or the hook. */\n private static isHookCallback(opts: { fn: Rule.Node }): boolean {\n const parent: unknown = AstNode.readField({ node: opts.fn, key: 'parent' });\n const callee = AstNode.readField({ node: parent, key: 'callee' });\n const name =\n AstNode.readField({ node: callee, key: 'name' }) ??\n AstNode.readField({\n node: AstNode.readField({ node: callee, key: 'property' }),\n key: 'name',\n });\n\n return (\n AstNode.getType({ node: parent }) === AstNodeTypes.CALL_EXPRESSION &&\n typeof name === 'string' &&\n /^use[A-Z0-9]/.test(name)\n );\n }\n\n /**\n * Whether `node` is in a component or a hook, which is where a hook can be called. A subscription (a listener, an\n * observer) counts through any handler or helper on the way up: it belongs in a hook. A plain read (`window.innerWidth`,\n * `window.confirm`) counts only in the body of the component or the hook, or in a callback it hands to a hook\n * (`useEffect`, `useMemo`): inside an event handler, or outside every component (a module function, a class), it is a\n * one-off call a hook cannot make.\n */\n private static isInReact(opts: {\n context: Rule.RuleContext;\n node: Rule.Node;\n subscribes: boolean;\n }): boolean {\n const { context, node, subscribes } = opts;\n\n for (const ancestor of [...context.sourceCode.getAncestors(node)].reverse()) {\n const type = AstNode.getType({ node: ancestor });\n\n if (\n type === undefined ||\n !PreferFrameworkApiRule.FUNCTIONS.has(type) ||\n !AstNode.isNode(ancestor)\n ) {\n continue;\n }\n\n if (PreferFrameworkApiRule.isReactFunction({ context, fn: ancestor })) {\n return true;\n }\n\n if (!subscribes && !PreferFrameworkApiRule.isHookCallback({ fn: ancestor })) {\n return false;\n }\n }\n\n return false;\n }\n\n static readonly RULE: Rule.RuleModule = {\n meta: {\n type: 'suggestion',\n schema: [\n {\n type: 'object',\n properties: { ignore: { type: 'array', items: { type: 'string' } } },\n additionalProperties: false,\n },\n ],\n messages: {\n framework:\n 'Use {{hooks}} from {{package}} instead of {{written}}: the hook owns the subscribe and the cleanup.',\n },\n },\n create: (context) => {\n const options: unknown = context.options[0];\n const ignored = AstNode.readField({ node: options, key: 'ignore' });\n const ignore = new Set(Array.isArray(ignored) ? ignored : []);\n const patterns = BrowserApiPatterns.TABLE.filter((pattern) => !ignore.has(pattern.id));\n\n const report = (opts: { node: Rule.Node; pattern: IBrowserApiPattern }) => {\n const { node, pattern } = opts;\n const subscribes = pattern.match.type === 'listener' || pattern.match.type === 'new';\n\n if (!PreferFrameworkApiRule.isInReact({ context, node, subscribes })) {\n return;\n }\n\n context.report({\n node,\n messageId: 'framework',\n data: {\n hooks: pattern.hooks,\n package: BrowserApiPatterns.PACKAGE,\n written: pattern.written,\n },\n });\n };\n\n return {\n // `window.matchMedia`, `window.innerWidth`, `navigator.onLine`, `navigator.clipboard.writeText`...\n [AstNodeTypes.MEMBER_EXPRESSION]: (node: Rule.Node) => {\n const path = PreferFrameworkApiRule.pathOf({ node });\n\n if (path === undefined || !PreferFrameworkApiRule.isGlobal({ context, node, path })) {\n return;\n }\n\n const bare = PreferFrameworkApiRule.withoutGlobalRoot({ path });\n\n for (const pattern of patterns) {\n const { match } = pattern;\n\n if (\n (match.type === 'global' &&\n GLOBAL_OBJECTS.includes(path.split('.')[0] ?? '') &&\n path.split('.').length === 2 &&\n match.names.includes(bare)) ||\n (match.type === 'path' && match.paths.includes(bare))\n ) {\n report({ node, pattern });\n }\n }\n },\n [AstNodeTypes.CALL_EXPRESSION]: (node: Rule.Node) => {\n const callee = AstNode.readField({ node, key: 'callee' });\n const args: unknown = AstNode.readField({ node, key: 'arguments' });\n const first = Array.isArray(args) ? args[0] : undefined;\n const event = AstNode.readField({ node: first, key: 'value' });\n\n // `matchMedia(...)`, `confirm(...)` with no `window.`.\n if (AstNode.getType({ node: callee }) === AstNodeTypes.IDENTIFIER) {\n const name = AstNode.readField({ node: callee, key: 'name' });\n\n for (const pattern of patterns) {\n if (\n pattern.match.type === 'global' &&\n typeof name === 'string' &&\n pattern.match.names.includes(name) &&\n PreferFrameworkApiRule.isGlobal({ context, node, path: name })\n ) {\n report({ node, pattern });\n }\n }\n }\n\n // `<object>.addEventListener('<event>', ...)`.\n const path = PreferFrameworkApiRule.pathOf({ node: callee });\n\n if (path === undefined || typeof event !== 'string') {\n return;\n }\n\n const parts = path.split('.');\n const method = parts.pop();\n const owner = parts.join('.');\n\n if (method !== 'addEventListener') {\n return;\n }\n\n // A listener on a socket, an element or an `EventTarget` of the author's own is not the browser's.\n const isOwnerGlobal =\n owner === '' ||\n (PreferFrameworkApiRule.isGlobal({ context, node, path: owner }) &&\n GLOBAL_TARGETS.includes(owner));\n\n for (const pattern of patterns) {\n const { match } = pattern;\n\n if (\n match.type === 'listener' &&\n match.events.includes(event) &&\n isOwnerGlobal &&\n (match.objects === undefined || owner === '' || match.objects.includes(owner))\n ) {\n report({ node, pattern });\n }\n }\n },\n [AstNodeTypes.NEW_EXPRESSION]: (node: Rule.Node) => {\n const path = PreferFrameworkApiRule.pathOf({\n node: AstNode.readField({ node, key: 'callee' }),\n });\n\n if (path === undefined || !PreferFrameworkApiRule.isGlobal({ context, node, path })) {\n return;\n }\n\n const bare = PreferFrameworkApiRule.withoutGlobalRoot({ path });\n\n for (const pattern of patterns) {\n if (pattern.match.type === 'new' && pattern.match.callees.includes(bare)) {\n report({ node, pattern });\n }\n }\n },\n };\n },\n };\n\n static build(\n opts: { severity?: TRuleSeverity; ignore?: ReadonlyArray<string> } = {},\n ): Linter.RuleEntry {\n const { severity = 'error', ignore } = opts;\n\n return ignore === undefined ? [severity] : [severity, { ignore: [...ignore] }];\n }\n}\n"]}
1
+ {"version":3,"file":"prefer-framework-api.rule.js","sourceRoot":"","sources":["../../../src/linters/house/prefer-framework-api.rule.ts"],"names":[],"mappings":";;;AAAA,yCAAoC;AAIpC,iEAA4D;AAC5D,qCAAyE;AAEzE,qEAAgE;AAEhE,2DAAuD;AAEvD,uDAAuD;AACvD,MAAM,cAAc,GAA0B,CAAC,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC;AAE3F,kDAAkD;AAClD,MAAM,cAAc,GAA0B,CAAC,QAAQ,EAAE,YAAY,EAAE,MAAM,CAAC,CAAC;AAE/E;;;;;;;;;;;;;;GAcG;AACH,MAAa,sBAAsB;aACjB,SAAI,GAAG,GAAG,+BAAsB,uBAAuB,CAAC;IAExE,uFAAuF;IAC/E,MAAM,CAAC,MAAM,CAAC,IAAuB;QAC3C,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;QAEtB,IAAI,gBAAO,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,CAAC,KAAK,qBAAY,CAAC,UAAU,EAAE,CAAC;YAC1D,MAAM,IAAI,GAAG,gBAAO,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,CAAC;YAEtD,OAAO,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;QACrD,CAAC;QAED,IAAI,gBAAO,CAAC,OAAO,CAAC,EAAE,IAA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AC,KAAK,CAAC;gBAClC,SAAS,EAAE;oBACT,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC;oBACxB,GAAG,sBAAsB,CAAC,YAAY,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;iBAC1D;aACF,CAAC,CAAC;QACL,CAAC;KACF,CAAC;IAEF;;;OAGG;IACH,MAAM,CAAC,KAAK,CACV,OAKI,EAAE;QAEN,MAAM,EAAE,QAAQ,GAAG,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;QAC1D,mFAAmF;QACnF,MAAM,OAAO,GAA4B,EAAE,CAAC;QAE5C,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,OAAO,CAAC,KAAK,GAAG,KAAK,CAAC;QACxB,CAAC;QAED,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YACzB,OAAO,CAAC,MAAM,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC;QAC/B,CAAC;QAED,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,OAAO,CAAC,KAAK,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC;QAC7B,CAAC;QAED,OAAO,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC9E,CAAC;;AA5rBH,wDA6rBC","sourcesContent":["import { dirname } from 'node:path';\nimport type { Linter, Rule, Scope } from 'eslint';\nimport type { TRuleSeverity } from '../rules/common';\nimport type { IBrowserApiPattern } from './browser-api-patterns';\nimport { BrowserApiPatterns } from './browser-api-patterns';\nimport { AstNode, AstNodeTypes, HOUSE_PLUGIN_NAMESPACE } from './common';\nimport type { IFrameworkApiPattern } from './framework-api-patterns';\nimport { FrameworkApiPatterns } from './framework-api-patterns';\nimport type { IPackageManifest } from './framework-exports';\nimport { FrameworkExports } from './framework-exports';\n\n/** The objects a global event listener is added to. */\nconst GLOBAL_TARGETS: ReadonlyArray<string> = ['window', 'document', 'self', 'globalThis'];\n\n/** The names that stand for the global object. */\nconst GLOBAL_OBJECTS: ReadonlyArray<string> = ['window', 'globalThis', 'self'];\n\n/**\n * `@venizia/prefer-framework-api`. A browser API that `@venizia/ardor-react` wraps in a hook (`window.matchMedia`, a\n * `ResizeObserver`, `navigator.onLine`, a `beforeunload` listener, `navigator.clipboard.writeText`, `window.confirm`...) is\n * used through the hook, which owns the subscribe and cleanup. The rows are `BrowserApiPatterns.TABLE`; the message names\n * the hook. The rule is for apps: the package that ships the hooks (the nearest `package.json` is named\n * `@venizia/ardor-react`) is not reported.\n *\n * The rows of `FrameworkApiPatterns.TABLE` and of the `extra` option are not about React: they report anywhere in a file,\n * with their own message, in a package their `dependsOn` and `owner` allow.\n *\n * For the hook rows, only a reference to the global is reported: a `window`, `navigator` or `document` the file binds itself is not. And only\n * where a hook can be called: in a component (a PascalCase function that draws JSX) or a hook (`useX`), see `isInReact`. A\n * module function, a class and an event handler making a one-off call are left alone. Hooks the author wants to bypass on\n * purpose take an `eslint-disable-next-line` with the reason, or `ignore` lists pattern ids.\n */\nexport class PreferFrameworkApiRule {\n static readonly NAME = `${HOUSE_PLUGIN_NAMESPACE}/prefer-framework-api`;\n\n /** The dotted text of `a.b.c` (identifiers only), or `undefined` for anything else. */\n private static pathOf(opts: { node: unknown }): string | undefined {\n const { node } = opts;\n\n if (AstNode.getType({ node }) === AstNodeTypes.IDENTIFIER) {\n const name = AstNode.readField({ node, key: 'name' });\n\n return typeof name === 'string' ? name : undefined;\n }\n\n if (AstNode.getType({ node }) !== AstNodeTypes.MEMBER_EXPRESSION) {\n return undefined;\n }\n\n const property = AstNode.readField({ node, key: 'property' });\n const name = AstNode.readField({ node: property, key: 'name' });\n const head = PreferFrameworkApiRule.pathOf({\n node: AstNode.readField({ node, key: 'object' }),\n });\n\n return head !== undefined &&\n typeof name === 'string' &&\n AstNode.readField({ node, key: 'computed' }) !== true\n ? `${head}.${name}`\n : undefined;\n }\n\n /** `window.navigator.onLine` is `navigator.onLine`. */\n private static withoutGlobalRoot(opts: { path: string }): string {\n const [first, ...rest] = opts.path.split('.');\n\n return GLOBAL_OBJECTS.includes(first ?? '') && rest.length > 0 ? rest.join('.') : opts.path;\n }\n\n /** Whether the root identifier of `path` is the global one: no scope of the file binds it. */\n private static isGlobal(opts: {\n context: Rule.RuleContext;\n node: Rule.Node;\n path: string;\n }): boolean {\n const { context, node, path } = opts;\n const root = path.split('.')[0] ?? '';\n let scope: Scope.Scope | null = context.sourceCode.getScope(node);\n\n while (scope) {\n if ((scope.set.get(root)?.defs.length ?? 0) > 0) {\n return false;\n }\n\n scope = scope.upper;\n }\n\n return true;\n }\n\n private static readonly FUNCTIONS = new Set<string>([\n AstNodeTypes.FUNCTION_DECLARATION,\n AstNodeTypes.FUNCTION_EXPRESSION,\n AstNodeTypes.ARROW_FUNCTION_EXPRESSION,\n ]);\n\n /** Whether a function has JSX anywhere in it: with a PascalCase name, that is a component. */\n private static readonly jsxCache = new WeakMap<object, boolean>();\n\n private static containsJsx(opts: { context: Rule.RuleContext; node: unknown }): boolean {\n const { context, node } = opts;\n\n if (typeof node !== 'object' || node === null) {\n return false;\n }\n\n const cached = PreferFrameworkApiRule.jsxCache.get(node);\n\n if (cached !== undefined) {\n return cached;\n }\n\n const type = AstNode.getType({ node });\n let found = type === AstNodeTypes.JSX_ELEMENT || type === AstNodeTypes.JSX_FRAGMENT;\n\n for (const key of type === undefined ? [] : (context.sourceCode.visitorKeys[type] ?? [])) {\n const child = AstNode.readField({ node, key });\n\n for (const entry of Array.isArray(child) ? child : [child]) {\n found = found || PreferFrameworkApiRule.containsJsx({ context, node: entry });\n }\n }\n\n PreferFrameworkApiRule.jsxCache.set(node, found);\n\n return found;\n }\n\n /** The name a function is known by: its own, or the variable it is assigned to (through one `memo(...)` / `forwardRef(...)`). */\n private static nameOf(opts: { fn: Rule.Node }): string | undefined {\n const { fn } = opts;\n const own = AstNode.readField({\n node: AstNode.readField({ node: fn, key: 'id' }),\n key: 'name',\n });\n\n if (typeof own === 'string') {\n return own;\n }\n\n let parent: unknown = AstNode.readField({ node: fn, key: 'parent' });\n\n if (AstNode.getType({ node: parent }) === AstNodeTypes.CALL_EXPRESSION) {\n parent = AstNode.readField({ node: parent, key: 'parent' });\n }\n\n const name = AstNode.readField({\n node: AstNode.readField({ node: parent, key: 'id' }),\n key: 'name',\n });\n\n return AstNode.getType({ node: parent }) === AstNodeTypes.VARIABLE_DECLARATOR &&\n typeof name === 'string'\n ? name\n : undefined;\n }\n\n /** A hook (`useX`), or a component: a PascalCase function that draws JSX. */\n private static isReactFunction(opts: { context: Rule.RuleContext; fn: Rule.Node }): boolean {\n const name = PreferFrameworkApiRule.nameOf({ fn: opts.fn });\n\n if (name === undefined) {\n return false;\n }\n\n return (\n /^use[A-Z0-9]/.test(name) ||\n (/^[A-Z]/.test(name) &&\n PreferFrameworkApiRule.containsJsx({ context: opts.context, node: opts.fn }))\n );\n }\n\n /** Whether `fn` is an argument of a hook call (`useEffect(() => ...)`): the callback runs for the component or the hook. */\n private static isHookCallback(opts: { fn: Rule.Node }): boolean {\n const parent: unknown = AstNode.readField({ node: opts.fn, key: 'parent' });\n const callee = AstNode.readField({ node: parent, key: 'callee' });\n const name =\n AstNode.readField({ node: callee, key: 'name' }) ??\n AstNode.readField({\n node: AstNode.readField({ node: callee, key: 'property' }),\n key: 'name',\n });\n\n return (\n AstNode.getType({ node: parent }) === AstNodeTypes.CALL_EXPRESSION &&\n typeof name === 'string' &&\n /^use[A-Z0-9]/.test(name)\n );\n }\n\n /**\n * Whether `node` is in a component or a hook, which is where a hook can be called. A subscription (a listener, an\n * observer) counts through any handler or helper on the way up: it belongs in a hook. A plain read (`window.innerWidth`,\n * `window.confirm`) counts only in the body of the component or the hook, or in a callback it hands to a hook\n * (`useEffect`, `useMemo`): inside an event handler, or outside every component (a module function, a class), it is a\n * one-off call a hook cannot make.\n */\n private static isInReact(opts: {\n context: Rule.RuleContext;\n node: Rule.Node;\n subscribes: boolean;\n }): boolean {\n const { context, node, subscribes } = opts;\n\n for (const ancestor of [...context.sourceCode.getAncestors(node)].reverse()) {\n const type = AstNode.getType({ node: ancestor });\n\n if (\n type === undefined ||\n !PreferFrameworkApiRule.FUNCTIONS.has(type) ||\n !AstNode.isNode(ancestor)\n ) {\n continue;\n }\n\n if (PreferFrameworkApiRule.isReactFunction({ context, fn: ancestor })) {\n return true;\n }\n\n if (!subscribes && !PreferFrameworkApiRule.isHookCallback({ fn: ancestor })) {\n return false;\n }\n }\n\n return false;\n }\n\n /** The rows that apply in a file of this package: the table and `extra`, less the ignored ones. */\n private static rowsFor(opts: {\n manifest: IPackageManifest | undefined;\n extra: ReadonlyArray<IFrameworkApiPattern>;\n ignore: ReadonlySet<unknown>;\n }): ReadonlyArray<IFrameworkApiPattern> {\n const { manifest, extra, ignore } = opts;\n\n return [...FrameworkApiPatterns.TABLE, ...extra].filter((row) => {\n const { id, dependsOn, owner } = row;\n\n if (ignore.has(id) || (owner !== undefined && manifest?.name === owner)) {\n return false;\n }\n\n return (\n dependsOn === undefined ||\n (manifest?.dependencies.some((entry) => entry.startsWith(dependsOn)) ?? false)\n );\n });\n }\n\n /** The listeners the rows outside React need, by node type or selector. */\n private static rowListeners(opts: {\n context: Rule.RuleContext;\n rows: ReadonlyArray<IFrameworkApiPattern>;\n }): Array<[string, (node: Rule.Node) => void]> {\n const { context, rows } = opts;\n const listeners: Array<[string, (node: Rule.Node) => void]> = [];\n\n for (const { match, message } of rows) {\n const report = (node: Rule.Node) => {\n context.report({ node, message });\n };\n\n /** Reports a global written as a member path, when `accepts` takes it. */\n const onPath = (given: {\n key: string;\n accepts: (bare: string) => boolean;\n property?: RegExp;\n isReadOnly?: boolean;\n }) => {\n listeners.push([\n AstNodeTypes.MEMBER_EXPRESSION,\n (node) => {\n const path = PreferFrameworkApiRule.pathOf({\n node: given.key === '' ? node : AstNode.readField({ node, key: given.key }),\n });\n\n if (\n path !== undefined &&\n !(given.isReadOnly === true && PreferFrameworkApiRule.isWritten({ node })) &&\n (given.property === undefined ||\n given.property.test(PreferFrameworkApiRule.memberName({ node }))) &&\n given.accepts(PreferFrameworkApiRule.withoutGlobalRoot({ path })) &&\n PreferFrameworkApiRule.isGlobal({ context, node, path })\n ) {\n report(node);\n }\n },\n ]);\n };\n\n switch (match.type) {\n case 'path': {\n onPath({ key: '', accepts: (bare) => match.paths.includes(bare) });\n break;\n }\n\n case 'member': {\n onPath({\n key: 'object',\n accepts: (bare) => match.objects.includes(bare),\n property: match.property === undefined ? undefined : new RegExp(match.property),\n isReadOnly: match.isReadOnly,\n });\n break;\n }\n\n case 'selector': {\n listeners.push([match.selector, report]);\n break;\n }\n\n case 'literal': {\n const pattern = new RegExp(match.pattern);\n\n const check = (node: Rule.Node, text: unknown) => {\n const isWanted =\n match.isFallbackOnly !== true || PreferFrameworkApiRule.isFallback({ node });\n\n if (typeof text === 'string' && isWanted && pattern.test(text)) {\n report(node);\n }\n };\n\n listeners.push([\n AstNodeTypes.LITERAL,\n (node) => check(node, AstNode.readField({ node, key: 'value' })),\n ]);\n listeners.push([\n AstNodeTypes.TEMPLATE_ELEMENT,\n (node) => {\n const value = AstNode.readField({ node, key: 'value' });\n const template: unknown = AstNode.readField({ node, key: 'parent' });\n const parts: unknown = AstNode.readField({ node: template, key: 'quasis' });\n\n // The first part is where a URL starts, and the template is what stands in a position.\n if (AstNode.isNode(template) && Array.isArray(parts) && parts[0] === node) {\n check(template, AstNode.readField({ node: value, key: 'cooked' }));\n }\n },\n ]);\n break;\n }\n\n case 'import': {\n const check = (node: Rule.Node) => {\n const source = AstNode.readField({ node, key: 'source' });\n const name = AstNode.readField({ node: source, key: 'value' });\n\n if (\n typeof name === 'string' &&\n match.sources.includes(name) &&\n !PreferFrameworkApiRule.isTypeOnly({ node })\n ) {\n report(node);\n }\n };\n\n listeners.push([AstNodeTypes.IMPORT_DECLARATION, check]);\n listeners.push([AstNodeTypes.IMPORT_EXPRESSION, check]);\n break;\n }\n\n default: {\n // The other types are hook rows of `BrowserApiPatterns`; as an `extra` row they match nothing here.\n break;\n }\n }\n }\n\n return listeners;\n }\n\n /** The name of `a.name` or `a['name']`; empty for `a[name]`, whose name the file does not state. */\n private static memberName(opts: { node: Rule.Node }): string {\n const property = AstNode.readField({ node: opts.node, key: 'property' });\n const computed = AstNode.readField({ node: opts.node, key: 'computed' }) === true;\n const name = AstNode.readField({ node: property, key: computed ? 'value' : 'name' });\n\n return typeof name === 'string' ? name : '';\n }\n\n /** The field each type of an `extra` row cannot do without. */\n private static readonly ROW_FIELDS = new Map<unknown, string>([\n ['path', 'paths'],\n ['member', 'objects'],\n ['selector', 'selector'],\n ['literal', 'pattern'],\n ['import', 'sources'],\n ]);\n\n /** Whether an `extra` entry is a row this rule can run. The option schema refuses the others before it gets here. */\n private static isRow(value: unknown): value is IFrameworkApiPattern {\n const match = AstNode.readField({ node: value, key: 'match' });\n const field = PreferFrameworkApiRule.ROW_FIELDS.get(AstNode.getType({ node: match }));\n\n return (\n typeof AstNode.readField({ node: value, key: 'id' }) === 'string' &&\n typeof AstNode.readField({ node: value, key: 'message' }) === 'string' &&\n field !== undefined &&\n AstNode.readField({ node: match, key: field }) !== undefined\n );\n }\n\n /** The schema of the `match` of an `extra` row: one shape per type, each with its own field required. */\n private static matchSchema() {\n const text = { type: 'string' } as const;\n const list = { type: 'array', items: text } as const;\n const flag = { type: 'boolean' } as const;\n const shapes: Array<{ type: string; more?: Record<string, typeof text | typeof flag> }> = [\n { type: 'path' },\n { type: 'member', more: { property: text, isReadOnly: flag } },\n { type: 'selector' },\n { type: 'literal', more: { isFallbackOnly: flag } },\n { type: 'import' },\n ];\n\n return {\n oneOf: shapes.map(({ type, more }) => {\n const field = PreferFrameworkApiRule.ROW_FIELDS.get(type) ?? type;\n const isText = type === 'selector' || type === 'literal';\n\n return {\n type: 'object' as const,\n properties: { type: { enum: [type] }, [field]: isText ? text : list, ...more },\n required: ['type', field],\n additionalProperties: false,\n };\n }),\n };\n }\n\n /**\n * Whether `node` is assigned to or deleted, rather than read. A member that a destructuring pattern writes\n * (`[process.env.APP_ENV_A] = values`) counts as a read and is reported.\n */\n private static isWritten(opts: { node: Rule.Node }): boolean {\n const { node } = opts;\n const parent: unknown = AstNode.readField({ node, key: 'parent' });\n const type = AstNode.getType({ node: parent });\n\n if (type === AstNodeTypes.ASSIGNMENT_EXPRESSION) {\n return AstNode.readField({ node: parent, key: 'left' }) === node;\n }\n\n return (\n type === AstNodeTypes.UNARY_EXPRESSION &&\n AstNode.readField({ node: parent, key: 'operator' }) === 'delete'\n );\n }\n\n private static readonly FALLBACK_KEYS = new Set<unknown>(['default', 'defaultValue', 'fallback']);\n\n /** Whether `node` is the value used when another is missing. */\n private static isFallback(opts: { node: Rule.Node }): boolean {\n const { node } = opts;\n const parent: unknown = AstNode.readField({ node, key: 'parent' });\n const type = AstNode.getType({ node: parent });\n const isRight = AstNode.readField({ node: parent, key: 'right' }) === node;\n\n if (type === AstNodeTypes.LOGICAL_EXPRESSION) {\n return isRight && AstNode.readField({ node: parent, key: 'operator' }) !== '&&';\n }\n\n if (type === AstNodeTypes.ASSIGNMENT_PATTERN) {\n return isRight;\n }\n\n if (type === AstNodeTypes.ASSIGNMENT_EXPRESSION) {\n const operator = AstNode.readField({ node: parent, key: 'operator' });\n\n return isRight && (operator === '??=' || operator === '||=');\n }\n\n return (\n type === AstNodeTypes.PROPERTY &&\n AstNode.readField({ node: parent, key: 'value' }) === node &&\n PreferFrameworkApiRule.FALLBACK_KEYS.has(\n AstNode.readField({\n node: AstNode.readField({ node: parent, key: 'key' }),\n key: 'name',\n }),\n )\n );\n }\n\n /** Whether an import declaration brings in types only. */\n private static isTypeOnly(opts: { node: unknown }): boolean {\n const { node } = opts;\n const specifiers: unknown = AstNode.readField({ node, key: 'specifiers' });\n const isType = (item: unknown) =>\n AstNode.readField({ node: item, key: 'importKind' }) === 'type';\n\n return (\n isType(node) ||\n (Array.isArray(specifiers) && specifiers.length > 0 && specifiers.every(isType))\n );\n }\n\n /** One listener object: two rows that visit the same node both run. */\n private static merge(opts: {\n listeners: Array<[string, (node: Rule.Node) => void]>;\n }): Rule.RuleListener {\n const byKey = new Map<string, Array<(node: Rule.Node) => void>>();\n\n for (const [key, listener] of opts.listeners) {\n byKey.set(key, [...(byKey.get(key) ?? []), listener]);\n }\n\n return Object.fromEntries(\n [...byKey].map(([key, all]) => [\n key,\n (node: Rule.Node) => {\n for (const listener of all) {\n listener(node);\n }\n },\n ]),\n );\n }\n\n static readonly RULE: Rule.RuleModule = {\n meta: {\n type: 'suggestion',\n schema: [\n {\n type: 'object',\n properties: {\n hooks: { type: 'boolean' },\n ignore: { type: 'array', items: { type: 'string' } },\n extra: {\n type: 'array',\n items: {\n type: 'object',\n properties: {\n id: { type: 'string' },\n message: { type: 'string' },\n dependsOn: { type: 'string' },\n owner: { type: 'string' },\n match: PreferFrameworkApiRule.matchSchema(),\n },\n required: ['id', 'match', 'message'],\n additionalProperties: false,\n },\n },\n },\n additionalProperties: false,\n },\n ],\n messages: {\n framework:\n \"Use {{hooks}} instead of {{written}}, the hook owns the subscribe and the cleanup: `import { {{name}} } from '{{package}}';`\",\n },\n },\n create: (context) => {\n const manifest = FrameworkExports.manifestFor({ directory: dirname(context.filename) });\n const options: unknown = context.options[0];\n const ignored = AstNode.readField({ node: options, key: 'ignore' });\n const ignore = new Set(Array.isArray(ignored) ? ignored : []);\n const added: unknown = AstNode.readField({ node: options, key: 'extra' });\n const rows = PreferFrameworkApiRule.rowsFor({\n manifest,\n extra: Array.isArray(added)\n ? added.filter((row: unknown) => PreferFrameworkApiRule.isRow(row))\n : [],\n ignore,\n });\n // The package that ships the hooks writes them with the browser APIs they wrap.\n const patterns =\n AstNode.readField({ node: options, key: 'hooks' }) === false ||\n manifest?.name === BrowserApiPatterns.PACKAGE\n ? []\n : BrowserApiPatterns.TABLE.filter((pattern) => !ignore.has(pattern.id));\n\n const report = (opts: { node: Rule.Node; pattern: IBrowserApiPattern }) => {\n const { node, pattern } = opts;\n const subscribes = pattern.match.type === 'listener' || pattern.match.type === 'new';\n\n if (!PreferFrameworkApiRule.isInReact({ context, node, subscribes })) {\n return;\n }\n\n context.report({\n node,\n messageId: 'framework',\n data: {\n hooks: pattern.hooks,\n // One import line, for the first hook the row suggests (the `useX` words are in backticks).\n name: /`(use\\w+)`/.exec(pattern.hooks)?.[1],\n package: BrowserApiPatterns.PACKAGE,\n written: pattern.written,\n },\n });\n };\n\n const hooks: Record<string, (node: Rule.Node) => void> = {\n // `window.matchMedia`, `window.innerWidth`, `navigator.onLine`, `navigator.clipboard.writeText`...\n [AstNodeTypes.MEMBER_EXPRESSION]: (node: Rule.Node) => {\n const path = PreferFrameworkApiRule.pathOf({ node });\n\n if (path === undefined || !PreferFrameworkApiRule.isGlobal({ context, node, path })) {\n return;\n }\n\n const bare = PreferFrameworkApiRule.withoutGlobalRoot({ path });\n\n for (const pattern of patterns) {\n const { match } = pattern;\n\n if (\n (match.type === 'global' &&\n GLOBAL_OBJECTS.includes(path.split('.')[0] ?? '') &&\n path.split('.').length === 2 &&\n match.names.includes(bare)) ||\n (match.type === 'path' && match.paths.includes(bare))\n ) {\n report({ node, pattern });\n }\n }\n },\n [AstNodeTypes.CALL_EXPRESSION]: (node: Rule.Node) => {\n const callee = AstNode.readField({ node, key: 'callee' });\n const args: unknown = AstNode.readField({ node, key: 'arguments' });\n const first = Array.isArray(args) ? args[0] : undefined;\n const event = AstNode.readField({ node: first, key: 'value' });\n\n // `matchMedia(...)`, `confirm(...)` with no `window.`.\n if (AstNode.getType({ node: callee }) === AstNodeTypes.IDENTIFIER) {\n const name = AstNode.readField({ node: callee, key: 'name' });\n\n for (const pattern of patterns) {\n if (\n pattern.match.type === 'global' &&\n typeof name === 'string' &&\n pattern.match.names.includes(name) &&\n PreferFrameworkApiRule.isGlobal({ context, node, path: name })\n ) {\n report({ node, pattern });\n }\n }\n }\n\n // `<object>.addEventListener('<event>', ...)`.\n const path = PreferFrameworkApiRule.pathOf({ node: callee });\n\n if (path === undefined || typeof event !== 'string') {\n return;\n }\n\n const parts = path.split('.');\n const method = parts.pop();\n const owner = parts.join('.');\n\n if (method !== 'addEventListener') {\n return;\n }\n\n // A listener on a socket, an element or an `EventTarget` of the author's own is not the browser's.\n const isOwnerGlobal =\n owner === '' ||\n (PreferFrameworkApiRule.isGlobal({ context, node, path: owner }) &&\n GLOBAL_TARGETS.includes(owner));\n\n for (const pattern of patterns) {\n const { match } = pattern;\n\n if (\n match.type === 'listener' &&\n match.events.includes(event) &&\n isOwnerGlobal &&\n (match.objects === undefined || owner === '' || match.objects.includes(owner))\n ) {\n report({ node, pattern });\n }\n }\n },\n [AstNodeTypes.NEW_EXPRESSION]: (node: Rule.Node) => {\n const path = PreferFrameworkApiRule.pathOf({\n node: AstNode.readField({ node, key: 'callee' }),\n });\n\n if (path === undefined || !PreferFrameworkApiRule.isGlobal({ context, node, path })) {\n return;\n }\n\n const bare = PreferFrameworkApiRule.withoutGlobalRoot({ path });\n\n for (const pattern of patterns) {\n if (pattern.match.type === 'new' && pattern.match.callees.includes(bare)) {\n report({ node, pattern });\n }\n }\n },\n };\n\n return PreferFrameworkApiRule.merge({\n listeners: [\n ...Object.entries(hooks),\n ...PreferFrameworkApiRule.rowListeners({ context, rows }),\n ],\n });\n },\n };\n\n /**\n * `hooks: false` leaves out the rows of `BrowserApiPatterns`, for code that is not React: a `use...` function of another\n * library reads as a hook. An entry that sets options replaces the earlier ones, so it states `hooks` again.\n */\n static build(\n opts: {\n severity?: TRuleSeverity;\n hooks?: boolean;\n ignore?: ReadonlyArray<string>;\n extra?: ReadonlyArray<IFrameworkApiPattern>;\n } = {},\n ): Linter.RuleEntry {\n const { severity = 'error', hooks, ignore, extra } = opts;\n // Only what was given: the option schema refuses a key whose value is `undefined`.\n const options: Record<string, unknown> = {};\n\n if (hooks !== undefined) {\n options.hooks = hooks;\n }\n\n if (ignore !== undefined) {\n options.ignore = [...ignore];\n }\n\n if (extra !== undefined) {\n options.extra = [...extra];\n }\n\n return Object.keys(options).length === 0 ? [severity] : [severity, options];\n }\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  import type { Linter, Rule } from 'eslint';
2
2
  import type { TRuleSeverity } from '../rules/common';
3
3
  /**
4
- * `venizia/prefer-promise-sleep`. A sleep written by hand, `new Promise((resolve) => setTimeout(resolve, ms))`, is
4
+ * `@venizia/prefer-promise-sleep`. A sleep written by hand, `new Promise((resolve) => setTimeout(resolve, ms))`, is
5
5
  * `PromiseUtility.sleep({ ms })` (`@venizia/ignis-helpers/core`). Only that exact shape is reported: a callback that
6
6
  * does anything else is not a sleep.
7
7
  *
@@ -9,7 +9,7 @@ import type { TRuleSeverity } from '../rules/common';
9
9
  * the fix off.
10
10
  */
11
11
  export declare class PreferPromiseSleepRule {
12
- static readonly NAME = "venizia/prefer-promise-sleep";
12
+ static readonly NAME = "@venizia/prefer-promise-sleep";
13
13
  static readonly DEFAULT_SOURCE = "@venizia/ignis-helpers/core";
14
14
  /** The `setTimeout(<resolve>, <delay>)` call a sleep callback consists of, or `undefined`. */
15
15
  private static delayOf;
@@ -4,7 +4,7 @@ exports.PreferPromiseSleepRule = void 0;
4
4
  const common_1 = require("./common");
5
5
  const import_support_1 = require("./import-support");
6
6
  /**
7
- * `venizia/prefer-promise-sleep`. A sleep written by hand, `new Promise((resolve) => setTimeout(resolve, ms))`, is
7
+ * `@venizia/prefer-promise-sleep`. A sleep written by hand, `new Promise((resolve) => setTimeout(resolve, ms))`, is
8
8
  * `PromiseUtility.sleep({ ms })` (`@venizia/ignis-helpers/core`). Only that exact shape is reported: a callback that
9
9
  * does anything else is not a sleep.
10
10
  *
@@ -88,7 +88,7 @@ class PreferPromiseSleepRule {
88
88
  },
89
89
  ],
90
90
  messages: {
91
- sleep: 'Use `await PromiseUtility.sleep({ ms })` (from @venizia/ignis-helpers/core), not a hand-written `new Promise(resolve => setTimeout(resolve, ms))`.',
91
+ sleep: "Use `await PromiseUtility.sleep({ ms })`, not a hand-written `new Promise(resolve => setTimeout(resolve, ms))`: `import { PromiseUtility } from '{{source}}';`",
92
92
  },
93
93
  },
94
94
  create: (context) => {
@@ -121,6 +121,7 @@ class PreferPromiseSleepRule {
121
121
  context.report({
122
122
  node,
123
123
  messageId: 'sleep',
124
+ data: { source: source ?? PreferPromiseSleepRule.DEFAULT_SOURCE },
124
125
  fix: (fixer) => {
125
126
  if (source === undefined &&
126
127
  !import_support_1.ImportSupport.isInScope({ context, name: 'PromiseUtility' })) {