@venizia/dev-configs 0.5.0-10 → 0.5.0-12

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 (79) hide show
  1. package/README.md +3 -3
  2. package/dist/cli/codemod/async-context.d.ts +22 -0
  3. package/dist/cli/codemod/async-context.js +146 -0
  4. package/dist/cli/codemod/async-context.js.map +1 -0
  5. package/dist/cli/codemod/class-renames.d.ts +63 -0
  6. package/dist/cli/codemod/class-renames.js +208 -17
  7. package/dist/cli/codemod/class-renames.js.map +1 -1
  8. package/dist/cli/codemod/execution-class.d.ts +14 -0
  9. package/dist/cli/codemod/execution-class.js +46 -0
  10. package/dist/cli/codemod/execution-class.js.map +1 -0
  11. package/dist/cli/codemod/execution-scope.d.ts +68 -0
  12. package/dist/cli/codemod/execution-scope.js +727 -0
  13. package/dist/cli/codemod/execution-scope.js.map +1 -0
  14. package/dist/cli/codemod/index.js +25 -0
  15. package/dist/cli/codemod/index.js.map +1 -1
  16. package/dist/cli/codemod/namespace-functions/mapping.d.ts +6 -0
  17. package/dist/cli/codemod/namespace-functions/mapping.js.map +1 -1
  18. package/dist/cli/codemod/namespace-functions/mappings/connectors.d.ts +2 -0
  19. package/dist/cli/codemod/namespace-functions/mappings/connectors.js +19 -1
  20. package/dist/cli/codemod/namespace-functions/mappings/connectors.js.map +1 -1
  21. package/dist/cli/codemod/namespace-functions/mappings/guards.d.ts +4 -0
  22. package/dist/cli/codemod/namespace-functions/mappings/guards.js +15 -0
  23. package/dist/cli/codemod/namespace-functions/mappings/guards.js.map +1 -0
  24. package/dist/cli/codemod/namespace-functions/mappings/helpers.d.ts +3 -2
  25. package/dist/cli/codemod/namespace-functions/mappings/helpers.js +30 -9
  26. package/dist/cli/codemod/namespace-functions/mappings/helpers.js.map +1 -1
  27. package/dist/cli/codemod/namespace-functions/mappings/inversion.d.ts +6 -2
  28. package/dist/cli/codemod/namespace-functions/mappings/inversion.js +42 -3
  29. package/dist/cli/codemod/namespace-functions/mappings/inversion.js.map +1 -1
  30. package/dist/cli/codemod/namespace-functions/mappings/kernel.d.ts +4 -2
  31. package/dist/cli/codemod/namespace-functions/mappings/kernel.js +16 -3
  32. package/dist/cli/codemod/namespace-functions/mappings/kernel.js.map +1 -1
  33. package/dist/cli/codemod/namespace-functions/rewriter.d.ts +7 -0
  34. package/dist/cli/codemod/namespace-functions/rewriter.js +75 -8
  35. package/dist/cli/codemod/namespace-functions/rewriter.js.map +1 -1
  36. package/dist/cli/codemod/public-names.d.ts +25 -0
  37. package/dist/cli/codemod/public-names.js +134 -0
  38. package/dist/cli/codemod/public-names.js.map +1 -0
  39. package/dist/cli/index.js +1 -0
  40. package/dist/cli/index.js.map +1 -1
  41. package/dist/compilers/bun.js +8 -1
  42. package/dist/compilers/bun.js.map +1 -1
  43. package/dist/linters/eslint.js.map +1 -1
  44. package/dist/linters/house/configs.js +8 -4
  45. package/dist/linters/house/configs.js.map +1 -1
  46. package/dist/linters/house/execution-support.d.ts +66 -0
  47. package/dist/linters/house/execution-support.js +161 -0
  48. package/dist/linters/house/execution-support.js.map +1 -0
  49. package/dist/linters/house/framework-api-patterns.js +1 -1
  50. package/dist/linters/house/framework-api-patterns.js.map +1 -1
  51. package/dist/linters/house/index.d.ts +3 -1
  52. package/dist/linters/house/index.js +3 -1
  53. package/dist/linters/house/index.js.map +1 -1
  54. package/dist/linters/house/no-shadow-framework-type.rule.d.ts +1 -1
  55. package/dist/linters/house/no-shadow-framework-type.rule.js +1 -1
  56. package/dist/linters/house/no-shadow-framework-type.rule.js.map +1 -1
  57. package/dist/linters/house/plugin.js +6 -2
  58. package/dist/linters/house/plugin.js.map +1 -1
  59. package/dist/linters/house/prefer-execution-sleep.rule.d.ts +31 -0
  60. package/dist/linters/house/{prefer-promise-sleep.rule.js → prefer-execution-sleep.rule.js} +57 -20
  61. package/dist/linters/house/prefer-execution-sleep.rule.js.map +1 -0
  62. package/dist/linters/house/prefer-http-method.rule.d.ts +6 -3
  63. package/dist/linters/house/prefer-http-method.rule.js +116 -9
  64. package/dist/linters/house/prefer-http-method.rule.js.map +1 -1
  65. package/dist/linters/house/restrict-execution-call-sites.rule.d.ts +30 -0
  66. package/dist/linters/house/restrict-execution-call-sites.rule.js +142 -0
  67. package/dist/linters/house/restrict-execution-call-sites.rule.js.map +1 -0
  68. package/dist/linters/house/static-execution-reason.rule.d.ts +27 -0
  69. package/dist/linters/house/static-execution-reason.rule.js +152 -0
  70. package/dist/linters/house/static-execution-reason.rule.js.map +1 -0
  71. package/dist/linters/rules/naming-convention.rule.js +1 -1
  72. package/dist/linters/rules/naming-convention.rule.js.map +1 -1
  73. package/dist/linters/rules/no-restricted-imports.rule.d.ts +4 -2
  74. package/dist/linters/rules/no-restricted-imports.rule.js.map +1 -1
  75. package/dist/linters/rules/no-unused-vars.rule.d.ts +13 -2
  76. package/dist/linters/rules/no-unused-vars.rule.js.map +1 -1
  77. package/package.json +2 -2
  78. package/dist/linters/house/prefer-promise-sleep.rule.d.ts +0 -26
  79. package/dist/linters/house/prefer-promise-sleep.rule.js.map +0 -1
@@ -16,8 +16,9 @@ const no_new_error_rule_1 = require("./no-new-error.rule");
16
16
  const no_shadow_framework_type_rule_1 = require("./no-shadow-framework-type.rule");
17
17
  const prefer_framework_api_rule_1 = require("./prefer-framework-api.rule");
18
18
  const prefer_http_method_rule_1 = require("./prefer-http-method.rule");
19
- const prefer_promise_sleep_rule_1 = require("./prefer-promise-sleep.rule");
19
+ const prefer_execution_sleep_rule_1 = require("./prefer-execution-sleep.rule");
20
20
  const prefer_tnullable_rule_1 = require("./prefer-tnullable.rule");
21
+ const static_execution_reason_rule_1 = require("./static-execution-reason.rule");
21
22
  const typed_route_context_rule_1 = require("./typed-route-context.rule");
22
23
  const zod_schema_convention_rule_1 = require("./zod-schema-convention.rule");
23
24
  const plugin_1 = require("./plugin");
@@ -31,7 +32,8 @@ const NO_CAST_RULE = '@typescript-eslint/consistent-type-assertions';
31
32
  /**
32
33
  * The house rules: at most 5 positional parameters on a function we write, and errors thrown through
33
34
  * `getError` only. Tests are exempt from `no-new-error`: a test throws a plain `Error` on purpose, to
34
- * stand in for what a driver or a third-party library throws.
35
+ * stand in for what a driver or a third-party library throws. `restrict-execution-call-sites` is not here:
36
+ * an application turns it on with its own list of files.
35
37
  *
36
38
  * Two rules only warn, so a project adopts them without failing its lint: `const-class-values` (V-C-08, a
37
39
  * string-literal union in an exported declaration) and `consistent-type-assertions` (V-C-10, an `as X`
@@ -46,7 +48,8 @@ const houseRuleConfigs = [
46
48
  [no_new_error_rule_1.NoNewErrorRule.NAME]: no_new_error_rule_1.NoNewErrorRule.build(),
47
49
  [no_shadow_framework_type_rule_1.NoShadowFrameworkTypeRule.NAME]: no_shadow_framework_type_rule_1.NoShadowFrameworkTypeRule.build(),
48
50
  [prefer_tnullable_rule_1.PreferTNullableRule.NAME]: prefer_tnullable_rule_1.PreferTNullableRule.build(),
49
- [prefer_promise_sleep_rule_1.PreferPromiseSleepRule.NAME]: prefer_promise_sleep_rule_1.PreferPromiseSleepRule.build(),
51
+ [prefer_execution_sleep_rule_1.PreferExecutionSleepRule.NAME]: prefer_execution_sleep_rule_1.PreferExecutionSleepRule.build(),
52
+ [static_execution_reason_rule_1.StaticExecutionReasonRule.NAME]: static_execution_reason_rule_1.StaticExecutionReasonRule.build(),
50
53
  [prefer_http_method_rule_1.PreferHttpMethodRule.NAME]: prefer_http_method_rule_1.PreferHttpMethodRule.build(),
51
54
  [prefer_framework_api_rule_1.PreferFrameworkApiRule.NAME]: prefer_framework_api_rule_1.PreferFrameworkApiRule.build({ hooks: false }),
52
55
  [const_class_values_rule_1.ConstClassValuesRule.NAME]: const_class_values_rule_1.ConstClassValuesRule.build({ severity: 'warn' }),
@@ -60,7 +63,8 @@ const houseRuleConfigs = [
60
63
  rules: {
61
64
  [no_new_error_rule_1.NoNewErrorRule.NAME]: 'off',
62
65
  [no_shadow_framework_type_rule_1.NoShadowFrameworkTypeRule.NAME]: 'off',
63
- [prefer_promise_sleep_rule_1.PreferPromiseSleepRule.NAME]: 'off',
66
+ [prefer_execution_sleep_rule_1.PreferExecutionSleepRule.NAME]: 'off',
67
+ [static_execution_reason_rule_1.StaticExecutionReasonRule.NAME]: 'off',
64
68
  [prefer_http_method_rule_1.PreferHttpMethodRule.NAME]: 'off',
65
69
  [prefer_framework_api_rule_1.PreferFrameworkApiRule.NAME]: 'off',
66
70
  [const_class_values_rule_1.ConstClassValuesRule.NAME]: 'off',
@@ -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,2DAAqD;AACrD,mFAA4E;AAC5E,2EAAqE;AACrE,uEAAiE;AACjE,2EAAqE;AACrE,mEAA8D;AAC9D,yEAAmE;AACnE,6EAAuE;AACvE,qCAA6C;AAE7C,MAAM,YAAY,GAAG,CAAC,uBAAuB,CAAC,CAAC;AAC/C,MAAM,UAAU,GAAG,CAAC,iBAAiB,EAAE,oBAAoB,EAAE,oBAAoB,CAAC,CAAC;AAEnF;;;GAGG;AACH,MAAM,YAAY,GAAG,+CAA+C,CAAC;AAErE;;;;;;;;GAQG;AACH,MAAM,gBAAgB,GAAoB;IACxC;QACE,KAAK,EAAE,YAAY;QACnB,OAAO,EAAE,EAAE,CAAC,+BAAsB,CAAC,EAAE,0BAAiB,EAAE;QACxD,KAAK,EAAE;YACL,CAAC,sCAAgB,CAAC,IAAI,CAAC,EAAE,sCAAgB,CAAC,KAAK,EAAE;YACjD,CAAC,kCAAc,CAAC,IAAI,CAAC,EAAE,kCAAc,CAAC,KAAK,EAAE;YAC7C,CAAC,yDAAyB,CAAC,IAAI,CAAC,EAAE,yDAAyB,CAAC,KAAK,EAAE;YACnE,CAA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M,gBAAgB,GAAoB;IACxC;QACE,KAAK,EAAE,qBAAS;QAChB,OAAO,EAAE,EAAE,CAAC,+BAAsB,CAAC,EAAE,0BAAiB,EAAE;QACxD,KAAK,EAAE,EAAE,CAAC,0CAAkB,CAAC,IAAI,CAAC,EAAE,0CAAkB,CAAC,KAAK,EAAE,EAAE;KACjE;CACF,CAAC;AAEF;;;;GAIG;AACH,MAAM,oBAAoB,GAAoB;IAC5C;QACE,KAAK,EAAE,YAAY;QACnB,OAAO,EAAE,EAAE,CAAC,+BAAsB,CAAC,EAAE,0BAAiB,EAAE;QACxD,KAAK,EAAE;YACL,CAAC,qDAAuB,CAAC,IAAI,CAAC,EAAE,qDAAuB,CAAC,KAAK,EAAE;YAC/D,CAAC,8DAA4B,CAAC,IAAI,CAAC,EAAE,8DAA4B,CAAC,KAAK,EAAE;SAC1E;KACF;IACD,yHAAyH;IACzH;QACE,KAAK,EAAE,YAAY;QACnB,OAAO,EAAE,EAAE,CAAC,+BAAsB,CAAC,EAAE,0BAAiB,EAAE;QACxD,KAAK,EAAE,EAAE,CAAC,kDAAsB,CAAC,IAAI,CAAC,EAAE,kDAAsB,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,EAAE;KACxF;IACD,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,EAAE,CAAC,kDAAsB,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 { PreferHttpMethodRule } from './prefer-http-method.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 [PreferHttpMethodRule.NAME]: PreferHttpMethodRule.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 [PreferHttpMethodRule.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
+ {"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,uEAAiE;AACjE,+EAAyE;AACzE,mEAA8D;AAC9D,iFAA2E;AAC3E,yEAAmE;AACnE,6EAAuE;AACvE,qCAA6C;AAE7C,MAAM,YAAY,GAAG,CAAC,uBAAuB,CAAC,CAAC;AAC/C,MAAM,UAAU,GAAG,CAAC,iBAAiB,EAAE,oBAAoB,EAAE,oBAAoB,CAAC,C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AsB,CAAC,IAAI,CAAC,EAAE,kDAAsB,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,EAAE;KACxF;IACD,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,EAAE,CAAC,kDAAsB,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 { PreferHttpMethodRule } from './prefer-http-method.rule';\nimport { PreferExecutionSleepRule } from './prefer-execution-sleep.rule';\nimport { PreferTNullableRule } from './prefer-tnullable.rule';\nimport { StaticExecutionReasonRule } from './static-execution-reason.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. `restrict-execution-call-sites` is not here:\n * an application turns it on with its own list of files.\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 [PreferExecutionSleepRule.NAME]: PreferExecutionSleepRule.build(),\n [StaticExecutionReasonRule.NAME]: StaticExecutionReasonRule.build(),\n [PreferHttpMethodRule.NAME]: PreferHttpMethodRule.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 [PreferExecutionSleepRule.NAME]: 'off',\n [StaticExecutionReasonRule.NAME]: 'off',\n [PreferHttpMethodRule.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"]}
@@ -0,0 +1,66 @@
1
+ import type { Rule, Scope } from 'eslint';
2
+ /** What an options object says about one key, as far as the syntax shows. */
3
+ export interface IExecutionOption {
4
+ /** The value last written for the key, when one is. */
5
+ value?: Rule.Node;
6
+ /** A spread or a computed key after it may supply or replace the value. */
7
+ isUnknown: boolean;
8
+ }
9
+ /**
10
+ * Reads the code that says who is running (`Execution`, `ExecutionFrames`, `ExecutionModes`) for the house rules.
11
+ * A name counts only when it is bound by an import from `@venizia/ignis`, `@venizia/ignis-helpers` or a sub-path of
12
+ * them, under an alias or a namespace too. A re-export of the application's own is not followed.
13
+ */
14
+ export declare class ExecutionSupport {
15
+ private static readonly PACKAGES;
16
+ /** The syntax around an expression that does not change which value it is. */
17
+ private static readonly WRAPPERS;
18
+ /** The node a field holds, or `undefined` for anything else. */
19
+ static child(opts: {
20
+ node: unknown;
21
+ key: string;
22
+ }): Rule.Node | undefined;
23
+ /** The nodes a field holds; empty for anything that is not a list. */
24
+ static list(opts: {
25
+ node: unknown;
26
+ key: string;
27
+ }): Rule.Node[];
28
+ /** The expression without the type wrappers and the optional chain around it. */
29
+ static unwrap(opts: {
30
+ node: Rule.Node | undefined;
31
+ }): Rule.Node | undefined;
32
+ /** The name an identifier or a string literal writes. */
33
+ private static textOf;
34
+ /** The text of a template without expressions. */
35
+ static templateTextOf(opts: {
36
+ node: unknown;
37
+ }): string | undefined;
38
+ /** The name a member expression or a property reads: `a.run`, `a['run']`, `{ run }`. */
39
+ static keyOf(opts: {
40
+ node: unknown;
41
+ key: string;
42
+ }): string | undefined;
43
+ /** The variable the identifier `node` refers to. */
44
+ static variableOf(opts: {
45
+ context: Rule.RuleContext;
46
+ node: Rule.Node;
47
+ }): Scope.Variable | undefined;
48
+ /** The import that binds the identifier `node`, when it is a value import from the framework. */
49
+ private static importOf;
50
+ /** The framework export an expression denotes (`Alias`, `namespace.Execution`), or `undefined`. */
51
+ static exportOf(opts: {
52
+ context: Rule.RuleContext;
53
+ node: Rule.Node | undefined;
54
+ }): string | undefined;
55
+ /** What the object literal `object` says about `name`, read in the order the properties are written. */
56
+ static optionOf(opts: {
57
+ object: Rule.Node;
58
+ name: string;
59
+ }): IExecutionOption;
60
+ /** Whether the options object writes a system mode: `ExecutionModes.SYSTEM` or `'system'`. */
61
+ static isSystemRun(opts: {
62
+ context: Rule.RuleContext;
63
+ object: Rule.Node;
64
+ }): boolean;
65
+ }
66
+ //# sourceMappingURL=execution-support.d.ts.map
@@ -0,0 +1,161 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ExecutionSupport = void 0;
4
+ const common_1 = require("./common");
5
+ /**
6
+ * Reads the code that says who is running (`Execution`, `ExecutionFrames`, `ExecutionModes`) for the house rules.
7
+ * A name counts only when it is bound by an import from `@venizia/ignis`, `@venizia/ignis-helpers` or a sub-path of
8
+ * them, under an alias or a namespace too. A re-export of the application's own is not followed.
9
+ */
10
+ class ExecutionSupport {
11
+ static { this.PACKAGES = ['@venizia/ignis', '@venizia/ignis-helpers']; }
12
+ /** The syntax around an expression that does not change which value it is. */
13
+ static { this.WRAPPERS = new Set([
14
+ common_1.AstNodeTypes.AS_EXPRESSION,
15
+ common_1.AstNodeTypes.SATISFIES_EXPRESSION,
16
+ common_1.AstNodeTypes.NON_NULL_EXPRESSION,
17
+ common_1.AstNodeTypes.CHAIN_EXPRESSION,
18
+ ]); }
19
+ /** The node a field holds, or `undefined` for anything else. */
20
+ static child(opts) {
21
+ const value = common_1.AstNode.readField(opts);
22
+ return common_1.AstNode.isNode(value) ? value : undefined;
23
+ }
24
+ /** The nodes a field holds; empty for anything that is not a list. */
25
+ static list(opts) {
26
+ const value = common_1.AstNode.readField(opts);
27
+ return Array.isArray(value) ? value.filter((item) => common_1.AstNode.isNode(item)) : [];
28
+ }
29
+ /** The expression without the type wrappers and the optional chain around it. */
30
+ static unwrap(opts) {
31
+ const { node } = opts;
32
+ return node && ExecutionSupport.WRAPPERS.has(node.type)
33
+ ? ExecutionSupport.unwrap({
34
+ node: ExecutionSupport.child({ node, key: 'expression' }),
35
+ })
36
+ : node;
37
+ }
38
+ /** The name an identifier or a string literal writes. */
39
+ static textOf(opts) {
40
+ const { node } = opts;
41
+ const name = common_1.AstNode.readField({ node, key: 'name' });
42
+ const value = common_1.AstNode.readField({ node, key: 'value' });
43
+ const text = name ?? value;
44
+ return typeof text === 'string' ? text : undefined;
45
+ }
46
+ /** The text of a template without expressions. */
47
+ static templateTextOf(opts) {
48
+ const { node } = opts;
49
+ if (common_1.AstNode.getType({ node }) !== common_1.AstNodeTypes.TEMPLATE_LITERAL ||
50
+ ExecutionSupport.list({ node, key: 'expressions' }).length > 0) {
51
+ return undefined;
52
+ }
53
+ const [quasi] = ExecutionSupport.list({ node, key: 'quasis' });
54
+ const cooked = common_1.AstNode.readField({
55
+ node: common_1.AstNode.readField({ node: quasi, key: 'value' }),
56
+ key: 'cooked',
57
+ });
58
+ return typeof cooked === 'string' ? cooked : undefined;
59
+ }
60
+ /** The name a member expression or a property reads: `a.run`, `a['run']`, `{ run }`. */
61
+ static keyOf(opts) {
62
+ const written = common_1.AstNode.readField(opts);
63
+ const isComputed = common_1.AstNode.readField({ node: opts.node, key: 'computed' }) === true;
64
+ if (isComputed && common_1.AstNode.getType({ node: written }) !== common_1.AstNodeTypes.LITERAL) {
65
+ return ExecutionSupport.templateTextOf({ node: written });
66
+ }
67
+ return ExecutionSupport.textOf({ node: written });
68
+ }
69
+ /** The variable the identifier `node` refers to. */
70
+ static variableOf(opts) {
71
+ const { context, node } = opts;
72
+ const name = ExecutionSupport.textOf({ node });
73
+ let scope = context.sourceCode.getScope(node);
74
+ while (scope && name !== undefined) {
75
+ const variable = scope.set.get(name);
76
+ if (variable) {
77
+ return variable;
78
+ }
79
+ scope = scope.upper;
80
+ }
81
+ return undefined;
82
+ }
83
+ /** The import that binds the identifier `node`, when it is a value import from the framework. */
84
+ static importOf(opts) {
85
+ const definition = ExecutionSupport.variableOf(opts)?.defs[0];
86
+ if (common_1.AstNode.readField({ node: definition, key: 'type' }) !== 'ImportBinding') {
87
+ return undefined;
88
+ }
89
+ const specifier = common_1.AstNode.readField({ node: definition, key: 'node' });
90
+ const declaration = common_1.AstNode.readField({ node: definition, key: 'parent' });
91
+ const source = ExecutionSupport.textOf({
92
+ node: common_1.AstNode.readField({ node: declaration, key: 'source' }),
93
+ });
94
+ const isFramework = ExecutionSupport.PACKAGES.some((name) => source === name || source?.startsWith(`${name}/`) === true);
95
+ const isType = [specifier, declaration].some((item) => common_1.AstNode.readField({ node: item, key: 'importKind' }) === 'type');
96
+ return isFramework && !isType ? specifier : undefined;
97
+ }
98
+ /** The framework export an expression denotes (`Alias`, `namespace.Execution`), or `undefined`. */
99
+ static exportOf(opts) {
100
+ const { context } = opts;
101
+ const node = ExecutionSupport.unwrap({ node: opts.node });
102
+ if (node?.type === common_1.AstNodeTypes.IDENTIFIER) {
103
+ const specifier = ExecutionSupport.importOf({ context, node });
104
+ return common_1.AstNode.getType({ node: specifier }) === common_1.AstNodeTypes.IMPORT_SPECIFIER
105
+ ? ExecutionSupport.textOf({
106
+ node: common_1.AstNode.readField({ node: specifier, key: 'imported' }),
107
+ })
108
+ : undefined;
109
+ }
110
+ if (node?.type !== common_1.AstNodeTypes.MEMBER_EXPRESSION) {
111
+ return undefined;
112
+ }
113
+ const object = ExecutionSupport.child({ node, key: 'object' });
114
+ if (object?.type !== common_1.AstNodeTypes.IDENTIFIER) {
115
+ return undefined;
116
+ }
117
+ const specifier = ExecutionSupport.importOf({ context, node: object });
118
+ return common_1.AstNode.getType({ node: specifier }) === 'ImportNamespaceSpecifier'
119
+ ? ExecutionSupport.keyOf({ node, key: 'property' })
120
+ : undefined;
121
+ }
122
+ /** What the object literal `object` says about `name`, read in the order the properties are written. */
123
+ static optionOf(opts) {
124
+ const { object, name } = opts;
125
+ let option = { isUnknown: false };
126
+ for (const property of ExecutionSupport.list({ node: object, key: 'properties' })) {
127
+ const key = property.type === common_1.AstNodeTypes.PROPERTY
128
+ ? ExecutionSupport.keyOf({ node: property, key: 'key' })
129
+ : undefined;
130
+ if (key === undefined) {
131
+ option = { value: option.value, isUnknown: true };
132
+ continue;
133
+ }
134
+ if (key === name) {
135
+ option = {
136
+ value: ExecutionSupport.child({ node: property, key: 'value' }),
137
+ isUnknown: false,
138
+ };
139
+ }
140
+ }
141
+ return option;
142
+ }
143
+ /** Whether the options object writes a system mode: `ExecutionModes.SYSTEM` or `'system'`. */
144
+ static isSystemRun(opts) {
145
+ const { context, object } = opts;
146
+ const mode = ExecutionSupport.unwrap({
147
+ node: ExecutionSupport.optionOf({ object, name: 'mode' }).value,
148
+ });
149
+ if (mode?.type === common_1.AstNodeTypes.LITERAL) {
150
+ return ExecutionSupport.textOf({ node: mode }) === 'system';
151
+ }
152
+ return (mode?.type === common_1.AstNodeTypes.MEMBER_EXPRESSION &&
153
+ ExecutionSupport.keyOf({ node: mode, key: 'property' }) === 'SYSTEM' &&
154
+ ExecutionSupport.exportOf({
155
+ context,
156
+ node: ExecutionSupport.child({ node: mode, key: 'object' }),
157
+ }) === 'ExecutionModes');
158
+ }
159
+ }
160
+ exports.ExecutionSupport = ExecutionSupport;
161
+ //# sourceMappingURL=execution-support.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution-support.js","sourceRoot":"","sources":["../../../src/linters/house/execution-support.ts"],"names":[],"mappings":";;;AACA,qCAAiD;AAUjD;;;;GAIG;AACH,MAAa,gBAAgB;aACH,aAAQ,GAAG,CAAC,gBAAgB,EAAE,wBAAwB,CAAC,CAAC;IAEhF,8EAA8E;aACtD,aAAQ,GAAwB,IAAI,GAAG,CAAC;QAC9D,qBAAY,CAAC,aAAa;QAC1B,q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AC7C,gBAAgB,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,UAAU,EAAE,CAAC,KAAK,QAAQ;YACpE,gBAAgB,CAAC,QAAQ,CAAC;gBACxB,OAAO;gBACP,IAAI,EAAE,gBAAgB,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC;aAC5D,CAAC,KAAK,gBAAgB,CACxB,CAAC;IACJ,CAAC;;AA5MH,4CA6MC","sourcesContent":["import type { Rule, Scope } from 'eslint';\nimport { AstNode, AstNodeTypes } from './common';\n\n/** What an options object says about one key, as far as the syntax shows. */\nexport interface IExecutionOption {\n /** The value last written for the key, when one is. */\n value?: Rule.Node;\n /** A spread or a computed key after it may supply or replace the value. */\n isUnknown: boolean;\n}\n\n/**\n * Reads the code that says who is running (`Execution`, `ExecutionFrames`, `ExecutionModes`) for the house rules.\n * A name counts only when it is bound by an import from `@venizia/ignis`, `@venizia/ignis-helpers` or a sub-path of\n * them, under an alias or a namespace too. A re-export of the application's own is not followed.\n */\nexport class ExecutionSupport {\n private static readonly PACKAGES = ['@venizia/ignis', '@venizia/ignis-helpers'];\n\n /** The syntax around an expression that does not change which value it is. */\n private static readonly WRAPPERS: ReadonlySet<string> = new Set([\n AstNodeTypes.AS_EXPRESSION,\n AstNodeTypes.SATISFIES_EXPRESSION,\n AstNodeTypes.NON_NULL_EXPRESSION,\n AstNodeTypes.CHAIN_EXPRESSION,\n ]);\n\n /** The node a field holds, or `undefined` for anything else. */\n static child(opts: { node: unknown; key: string }): Rule.Node | undefined {\n const value = AstNode.readField(opts);\n\n return AstNode.isNode(value) ? value : undefined;\n }\n\n /** The nodes a field holds; empty for anything that is not a list. */\n static list(opts: { node: unknown; key: string }): Rule.Node[] {\n const value: unknown = AstNode.readField(opts);\n\n return Array.isArray(value) ? value.filter((item) => AstNode.isNode(item)) : [];\n }\n\n /** The expression without the type wrappers and the optional chain around it. */\n static unwrap(opts: { node: Rule.Node | undefined }): Rule.Node | undefined {\n const { node } = opts;\n\n return node && ExecutionSupport.WRAPPERS.has(node.type)\n ? ExecutionSupport.unwrap({\n node: ExecutionSupport.child({ node, key: 'expression' }),\n })\n : node;\n }\n\n /** The name an identifier or a string literal writes. */\n private static textOf(opts: { node: unknown }): string | undefined {\n const { node } = opts;\n const name = AstNode.readField({ node, key: 'name' });\n const value = AstNode.readField({ node, key: 'value' });\n const text = name ?? value;\n\n return typeof text === 'string' ? text : undefined;\n }\n\n /** The text of a template without expressions. */\n static templateTextOf(opts: { node: unknown }): string | undefined {\n const { node } = opts;\n\n if (\n AstNode.getType({ node }) !== AstNodeTypes.TEMPLATE_LITERAL ||\n ExecutionSupport.list({ node, key: 'expressions' }).length > 0\n ) {\n return undefined;\n }\n\n const [quasi] = ExecutionSupport.list({ node, key: 'quasis' });\n const cooked = AstNode.readField({\n node: AstNode.readField({ node: quasi, key: 'value' }),\n key: 'cooked',\n });\n\n return typeof cooked === 'string' ? cooked : undefined;\n }\n\n /** The name a member expression or a property reads: `a.run`, `a['run']`, `{ run }`. */\n static keyOf(opts: { node: unknown; key: string }): string | undefined {\n const written = AstNode.readField(opts);\n const isComputed = AstNode.readField({ node: opts.node, key: 'computed' }) === true;\n\n if (isComputed && AstNode.getType({ node: written }) !== AstNodeTypes.LITERAL) {\n return ExecutionSupport.templateTextOf({ node: written });\n }\n\n return ExecutionSupport.textOf({ node: written });\n }\n\n /** The variable the identifier `node` refers to. */\n static variableOf(opts: {\n context: Rule.RuleContext;\n node: Rule.Node;\n }): Scope.Variable | undefined {\n const { context, node } = opts;\n const name = ExecutionSupport.textOf({ node });\n let scope: Scope.Scope | null = context.sourceCode.getScope(node);\n\n while (scope && name !== undefined) {\n const variable = scope.set.get(name);\n\n if (variable) {\n return variable;\n }\n\n scope = scope.upper;\n }\n\n return undefined;\n }\n\n /** The import that binds the identifier `node`, when it is a value import from the framework. */\n private static importOf(opts: { context: Rule.RuleContext; node: Rule.Node }): unknown {\n const definition: unknown = ExecutionSupport.variableOf(opts)?.defs[0];\n\n if (AstNode.readField({ node: definition, key: 'type' }) !== 'ImportBinding') {\n return undefined;\n }\n\n const specifier = AstNode.readField({ node: definition, key: 'node' });\n const declaration = AstNode.readField({ node: definition, key: 'parent' });\n const source = ExecutionSupport.textOf({\n node: AstNode.readField({ node: declaration, key: 'source' }),\n });\n const isFramework = ExecutionSupport.PACKAGES.some(\n (name) => source === name || source?.startsWith(`${name}/`) === true,\n );\n const isType = [specifier, declaration].some(\n (item) => AstNode.readField({ node: item, key: 'importKind' }) === 'type',\n );\n\n return isFramework && !isType ? specifier : undefined;\n }\n\n /** The framework export an expression denotes (`Alias`, `namespace.Execution`), or `undefined`. */\n static exportOf(opts: {\n context: Rule.RuleContext;\n node: Rule.Node | undefined;\n }): string | undefined {\n const { context } = opts;\n const node = ExecutionSupport.unwrap({ node: opts.node });\n\n if (node?.type === AstNodeTypes.IDENTIFIER) {\n const specifier = ExecutionSupport.importOf({ context, node });\n\n return AstNode.getType({ node: specifier }) === AstNodeTypes.IMPORT_SPECIFIER\n ? ExecutionSupport.textOf({\n node: AstNode.readField({ node: specifier, key: 'imported' }),\n })\n : undefined;\n }\n\n if (node?.type !== AstNodeTypes.MEMBER_EXPRESSION) {\n return undefined;\n }\n\n const object = ExecutionSupport.child({ node, key: 'object' });\n\n if (object?.type !== AstNodeTypes.IDENTIFIER) {\n return undefined;\n }\n\n const specifier = ExecutionSupport.importOf({ context, node: object });\n\n return AstNode.getType({ node: specifier }) === 'ImportNamespaceSpecifier'\n ? ExecutionSupport.keyOf({ node, key: 'property' })\n : undefined;\n }\n\n /** What the object literal `object` says about `name`, read in the order the properties are written. */\n static optionOf(opts: { object: Rule.Node; name: string }): IExecutionOption {\n const { object, name } = opts;\n let option: IExecutionOption = { isUnknown: false };\n\n for (const property of ExecutionSupport.list({ node: object, key: 'properties' })) {\n const key =\n property.type === AstNodeTypes.PROPERTY\n ? ExecutionSupport.keyOf({ node: property, key: 'key' })\n : undefined;\n\n if (key === undefined) {\n option = { value: option.value, isUnknown: true };\n continue;\n }\n\n if (key === name) {\n option = {\n value: ExecutionSupport.child({ node: property, key: 'value' }),\n isUnknown: false,\n };\n }\n }\n\n return option;\n }\n\n /** Whether the options object writes a system mode: `ExecutionModes.SYSTEM` or `'system'`. */\n static isSystemRun(opts: { context: Rule.RuleContext; object: Rule.Node }): boolean {\n const { context, object } = opts;\n const mode = ExecutionSupport.unwrap({\n node: ExecutionSupport.optionOf({ object, name: 'mode' }).value,\n });\n\n if (mode?.type === AstNodeTypes.LITERAL) {\n return ExecutionSupport.textOf({ node: mode }) === 'system';\n }\n\n return (\n mode?.type === AstNodeTypes.MEMBER_EXPRESSION &&\n ExecutionSupport.keyOf({ node: mode, key: 'property' }) === 'SYSTEM' &&\n ExecutionSupport.exportOf({\n context,\n node: ExecutionSupport.child({ node: mode, key: 'object' }),\n }) === 'ExecutionModes'\n );\n }\n}\n"]}
@@ -13,7 +13,7 @@ class FrameworkApiPatterns {
13
13
  type: 'selector',
14
14
  selector: "BinaryExpression[operator='instanceof'][right.name='ApplicationError']",
15
15
  },
16
- message: "Use `isApplicationError(error)`, not `instanceof ApplicationError`, which fails across two installed copies: `import { isApplicationError } from '@venizia/ignis-helpers/core';`",
16
+ message: "Use `ApplicationError.isApplicationError(error)`, not `instanceof ApplicationError`, which fails across two installed copies: `import { ApplicationError } from '@venizia/ignis-helpers/core';`",
17
17
  dependsOn: '@venizia/ignis',
18
18
  owner: '@venizia/ignis-inversion',
19
19
  },
@@ -1 +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,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ApiMatch } 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"]}
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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,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 `ApplicationError.isApplicationError(error)`, not `instanceof ApplicationError`, which fails across two installed copies: `import { ApplicationError } 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"]}
@@ -21,8 +21,10 @@ export * from './no-silent-catch.rule';
21
21
  export * from './no-unbraced-case.rule';
22
22
  export * from './prefer-framework-api.rule';
23
23
  export * from './prefer-http-method.rule';
24
- export * from './prefer-promise-sleep.rule';
24
+ export * from './prefer-execution-sleep.rule';
25
25
  export * from './prefer-tnullable.rule';
26
+ export * from './restrict-execution-call-sites.rule';
27
+ export * from './static-execution-reason.rule';
26
28
  export * from './typed-route-context.rule';
27
29
  export * from './zod-schema-convention.rule';
28
30
  export * from './plugin';
@@ -41,8 +41,10 @@ __exportStar(require("./no-silent-catch.rule"), exports);
41
41
  __exportStar(require("./no-unbraced-case.rule"), exports);
42
42
  __exportStar(require("./prefer-framework-api.rule"), exports);
43
43
  __exportStar(require("./prefer-http-method.rule"), exports);
44
- __exportStar(require("./prefer-promise-sleep.rule"), exports);
44
+ __exportStar(require("./prefer-execution-sleep.rule"), exports);
45
45
  __exportStar(require("./prefer-tnullable.rule"), exports);
46
+ __exportStar(require("./restrict-execution-call-sites.rule"), exports);
47
+ __exportStar(require("./static-execution-reason.rule"), exports);
46
48
  __exportStar(require("./typed-route-context.rule"), exports);
47
49
  __exportStar(require("./zod-schema-convention.rule"), exports);
48
50
  __exportStar(require("./plugin"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/linters/house/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,iDAA+C;AAAtC,6GAAA,YAAY,OAAA;AACrB,yDAAuC;AACvC,yDAAuD;AAA9C,qHAAA,gBAAgB,OAAA;AACzB,mDAAiD;AAAxC,+GAAA,aAAa,OAAA;AACtB,2CAAyB;AACzB,4DAA0C;AAC1C,oEAAkD;AAClD,2DAAyC;AACzC,iDAA+B;AAC/B,wDAAsC;AACtC,gEAA8C;AAC9C,4DAA0C;AAC1C,gEAA8C;AAC9C,yDAAuC;AACvC,0DAAwC;AACxC,sDAAoC;AACpC,0DAAwC;AACxC,kEAAgD;AAChD,yDAAuC;AACvC,yDAAuC;AACvC,0DAAwC;AACxC,8DAA4C;AAC5C,4DAA0C;AAC1C,8DAA4C;AAC5C,0DAAwC;AACxC,6DAA2C;AAC3C,+DAA6C;AAC7C,2CAAyB;AACzB,0DAAwC;AACxC,4CAA0B","sourcesContent":["export { AwaitSupport } from './await-support';\nexport * from './browser-api-patterns';\nexport { FrameworkExports } from './framework-exports';\nexport { ImportSupport } from './import-support';\nexport * from './common';\nexport * from './const-class-values.rule';\nexport * from './effect-cleanup-consistency.rule';\nexport * from './framework-api-patterns';\nexport * from './hook-support';\nexport * from './max-params-own.rule';\nexport * from './no-async-hook-callback.rule';\nexport * from './no-await-new-chain.rule';\nexport * from './no-await-promise-chain.rule';\nexport * from './no-inline-await.rule';\nexport * from './no-leaked-render.rule';\nexport * from './no-new-error.rule';\nexport * from './no-parent-import.rule';\nexport * from './no-shadow-framework-type.rule';\nexport * from './no-return-await.rule';\nexport * from './no-silent-catch.rule';\nexport * from './no-unbraced-case.rule';\nexport * from './prefer-framework-api.rule';\nexport * from './prefer-http-method.rule';\nexport * from './prefer-promise-sleep.rule';\nexport * from './prefer-tnullable.rule';\nexport * from './typed-route-context.rule';\nexport * from './zod-schema-convention.rule';\nexport * from './plugin';\nexport * from './promise-chain-support';\nexport * from './configs';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/linters/house/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,iDAA+C;AAAtC,6GAAA,YAAY,OAAA;AACrB,yDAAuC;AACvC,yDAAuD;AAA9C,qHAAA,gBAAgB,OAAA;AACzB,mDAAiD;AAAxC,+GAAA,aAAa,OAAA;AACtB,2CAAyB;AACzB,4DAA0C;AAC1C,oEAAkD;AAClD,2DAAyC;AACzC,iDAA+B;AAC/B,wDAAsC;AACtC,gEAA8C;AAC9C,4DAA0C;AAC1C,gEAA8C;AAC9C,yDAAuC;AACvC,0DAAwC;AACxC,sDAAoC;AACpC,0DAAwC;AACxC,kEAAgD;AAChD,yDAAuC;AACvC,yDAAuC;AACvC,0DAAwC;AACxC,8DAA4C;AAC5C,4DAA0C;AAC1C,gEAA8C;AAC9C,0DAAwC;AACxC,uEAAqD;AACrD,iEAA+C;AAC/C,6DAA2C;AAC3C,+DAA6C;AAC7C,2CAAyB;AACzB,0DAAwC;AACxC,4CAA0B","sourcesContent":["export { AwaitSupport } from './await-support';\nexport * from './browser-api-patterns';\nexport { FrameworkExports } from './framework-exports';\nexport { ImportSupport } from './import-support';\nexport * from './common';\nexport * from './const-class-values.rule';\nexport * from './effect-cleanup-consistency.rule';\nexport * from './framework-api-patterns';\nexport * from './hook-support';\nexport * from './max-params-own.rule';\nexport * from './no-async-hook-callback.rule';\nexport * from './no-await-new-chain.rule';\nexport * from './no-await-promise-chain.rule';\nexport * from './no-inline-await.rule';\nexport * from './no-leaked-render.rule';\nexport * from './no-new-error.rule';\nexport * from './no-parent-import.rule';\nexport * from './no-shadow-framework-type.rule';\nexport * from './no-return-await.rule';\nexport * from './no-silent-catch.rule';\nexport * from './no-unbraced-case.rule';\nexport * from './prefer-framework-api.rule';\nexport * from './prefer-http-method.rule';\nexport * from './prefer-execution-sleep.rule';\nexport * from './prefer-tnullable.rule';\nexport * from './restrict-execution-call-sites.rule';\nexport * from './static-execution-reason.rule';\nexport * from './typed-route-context.rule';\nexport * from './zod-schema-convention.rule';\nexport * from './plugin';\nexport * from './promise-chain-support';\nexport * from './configs';\n"]}
@@ -2,7 +2,7 @@ import type { Linter, Rule } from 'eslint';
2
2
  import type { TRuleSeverity } from '../rules/common';
3
3
  /**
4
4
  * `@venizia/no-shadow-framework-type`. A type alias or interface written in your project under the name a `@venizia/*`
5
- * package already exports (`ValueOrPromise`, `TNullable`, `TConstValue`) is a copy of the framework's: import it.
5
+ * package already exports (`TValueOrPromise`, `TNullable`, `TConstValue`) is a copy of the framework's: import it.
6
6
  *
7
7
  * The names come from the installed packages' `.d.ts` files (see `FrameworkExports`), for the packages your nearest
8
8
  * `package.json` depends on. Not reported: a name the file imports, a name shorter than `minLength` (default 4, so a
@@ -7,7 +7,7 @@ const framework_exports_1 = require("./framework-exports");
7
7
  const import_support_1 = require("./import-support");
8
8
  /**
9
9
  * `@venizia/no-shadow-framework-type`. A type alias or interface written in your project under the name a `@venizia/*`
10
- * package already exports (`ValueOrPromise`, `TNullable`, `TConstValue`) is a copy of the framework's: import it.
10
+ * package already exports (`TValueOrPromise`, `TNullable`, `TConstValue`) is a copy of the framework's: import it.
11
11
  *
12
12
  * The names come from the installed packages' `.d.ts` files (see `FrameworkExports`), for the packages your nearest
13
13
  * `package.json` depends on. Not reported: a name the file imports, a name shorter than `minLength` (default 4, so a
@@ -1 +1 @@
1
- {"version":3,"file":"no-shadow-framework-type.rule.js","sourceRoot":"","sources":["../../../src/linters/house/no-shadow-framework-type.rule.ts"],"names":[],"mappings":";;;AAAA,yCAAoC;AAGpC,qCAAyE;AACzE,2DAAuD;AACvD,qDAAiD;AAEjD;;;;;;;;;GASG;AACH,MAAa,yBAAyB;aACpB,SAAI,GAAG,GAAG,+BAAsB,2BAA2B,CAAC;aAE5D,uBAAkB,GAAG,CAAC,CAAC;IAEvC,yGAAyG;IACjG,MAAM,CAAC,eAAe,CAAC,IAA4C;QACzE,MAAM,QAAQ,GAAY,gBAAO,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,WAAW,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC,CAAC;QAExF,OAAO,CACL,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC;YACvB,QAAQ,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE;gBACtB,MAAM,UAAU,GAAG,gBAAO,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,YAAY,EAAE,CAAC,CAAC;gBACzE,MAAM,QAAQ,GAAG,gBAAO,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE,UAAU,EAAE,CAAC,CAAC;gBAE1E,OAAO,CACL,gBAAO,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,KAAK,IAAI,CAAC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;wBAED,KAAK,KAAK,oCAAgB,CAAC,EAAE,CAAC,EAAE,SAAS,EAAE,IAAA,mBAAO,EAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;wBACxE,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;wBAE/B,IAAI,MAAM,KAAK,SAAS,IAAI,8BAAa,CAAC,UAAU,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;4BACxE,SAAS;wBACX,CAAC;wBAED,IAAI,gBAAO,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC;4BAC/B,OAAO,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;wBACpF,CAAC;oBACH,CAAC;gBACH,CAAC;aACF,CAAC;QACJ,CAAC;KACF,CAAC;IAEF,MAAM,CAAC,KAAK,CAAC,OAA4D,EAAE;QACzE,MAAM,EAAE,QAAQ,GAAG,OAAO,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;QAE3C,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IAClE,CAAC;;AAxGH,8DAyGC","sourcesContent":["import { dirname } from 'node:path';\nimport type { Linter, Rule } from 'eslint';\nimport type { TRuleSeverity } from '../rules/common';\nimport { AstNode, AstNodeTypes, HOUSE_PLUGIN_NAMESPACE } from './common';\nimport { FrameworkExports } from './framework-exports';\nimport { ImportSupport } from './import-support';\n\n/**\n * `@venizia/no-shadow-framework-type`. A type alias or interface written in your project under the name a `@venizia/*`\n * package already exports (`ValueOrPromise`, `TNullable`, `TConstValue`) is a copy of the framework's: import it.\n *\n * The names come from the installed packages' `.d.ts` files (see `FrameworkExports`), for the packages your nearest\n * `package.json` depends on. Not reported: a name the file imports, a name shorter than `minLength` (default 4, so a\n * generic `T` never matches), a name in `allow`, anything inside `declare module` or `declare global` (an augmentation),\n * a declaration file, and a package's own declarations of what it exports. There is no fix: a copy may differ from the\n * original, so the replacement is the author's to check.\n */\nexport class NoShadowFrameworkTypeRule {\n static readonly NAME = `${HOUSE_PLUGIN_NAMESPACE}/no-shadow-framework-type`;\n\n static readonly DEFAULT_MIN_LENGTH = 4;\n\n /** Whether an interface lists `name` (bare or through a namespace import) among the types it extends. */\n private static extendsSameName(opts: { declaration: unknown; name: string }): boolean {\n const heritage: unknown = AstNode.readField({ node: opts.declaration, key: 'extends' });\n\n return (\n Array.isArray(heritage) &&\n heritage.some((entry) => {\n const expression = AstNode.readField({ node: entry, key: 'expression' });\n const property = AstNode.readField({ node: expression, key: 'property' });\n\n return (\n AstNode.readField({ node: expression, key: 'name' }) === opts.name ||\n AstNode.readField({ node: property, key: 'name' }) === opts.name\n );\n })\n );\n }\n\n static readonly RULE: Rule.RuleModule = {\n meta: {\n type: 'problem',\n schema: [\n {\n type: 'object',\n properties: {\n allow: { type: 'array', items: { type: 'string' } },\n minLength: { type: 'integer', minimum: 1 },\n },\n additionalProperties: false,\n },\n ],\n messages: {\n shadow:\n \"`{{name}}` is a framework type, do not declare your own: `import type { {{name}} } from '{{source}}';`\",\n },\n },\n create: (context) => {\n if (context.filename.endsWith('.d.ts')) {\n return {};\n }\n\n const options: unknown = context.options[0];\n const allowed = AstNode.readField({ node: options, key: 'allow' });\n const configuredLength = AstNode.readField({ node: options, key: 'minLength' });\n const allow = new Set(Array.isArray(allowed) ? allowed : []);\n const minLength =\n typeof configuredLength === 'number'\n ? configuredLength\n : NoShadowFrameworkTypeRule.DEFAULT_MIN_LENGTH;\n let known: Map<string, string> | undefined;\n\n return {\n [AstNodeTypes.PROGRAM]: () => {\n for (const statement of context.sourceCode.ast.body) {\n const declaration =\n AstNode.getType({ node: statement }) === AstNodeTypes.EXPORT_NAMED_DECLARATION\n ? AstNode.readField({ node: statement, key: 'declaration' })\n : statement;\n const type = AstNode.getType({ node: declaration });\n\n if (\n type !== AstNodeTypes.TYPE_ALIAS_DECLARATION &&\n type !== AstNodeTypes.INTERFACE_DECLARATION\n ) {\n continue;\n }\n\n const identifier = AstNode.readField({ node: declaration, key: 'id' });\n const name = AstNode.readField({ node: identifier, key: 'name' });\n\n if (typeof name !== 'string' || name.length < minLength || allow.has(name)) {\n continue;\n }\n\n // `interface X extends X` (or `extends H.X`) is the framework's type being extended on purpose.\n if (NoShadowFrameworkTypeRule.extendsSameName({ declaration, name })) {\n continue;\n }\n\n known ??= FrameworkExports.of({ directory: dirname(context.filename) });\n const source = known.get(name);\n\n if (source === undefined || ImportSupport.isImported({ context, name })) {\n continue;\n }\n\n if (AstNode.isNode(identifier)) {\n context.report({ node: identifier, messageId: 'shadow', data: { name, source } });\n }\n }\n },\n };\n },\n };\n\n static build(opts: { severity?: TRuleSeverity; allow?: Array<string> } = {}): Linter.RuleEntry {\n const { severity = 'error', allow } = opts;\n\n return allow === undefined ? [severity] : [severity, { allow }];\n }\n}\n"]}
1
+ {"version":3,"file":"no-shadow-framework-type.rule.js","sourceRoot":"","sources":["../../../src/linters/house/no-shadow-framework-type.rule.ts"],"names":[],"mappings":";;;AAAA,yCAAoC;AAGpC,qCAAyE;AACzE,2DAAuD;AACvD,qDAAiD;AAEjD;;;;;;;;;GASG;AACH,MAAa,yBAAyB;aACpB,SAAI,GAAG,GAAG,+BAAsB,2BAA2B,CAAC;aAE5D,uBAAkB,GAAG,CAAC,CAAC;IAEvC,yGAAyG;IACjG,MAAM,CAAC,eAAe,CAAC,IAA4C;QACzE,MAAM,QAAQ,GAAY,gBAAO,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,WAAW,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC,CAAC;QAExF,OAAO,CACL,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC;YACvB,QAAQ,CAAC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,KAAK,EAAE,CAAC,CAAC;IAClE,CAAC;;AAxGH,8DAyGC","sourcesContent":["import { dirname } from 'node:path';\nimport type { Linter, Rule } from 'eslint';\nimport type { TRuleSeverity } from '../rules/common';\nimport { AstNode, AstNodeTypes, HOUSE_PLUGIN_NAMESPACE } from './common';\nimport { FrameworkExports } from './framework-exports';\nimport { ImportSupport } from './import-support';\n\n/**\n * `@venizia/no-shadow-framework-type`. A type alias or interface written in your project under the name a `@venizia/*`\n * package already exports (`TValueOrPromise`, `TNullable`, `TConstValue`) is a copy of the framework's: import it.\n *\n * The names come from the installed packages' `.d.ts` files (see `FrameworkExports`), for the packages your nearest\n * `package.json` depends on. Not reported: a name the file imports, a name shorter than `minLength` (default 4, so a\n * generic `T` never matches), a name in `allow`, anything inside `declare module` or `declare global` (an augmentation),\n * a declaration file, and a package's own declarations of what it exports. There is no fix: a copy may differ from the\n * original, so the replacement is the author's to check.\n */\nexport class NoShadowFrameworkTypeRule {\n static readonly NAME = `${HOUSE_PLUGIN_NAMESPACE}/no-shadow-framework-type`;\n\n static readonly DEFAULT_MIN_LENGTH = 4;\n\n /** Whether an interface lists `name` (bare or through a namespace import) among the types it extends. */\n private static extendsSameName(opts: { declaration: unknown; name: string }): boolean {\n const heritage: unknown = AstNode.readField({ node: opts.declaration, key: 'extends' });\n\n return (\n Array.isArray(heritage) &&\n heritage.some((entry) => {\n const expression = AstNode.readField({ node: entry, key: 'expression' });\n const property = AstNode.readField({ node: expression, key: 'property' });\n\n return (\n AstNode.readField({ node: expression, key: 'name' }) === opts.name ||\n AstNode.readField({ node: property, key: 'name' }) === opts.name\n );\n })\n );\n }\n\n static readonly RULE: Rule.RuleModule = {\n meta: {\n type: 'problem',\n schema: [\n {\n type: 'object',\n properties: {\n allow: { type: 'array', items: { type: 'string' } },\n minLength: { type: 'integer', minimum: 1 },\n },\n additionalProperties: false,\n },\n ],\n messages: {\n shadow:\n \"`{{name}}` is a framework type, do not declare your own: `import type { {{name}} } from '{{source}}';`\",\n },\n },\n create: (context) => {\n if (context.filename.endsWith('.d.ts')) {\n return {};\n }\n\n const options: unknown = context.options[0];\n const allowed = AstNode.readField({ node: options, key: 'allow' });\n const configuredLength = AstNode.readField({ node: options, key: 'minLength' });\n const allow = new Set(Array.isArray(allowed) ? allowed : []);\n const minLength =\n typeof configuredLength === 'number'\n ? configuredLength\n : NoShadowFrameworkTypeRule.DEFAULT_MIN_LENGTH;\n let known: Map<string, string> | undefined;\n\n return {\n [AstNodeTypes.PROGRAM]: () => {\n for (const statement of context.sourceCode.ast.body) {\n const declaration =\n AstNode.getType({ node: statement }) === AstNodeTypes.EXPORT_NAMED_DECLARATION\n ? AstNode.readField({ node: statement, key: 'declaration' })\n : statement;\n const type = AstNode.getType({ node: declaration });\n\n if (\n type !== AstNodeTypes.TYPE_ALIAS_DECLARATION &&\n type !== AstNodeTypes.INTERFACE_DECLARATION\n ) {\n continue;\n }\n\n const identifier = AstNode.readField({ node: declaration, key: 'id' });\n const name = AstNode.readField({ node: identifier, key: 'name' });\n\n if (typeof name !== 'string' || name.length < minLength || allow.has(name)) {\n continue;\n }\n\n // `interface X extends X` (or `extends H.X`) is the framework's type being extended on purpose.\n if (NoShadowFrameworkTypeRule.extendsSameName({ declaration, name })) {\n continue;\n }\n\n known ??= FrameworkExports.of({ directory: dirname(context.filename) });\n const source = known.get(name);\n\n if (source === undefined || ImportSupport.isImported({ context, name })) {\n continue;\n }\n\n if (AstNode.isNode(identifier)) {\n context.report({ node: identifier, messageId: 'shadow', data: { name, source } });\n }\n }\n },\n };\n },\n };\n\n static build(opts: { severity?: TRuleSeverity; allow?: Array<string> } = {}): Linter.RuleEntry {\n const { severity = 'error', allow } = opts;\n\n return allow === undefined ? [severity] : [severity, { allow }];\n }\n}\n"]}
@@ -18,8 +18,10 @@ const no_silent_catch_rule_1 = require("./no-silent-catch.rule");
18
18
  const no_unbraced_case_rule_1 = require("./no-unbraced-case.rule");
19
19
  const prefer_framework_api_rule_1 = require("./prefer-framework-api.rule");
20
20
  const prefer_http_method_rule_1 = require("./prefer-http-method.rule");
21
- const prefer_promise_sleep_rule_1 = require("./prefer-promise-sleep.rule");
21
+ const prefer_execution_sleep_rule_1 = require("./prefer-execution-sleep.rule");
22
22
  const prefer_tnullable_rule_1 = require("./prefer-tnullable.rule");
23
+ const restrict_execution_call_sites_rule_1 = require("./restrict-execution-call-sites.rule");
24
+ const static_execution_reason_rule_1 = require("./static-execution-reason.rule");
23
25
  const typed_route_context_rule_1 = require("./typed-route-context.rule");
24
26
  const zod_schema_convention_rule_1 = require("./zod-schema-convention.rule");
25
27
  /** The ESLint plugin that carries the house rules oxlint cannot express, registered as `@venizia`. */
@@ -42,8 +44,10 @@ exports.houseEslintPlugin = {
42
44
  'no-unbraced-case': no_unbraced_case_rule_1.NoUnbracedCaseRule.RULE,
43
45
  'prefer-framework-api': prefer_framework_api_rule_1.PreferFrameworkApiRule.RULE,
44
46
  'prefer-http-method': prefer_http_method_rule_1.PreferHttpMethodRule.RULE,
45
- 'prefer-promise-sleep': prefer_promise_sleep_rule_1.PreferPromiseSleepRule.RULE,
47
+ 'prefer-execution-sleep': prefer_execution_sleep_rule_1.PreferExecutionSleepRule.RULE,
46
48
  'prefer-tnullable': prefer_tnullable_rule_1.PreferTNullableRule.RULE,
49
+ 'restrict-execution-call-sites': restrict_execution_call_sites_rule_1.RestrictExecutionCallSitesRule.RULE,
50
+ 'static-execution-reason': static_execution_reason_rule_1.StaticExecutionReasonRule.RULE,
47
51
  'typed-route-context': typed_route_context_rule_1.TypedRouteContextRule.RULE,
48
52
  'zod-schema-convention': zod_schema_convention_rule_1.ZodSchemaConventionRule.RULE,
49
53
  },
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../../src/linters/house/plugin.ts"],"names":[],"mappings":";;;AACA,qCAAkD;AAClD,uEAAiE;AACjE,uFAAiF;AACjF,+DAAyD;AACzD,+EAAwE;AACxE,uEAAgE;AAChE,+EAAwE;AACxE,iEAA2D;AA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{ 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 { NoAwaitNewChainRule } from './no-await-new-chain.rule';\nimport { NoAwaitPromiseChainRule } from './no-await-promise-chain.rule';\nimport { NoInlineAwaitRule } from './no-inline-await.rule';\nimport { NoLeakedRenderRule } from './no-leaked-render.rule';\nimport { NoNewErrorRule } from './no-new-error.rule';\nimport { NoParentImportRule } from './no-parent-import.rule';\nimport { NoReturnAwaitRule } from './no-return-await.rule';\nimport { NoShadowFrameworkTypeRule } from './no-shadow-framework-type.rule';\nimport { NoSilentCatchRule } from './no-silent-catch.rule';\nimport { NoUnbracedCaseRule } from './no-unbraced-case.rule';\nimport { PreferFrameworkApiRule } from './prefer-framework-api.rule';\nimport { PreferHttpMethodRule } from './prefer-http-method.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';\n\n/** The ESLint plugin that carries the house rules oxlint cannot express, registered as `@venizia`. */\nexport const houseEslintPlugin: ESLint.Plugin = {\n meta: { name: `${HOUSE_PLUGIN_NAMESPACE}/eslint-plugin` },\n rules: {\n 'const-class-values': ConstClassValuesRule.RULE,\n 'effect-cleanup-consistency': EffectCleanupConsistencyRule.RULE,\n 'max-params-own': MaxParamsOwnRule.RULE,\n 'no-async-hook-callback': NoAsyncHookCallbackRule.RULE,\n 'no-await-new-chain': NoAwaitNewChainRule.RULE,\n 'no-await-promise-chain': NoAwaitPromiseChainRule.RULE,\n 'no-inline-await': NoInlineAwaitRule.RULE,\n 'no-leaked-render': NoLeakedRenderRule.RULE,\n 'no-new-error': NoNewErrorRule.RULE,\n 'no-parent-import': NoParentImportRule.RULE,\n 'no-return-await': NoReturnAwaitRule.RULE,\n 'no-shadow-framework-type': NoShadowFrameworkTypeRule.RULE,\n 'no-silent-catch': NoSilentCatchRule.RULE,\n 'no-unbraced-case': NoUnbracedCaseRule.RULE,\n 'prefer-framework-api': PreferFrameworkApiRule.RULE,\n 'prefer-http-method': PreferHttpMethodRule.RULE,\n 'prefer-promise-sleep': PreferPromiseSleepRule.RULE,\n 'prefer-tnullable': PreferTNullableRule.RULE,\n 'typed-route-context': TypedRouteContextRule.RULE,\n 'zod-schema-convention': ZodSchemaConventionRule.RULE,\n },\n};\n"]}
1
+ {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../../src/linters/house/plugin.ts"],"names":[],"mappings":";;;AACA,qCAAkD;AAClD,uEAAiE;AACjE,uFAAiF;AACjF,+DAAyD;AACzD,+EAAwE;AACxE,uEAAgE;AAChE,+EAAwE;AACxE,iEAA2D;AAC3D,mEAA6D;AAC7D,2DAAqD;AACrD,mEAA6D;AAC7D,iEAA2D;AAC3D,mFAA4E;AAC5E,iEAA2D;AAC3D,mEAA6D;AAC7D,2EAAqE;AACrE,uEAAiE;AACjE,+EAAyE;AACzE,mEAA8D;AAC9D,6FAAsF;AACtF,iFAA2E;AAC3E,yEAAmE;AACnE,6EAAuE;AAEvE,sGAAsG;AACzF,QAAA,iBAAiB,GAAkB;IAC9C,IAAI,EAAE,EAAE,IAAI,EAAE,GAAG,+BAAsB,gBAAgB,EAAE;IACzD,KAAK,EAAE;QACL,oBAAoB,EAAE,8CAAoB,CAAC,IAAI;QAC/C,4BAA4B,EAAE,8DAA4B,CAAC,IAAI;QAC/D,gBAAgB,EAAE,sCAAgB,CAAC,IAAI;QACvC,wBAAwB,EAAE,qDAAuB,CAAC,IAAI;QACtD,oBAAoB,EAAE,6CAAmB,CAAC,IAAI;QAC9C,wBAAwB,EAAE,qDAAuB,CAAC,IAAI;QACtD,iBAAiB,EAAE,wCAAiB,CAAC,IAAI;QACzC,kBAAkB,EAAE,0CAAkB,CAAC,IAAI;QAC3C,cAAc,EAAE,kCAAc,CAAC,IAAI;QACnC,kBAAkB,EAAE,0CAAkB,CAAC,IAAI;QAC3C,iBAAiB,EAAE,wCAAiB,CAAC,IAAI;QACzC,0BAA0B,EAAE,yDAAyB,CAAC,IAAI;QAC1D,iBAAiB,EAAE,wCAAiB,CAAC,IAAI;QACzC,kBAAkB,EAAE,0CAAkB,CAAC,IAAI;QAC3C,sBAAsB,EAAE,kDAAsB,CAAC,IAAI;QACnD,oBAAoB,EAAE,8CAAoB,CAAC,IAAI;QAC/C,wBAAwB,EAAE,sDAAwB,CAAC,IAAI;QACvD,kBAAkB,EAAE,2CAAmB,CAAC,IAAI;QAC5C,+BAA+B,EAAE,mEAA8B,CAAC,IAAI;QACpE,yBAAyB,EAAE,wDAAyB,CAAC,IAAI;QACzD,qBAAqB,EAAE,gDAAqB,CAAC,IAAI;QACjD,uBAAuB,EAAE,oDAAuB,CAAC,IAAI;KACtD;CACF,CAAC","sourcesContent":["import type { ESLint } from 'eslint';\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 { NoAwaitNewChainRule } from './no-await-new-chain.rule';\nimport { NoAwaitPromiseChainRule } from './no-await-promise-chain.rule';\nimport { NoInlineAwaitRule } from './no-inline-await.rule';\nimport { NoLeakedRenderRule } from './no-leaked-render.rule';\nimport { NoNewErrorRule } from './no-new-error.rule';\nimport { NoParentImportRule } from './no-parent-import.rule';\nimport { NoReturnAwaitRule } from './no-return-await.rule';\nimport { NoShadowFrameworkTypeRule } from './no-shadow-framework-type.rule';\nimport { NoSilentCatchRule } from './no-silent-catch.rule';\nimport { NoUnbracedCaseRule } from './no-unbraced-case.rule';\nimport { PreferFrameworkApiRule } from './prefer-framework-api.rule';\nimport { PreferHttpMethodRule } from './prefer-http-method.rule';\nimport { PreferExecutionSleepRule } from './prefer-execution-sleep.rule';\nimport { PreferTNullableRule } from './prefer-tnullable.rule';\nimport { RestrictExecutionCallSitesRule } from './restrict-execution-call-sites.rule';\nimport { StaticExecutionReasonRule } from './static-execution-reason.rule';\nimport { TypedRouteContextRule } from './typed-route-context.rule';\nimport { ZodSchemaConventionRule } from './zod-schema-convention.rule';\n\n/** The ESLint plugin that carries the house rules oxlint cannot express, registered as `@venizia`. */\nexport const houseEslintPlugin: ESLint.Plugin = {\n meta: { name: `${HOUSE_PLUGIN_NAMESPACE}/eslint-plugin` },\n rules: {\n 'const-class-values': ConstClassValuesRule.RULE,\n 'effect-cleanup-consistency': EffectCleanupConsistencyRule.RULE,\n 'max-params-own': MaxParamsOwnRule.RULE,\n 'no-async-hook-callback': NoAsyncHookCallbackRule.RULE,\n 'no-await-new-chain': NoAwaitNewChainRule.RULE,\n 'no-await-promise-chain': NoAwaitPromiseChainRule.RULE,\n 'no-inline-await': NoInlineAwaitRule.RULE,\n 'no-leaked-render': NoLeakedRenderRule.RULE,\n 'no-new-error': NoNewErrorRule.RULE,\n 'no-parent-import': NoParentImportRule.RULE,\n 'no-return-await': NoReturnAwaitRule.RULE,\n 'no-shadow-framework-type': NoShadowFrameworkTypeRule.RULE,\n 'no-silent-catch': NoSilentCatchRule.RULE,\n 'no-unbraced-case': NoUnbracedCaseRule.RULE,\n 'prefer-framework-api': PreferFrameworkApiRule.RULE,\n 'prefer-http-method': PreferHttpMethodRule.RULE,\n 'prefer-execution-sleep': PreferExecutionSleepRule.RULE,\n 'prefer-tnullable': PreferTNullableRule.RULE,\n 'restrict-execution-call-sites': RestrictExecutionCallSitesRule.RULE,\n 'static-execution-reason': StaticExecutionReasonRule.RULE,\n 'typed-route-context': TypedRouteContextRule.RULE,\n 'zod-schema-convention': ZodSchemaConventionRule.RULE,\n },\n};\n"]}
@@ -0,0 +1,31 @@
1
+ import type { Linter, Rule } from 'eslint';
2
+ import type { TRuleSeverity } from '../rules/common';
3
+ /**
4
+ * `@venizia/prefer-execution-sleep`. A sleep written by hand, `new Promise((resolve) => setTimeout(resolve, ms))`, is
5
+ * `Execution.sleep({ ms })` (`@venizia/ignis-helpers/core`). Only that exact shape is reported: a callback that
6
+ * does anything else is not a sleep.
7
+ *
8
+ * The fix replaces the expression and adds the import; `source` is where `Execution` comes from, `null` turns
9
+ * the fix off.
10
+ */
11
+ export declare class PreferExecutionSleepRule {
12
+ static readonly NAME = "@venizia/prefer-execution-sleep";
13
+ static readonly DEFAULT_SOURCE = "@venizia/ignis-helpers/core";
14
+ /** The `setTimeout(<resolve>, <delay>)` call a sleep callback consists of, or `undefined`. */
15
+ private static delayOf;
16
+ /** `Execution.sleep({ ms })`, with the shorthand when the delay is a variable named `ms`. */
17
+ private static call;
18
+ /**
19
+ * Whether the file binds `Execution` to something else: an import from a module other than the helpers or the
20
+ * configured `source`. The fix would call that one.
21
+ */
22
+ private static isForeign;
23
+ /** Whether `setTimeout` at `node` resolves to a binding of the file (not the global timer). */
24
+ private static isRebound;
25
+ static readonly RULE: Rule.RuleModule;
26
+ static build(opts?: {
27
+ severity?: TRuleSeverity;
28
+ source?: string | null;
29
+ }): Linter.RuleEntry;
30
+ }
31
+ //# sourceMappingURL=prefer-execution-sleep.rule.d.ts.map