@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
@@ -13,11 +13,12 @@ const max_params_own_rule_1 = require("./max-params-own.rule");
13
13
  const no_async_hook_callback_rule_1 = require("./no-async-hook-callback.rule");
14
14
  const no_leaked_render_rule_1 = require("./no-leaked-render.rule");
15
15
  const no_new_error_rule_1 = require("./no-new-error.rule");
16
- const no_parent_import_rule_1 = require("./no-parent-import.rule");
17
16
  const no_shadow_framework_type_rule_1 = require("./no-shadow-framework-type.rule");
18
17
  const prefer_framework_api_rule_1 = require("./prefer-framework-api.rule");
19
18
  const prefer_promise_sleep_rule_1 = require("./prefer-promise-sleep.rule");
20
19
  const prefer_tnullable_rule_1 = require("./prefer-tnullable.rule");
20
+ const typed_route_context_rule_1 = require("./typed-route-context.rule");
21
+ const zod_schema_convention_rule_1 = require("./zod-schema-convention.rule");
21
22
  const plugin_1 = require("./plugin");
22
23
  const SOURCE_FILES = ['**/*.{ts,tsx,mts,cts}'];
23
24
  const TEST_FILES = ['**/__tests__/**', '**/*.test.{ts,tsx}', '**/*.spec.{ts,tsx}'];
@@ -45,8 +46,10 @@ const houseRuleConfigs = [
45
46
  [no_shadow_framework_type_rule_1.NoShadowFrameworkTypeRule.NAME]: no_shadow_framework_type_rule_1.NoShadowFrameworkTypeRule.build(),
46
47
  [prefer_tnullable_rule_1.PreferTNullableRule.NAME]: prefer_tnullable_rule_1.PreferTNullableRule.build(),
47
48
  [prefer_promise_sleep_rule_1.PreferPromiseSleepRule.NAME]: prefer_promise_sleep_rule_1.PreferPromiseSleepRule.build(),
48
- [no_parent_import_rule_1.NoParentImportRule.NAME]: no_parent_import_rule_1.NoParentImportRule.build(),
49
+ [prefer_framework_api_rule_1.PreferFrameworkApiRule.NAME]: prefer_framework_api_rule_1.PreferFrameworkApiRule.build({ hooks: false }),
49
50
  [const_class_values_rule_1.ConstClassValuesRule.NAME]: const_class_values_rule_1.ConstClassValuesRule.build({ severity: 'warn' }),
51
+ [zod_schema_convention_rule_1.ZodSchemaConventionRule.NAME]: zod_schema_convention_rule_1.ZodSchemaConventionRule.build(),
52
+ [typed_route_context_rule_1.TypedRouteContextRule.NAME]: typed_route_context_rule_1.TypedRouteContextRule.build(),
50
53
  [NO_CAST_RULE]: ['warn', { assertionStyle: 'never' }],
51
54
  },
52
55
  },
@@ -56,7 +59,7 @@ const houseRuleConfigs = [
56
59
  [no_new_error_rule_1.NoNewErrorRule.NAME]: 'off',
57
60
  [no_shadow_framework_type_rule_1.NoShadowFrameworkTypeRule.NAME]: 'off',
58
61
  [prefer_promise_sleep_rule_1.PreferPromiseSleepRule.NAME]: 'off',
59
- [no_parent_import_rule_1.NoParentImportRule.NAME]: 'off',
62
+ [prefer_framework_api_rule_1.PreferFrameworkApiRule.NAME]: 'off',
60
63
  [const_class_values_rule_1.ConstClassValuesRule.NAME]: 'off',
61
64
  [NO_CAST_RULE]: 'off',
62
65
  },
@@ -92,8 +95,7 @@ const reactRuleConfigs = [
92
95
  ];
93
96
  /**
94
97
  * The hook rules: a hook never gets an async function (`no-async-hook-callback`), and an effect callback returns a
95
- * cleanup on every path or on none (`effect-cleanup-consistency`), and `prefer-framework-api` (a browser API ardor-react wraps
96
- * in a hook is used through the hook). Hooks live in `.ts` files too, so it covers all
98
+ * cleanup on every path or on none (`effect-cleanup-consistency`). Hooks live in `.ts` files too, so it covers all
97
99
  * source files.
98
100
  */
99
101
  const reactHookRuleConfigs = [
@@ -109,7 +111,7 @@ const reactHookRuleConfigs = [
109
111
  {
110
112
  files: SOURCE_FILES,
111
113
  plugins: { [common_1.HOUSE_PLUGIN_NAMESPACE]: plugin_1.houseEslintPlugin },
112
- rules: { [prefer_framework_api_rule_1.PreferFrameworkApiRule.NAME]: prefer_framework_api_rule_1.PreferFrameworkApiRule.build() },
114
+ rules: { [prefer_framework_api_rule_1.PreferFrameworkApiRule.NAME]: prefer_framework_api_rule_1.PreferFrameworkApiRule.build({ hooks: true }) },
113
115
  },
114
116
  { files: TEST_FILES, rules: { [prefer_framework_api_rule_1.PreferFrameworkApiRule.NAME]: 'off' } },
115
117
  ];
@@ -1 +1 @@
1
- {"version":3,"file":"configs.js","sourceRoot":"","sources":["../../../src/linters/house/configs.ts"],"names":[],"mappings":";;;AACA,sCAAoD;AACpD,4CAAyC;AACzC,wCAA4C;AAC5C,kDAA+D;AAC/D,+CAAiD;AACjD,qCAAkD;AAClD,uEAAiE;AACjE,uFAAiF;AACjF,+DAAyD;AACzD,+EAAwE;AACxE,mEAA6D;AAC7D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yJAAyJ;AAC5I,QAAA,iBAAiB,GAAoB;IAChD,GAAG,2CAA4B;IAC/B,GAAG,gBAAgB;IACnB,GAAG,8BAAgB;IACnB,GAAG,wBAAc;IACjB,GAAG,gBAAgB;IACnB,GAAG,oBAAoB;CACxB,CAAC","sourcesContent":["import type { Linter } from 'eslint';\nimport { namingConventionConfigs } from '../eslint';\nimport { JSX_FILES } from '../jsx-files';\nimport { paddingConfigs } from '../padding';\nimport { reactNamingConventionConfigs } from '../react-eslint';\nimport { asyncRuleConfigs } from './async-rules';\nimport { HOUSE_PLUGIN_NAMESPACE } from './common';\nimport { ConstClassValuesRule } from './const-class-values.rule';\nimport { EffectCleanupConsistencyRule } from './effect-cleanup-consistency.rule';\nimport { MaxParamsOwnRule } from './max-params-own.rule';\nimport { NoAsyncHookCallbackRule } from './no-async-hook-callback.rule';\nimport { NoLeakedRenderRule } from './no-leaked-render.rule';\nimport { NoNewErrorRule } from './no-new-error.rule';\nimport { NoParentImportRule } from './no-parent-import.rule';\nimport { NoShadowFrameworkTypeRule } from './no-shadow-framework-type.rule';\nimport { PreferFrameworkApiRule } from './prefer-framework-api.rule';\nimport { PreferPromiseSleepRule } from './prefer-promise-sleep.rule';\nimport { PreferTNullableRule } from './prefer-tnullable.rule';\nimport { houseEslintPlugin } from './plugin';\n\nconst SOURCE_FILES = ['**/*.{ts,tsx,mts,cts}'];\nconst TEST_FILES = ['**/__tests__/**', '**/*.test.{ts,tsx}', '**/*.spec.{ts,tsx}'];\n\n/**\n * V-C-10: no explicit cast. `as const` is always allowed; `satisfies`, a generic or a narrower type\n * replaces the rest.\n */\nconst NO_CAST_RULE = '@typescript-eslint/consistent-type-assertions';\n\n/**\n * The house rules: at most 5 positional parameters on a function we write, and errors thrown through\n * `getError` only. Tests are exempt from `no-new-error`: a test throws a plain `Error` on purpose, to\n * stand in for what a driver or a third-party library throws.\n *\n * Two rules only warn, so a project adopts them without failing its lint: `const-class-values` (V-C-08, a\n * string-literal union in an exported declaration) and `consistent-type-assertions` (V-C-10, an `as X`\n * cast). Tests are exempt from both: a test stubs what it does not build.\n */\nconst houseRuleConfigs: Linter.Config[] = [\n {\n files: SOURCE_FILES,\n plugins: { [HOUSE_PLUGIN_NAMESPACE]: houseEslintPlugin },\n rules: {\n [MaxParamsOwnRule.NAME]: MaxParamsOwnRule.build(),\n [NoNewErrorRule.NAME]: NoNewErrorRule.build(),\n [NoShadowFrameworkTypeRule.NAME]: NoShadowFrameworkTypeRule.build(),\n [PreferTNullableRule.NAME]: PreferTNullableRule.build(),\n [PreferPromiseSleepRule.NAME]: PreferPromiseSleepRule.build(),\n [NoParentImportRule.NAME]: NoParentImportRule.build(),\n [ConstClassValuesRule.NAME]: ConstClassValuesRule.build({ severity: 'warn' }),\n [NO_CAST_RULE]: ['warn', { assertionStyle: 'never' }],\n },\n },\n {\n files: TEST_FILES,\n rules: {\n [NoNewErrorRule.NAME]: 'off',\n [NoShadowFrameworkTypeRule.NAME]: 'off',\n [PreferPromiseSleepRule.NAME]: 'off',\n [NoParentImportRule.NAME]: 'off',\n [ConstClassValuesRule.NAME]: 'off',\n [NO_CAST_RULE]: 'off',\n },\n },\n];\n\n/**\n * The ESLint side of a project that lints with oxlint: the naming convention, the house rules and the async style\n * rules - everything oxlint cannot express. Run it next to `oxlintConfigs`.\n *\n * ```js\n * // .configs/lints/eslint.config.mjs\n * import { houseConfigs } from '@venizia/dev-configs/linters';\n *\n * export default houseConfigs;\n * ```\n */\nexport const houseConfigs: Linter.Config[] = [\n ...namingConventionConfigs,\n ...houseRuleConfigs,\n ...asyncRuleConfigs,\n ...paddingConfigs,\n];\n\n/**\n * The React house rule: a JSX child is drawn with `cond ? <X /> : null`, never `cond && <X />`, which\n * draws `0` when `cond` is `0`.\n */\nconst reactRuleConfigs: Linter.Config[] = [\n {\n files: JSX_FILES,\n plugins: { [HOUSE_PLUGIN_NAMESPACE]: houseEslintPlugin },\n rules: { [NoLeakedRenderRule.NAME]: NoLeakedRenderRule.build() },\n },\n];\n\n/**\n * The hook rules: a hook never gets an async function (`no-async-hook-callback`), and an effect callback returns a\n * cleanup on every path or on none (`effect-cleanup-consistency`), and `prefer-framework-api` (a browser API ardor-react wraps\n * in a hook is used through the hook). Hooks live in `.ts` files too, so it covers all\n * source files.\n */\nconst reactHookRuleConfigs: Linter.Config[] = [\n {\n files: SOURCE_FILES,\n plugins: { [HOUSE_PLUGIN_NAMESPACE]: houseEslintPlugin },\n rules: {\n [NoAsyncHookCallbackRule.NAME]: NoAsyncHookCallbackRule.build(),\n [EffectCleanupConsistencyRule.NAME]: EffectCleanupConsistencyRule.build(),\n },\n },\n // A hook or a util in a `.ts` file reaches the browser as well as a component does; a test stubs the browser on purpose.\n {\n files: SOURCE_FILES,\n plugins: { [HOUSE_PLUGIN_NAMESPACE]: houseEslintPlugin },\n rules: { [PreferFrameworkApiRule.NAME]: PreferFrameworkApiRule.build() },\n },\n { files: TEST_FILES, rules: { [PreferFrameworkApiRule.NAME]: 'off' } },\n];\n\n/** `houseConfigs` for a React project: `reactNamingConventionConfigs`, the house rules, the async style rules, `no-leaked-render` and the hook rules. */\nexport const reactHouseConfigs: Linter.Config[] = [\n ...reactNamingConventionConfigs,\n ...houseRuleConfigs,\n ...asyncRuleConfigs,\n ...paddingConfigs,\n ...reactRuleConfigs,\n ...reactHookRuleConfigs,\n];\n"]}
1
+ {"version":3,"file":"configs.js","sourceRoot":"","sources":["../../../src/linters/house/configs.ts"],"names":[],"mappings":";;;AACA,sCAAoD;AACpD,4CAAyC;AACzC,wCAA4C;AAC5C,kDAA+D;AAC/D,+CAAiD;AACjD,qCAAkD;AAClD,uEAAiE;AACjE,uFAAiF;AACjF,+DAAyD;AACzD,+EAAwE;AACxE,mEAA6D;AAC7D,2DAAqD;AACrD,mFAA4E;AAC5E,2EAAqE;AACrE,2EAAqE;AACrE,mEAA8D;AAC9D,yEAAmE;AACnE,6EAAuE;AACvE,qCAA6C;AAE7C,MAAM,YAAY,GAAG,CAAC,uBAAuB,CAAC,CAAC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AAsB,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,EAAE;CACvE,CAAC;AAEF,yJAAyJ;AAC5I,QAAA,iBAAiB,GAAoB;IAChD,GAAG,2CAA4B;IAC/B,GAAG,gBAAgB;IACnB,GAAG,8BAAgB;IACnB,GAAG,wBAAc;IACjB,GAAG,gBAAgB;IACnB,GAAG,oBAAoB;CACxB,CAAC","sourcesContent":["import type { Linter } from 'eslint';\nimport { namingConventionConfigs } from '../eslint';\nimport { JSX_FILES } from '../jsx-files';\nimport { paddingConfigs } from '../padding';\nimport { reactNamingConventionConfigs } from '../react-eslint';\nimport { asyncRuleConfigs } from './async-rules';\nimport { HOUSE_PLUGIN_NAMESPACE } from './common';\nimport { ConstClassValuesRule } from './const-class-values.rule';\nimport { EffectCleanupConsistencyRule } from './effect-cleanup-consistency.rule';\nimport { MaxParamsOwnRule } from './max-params-own.rule';\nimport { NoAsyncHookCallbackRule } from './no-async-hook-callback.rule';\nimport { NoLeakedRenderRule } from './no-leaked-render.rule';\nimport { NoNewErrorRule } from './no-new-error.rule';\nimport { NoShadowFrameworkTypeRule } from './no-shadow-framework-type.rule';\nimport { PreferFrameworkApiRule } from './prefer-framework-api.rule';\nimport { PreferPromiseSleepRule } from './prefer-promise-sleep.rule';\nimport { PreferTNullableRule } from './prefer-tnullable.rule';\nimport { TypedRouteContextRule } from './typed-route-context.rule';\nimport { ZodSchemaConventionRule } from './zod-schema-convention.rule';\nimport { houseEslintPlugin } from './plugin';\n\nconst SOURCE_FILES = ['**/*.{ts,tsx,mts,cts}'];\nconst TEST_FILES = ['**/__tests__/**', '**/*.test.{ts,tsx}', '**/*.spec.{ts,tsx}'];\n\n/**\n * V-C-10: no explicit cast. `as const` is always allowed; `satisfies`, a generic or a narrower type\n * replaces the rest.\n */\nconst NO_CAST_RULE = '@typescript-eslint/consistent-type-assertions';\n\n/**\n * The house rules: at most 5 positional parameters on a function we write, and errors thrown through\n * `getError` only. Tests are exempt from `no-new-error`: a test throws a plain `Error` on purpose, to\n * stand in for what a driver or a third-party library throws.\n *\n * Two rules only warn, so a project adopts them without failing its lint: `const-class-values` (V-C-08, a\n * string-literal union in an exported declaration) and `consistent-type-assertions` (V-C-10, an `as X`\n * cast). Tests are exempt from both: a test stubs what it does not build.\n */\nconst houseRuleConfigs: Linter.Config[] = [\n {\n files: SOURCE_FILES,\n plugins: { [HOUSE_PLUGIN_NAMESPACE]: houseEslintPlugin },\n rules: {\n [MaxParamsOwnRule.NAME]: MaxParamsOwnRule.build(),\n [NoNewErrorRule.NAME]: NoNewErrorRule.build(),\n [NoShadowFrameworkTypeRule.NAME]: NoShadowFrameworkTypeRule.build(),\n [PreferTNullableRule.NAME]: PreferTNullableRule.build(),\n [PreferPromiseSleepRule.NAME]: PreferPromiseSleepRule.build(),\n [PreferFrameworkApiRule.NAME]: PreferFrameworkApiRule.build({ hooks: false }),\n [ConstClassValuesRule.NAME]: ConstClassValuesRule.build({ severity: 'warn' }),\n [ZodSchemaConventionRule.NAME]: ZodSchemaConventionRule.build(),\n [TypedRouteContextRule.NAME]: TypedRouteContextRule.build(),\n [NO_CAST_RULE]: ['warn', { assertionStyle: 'never' }],\n },\n },\n {\n files: TEST_FILES,\n rules: {\n [NoNewErrorRule.NAME]: 'off',\n [NoShadowFrameworkTypeRule.NAME]: 'off',\n [PreferPromiseSleepRule.NAME]: 'off',\n [PreferFrameworkApiRule.NAME]: 'off',\n [ConstClassValuesRule.NAME]: 'off',\n [NO_CAST_RULE]: 'off',\n },\n },\n];\n\n/**\n * The ESLint side of a project that lints with oxlint: the naming convention, the house rules and the async style\n * rules - everything oxlint cannot express. Run it next to `oxlintConfigs`.\n *\n * ```js\n * // .configs/lints/eslint.config.mjs\n * import { houseConfigs } from '@venizia/dev-configs/linters';\n *\n * export default houseConfigs;\n * ```\n */\nexport const houseConfigs: Linter.Config[] = [\n ...namingConventionConfigs,\n ...houseRuleConfigs,\n ...asyncRuleConfigs,\n ...paddingConfigs,\n];\n\n/**\n * The React house rule: a JSX child is drawn with `cond ? <X /> : null`, never `cond && <X />`, which\n * draws `0` when `cond` is `0`.\n */\nconst reactRuleConfigs: Linter.Config[] = [\n {\n files: JSX_FILES,\n plugins: { [HOUSE_PLUGIN_NAMESPACE]: houseEslintPlugin },\n rules: { [NoLeakedRenderRule.NAME]: NoLeakedRenderRule.build() },\n },\n];\n\n/**\n * The hook rules: a hook never gets an async function (`no-async-hook-callback`), and an effect callback returns a\n * cleanup on every path or on none (`effect-cleanup-consistency`). Hooks live in `.ts` files too, so it covers all\n * source files.\n */\nconst reactHookRuleConfigs: Linter.Config[] = [\n {\n files: SOURCE_FILES,\n plugins: { [HOUSE_PLUGIN_NAMESPACE]: houseEslintPlugin },\n rules: {\n [NoAsyncHookCallbackRule.NAME]: NoAsyncHookCallbackRule.build(),\n [EffectCleanupConsistencyRule.NAME]: EffectCleanupConsistencyRule.build(),\n },\n },\n // A hook or a util in a `.ts` file reaches the browser as well as a component does; a test stubs the browser on purpose.\n {\n files: SOURCE_FILES,\n plugins: { [HOUSE_PLUGIN_NAMESPACE]: houseEslintPlugin },\n rules: { [PreferFrameworkApiRule.NAME]: PreferFrameworkApiRule.build({ hooks: true }) },\n },\n { files: TEST_FILES, rules: { [PreferFrameworkApiRule.NAME]: 'off' } },\n];\n\n/** `houseConfigs` for a React project: `reactNamingConventionConfigs`, the house rules, the async style rules, `no-leaked-render` and the hook rules. */\nexport const reactHouseConfigs: Linter.Config[] = [\n ...reactNamingConventionConfigs,\n ...houseRuleConfigs,\n ...asyncRuleConfigs,\n ...paddingConfigs,\n ...reactRuleConfigs,\n ...reactHookRuleConfigs,\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/const-class-values`. An enumerable string is a const class plus `TConstValue<typeof X>`,
4
+ * `@venizia/const-class-values`. An enumerable string is a const class plus `TConstValue<typeof X>`,
5
5
  * never a union of string literals in an exported declaration: a type alias, an interface member, a
6
6
  * generic constraint, a parameter or a return type of an exported function or class.
7
7
  *
@@ -11,7 +11,7 @@ import type { TRuleSeverity } from '../rules/common';
11
11
  * matches it (`(State|Status)$`), for a project that adopts the rule one name at a time.
12
12
  */
13
13
  export declare class ConstClassValuesRule {
14
- static readonly NAME = "venizia/const-class-values";
14
+ static readonly NAME = "@venizia/const-class-values";
15
15
  static readonly RULE: Rule.RuleModule;
16
16
  static build(opts?: {
17
17
  severity?: TRuleSeverity;
@@ -4,6 +4,12 @@ exports.ConstClassValuesRule = void 0;
4
4
  const common_1 = require("./common");
5
5
  /** Utility types whose type argument is a set of keys, not an enumerable value: `Pick<T, 'a' | 'b'>`. */
6
6
  const KEY_SET_TYPES = new Set(['Pick', 'Omit', 'Extract', 'Exclude', 'Record']);
7
+ /** The node types that take type arguments, each with the field that holds the type's name. */
8
+ const TYPE_NAME_KEYS = new Map([
9
+ [common_1.AstNodeTypes.TYPE_REFERENCE, 'typeName'],
10
+ [common_1.AstNodeTypes.INTERFACE_HERITAGE, 'expression'],
11
+ [common_1.AstNodeTypes.CLASS_IMPLEMENTS, 'expression'],
12
+ ]);
7
13
  /** The union is a type argument of a key-set utility type, or the key range of a mapped type. */
8
14
  const isKeySet = (opts) => {
9
15
  const parent = common_1.AstNode.readField({ node: opts.node, key: 'parent' });
@@ -14,12 +20,15 @@ const isKeySet = (opts) => {
14
20
  return false;
15
21
  }
16
22
  const reference = common_1.AstNode.readField({ node: parent, key: 'parent' });
23
+ const key = TYPE_NAME_KEYS.get(String(common_1.AstNode.getType({ node: reference })));
24
+ if (key === undefined) {
25
+ return false;
26
+ }
17
27
  const name = common_1.AstNode.readField({
18
- node: common_1.AstNode.readField({ node: reference, key: 'typeName' }),
28
+ node: common_1.AstNode.readField({ node: reference, key }),
19
29
  key: 'name',
20
30
  });
21
- return (common_1.AstNode.getType({ node: reference }) === common_1.AstNodeTypes.TYPE_REFERENCE &&
22
- KEY_SET_TYPES.has(String(name)));
31
+ return KEY_SET_TYPES.has(String(name));
23
32
  };
24
33
  /** The statement of the module that holds the node: the node's last ancestor before `Program`. */
25
34
  const topLevelStatement = (opts) => {
@@ -46,7 +55,7 @@ const isNullish = (opts) => {
46
55
  return type === common_1.AstNodeTypes.NULL_KEYWORD || type === common_1.AstNodeTypes.UNDEFINED_KEYWORD;
47
56
  };
48
57
  /**
49
- * `venizia/const-class-values`. An enumerable string is a const class plus `TConstValue<typeof X>`,
58
+ * `@venizia/const-class-values`. An enumerable string is a const class plus `TConstValue<typeof X>`,
50
59
  * never a union of string literals in an exported declaration: a type alias, an interface member, a
51
60
  * generic constraint, a parameter or a return type of an exported function or class.
52
61
  *
@@ -62,7 +71,7 @@ class ConstClassValuesRule {
62
71
  type: 'suggestion',
63
72
  schema: [{ type: 'object', properties: { namePattern: { type: 'string' } } }],
64
73
  messages: {
65
- constClass: 'An enumerable string is a const class plus TConstValue<typeof X>, not a union of string literals.',
74
+ constClass: "An enumerable string is a class that extends `ConstClass`, typed as `TConstValue<typeof X>`, not a union of string literals: `import { ConstClass, type TConstValue } from '@venizia/ignis-helpers/common';`",
66
75
  },
67
76
  },
68
77
  create: (context) => {
@@ -1 +1 @@
1
- {"version":3,"file":"const-class-values.rule.js","sourceRoot":"","sources":["../../../src/linters/house/const-class-values.rule.ts"],"names":[],"mappings":";;;AAEA,qCAAyE;AAEzE,yGAAyG;AACzG,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC;AAEhF,iGAAiG;AACjG,MAAM,QAAQ,GAAG,CAAC,IAAuB,EAAW,EAAE;IACpD,MAAM,MAAM,GAAG,gBAAO,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC,CAAC;IAErE,IAAI,gBAAO,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,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N_NAMESPACE } from './common';\n\n/** Utility types whose type argument is a set of keys, not an enumerable value: `Pick<T, 'a' | 'b'>`. */\nconst KEY_SET_TYPES = new Set(['Pick', 'Omit', 'Extract', 'Exclude', 'Record']);\n\n/** The union is a type argument of a key-set utility type, or the key range of a mapped type. */\nconst isKeySet = (opts: { node: unknown }): boolean => {\n const parent = AstNode.readField({ node: opts.node, key: 'parent' });\n\n if (AstNode.getType({ node: parent }) === AstNodeTypes.MAPPED_TYPE) {\n return true;\n }\n\n if (AstNode.getType({ node: parent }) !== AstNodeTypes.TYPE_PARAMETER_INSTANTIATION) {\n return false;\n }\n\n const reference = AstNode.readField({ node: parent, key: 'parent' });\n const name = AstNode.readField({\n node: AstNode.readField({ node: reference, key: 'typeName' }),\n key: 'name',\n });\n\n return (\n AstNode.getType({ node: reference }) === AstNodeTypes.TYPE_REFERENCE &&\n KEY_SET_TYPES.has(String(name))\n );\n};\n\n/** The statement of the module that holds the node: the node's last ancestor before `Program`. */\nconst topLevelStatement = (opts: { node: unknown }): unknown => {\n let current = opts.node;\n\n while (current) {\n const parent = AstNode.readField({ node: current, key: 'parent' });\n\n if (AstNode.getType({ node: parent }) === AstNodeTypes.PROGRAM) {\n return current;\n }\n\n current = parent;\n }\n\n return undefined;\n};\n\nconst isStringLiteral = (opts: { member: unknown }): boolean => {\n const { member } = opts;\n\n return (\n AstNode.getType({ node: member }) === AstNodeTypes.LITERAL_TYPE &&\n typeof AstNode.readField({\n node: AstNode.readField({ node: member, key: 'literal' }),\n key: 'value',\n }) === 'string'\n );\n};\n\nconst isNullish = (opts: { member: unknown }): boolean => {\n const type = AstNode.getType({ node: opts.member });\n\n return type === AstNodeTypes.NULL_KEYWORD || type === AstNodeTypes.UNDEFINED_KEYWORD;\n};\n\n/**\n * `venizia/const-class-values`. An enumerable string is a const class plus `TConstValue<typeof X>`,\n * never a union of string literals in an exported declaration: a type alias, an interface member, a\n * generic constraint, a parameter or a return type of an exported function or class.\n *\n * Not counted: a union that is not all string literals (a `null` or `undefined` member is ignored),\n * a key set (`Pick`, `Omit`, `Extract`, `Exclude`, `Record` arguments and mapped-type keys), and a\n * declaration that is not exported. `namePattern` narrows the rule to exported type aliases whose name\n * matches it (`(State|Status)$`), for a project that adopts the rule one name at a time.\n */\nexport class ConstClassValuesRule {\n static readonly NAME = `${HOUSE_PLUGIN_NAMESPACE}/const-class-values`;\n\n static readonly RULE: Rule.RuleModule = {\n meta: {\n type: 'suggestion',\n schema: [{ type: 'object', properties: { namePattern: { type: 'string' } } }],\n messages: {\n constClass:\n 'An enumerable string is a const class plus TConstValue<typeof X>, not a union of string literals.',\n },\n },\n create: (context) => {\n const options: unknown = context.options[0];\n const configured = AstNode.readField({ node: options, key: 'namePattern' });\n const namePattern = typeof configured === 'string' ? new RegExp(configured) : undefined;\n\n const isNamed = (opts: { statement: unknown; node: unknown }) => {\n const { statement, node } = opts;\n const declaration = AstNode.readField({ node: statement, key: 'declaration' });\n const name = AstNode.readField({\n node: AstNode.readField({ node: declaration, key: 'id' }),\n key: 'name',\n });\n\n return (\n namePattern === undefined ||\n (AstNode.getType({ node: declaration }) === AstNodeTypes.TYPE_ALIAS_DECLARATION &&\n AstNode.readField({ node: declaration, key: 'typeAnnotation' }) === node &&\n typeof name === 'string' &&\n namePattern.test(name))\n );\n };\n\n return {\n [AstNodeTypes.UNION_TYPE]: (node: Rule.Node) => {\n const members = AstNode.readField({ node, key: 'types' });\n\n if (!Array.isArray(members)) {\n return;\n }\n\n const values = members.filter((member) => !isNullish({ member }));\n\n if (values.length < 2 || !values.every((member) => isStringLiteral({ member }))) {\n return;\n }\n\n const statement = topLevelStatement({ node });\n const statementType = AstNode.getType({ node: statement });\n const isExported =\n statementType === AstNodeTypes.EXPORT_NAMED_DECLARATION ||\n statementType === AstNodeTypes.EXPORT_DEFAULT_DECLARATION;\n\n if (!isExported || isKeySet({ node }) || !isNamed({ statement, node })) {\n return;\n }\n\n context.report({ node, messageId: 'constClass' });\n },\n };\n },\n };\n\n static build(opts: { severity?: TRuleSeverity; namePattern?: string } = {}): Linter.RuleEntry {\n const { severity = 'error', namePattern } = opts;\n\n return namePattern === undefined ? [severity] : [severity, { namePattern }];\n }\n}\n"]}
1
+ {"version":3,"file":"const-class-values.rule.js","sourceRoot":"","sources":["../../../src/linters/house/const-class-values.rule.ts"],"names":[],"mappings":";;;AAEA,qCAAyE;AAEzE,yGAAyG;AACzG,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC;AAEhF,+FAA+F;AAC/F,MAAM,cAAc,GAAgC,IAAI,GAAG,CAAC;IAC1D,CAAC,qBAAY,CAAC,cAAc,EAAE,UAAU,CAAC;IACzC,CAAC,qBAAY,CAAC,kBAAkB,EAAE,YAAY,CAAC;IAC/C,CAAC,qBAAY,CAAC,gBAAgB,EAAE,YAAY,CAAC;CAC9C,CAAC,CAAC;AAEH,iGAAiG;AACjG,MAAM,QAAQ,GAAG,CAAC,IAAuB,EAAW,EAAE;IACpD,MAAM,MAAM,GAAG,gBAAO,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC,CAAC;IAErE,IAAI,gBAAO,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,KAAK,qBAAY,CAAC,WAAW,EAAE,CAAC;QACnE,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,gBAAO,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,KAAK,qBAAY,CAAC,4BAA4B,EAAE,CAAC;QACpF,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,SAAS,GAAG,gBAAO,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC,CAAC;IACrE,MAAM,GAAG,GAAG,cAAc,CAA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F,OAAO;oBACT,CAAC;oBAED,MAAM,SAAS,GAAG,iBAAiB,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;oBAC9C,MAAM,aAAa,GAAG,gBAAO,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;oBAC3D,MAAM,UAAU,GACd,aAAa,KAAK,qBAAY,CAAC,wBAAwB;wBACvD,aAAa,KAAK,qBAAY,CAAC,0BAA0B,CAAC;oBAE5D,IAAI,CAAC,UAAU,IAAI,QAAQ,CAAC,EAAE,IAAI,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;wBACvE,OAAO;oBACT,CAAC;oBAED,OAAO,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC,CAAC;gBACpD,CAAC;aACF,CAAC;QACJ,CAAC;KACF,CAAC;IAEF,MAAM,CAAC,KAAK,CAAC,OAA2D,EAAE;QACxE,MAAM,EAAE,QAAQ,GAAG,OAAO,EAAE,WAAW,EAAE,GAAG,IAAI,CAAC;QAEjD,OAAO,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,EAAE,WAAW,EAAE,CAAC,CAAC;IAC9E,CAAC;;AApEH,oDAqEC","sourcesContent":["import type { Linter, Rule } from 'eslint';\nimport type { TRuleSeverity } from '../rules/common';\nimport { AstNode, AstNodeTypes, HOUSE_PLUGIN_NAMESPACE } from './common';\n\n/** Utility types whose type argument is a set of keys, not an enumerable value: `Pick<T, 'a' | 'b'>`. */\nconst KEY_SET_TYPES = new Set(['Pick', 'Omit', 'Extract', 'Exclude', 'Record']);\n\n/** The node types that take type arguments, each with the field that holds the type's name. */\nconst TYPE_NAME_KEYS: ReadonlyMap<string, string> = new Map([\n [AstNodeTypes.TYPE_REFERENCE, 'typeName'],\n [AstNodeTypes.INTERFACE_HERITAGE, 'expression'],\n [AstNodeTypes.CLASS_IMPLEMENTS, 'expression'],\n]);\n\n/** The union is a type argument of a key-set utility type, or the key range of a mapped type. */\nconst isKeySet = (opts: { node: unknown }): boolean => {\n const parent = AstNode.readField({ node: opts.node, key: 'parent' });\n\n if (AstNode.getType({ node: parent }) === AstNodeTypes.MAPPED_TYPE) {\n return true;\n }\n\n if (AstNode.getType({ node: parent }) !== AstNodeTypes.TYPE_PARAMETER_INSTANTIATION) {\n return false;\n }\n\n const reference = AstNode.readField({ node: parent, key: 'parent' });\n const key = TYPE_NAME_KEYS.get(String(AstNode.getType({ node: reference })));\n\n if (key === undefined) {\n return false;\n }\n\n const name = AstNode.readField({\n node: AstNode.readField({ node: reference, key }),\n key: 'name',\n });\n\n return KEY_SET_TYPES.has(String(name));\n};\n\n/** The statement of the module that holds the node: the node's last ancestor before `Program`. */\nconst topLevelStatement = (opts: { node: unknown }): unknown => {\n let current = opts.node;\n\n while (current) {\n const parent = AstNode.readField({ node: current, key: 'parent' });\n\n if (AstNode.getType({ node: parent }) === AstNodeTypes.PROGRAM) {\n return current;\n }\n\n current = parent;\n }\n\n return undefined;\n};\n\nconst isStringLiteral = (opts: { member: unknown }): boolean => {\n const { member } = opts;\n\n return (\n AstNode.getType({ node: member }) === AstNodeTypes.LITERAL_TYPE &&\n typeof AstNode.readField({\n node: AstNode.readField({ node: member, key: 'literal' }),\n key: 'value',\n }) === 'string'\n );\n};\n\nconst isNullish = (opts: { member: unknown }): boolean => {\n const type = AstNode.getType({ node: opts.member });\n\n return type === AstNodeTypes.NULL_KEYWORD || type === AstNodeTypes.UNDEFINED_KEYWORD;\n};\n\n/**\n * `@venizia/const-class-values`. An enumerable string is a const class plus `TConstValue<typeof X>`,\n * never a union of string literals in an exported declaration: a type alias, an interface member, a\n * generic constraint, a parameter or a return type of an exported function or class.\n *\n * Not counted: a union that is not all string literals (a `null` or `undefined` member is ignored),\n * a key set (`Pick`, `Omit`, `Extract`, `Exclude`, `Record` arguments and mapped-type keys), and a\n * declaration that is not exported. `namePattern` narrows the rule to exported type aliases whose name\n * matches it (`(State|Status)$`), for a project that adopts the rule one name at a time.\n */\nexport class ConstClassValuesRule {\n static readonly NAME = `${HOUSE_PLUGIN_NAMESPACE}/const-class-values`;\n\n static readonly RULE: Rule.RuleModule = {\n meta: {\n type: 'suggestion',\n schema: [{ type: 'object', properties: { namePattern: { type: 'string' } } }],\n messages: {\n constClass:\n \"An enumerable string is a class that extends `ConstClass`, typed as `TConstValue<typeof X>`, not a union of string literals: `import { ConstClass, type TConstValue } from '@venizia/ignis-helpers/common';`\",\n },\n },\n create: (context) => {\n const options: unknown = context.options[0];\n const configured = AstNode.readField({ node: options, key: 'namePattern' });\n const namePattern = typeof configured === 'string' ? new RegExp(configured) : undefined;\n\n const isNamed = (opts: { statement: unknown; node: unknown }) => {\n const { statement, node } = opts;\n const declaration = AstNode.readField({ node: statement, key: 'declaration' });\n const name = AstNode.readField({\n node: AstNode.readField({ node: declaration, key: 'id' }),\n key: 'name',\n });\n\n return (\n namePattern === undefined ||\n (AstNode.getType({ node: declaration }) === AstNodeTypes.TYPE_ALIAS_DECLARATION &&\n AstNode.readField({ node: declaration, key: 'typeAnnotation' }) === node &&\n typeof name === 'string' &&\n namePattern.test(name))\n );\n };\n\n return {\n [AstNodeTypes.UNION_TYPE]: (node: Rule.Node) => {\n const members = AstNode.readField({ node, key: 'types' });\n\n if (!Array.isArray(members)) {\n return;\n }\n\n const values = members.filter((member) => !isNullish({ member }));\n\n if (values.length < 2 || !values.every((member) => isStringLiteral({ member }))) {\n return;\n }\n\n const statement = topLevelStatement({ node });\n const statementType = AstNode.getType({ node: statement });\n const isExported =\n statementType === AstNodeTypes.EXPORT_NAMED_DECLARATION ||\n statementType === AstNodeTypes.EXPORT_DEFAULT_DECLARATION;\n\n if (!isExported || isKeySet({ node }) || !isNamed({ statement, node })) {\n return;\n }\n\n context.report({ node, messageId: 'constClass' });\n },\n };\n },\n };\n\n static build(opts: { severity?: TRuleSeverity; namePattern?: string } = {}): Linter.RuleEntry {\n const { severity = 'error', namePattern } = opts;\n\n return namePattern === undefined ? [severity] : [severity, { namePattern }];\n }\n}\n"]}
@@ -1,14 +1,14 @@
1
1
  import type { Rule } from 'eslint';
2
2
  import type { TRuleSeverity } from '../rules/common';
3
3
  /**
4
- * `venizia/effect-cleanup-consistency`. The callback of `useEffect`, `useLayoutEffect` and `useInsertionEffect`
4
+ * `@venizia/effect-cleanup-consistency`. The callback of `useEffect`, `useLayoutEffect` and `useInsertionEffect`
5
5
  * returns a cleanup on every path or on none. An early `return;` beside a later `return () => {}` leaves React
6
6
  * with a cleanup on some runs only; the early exit returns a no-op instead. A bare `return;` and falling off the
7
7
  * end both mean "no value". It uses ESLint's code path analysis the way `consistent-return` does, so an
8
8
  * unreachable end of the function is not a path. A nested function's own `return` is not counted.
9
9
  */
10
10
  export declare class EffectCleanupConsistencyRule {
11
- static readonly NAME = "venizia/effect-cleanup-consistency";
11
+ static readonly NAME = "@venizia/effect-cleanup-consistency";
12
12
  static readonly RULE: Rule.RuleModule;
13
13
  static build(opts?: {
14
14
  severity?: TRuleSeverity;
@@ -4,7 +4,7 @@ exports.EffectCleanupConsistencyRule = void 0;
4
4
  const common_1 = require("./common");
5
5
  const hook_support_1 = require("./hook-support");
6
6
  /**
7
- * `venizia/effect-cleanup-consistency`. The callback of `useEffect`, `useLayoutEffect` and `useInsertionEffect`
7
+ * `@venizia/effect-cleanup-consistency`. The callback of `useEffect`, `useLayoutEffect` and `useInsertionEffect`
8
8
  * returns a cleanup on every path or on none. An early `return;` beside a later `return () => {}` leaves React
9
9
  * with a cleanup on some runs only; the early exit returns a no-op instead. A bare `return;` and falling off the
10
10
  * end both mean "no value". It uses ESLint's code path analysis the way `consistent-return` does, so an
@@ -1 +1 @@
1
- {"version":3,"file":"effect-cleanup-consistency.rule.js","sourceRoot":"","sources":["../../../src/linters/house/effect-cleanup-consistency.rule.ts"],"names":[],"mappings":";;;AAEA,qCAA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E,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC;gBAC7E,CAAC,qBAAY,CAAC,gBAAgB,CAAC,EAAE,CAAC,IAAe,EAAE,EAAE;oBACnD,IAAI,CAAC,KAAK,EAAE,CAAC;wBACX,OAAO;oBACT,CAAC;oBAED,IAAI,gBAAO,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC;wBACjD,KAAK,CAAC,YAAY,GAAG,IAAI,CAAC;oBAC5B,CAAC;yBAAM,CAAC;wBACN,KAAK,CAAC,cAAc,GAAG,IAAI,CAAC;oBAC9B,CAAC;gBACH,CAAC;gBACD,yBAAyB,EAAE,SAAS;gBACpC,8BAA8B,EAAE,SAAS;aAC1C,CAAC;QACJ,CAAC;KACF,CAAC;IAEF,MAAM,CAAC,KAAK,CAAC,OAAqC,EAAE;QAClD,OAAO,IAAI,CAAC,QAAQ,IAAI,OAAO,CAAC;IAClC,CAAC;;AAtFH,oEAuFC","sourcesContent":["import type { Rule } from 'eslint';\nimport type { TRuleSeverity } from '../rules/common';\nimport { AstNode, AstNodeTypes, HOUSE_PLUGIN_NAMESPACE } from './common';\nimport { HookSupport } from './hook-support';\n\n/** What the rule knows about the function whose code path is open; one per function, so a nested function is its own. */\ninterface IFunctionFrame {\n upper: IFunctionFrame | undefined;\n hook: string | undefined;\n returnsValue: boolean;\n returnsNothing: boolean;\n segments: Set<{ reachable: boolean }>;\n}\n\n/**\n * `venizia/effect-cleanup-consistency`. The callback of `useEffect`, `useLayoutEffect` and `useInsertionEffect`\n * returns a cleanup on every path or on none. An early `return;` beside a later `return () => {}` leaves React\n * with a cleanup on some runs only; the early exit returns a no-op instead. A bare `return;` and falling off the\n * end both mean \"no value\". It uses ESLint's code path analysis the way `consistent-return` does, so an\n * unreachable end of the function is not a path. A nested function's own `return` is not counted.\n */\nexport class EffectCleanupConsistencyRule {\n static readonly NAME = `${HOUSE_PLUGIN_NAMESPACE}/effect-cleanup-consistency`;\n\n static readonly RULE: Rule.RuleModule = {\n meta: {\n type: 'problem',\n schema: [],\n messages: {\n inconsistent:\n 'The callback of `{{hook}}` returns a cleanup on some paths only; return one on every path (a no-op `() => {}` for an early exit) or on none.',\n },\n },\n create: (context) => {\n const targets = new Map<unknown, string>();\n let frame: IFunctionFrame | undefined;\n\n const checkExit = (node: Rule.Node) => {\n const current = frame;\n\n if (\n !current?.hook ||\n AstNode.getType({ node: AstNode.readField({ node, key: 'body' }) }) !==\n AstNodeTypes.BLOCK_STATEMENT\n ) {\n return;\n }\n\n const endIsReachable = [...current.segments].some((segment) => segment.reachable);\n\n if (current.returnsValue && (current.returnsNothing || endIsReachable)) {\n context.report({ node, messageId: 'inconsistent', data: { hook: current.hook } });\n }\n };\n\n return {\n [AstNodeTypes.CALL_EXPRESSION]: (node: Rule.Node) => {\n const hook = HookSupport.calleeName({ call: node });\n const args = AstNode.readField({ node, key: 'arguments' });\n\n if (\n !HookSupport.isEffectHook({ name: hook }) ||\n hook === undefined ||\n !Array.isArray(args)\n ) {\n return;\n }\n\n if (HookSupport.isCallback({ node: args[0] })) {\n targets.set(args[0], hook);\n }\n },\n onCodePathStart: (_codePath, node) => {\n frame = {\n upper: frame,\n hook: targets.get(node),\n returnsValue: false,\n returnsNothing: false,\n segments: new Set(),\n };\n },\n onCodePathEnd: () => {\n frame = frame?.upper;\n },\n onCodePathSegmentStart: (segment) => frame?.segments.add(segment),\n onCodePathSegmentEnd: (segment) => frame?.segments.delete(segment),\n onUnreachableCodePathSegmentStart: (segment) => frame?.segments.add(segment),\n onUnreachableCodePathSegmentEnd: (segment) => frame?.segments.delete(segment),\n [AstNodeTypes.RETURN_STATEMENT]: (node: Rule.Node) => {\n if (!frame) {\n return;\n }\n\n if (AstNode.readField({ node, key: 'argument' })) {\n frame.returnsValue = true;\n } else {\n frame.returnsNothing = true;\n }\n },\n 'FunctionExpression:exit': checkExit,\n 'ArrowFunctionExpression:exit': checkExit,\n };\n },\n };\n\n static build(opts: { severity?: TRuleSeverity } = {}): TRuleSeverity {\n return opts.severity ?? 'error';\n }\n}\n"]}
1
+ {"version":3,"file":"effect-cleanup-consistency.rule.js","sourceRoot":"","sources":["../../../src/linters/house/effect-cleanup-consistency.rule.ts"],"names":[],"mappings":";;;AAEA,qCAAyE;AACzE,iDAA6C;AAW7C;;;;;;GAMG;AACH,MAAa,4BAA4B;aACvB,SAAI,GAAG,GAAG,+BAAsB,6BAA6B,CAAC;aAE9D,SAAI,GAAoB;QACtC,IAAI,EAAE;YACJ,IAAI,EAAE,SAAS;YACf,MAAM,EAAE,EAAE;YACV,QAAQ,EAAE;gBACR,YAAY,EACV,8IAA8I;aACjJ;SACF;QACD,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE;YAClB,MAAM,OAAO,GAAG,IAAI,GAAG,EAAmB,CAAC;YAC3C,IAAI,KAAiC,CAAC;YAEtC,MAAM,SAAS,GAAG,CAAC,IAAe,EAAE,EAAE;gBACpC,MAAM,OAAO,GAAG,KAAK,CAAC;gBAEtB,IACE,CAAC,OAAO,EAAE,IAAI;oBACd,gBAAO,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,gBAAO,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;wBACjE,qBAAY,CAAC,eAAe,EAC9B,CAAC;oBACD,OAAO;gBACT,CAAC;gBAED,MAAM,cAAc,GAAG,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;gBAElF,IAAI,OAAO,CAAC,YAAY,IAAI,CAAC,OAAO,CAAC,cAAc,IAAI,cAAc,CAAC,EAAE,CAAC;oBACvE,OAAO,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,cAAc,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,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,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC;gBAClE,iCAAiC,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC;gBAC5E,+BAA+B,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC;gBAC7E,CAAC,qBAAY,CAAC,gBAAgB,CAAC,EAAE,CAAC,IAAe,EAAE,EAAE;oBACnD,IAAI,CAAC,KAAK,EAAE,CAAC;wBACX,OAAO;oBACT,CAAC;oBAED,IAAI,gBAAO,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC;wBACjD,KAAK,CAAC,YAAY,GAAG,IAAI,CAAC;oBAC5B,CAAC;yBAAM,CAAC;wBACN,KAAK,CAAC,cAAc,GAAG,IAAI,CAAC;oBAC9B,CAAC;gBACH,CAAC;gBACD,yBAAyB,EAAE,SAAS;gBACpC,8BAA8B,EAAE,SAAS;aAC1C,CAAC;QACJ,CAAC;KACF,CAAC;IAEF,MAAM,CAAC,KAAK,CAAC,OAAqC,EAAE;QAClD,OAAO,IAAI,CAAC,QAAQ,IAAI,OAAO,CAAC;IAClC,CAAC;;AAtFH,oEAuFC","sourcesContent":["import type { Rule } from 'eslint';\nimport type { TRuleSeverity } from '../rules/common';\nimport { AstNode, AstNodeTypes, HOUSE_PLUGIN_NAMESPACE } from './common';\nimport { HookSupport } from './hook-support';\n\n/** What the rule knows about the function whose code path is open; one per function, so a nested function is its own. */\ninterface IFunctionFrame {\n upper: IFunctionFrame | undefined;\n hook: string | undefined;\n returnsValue: boolean;\n returnsNothing: boolean;\n segments: Set<{ reachable: boolean }>;\n}\n\n/**\n * `@venizia/effect-cleanup-consistency`. The callback of `useEffect`, `useLayoutEffect` and `useInsertionEffect`\n * returns a cleanup on every path or on none. An early `return;` beside a later `return () => {}` leaves React\n * with a cleanup on some runs only; the early exit returns a no-op instead. A bare `return;` and falling off the\n * end both mean \"no value\". It uses ESLint's code path analysis the way `consistent-return` does, so an\n * unreachable end of the function is not a path. A nested function's own `return` is not counted.\n */\nexport class EffectCleanupConsistencyRule {\n static readonly NAME = `${HOUSE_PLUGIN_NAMESPACE}/effect-cleanup-consistency`;\n\n static readonly RULE: Rule.RuleModule = {\n meta: {\n type: 'problem',\n schema: [],\n messages: {\n inconsistent:\n 'The callback of `{{hook}}` returns a cleanup on some paths only; return one on every path (a no-op `() => {}` for an early exit) or on none.',\n },\n },\n create: (context) => {\n const targets = new Map<unknown, string>();\n let frame: IFunctionFrame | undefined;\n\n const checkExit = (node: Rule.Node) => {\n const current = frame;\n\n if (\n !current?.hook ||\n AstNode.getType({ node: AstNode.readField({ node, key: 'body' }) }) !==\n AstNodeTypes.BLOCK_STATEMENT\n ) {\n return;\n }\n\n const endIsReachable = [...current.segments].some((segment) => segment.reachable);\n\n if (current.returnsValue && (current.returnsNothing || endIsReachable)) {\n context.report({ node, messageId: 'inconsistent', data: { hook: current.hook } });\n }\n };\n\n return {\n [AstNodeTypes.CALL_EXPRESSION]: (node: Rule.Node) => {\n const hook = HookSupport.calleeName({ call: node });\n const args = AstNode.readField({ node, key: 'arguments' });\n\n if (\n !HookSupport.isEffectHook({ name: hook }) ||\n hook === undefined ||\n !Array.isArray(args)\n ) {\n return;\n }\n\n if (HookSupport.isCallback({ node: args[0] })) {\n targets.set(args[0], hook);\n }\n },\n onCodePathStart: (_codePath, node) => {\n frame = {\n upper: frame,\n hook: targets.get(node),\n returnsValue: false,\n returnsNothing: false,\n segments: new Set(),\n };\n },\n onCodePathEnd: () => {\n frame = frame?.upper;\n },\n onCodePathSegmentStart: (segment) => frame?.segments.add(segment),\n onCodePathSegmentEnd: (segment) => frame?.segments.delete(segment),\n onUnreachableCodePathSegmentStart: (segment) => frame?.segments.add(segment),\n onUnreachableCodePathSegmentEnd: (segment) => frame?.segments.delete(segment),\n [AstNodeTypes.RETURN_STATEMENT]: (node: Rule.Node) => {\n if (!frame) {\n return;\n }\n\n if (AstNode.readField({ node, key: 'argument' })) {\n frame.returnsValue = true;\n } else {\n frame.returnsNothing = true;\n }\n },\n 'FunctionExpression:exit': checkExit,\n 'ArrowFunctionExpression:exit': checkExit,\n };\n },\n };\n\n static build(opts: { severity?: TRuleSeverity } = {}): TRuleSeverity {\n return opts.severity ?? 'error';\n }\n}\n"]}
@@ -0,0 +1,54 @@
1
+ import type { TBrowserApiMatch } from './browser-api-patterns';
2
+ /** How a hand-written form shows up in code. */
3
+ export type TFrameworkApiMatch = TBrowserApiMatch
4
+ /**
5
+ * A member of a global object read or called: `localStorage.getItem`; `window.` in front is the same object. With
6
+ * `property`, the source of a regular expression, only a member whose name matches it. With `isReadOnly`, an
7
+ * assignment to it and a `delete` of it pass.
8
+ */
9
+ | {
10
+ type: 'member';
11
+ objects: ReadonlyArray<string>;
12
+ property?: string;
13
+ isReadOnly?: boolean;
14
+ }
15
+ /**
16
+ * A string or a template whose text matches `pattern`, the source of a regular expression. With
17
+ * `isFallbackOnly`, only where it stands in for a missing value: after `??`, `||`, `??=` or `||=`, a
18
+ * parameter default, or a `default`, `defaultValue` or `fallback` property.
19
+ */
20
+ | {
21
+ type: 'literal';
22
+ pattern: string;
23
+ isFallbackOnly?: boolean;
24
+ }
25
+ /** An `import` or `import()` of one of these modules; `import type` is not one. */
26
+ | {
27
+ type: 'import';
28
+ sources: ReadonlyArray<string>;
29
+ }
30
+ /** Every node an ESLint selector matches. */
31
+ | {
32
+ type: 'selector';
33
+ selector: string;
34
+ };
35
+ /** One hand-written form `@venizia/prefer-framework-api` reports anywhere in a file. */
36
+ export interface IFrameworkApiPattern {
37
+ /** The name `ignore` takes to switch the row off. */
38
+ id: string;
39
+ match: TFrameworkApiMatch;
40
+ /** The whole message. */
41
+ message: string;
42
+ /** The row applies only in a package that depends on a package whose name starts with this. */
43
+ dependsOn?: string;
44
+ /** The package that writes the API: the row is not reported in it. */
45
+ owner?: string;
46
+ }
47
+ /**
48
+ * The forms the framework replaces outside React, one row each. Unlike `BrowserApiPatterns`, a row counts anywhere in a
49
+ * file: a service or a module function can call the API as well as a component.
50
+ */
51
+ export declare class FrameworkApiPatterns {
52
+ static readonly TABLE: ReadonlyArray<IFrameworkApiPattern>;
53
+ }
54
+ //# sourceMappingURL=framework-api-patterns.d.ts.map
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FrameworkApiPatterns = void 0;
4
+ /**
5
+ * The forms the framework replaces outside React, one row each. Unlike `BrowserApiPatterns`, a row counts anywhere in a
6
+ * file: a service or a module function can call the API as well as a component.
7
+ */
8
+ class FrameworkApiPatterns {
9
+ static { this.TABLE = [
10
+ {
11
+ id: 'application-error-instanceof',
12
+ match: {
13
+ type: 'selector',
14
+ selector: "BinaryExpression[operator='instanceof'][right.name='ApplicationError']",
15
+ },
16
+ message: "Use `isApplicationError(error)`, not `instanceof ApplicationError`, which fails across two installed copies: `import { isApplicationError } from '@venizia/ignis-helpers/core';`",
17
+ dependsOn: '@venizia/ignis',
18
+ owner: '@venizia/ignis-inversion',
19
+ },
20
+ {
21
+ id: 'process-env',
22
+ // Only the names `AppEnvs` keeps: it drops a key without its prefix, such as `PORT`.
23
+ match: { type: 'member', objects: ['process.env'], property: '^APP_ENV_', isReadOnly: true },
24
+ message: "Read an `APP_ENV_` name with `AppEnvs.get(key)`, not `process.env`: `import { AppEnvs } from '@venizia/ignis-helpers';`",
25
+ dependsOn: '@venizia/ignis',
26
+ owner: '@venizia/ignis-helpers',
27
+ },
28
+ {
29
+ id: 'env-boolean-comparison',
30
+ match: {
31
+ type: 'selector',
32
+ selector: ['left', 'right']
33
+ .map((side) => {
34
+ const other = side === 'left' ? 'right' : 'left';
35
+ return `BinaryExpression[operator=/^[!=]==?$/][${side}.callee.property.name='get'][${side}.callee.object.name=/^(AppEnvs|applicationEnvironment)$/][${other}.value=/^(true|false)$/]`;
36
+ })
37
+ .join(', '),
38
+ },
39
+ message: "Read a boolean setting with `ParseUtility.toBoolean({ input: AppEnvs.get(key) })`, not a comparison with `'true'` or `'false'`: `import { ParseUtility } from '@venizia/ignis-helpers/core';`",
40
+ dependsOn: '@venizia/ignis',
41
+ owner: '@venizia/ignis-helpers',
42
+ },
43
+ {
44
+ id: 'web-storage',
45
+ match: { type: 'member', objects: ['localStorage', 'sessionStorage'] },
46
+ message: "Use `BrowserStorage` (or the `useStoredState` hook), not `localStorage` / `sessionStorage`: it never throws: `import { BrowserStorage } from '@venizia/ardor-kernel';`",
47
+ dependsOn: '@venizia/ardor',
48
+ owner: '@venizia/ardor-kernel',
49
+ },
50
+ {
51
+ id: 'localhost-url',
52
+ match: {
53
+ type: 'literal',
54
+ pattern: '^https?://(?:localhost|127\\.0\\.0\\.1)(?![\\w.-])',
55
+ isFallbackOnly: true,
56
+ },
57
+ message: "Require the value instead, a `localhost` URL as a fallback is used wherever the setting is missing: `AppEnvs.getRequired(key)` (`import { AppEnvs } from '@venizia/ignis-helpers';`) or `RuntimeConfig.getRequired({ key })` (`import { RuntimeConfig } from '@venizia/ardor-kernel';`).",
58
+ },
59
+ ]; }
60
+ }
61
+ exports.FrameworkApiPatterns = FrameworkApiPatterns;
62
+ //# sourceMappingURL=framework-api-patterns.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"framework-api-patterns.js","sourceRoot":"","sources":["../../../src/linters/house/framework-api-patterns.ts"],"names":[],"mappings":";;;AAmCA;;;GAGG;AACH,MAAa,oBAAoB;aACf,UAAK,GAAwC;QAC3D;YACE,EAAE,EAAE,8BAA8B;YAClC,KAAK,EAAE;gBACL,IAAI,EAAE,UAAU;gBAChB,QAAQ,EAAE,wEAAwE;aACnF;YACD,OAAO,EACL,kLAAkL;YACpL,SAAS,EAAE,gBAAgB;YAC3B,KAAK,EAAE,0BAA0B;SAClC;QACD;YACE,EAAE,EAAE,aAAa;YACjB,qFAAqF;YACrF,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,aAAa,CAAC,EAAE,QAAQ,EAAE,WAAW,EAAE,UAAU,EAAE,IAAI,EAAE;YAC5F,OAAO,EACL,yHAAyH;YAC3H,SAAS,EAAE,gBAAgB;YAC3B,KAAK,EAAE,wBAAwB;SAChC;QACD;YACE,EAAE,EAAE,wBAAwB;YAC5B,KAAK,EAAE;gBACL,IAAI,EAAE,UAAU;gBAChB,QAAQ,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC;qBACxB,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;oBACZ,MAAM,KAAK,GAAG,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC;oBAEjD,OAAO,0CAA0C,IAAI,gCAAgC,IAAI,6DAA6D,KAAK,0BAA0B,CAAC;gBACxL,CAAC,CAAC;qBACD,IAAI,CAAC,IAAI,CAAC;aACd;YACD,OAAO,EACL,+LAA+L;YACjM,SAAS,EAAE,gBAAgB;YAC3B,KAAK,EAAE,wBAAwB;SAChC;QACD;YACE,EAAE,EAAE,aAAa;YACjB,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,cAAc,EAAE,gBAAgB,CAAC,EAAE;YACtE,OAAO,EACL,wKAAwK;YAC1K,SAAS,EAAE,gBAAgB;YAC3B,KAAK,EAAE,uBAAuB;SAC/B;QACD;YACE,EAAE,EAAE,eAAe;YACnB,KAAK,EAAE;gBACL,IAAI,EAAE,SAAS;gBACf,OAAO,EAAE,oDAAoD;gBAC7D,cAAc,EAAE,IAAI;aACrB;YACD,OAAO,EACL,0RAA0R;SAC7R;KACF,CAAC;;AAzDJ,oDA0DC","sourcesContent":["import type { TBrowserApiMatch } from './browser-api-patterns';\n\n/** How a hand-written form shows up in code. */\nexport type TFrameworkApiMatch =\n | TBrowserApiMatch\n /**\n * A member of a global object read or called: `localStorage.getItem`; `window.` in front is the same object. With\n * `property`, the source of a regular expression, only a member whose name matches it. With `isReadOnly`, an\n * assignment to it and a `delete` of it pass.\n */\n | { type: 'member'; objects: ReadonlyArray<string>; property?: string; isReadOnly?: boolean }\n /**\n * A string or a template whose text matches `pattern`, the source of a regular expression. With\n * `isFallbackOnly`, only where it stands in for a missing value: after `??`, `||`, `??=` or `||=`, a\n * parameter default, or a `default`, `defaultValue` or `fallback` property.\n */\n | { type: 'literal'; pattern: string; isFallbackOnly?: boolean }\n /** An `import` or `import()` of one of these modules; `import type` is not one. */\n | { type: 'import'; sources: ReadonlyArray<string> }\n /** Every node an ESLint selector matches. */\n | { type: 'selector'; selector: string };\n\n/** One hand-written form `@venizia/prefer-framework-api` reports anywhere in a file. */\nexport interface IFrameworkApiPattern {\n /** The name `ignore` takes to switch the row off. */\n id: string;\n match: TFrameworkApiMatch;\n /** The whole message. */\n message: string;\n /** The row applies only in a package that depends on a package whose name starts with this. */\n dependsOn?: string;\n /** The package that writes the API: the row is not reported in it. */\n owner?: string;\n}\n\n/**\n * The forms the framework replaces outside React, one row each. Unlike `BrowserApiPatterns`, a row counts anywhere in a\n * file: a service or a module function can call the API as well as a component.\n */\nexport class FrameworkApiPatterns {\n static readonly TABLE: ReadonlyArray<IFrameworkApiPattern> = [\n {\n id: 'application-error-instanceof',\n match: {\n type: 'selector',\n selector: \"BinaryExpression[operator='instanceof'][right.name='ApplicationError']\",\n },\n message:\n \"Use `isApplicationError(error)`, not `instanceof ApplicationError`, which fails across two installed copies: `import { isApplicationError } from '@venizia/ignis-helpers/core';`\",\n dependsOn: '@venizia/ignis',\n owner: '@venizia/ignis-inversion',\n },\n {\n id: 'process-env',\n // Only the names `AppEnvs` keeps: it drops a key without its prefix, such as `PORT`.\n match: { type: 'member', objects: ['process.env'], property: '^APP_ENV_', isReadOnly: true },\n message:\n \"Read an `APP_ENV_` name with `AppEnvs.get(key)`, not `process.env`: `import { AppEnvs } from '@venizia/ignis-helpers';`\",\n dependsOn: '@venizia/ignis',\n owner: '@venizia/ignis-helpers',\n },\n {\n id: 'env-boolean-comparison',\n match: {\n type: 'selector',\n selector: ['left', 'right']\n .map((side) => {\n const other = side === 'left' ? 'right' : 'left';\n\n return `BinaryExpression[operator=/^[!=]==?$/][${side}.callee.property.name='get'][${side}.callee.object.name=/^(AppEnvs|applicationEnvironment)$/][${other}.value=/^(true|false)$/]`;\n })\n .join(', '),\n },\n message:\n \"Read a boolean setting with `ParseUtility.toBoolean({ input: AppEnvs.get(key) })`, not a comparison with `'true'` or `'false'`: `import { ParseUtility } from '@venizia/ignis-helpers/core';`\",\n dependsOn: '@venizia/ignis',\n owner: '@venizia/ignis-helpers',\n },\n {\n id: 'web-storage',\n match: { type: 'member', objects: ['localStorage', 'sessionStorage'] },\n message:\n \"Use `BrowserStorage` (or the `useStoredState` hook), not `localStorage` / `sessionStorage`: it never throws: `import { BrowserStorage } from '@venizia/ardor-kernel';`\",\n dependsOn: '@venizia/ardor',\n owner: '@venizia/ardor-kernel',\n },\n {\n id: 'localhost-url',\n match: {\n type: 'literal',\n pattern: '^https?://(?:localhost|127\\\\.0\\\\.0\\\\.1)(?![\\\\w.-])',\n isFallbackOnly: true,\n },\n message:\n \"Require the value instead, a `localhost` URL as a fallback is used wherever the setting is missing: `AppEnvs.getRequired(key)` (`import { AppEnvs } from '@venizia/ignis-helpers';`) or `RuntimeConfig.getRequired({ key })` (`import { RuntimeConfig } from '@venizia/ardor-kernel';`).\",\n },\n ];\n}\n"]}
@@ -32,7 +32,7 @@ class FrameworkExports {
32
32
  static readText(opts) {
33
33
  try {
34
34
  return (0, node_fs_1.readFileSync)(opts.file, 'utf8');
35
- // eslint-disable-next-line venizia/no-silent-catch -- an unreadable file only means fewer names
35
+ // eslint-disable-next-line @venizia/no-silent-catch -- an unreadable file only means fewer names
36
36
  }
37
37
  catch {
38
38
  return undefined;
@@ -46,7 +46,7 @@ class FrameworkExports {
46
46
  }
47
47
  try {
48
48
  return JSON.parse(text);
49
- // eslint-disable-next-line venizia/no-silent-catch -- a package.json that does not parse only means fewer names
49
+ // eslint-disable-next-line @venizia/no-silent-catch -- a package.json that does not parse only means fewer names
50
50
  }
51
51
  catch {
52
52
  return undefined;
@@ -77,7 +77,7 @@ class FrameworkExports {
77
77
  FrameworkExports.typescripts.set(directory, loaded);
78
78
  return loaded;
79
79
  }
80
- // eslint-disable-next-line venizia/no-silent-catch -- not installed at this start: the next one is tried
80
+ // eslint-disable-next-line @venizia/no-silent-catch -- not installed at this start: the next one is tried
81
81
  }
82
82
  catch {
83
83
  continue;
@@ -1 +1 @@
1
- {"version":3,"file":"framework-exports.js","sourceRoot":"","sources":["../../../src/linters/house/framework-exports.ts"],"names":[],"mappings":";;;AAAA,qCAAmD;AACnD,6CAA4C;AAC5C,yCAAmD;AAEnD,qCAAmC;AAYnC;;;;;;;;;GASG;AACH,MAAa,gBAAgB;aACX,UAAK,GAAG,WAAW,CAAC;aAEZ,cAAS,GAAG,IAAI,GAAG,EAAmC,CAAC;aACvD,aAAQ,GAAG,IAAI,GAAG,EAA+B,CAAC;aAClD,gBAAW,GAAG,IAAI,GAAG,EAA4B,CAAC;IAE1E,kFAAkF;IAC1E,MAAM,CAAC,QAAQ,CAAC,KAAc;QACpC,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;YACzB,KAAK,KAAK,IAAI;YACd,OAAO,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,kBAAkB,CAAC,KAAK,UAAU;YAC5D,OAAO,gBAAO,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,cAAc,CAAC,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC;gBACnF,QAAQ,CACX,CAAC;IACJ,CAAC;IAED,iEAAiE;IACzD,MAAM,CAAC,QAAQ,CAAC,IAAsB;QAC5C,IAAI,CAAC;YACH,OAAO,IAAA,sBAAY,EAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;YACvC,gGAAgG;Q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,CAAC,IAAI,EAAE,CAAC;gBAC/C,SAAS;YACX,CAAC;YAED,KAAK,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,IAAI,gBAAgB,CAAC,WAAW,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC;gBACvF,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;oBACnB,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;gBAC3B,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,GAAG,CAAC;IACb,CAAC;;AApYH,4CAqYC","sourcesContent":["import { existsSync, readFileSync } from 'node:fs';\nimport { createRequire } from 'node:module';\nimport { dirname, join, resolve } from 'node:path';\nimport type ts from 'typescript';\nimport { AstNode } from './common';\n\n/** The nearest package.json at or above a folder: where it is, and what it says. */\nexport interface IPackageManifest {\n directory: string;\n name: string | undefined;\n dependencies: ReadonlyArray<string>;\n}\n\n/** Whether a declared name is a type (an interface or a type alias) or something with a runtime value (a class, a function, a const, an enum, a namespace). */\ntype TDeclarationType = 'type' | 'value';\n\n/**\n * The type names the installed `@venizia/*` packages export, read from their published `.d.ts` files: the names a project\n * must import, not write again. Only interfaces and type aliases count (a class or a const is not a type your own\n * `interface Logger` copies). A declaration scan only (the TypeScript parser, no program, no type check), memoized per\n * package for the life of the process: after an upgrade an ESLint server must be restarted to read the new names.\n *\n * It never stops a lint run. TypeScript is looked up from the linted package, the working directory and dev-configs' own\n * install, and only a copy that has the parser API is used (the native TypeScript 7 has none); a package.json or a `.d.ts`\n * that cannot be read is skipped. Whatever is missing, the answer is fewer names, never an exception.\n */\nexport class FrameworkExports {\n static readonly SCOPE = '@venizia/';\n\n private static readonly manifests = new Map<string, IPackageManifest | null>();\n private static readonly packages = new Map<string, Map<string, string>>();\n private static readonly typescripts = new Map<string, typeof ts | null>();\n\n /** `value` as the TypeScript module when it has the parser API this scan uses. */\n private static isParser(value: unknown): value is typeof ts {\n return (\n typeof value === 'object' &&\n value !== null &&\n typeof Reflect.get(value, 'createSourceFile') === 'function' &&\n typeof AstNode.readField({ node: Reflect.get(value, 'ScriptTarget'), key: 'Latest' }) ===\n 'number'\n );\n }\n\n /** The text of a file, or `undefined` when it cannot be read. */\n private static readText(opts: { file: string }): string | undefined {\n try {\n return readFileSync(opts.file, 'utf8');\n // eslint-disable-next-line venizia/no-silent-catch -- an unreadable file only means fewer names\n } catch {\n return undefined;\n }\n }\n\n /** A JSON file, or `undefined` when it cannot be read or does not parse. */\n private static readJson(opts: { file: string }): unknown {\n const text = FrameworkExports.readText(opts);\n\n if (text === undefined) {\n return undefined;\n }\n\n try {\n return JSON.parse(text);\n // eslint-disable-next-line venizia/no-silent-catch -- a package.json that does not parse only means fewer names\n } catch {\n return undefined;\n }\n }\n\n /**\n * TypeScript for the linted package: from its own folder, the working directory, or this package's install, the first that\n * has the parser API. `undefined` when none does (the rule then reports nothing).\n */\n static loadTypeScript(opts: { directory: string }): typeof ts | undefined {\n const { directory } = opts;\n const cached = FrameworkExports.typescripts.get(directory);\n\n if (cached !== undefined) {\n return cached ?? undefined;\n }\n\n const starts = [\n directory,\n process.cwd(),\n typeof __dirname === 'string' ? __dirname : undefined,\n ];\n\n for (const start of starts) {\n if (start === undefined) {\n continue;\n }\n\n try {\n const loaded: unknown = createRequire(join(start, 'noop.js'))('typescript');\n\n if (FrameworkExports.isParser(loaded)) {\n FrameworkExports.typescripts.set(directory, loaded);\n\n return loaded;\n }\n // eslint-disable-next-line venizia/no-silent-catch -- not installed at this start: the next one is tried\n } catch {\n continue;\n }\n }\n\n FrameworkExports.typescripts.set(directory, null);\n\n return undefined;\n }\n\n /** The nearest package.json at or above `directory`. */\n static manifestFor(opts: { directory: string }): IPackageManifest | undefined {\n const { directory } = opts;\n const cached = FrameworkExports.manifests.get(directory);\n\n if (cached !== undefined) {\n return cached ?? undefined;\n }\n\n const file = join(directory, 'package.json');\n let found: IPackageManifest | undefined;\n\n if (existsSync(file)) {\n const parsed = FrameworkExports.readJson({ file });\n const name = AstNode.readField({ node: parsed, key: 'name' });\n const names = ['dependencies', 'peerDependencies'].flatMap((key) => {\n const group = AstNode.readField({ node: parsed, key });\n\n return typeof group === 'object' && group !== null ? Object.keys(group) : [];\n });\n\n found = {\n directory,\n name: typeof name === 'string' ? name : undefined,\n dependencies: names.filter((entry) => entry.startsWith(FrameworkExports.SCOPE)),\n };\n } else {\n const parent = dirname(directory);\n found =\n parent === directory ? undefined : FrameworkExports.manifestFor({ directory: parent });\n }\n\n FrameworkExports.manifests.set(directory, found ?? null);\n\n return found;\n }\n\n /** The folder of the installed package `name`, looked up from `directory` upwards. */\n private static locate(opts: { name: string; directory: string }): string | undefined {\n const candidate = join(opts.directory, 'node_modules', opts.name);\n\n if (existsSync(join(candidate, 'package.json'))) {\n return candidate;\n }\n\n const parent = dirname(opts.directory);\n\n return parent === opts.directory\n ? undefined\n : FrameworkExports.locate({ name: opts.name, directory: parent });\n }\n\n /** Every `.d.ts` path an `exports` value names, with the subpath it is reached by. */\n private static entriesOf(opts: { manifest: unknown }): Array<{ subpath: string; file: string }> {\n const { manifest } = opts;\n const exported = AstNode.readField({ node: manifest, key: 'exports' });\n\n const declarations = (value: unknown): Array<string> => {\n if (typeof value === 'string') {\n return /\\.d\\.[cm]?ts$/.test(value) ? [value] : [];\n }\n\n return typeof value === 'object' && value !== null\n ? Object.values(value).flatMap((entry) => declarations(entry))\n : [];\n };\n\n if (typeof exported === 'object' && exported !== null) {\n return Object.entries(exported).flatMap(([key, value]) =>\n declarations(value).map((file) => ({ subpath: key === '.' ? '' : key.slice(1), file })),\n );\n }\n\n const legacy = AstNode.readField({ node: manifest, key: 'types' });\n\n return typeof legacy === 'string' ? [{ subpath: '', file: legacy }] : [];\n }\n\n /** The declaration file a relative specifier points at (`./x.js` is `./x.d.ts`). */\n private static resolveRelative(opts: { from: string; specifier: string }): string | undefined {\n const base = resolve(dirname(opts.from), opts.specifier.replace(/\\.(?:[cm]?js|[cm]?ts)$/, ''));\n\n return [`${base}.d.ts`, `${base}.d.mts`, join(base, 'index.d.ts')].find((file) =>\n existsSync(file),\n );\n }\n\n /**\n * The names `file` exports, each with what it is, following `export *` into relative files and into other `@venizia/*`\n * packages (an umbrella package re-exports its siblings). A name re-exported by `export { X } from` takes the type it has\n * where it is declared; `export type { X }` is a type whatever the target says.\n */\n private static namesOf(opts: {\n typescript: typeof ts;\n file: string;\n seen: Set<string>;\n }): Map<string, TDeclarationType> {\n const { typescript, file, seen } = opts;\n const names = new Map<string, TDeclarationType>();\n const text = FrameworkExports.readText({ file });\n\n if (seen.has(file) || text === undefined) {\n return names;\n }\n\n seen.add(file);\n\n const source = typescript.createSourceFile(file, text, typescript.ScriptTarget.Latest, false);\n const typeOf = (node: ts.Statement): TDeclarationType =>\n typescript.isInterfaceDeclaration(node) || typescript.isTypeAliasDeclaration(node)\n ? 'type'\n : 'value';\n const isExported = (node: ts.Node) =>\n typescript.canHaveModifiers(node) &&\n (typescript.getModifiers(node) ?? []).some(\n (modifier) => modifier.kind === typescript.SyntaxKind.ExportKeyword,\n );\n\n // What the file declares, exported or not: `declare class X {}` then `export { X }` is a value.\n const locals = new Map<string, TDeclarationType>();\n\n for (const statement of source.statements) {\n if (typescript.isVariableStatement(statement)) {\n for (const declaration of statement.declarationList.declarations) {\n if (typescript.isIdentifier(declaration.name)) {\n locals.set(declaration.name.text, 'value');\n }\n }\n } else if (\n (typescript.isInterfaceDeclaration(statement) ||\n typescript.isTypeAliasDeclaration(statement) ||\n typescript.isClassDeclaration(statement) ||\n typescript.isFunctionDeclaration(statement) ||\n typescript.isEnumDeclaration(statement) ||\n typescript.isModuleDeclaration(statement)) &&\n statement.name &&\n typescript.isIdentifier(statement.name)\n ) {\n // An interface merged with a class or a namespace of the same name has a value too.\n locals.set(\n statement.name.text,\n locals.get(statement.name.text) === 'value' ? 'value' : typeOf(statement),\n );\n }\n }\n\n for (const statement of source.statements) {\n if (typescript.isExportDeclaration(statement)) {\n const clause = statement.exportClause;\n const specifier =\n statement.moduleSpecifier && typescript.isStringLiteral(statement.moduleSpecifier)\n ? statement.moduleSpecifier.text\n : undefined;\n\n if (clause && typescript.isNamedExports(clause)) {\n const remote =\n specifier?.startsWith('.') === true\n ? FrameworkExports.resolveRelative({ from: file, specifier })\n : undefined;\n const there = remote\n ? FrameworkExports.namesOf({ typescript, file: remote, seen: new Set(seen) })\n : undefined;\n\n for (const element of clause.elements) {\n const original = (element.propertyName ?? element.name).text;\n const declared: TDeclarationType | undefined =\n statement.isTypeOnly || element.isTypeOnly\n ? 'type'\n : specifier === undefined\n ? locals.get(original)\n : there?.get(original);\n\n if (declared !== undefined) {\n names.set(element.name.text, declared);\n }\n }\n } else if (!clause && specifier?.startsWith('.') === true) {\n const target = FrameworkExports.resolveRelative({ from: file, specifier });\n\n if (target) {\n for (const [name, declared] of FrameworkExports.namesOf({\n typescript,\n file: target,\n seen,\n })) {\n names.set(name, declared);\n }\n }\n } else if (!clause && specifier?.startsWith(FrameworkExports.SCOPE) === true) {\n const sibling = FrameworkExports.locate({ name: specifier, directory: dirname(file) });\n\n if (sibling) {\n for (const name of FrameworkExports.readPackage({ directory: sibling }).keys()) {\n names.set(name, 'type');\n }\n }\n }\n\n continue;\n }\n\n if (!isExported(statement)) {\n continue;\n }\n\n if (typescript.isVariableStatement(statement)) {\n for (const declaration of statement.declarationList.declarations) {\n if (typescript.isIdentifier(declaration.name)) {\n names.set(declaration.name.text, 'value');\n }\n }\n } else if (\n (typescript.isInterfaceDeclaration(statement) ||\n typescript.isTypeAliasDeclaration(statement) ||\n typescript.isClassDeclaration(statement) ||\n typescript.isFunctionDeclaration(statement) ||\n typescript.isEnumDeclaration(statement) ||\n typescript.isModuleDeclaration(statement)) &&\n statement.name &&\n typescript.isIdentifier(statement.name)\n ) {\n names.set(statement.name.text, locals.get(statement.name.text) ?? typeOf(statement));\n }\n }\n\n return names;\n }\n\n /** Type name to the specifier that exports it (`@venizia/ignis-helpers/common`), for one installed package. */\n private static readPackage(opts: { directory: string }): Map<string, string> {\n const { directory } = opts;\n const cached = FrameworkExports.packages.get(directory);\n\n if (cached) {\n return cached;\n }\n\n const exported = new Map<string, string>();\n FrameworkExports.packages.set(directory, exported);\n\n const typescript = FrameworkExports.loadTypeScript({ directory });\n const manifest = FrameworkExports.readJson({ file: join(directory, 'package.json') });\n const name = AstNode.readField({ node: manifest, key: 'name' });\n\n if (!typescript || typeof name !== 'string') {\n return exported;\n }\n\n // A name reachable from several entries is imported from the narrowest one: `/common` over the root that re-exports it.\n const sizes = new Map<string, number>();\n\n for (const { subpath, file } of FrameworkExports.entriesOf({ manifest })) {\n const path = resolve(directory, file);\n\n if (!existsSync(path)) {\n continue;\n }\n\n const declared = FrameworkExports.namesOf({ typescript, file: path, seen: new Set() });\n const types = [...declared].filter(([, type]) => type === 'type').map(([entry]) => entry);\n\n for (const entry of types) {\n if (types.length < (sizes.get(entry) ?? Number.POSITIVE_INFINITY)) {\n sizes.set(entry, types.length);\n exported.set(entry, `${name}${subpath}`);\n }\n }\n }\n\n return exported;\n }\n\n /**\n * The type names the `@venizia/*` packages that `directory`'s project depends on export, each with the specifier to import\n * it from. The project's own package is left out: it may declare what it exports.\n */\n static of(opts: { directory: string }): Map<string, string> {\n const manifest = FrameworkExports.manifestFor({ directory: opts.directory });\n const all = new Map<string, string>();\n\n if (!manifest) {\n return all;\n }\n\n for (const dependency of manifest.dependencies) {\n const installed = FrameworkExports.locate({\n name: dependency,\n directory: manifest.directory,\n });\n\n if (!installed || dependency === manifest.name) {\n continue;\n }\n\n for (const [name, specifier] of FrameworkExports.readPackage({ directory: installed })) {\n if (!all.has(name)) {\n all.set(name, specifier);\n }\n }\n }\n\n return all;\n }\n}\n"]}
1
+ {"version":3,"file":"framework-exports.js","sourceRoot":"","sources":["../../../src/linters/house/framework-exports.ts"],"names":[],"mappings":";;;AAAA,qCAAmD;AACnD,6CAA4C;AAC5C,yCAAmD;AAEnD,qCAAmC;AAYnC;;;;;;;;;GASG;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E,KAAK,CAAC,MAAM,CAAC,CAAC;oBAC/B,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,IAAI,GAAG,OAAO,EAAE,CAAC,CAAC;gBAC3C,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,EAAE,CAAC,IAA2B;QACnC,MAAM,QAAQ,GAAG,gBAAgB,CAAC,WAAW,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC;QAC7E,MAAM,GAAG,GAAG,IAAI,GAAG,EAAkB,CAAC;QAEtC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,OAAO,GAAG,CAAC;QACb,CAAC;QAED,KAAK,MAAM,UAAU,IAAI,QAAQ,CAAC,YAAY,EAAE,CAAC;YAC/C,MAAM,SAAS,GAAG,gBAAgB,CAAC,MAAM,CAAC;gBACxC,IAAI,EAAE,UAAU;gBAChB,SAAS,EAAE,QAAQ,CAAC,SAAS;aAC9B,CAAC,CAAC;YAEH,IAAI,CAAC,SAAS,IAAI,UAAU,KAAK,QAAQ,CAAC,IAAI,EAAE,CAAC;gBAC/C,SAAS;YACX,CAAC;YAED,KAAK,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,IAAI,gBAAgB,CAAC,WAAW,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC;gBACvF,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;oBACnB,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;gBAC3B,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,GAAG,CAAC;IACb,CAAC;;AApYH,4CAqYC","sourcesContent":["import { existsSync, readFileSync } from 'node:fs';\nimport { createRequire } from 'node:module';\nimport { dirname, join, resolve } from 'node:path';\nimport type ts from 'typescript';\nimport { AstNode } from './common';\n\n/** The nearest package.json at or above a folder: where it is, and what it says. */\nexport interface IPackageManifest {\n directory: string;\n name: string | undefined;\n dependencies: ReadonlyArray<string>;\n}\n\n/** Whether a declared name is a type (an interface or a type alias) or something with a runtime value (a class, a function, a const, an enum, a namespace). */\ntype TDeclarationType = 'type' | 'value';\n\n/**\n * The type names the installed `@venizia/*` packages export, read from their published `.d.ts` files: the names a project\n * must import, not write again. Only interfaces and type aliases count (a class or a const is not a type your own\n * `interface Logger` copies). A declaration scan only (the TypeScript parser, no program, no type check), memoized per\n * package for the life of the process: after an upgrade an ESLint server must be restarted to read the new names.\n *\n * It never stops a lint run. TypeScript is looked up from the linted package, the working directory and dev-configs' own\n * install, and only a copy that has the parser API is used (the native TypeScript 7 has none); a package.json or a `.d.ts`\n * that cannot be read is skipped. Whatever is missing, the answer is fewer names, never an exception.\n */\nexport class FrameworkExports {\n static readonly SCOPE = '@venizia/';\n\n private static readonly manifests = new Map<string, IPackageManifest | null>();\n private static readonly packages = new Map<string, Map<string, string>>();\n private static readonly typescripts = new Map<string, typeof ts | null>();\n\n /** `value` as the TypeScript module when it has the parser API this scan uses. */\n private static isParser(value: unknown): value is typeof ts {\n return (\n typeof value === 'object' &&\n value !== null &&\n typeof Reflect.get(value, 'createSourceFile') === 'function' &&\n typeof AstNode.readField({ node: Reflect.get(value, 'ScriptTarget'), key: 'Latest' }) ===\n 'number'\n );\n }\n\n /** The text of a file, or `undefined` when it cannot be read. */\n private static readText(opts: { file: string }): string | undefined {\n try {\n return readFileSync(opts.file, 'utf8');\n // eslint-disable-next-line @venizia/no-silent-catch -- an unreadable file only means fewer names\n } catch {\n return undefined;\n }\n }\n\n /** A JSON file, or `undefined` when it cannot be read or does not parse. */\n private static readJson(opts: { file: string }): unknown {\n const text = FrameworkExports.readText(opts);\n\n if (text === undefined) {\n return undefined;\n }\n\n try {\n return JSON.parse(text);\n // eslint-disable-next-line @venizia/no-silent-catch -- a package.json that does not parse only means fewer names\n } catch {\n return undefined;\n }\n }\n\n /**\n * TypeScript for the linted package: from its own folder, the working directory, or this package's install, the first that\n * has the parser API. `undefined` when none does (the rule then reports nothing).\n */\n static loadTypeScript(opts: { directory: string }): typeof ts | undefined {\n const { directory } = opts;\n const cached = FrameworkExports.typescripts.get(directory);\n\n if (cached !== undefined) {\n return cached ?? undefined;\n }\n\n const starts = [\n directory,\n process.cwd(),\n typeof __dirname === 'string' ? __dirname : undefined,\n ];\n\n for (const start of starts) {\n if (start === undefined) {\n continue;\n }\n\n try {\n const loaded: unknown = createRequire(join(start, 'noop.js'))('typescript');\n\n if (FrameworkExports.isParser(loaded)) {\n FrameworkExports.typescripts.set(directory, loaded);\n\n return loaded;\n }\n // eslint-disable-next-line @venizia/no-silent-catch -- not installed at this start: the next one is tried\n } catch {\n continue;\n }\n }\n\n FrameworkExports.typescripts.set(directory, null);\n\n return undefined;\n }\n\n /** The nearest package.json at or above `directory`. */\n static manifestFor(opts: { directory: string }): IPackageManifest | undefined {\n const { directory } = opts;\n const cached = FrameworkExports.manifests.get(directory);\n\n if (cached !== undefined) {\n return cached ?? undefined;\n }\n\n const file = join(directory, 'package.json');\n let found: IPackageManifest | undefined;\n\n if (existsSync(file)) {\n const parsed = FrameworkExports.readJson({ file });\n const name = AstNode.readField({ node: parsed, key: 'name' });\n const names = ['dependencies', 'peerDependencies'].flatMap((key) => {\n const group = AstNode.readField({ node: parsed, key });\n\n return typeof group === 'object' && group !== null ? Object.keys(group) : [];\n });\n\n found = {\n directory,\n name: typeof name === 'string' ? name : undefined,\n dependencies: names.filter((entry) => entry.startsWith(FrameworkExports.SCOPE)),\n };\n } else {\n const parent = dirname(directory);\n found =\n parent === directory ? undefined : FrameworkExports.manifestFor({ directory: parent });\n }\n\n FrameworkExports.manifests.set(directory, found ?? null);\n\n return found;\n }\n\n /** The folder of the installed package `name`, looked up from `directory` upwards. */\n private static locate(opts: { name: string; directory: string }): string | undefined {\n const candidate = join(opts.directory, 'node_modules', opts.name);\n\n if (existsSync(join(candidate, 'package.json'))) {\n return candidate;\n }\n\n const parent = dirname(opts.directory);\n\n return parent === opts.directory\n ? undefined\n : FrameworkExports.locate({ name: opts.name, directory: parent });\n }\n\n /** Every `.d.ts` path an `exports` value names, with the subpath it is reached by. */\n private static entriesOf(opts: { manifest: unknown }): Array<{ subpath: string; file: string }> {\n const { manifest } = opts;\n const exported = AstNode.readField({ node: manifest, key: 'exports' });\n\n const declarations = (value: unknown): Array<string> => {\n if (typeof value === 'string') {\n return /\\.d\\.[cm]?ts$/.test(value) ? [value] : [];\n }\n\n return typeof value === 'object' && value !== null\n ? Object.values(value).flatMap((entry) => declarations(entry))\n : [];\n };\n\n if (typeof exported === 'object' && exported !== null) {\n return Object.entries(exported).flatMap(([key, value]) =>\n declarations(value).map((file) => ({ subpath: key === '.' ? '' : key.slice(1), file })),\n );\n }\n\n const legacy = AstNode.readField({ node: manifest, key: 'types' });\n\n return typeof legacy === 'string' ? [{ subpath: '', file: legacy }] : [];\n }\n\n /** The declaration file a relative specifier points at (`./x.js` is `./x.d.ts`). */\n private static resolveRelative(opts: { from: string; specifier: string }): string | undefined {\n const base = resolve(dirname(opts.from), opts.specifier.replace(/\\.(?:[cm]?js|[cm]?ts)$/, ''));\n\n return [`${base}.d.ts`, `${base}.d.mts`, join(base, 'index.d.ts')].find((file) =>\n existsSync(file),\n );\n }\n\n /**\n * The names `file` exports, each with what it is, following `export *` into relative files and into other `@venizia/*`\n * packages (an umbrella package re-exports its siblings). A name re-exported by `export { X } from` takes the type it has\n * where it is declared; `export type { X }` is a type whatever the target says.\n */\n private static namesOf(opts: {\n typescript: typeof ts;\n file: string;\n seen: Set<string>;\n }): Map<string, TDeclarationType> {\n const { typescript, file, seen } = opts;\n const names = new Map<string, TDeclarationType>();\n const text = FrameworkExports.readText({ file });\n\n if (seen.has(file) || text === undefined) {\n return names;\n }\n\n seen.add(file);\n\n const source = typescript.createSourceFile(file, text, typescript.ScriptTarget.Latest, false);\n const typeOf = (node: ts.Statement): TDeclarationType =>\n typescript.isInterfaceDeclaration(node) || typescript.isTypeAliasDeclaration(node)\n ? 'type'\n : 'value';\n const isExported = (node: ts.Node) =>\n typescript.canHaveModifiers(node) &&\n (typescript.getModifiers(node) ?? []).some(\n (modifier) => modifier.kind === typescript.SyntaxKind.ExportKeyword,\n );\n\n // What the file declares, exported or not: `declare class X {}` then `export { X }` is a value.\n const locals = new Map<string, TDeclarationType>();\n\n for (const statement of source.statements) {\n if (typescript.isVariableStatement(statement)) {\n for (const declaration of statement.declarationList.declarations) {\n if (typescript.isIdentifier(declaration.name)) {\n locals.set(declaration.name.text, 'value');\n }\n }\n } else if (\n (typescript.isInterfaceDeclaration(statement) ||\n typescript.isTypeAliasDeclaration(statement) ||\n typescript.isClassDeclaration(statement) ||\n typescript.isFunctionDeclaration(statement) ||\n typescript.isEnumDeclaration(statement) ||\n typescript.isModuleDeclaration(statement)) &&\n statement.name &&\n typescript.isIdentifier(statement.name)\n ) {\n // An interface merged with a class or a namespace of the same name has a value too.\n locals.set(\n statement.name.text,\n locals.get(statement.name.text) === 'value' ? 'value' : typeOf(statement),\n );\n }\n }\n\n for (const statement of source.statements) {\n if (typescript.isExportDeclaration(statement)) {\n const clause = statement.exportClause;\n const specifier =\n statement.moduleSpecifier && typescript.isStringLiteral(statement.moduleSpecifier)\n ? statement.moduleSpecifier.text\n : undefined;\n\n if (clause && typescript.isNamedExports(clause)) {\n const remote =\n specifier?.startsWith('.') === true\n ? FrameworkExports.resolveRelative({ from: file, specifier })\n : undefined;\n const there = remote\n ? FrameworkExports.namesOf({ typescript, file: remote, seen: new Set(seen) })\n : undefined;\n\n for (const element of clause.elements) {\n const original = (element.propertyName ?? element.name).text;\n const declared: TDeclarationType | undefined =\n statement.isTypeOnly || element.isTypeOnly\n ? 'type'\n : specifier === undefined\n ? locals.get(original)\n : there?.get(original);\n\n if (declared !== undefined) {\n names.set(element.name.text, declared);\n }\n }\n } else if (!clause && specifier?.startsWith('.') === true) {\n const target = FrameworkExports.resolveRelative({ from: file, specifier });\n\n if (target) {\n for (const [name, declared] of FrameworkExports.namesOf({\n typescript,\n file: target,\n seen,\n })) {\n names.set(name, declared);\n }\n }\n } else if (!clause && specifier?.startsWith(FrameworkExports.SCOPE) === true) {\n const sibling = FrameworkExports.locate({ name: specifier, directory: dirname(file) });\n\n if (sibling) {\n for (const name of FrameworkExports.readPackage({ directory: sibling }).keys()) {\n names.set(name, 'type');\n }\n }\n }\n\n continue;\n }\n\n if (!isExported(statement)) {\n continue;\n }\n\n if (typescript.isVariableStatement(statement)) {\n for (const declaration of statement.declarationList.declarations) {\n if (typescript.isIdentifier(declaration.name)) {\n names.set(declaration.name.text, 'value');\n }\n }\n } else if (\n (typescript.isInterfaceDeclaration(statement) ||\n typescript.isTypeAliasDeclaration(statement) ||\n typescript.isClassDeclaration(statement) ||\n typescript.isFunctionDeclaration(statement) ||\n typescript.isEnumDeclaration(statement) ||\n typescript.isModuleDeclaration(statement)) &&\n statement.name &&\n typescript.isIdentifier(statement.name)\n ) {\n names.set(statement.name.text, locals.get(statement.name.text) ?? typeOf(statement));\n }\n }\n\n return names;\n }\n\n /** Type name to the specifier that exports it (`@venizia/ignis-helpers/common`), for one installed package. */\n private static readPackage(opts: { directory: string }): Map<string, string> {\n const { directory } = opts;\n const cached = FrameworkExports.packages.get(directory);\n\n if (cached) {\n return cached;\n }\n\n const exported = new Map<string, string>();\n FrameworkExports.packages.set(directory, exported);\n\n const typescript = FrameworkExports.loadTypeScript({ directory });\n const manifest = FrameworkExports.readJson({ file: join(directory, 'package.json') });\n const name = AstNode.readField({ node: manifest, key: 'name' });\n\n if (!typescript || typeof name !== 'string') {\n return exported;\n }\n\n // A name reachable from several entries is imported from the narrowest one: `/common` over the root that re-exports it.\n const sizes = new Map<string, number>();\n\n for (const { subpath, file } of FrameworkExports.entriesOf({ manifest })) {\n const path = resolve(directory, file);\n\n if (!existsSync(path)) {\n continue;\n }\n\n const declared = FrameworkExports.namesOf({ typescript, file: path, seen: new Set() });\n const types = [...declared].filter(([, type]) => type === 'type').map(([entry]) => entry);\n\n for (const entry of types) {\n if (types.length < (sizes.get(entry) ?? Number.POSITIVE_INFINITY)) {\n sizes.set(entry, types.length);\n exported.set(entry, `${name}${subpath}`);\n }\n }\n }\n\n return exported;\n }\n\n /**\n * The type names the `@venizia/*` packages that `directory`'s project depends on export, each with the specifier to import\n * it from. The project's own package is left out: it may declare what it exports.\n */\n static of(opts: { directory: string }): Map<string, string> {\n const manifest = FrameworkExports.manifestFor({ directory: opts.directory });\n const all = new Map<string, string>();\n\n if (!manifest) {\n return all;\n }\n\n for (const dependency of manifest.dependencies) {\n const installed = FrameworkExports.locate({\n name: dependency,\n directory: manifest.directory,\n });\n\n if (!installed || dependency === manifest.name) {\n continue;\n }\n\n for (const [name, specifier] of FrameworkExports.readPackage({ directory: installed })) {\n if (!all.has(name)) {\n all.set(name, specifier);\n }\n }\n }\n\n return all;\n }\n}\n"]}
@@ -1,11 +1,11 @@
1
1
  export { AwaitSupport } from './await-support';
2
2
  export * from './browser-api-patterns';
3
3
  export { FrameworkExports } from './framework-exports';
4
- export * from './framework-rule-apis';
5
4
  export { ImportSupport } from './import-support';
6
5
  export * from './common';
7
6
  export * from './const-class-values.rule';
8
7
  export * from './effect-cleanup-consistency.rule';
8
+ export * from './framework-api-patterns';
9
9
  export * from './hook-support';
10
10
  export * from './max-params-own.rule';
11
11
  export * from './no-async-hook-callback.rule';
@@ -22,9 +22,8 @@ export * from './no-unbraced-case.rule';
22
22
  export * from './prefer-framework-api.rule';
23
23
  export * from './prefer-promise-sleep.rule';
24
24
  export * from './prefer-tnullable.rule';
25
- export { PublicSurface } from './public-surface';
26
- export * from './published-package-configs';
27
- export * from './require-use-when.rule';
25
+ export * from './typed-route-context.rule';
26
+ export * from './zod-schema-convention.rule';
28
27
  export * from './plugin';
29
28
  export * from './promise-chain-support';
30
29
  export * from './configs';