@venizia/dev-configs 0.4.7 → 0.4.8-1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (199) hide show
  1. package/README.md +3 -3
  2. package/dist/checks/catalog.d.ts +15 -2
  3. package/dist/checks/catalog.js +1 -0
  4. package/dist/checks/catalog.js.map +1 -1
  5. package/dist/checks/module-cycles.d.ts +2 -0
  6. package/dist/checks/module-cycles.js +2 -0
  7. package/dist/checks/module-cycles.js.map +1 -1
  8. package/dist/checks/purity/manifest.d.ts +6 -1
  9. package/dist/checks/purity/manifest.js.map +1 -1
  10. package/dist/checks/purity/probe.d.ts +4 -1
  11. package/dist/checks/purity/probe.js +1 -0
  12. package/dist/checks/purity/probe.js.map +1 -1
  13. package/dist/checks/purity/run.d.ts +3 -0
  14. package/dist/checks/purity/run.js +1 -0
  15. package/dist/checks/purity/run.js.map +1 -1
  16. package/dist/checks/split-report.d.ts +1 -0
  17. package/dist/checks/split-report.js +1 -0
  18. package/dist/checks/split-report.js.map +1 -1
  19. package/dist/checks/test-controls.d.ts +11 -2
  20. package/dist/checks/test-controls.js +1 -0
  21. package/dist/checks/test-controls.js.map +1 -1
  22. package/dist/checks/test-dead-code.d.ts +1 -0
  23. package/dist/checks/test-dead-code.js +1 -0
  24. package/dist/checks/test-dead-code.js.map +1 -1
  25. package/dist/checks/test-mutate.d.ts +14 -2
  26. package/dist/checks/test-mutate.js +1 -0
  27. package/dist/checks/test-mutate.js.map +1 -1
  28. package/dist/checks/test-weight.d.ts +3 -0
  29. package/dist/checks/test-weight.js +1 -0
  30. package/dist/checks/test-weight.js.map +1 -1
  31. package/dist/cli/check.js.map +1 -1
  32. package/dist/cli/clean.js.map +1 -1
  33. package/dist/cli/codemod/async-style.d.ts +1 -1
  34. package/dist/cli/codemod/async-style.js +3 -3
  35. package/dist/cli/codemod/async-style.js.map +1 -1
  36. package/dist/cli/codemod/connector-imports.js.map +1 -1
  37. package/dist/cli/codemod/const-classes.js.map +1 -1
  38. package/dist/cli/codemod/drop-redundant-casts.js.map +1 -1
  39. package/dist/cli/codemod/files.js.map +1 -1
  40. package/dist/cli/codemod/index.js.map +1 -1
  41. package/dist/cli/codemod/namespace-functions/index.js.map +1 -1
  42. package/dist/cli/codemod/namespace-functions/logger-scope.js.map +1 -1
  43. package/dist/cli/codemod/namespace-functions/mapping.js.map +1 -1
  44. package/dist/cli/codemod/namespace-functions/rewriter.js.map +1 -1
  45. package/dist/cli/index.js.map +1 -1
  46. package/dist/cli/lint.js.map +1 -1
  47. package/dist/linters/eslint.js +7 -5
  48. package/dist/linters/eslint.js.map +1 -1
  49. package/dist/linters/house/async-rules.d.ts +10 -0
  50. package/dist/linters/house/async-rules.js +29 -0
  51. package/dist/linters/house/async-rules.js.map +1 -0
  52. package/dist/linters/house/await-support.d.ts +2 -0
  53. package/dist/linters/house/await-support.js +15 -10
  54. package/dist/linters/house/await-support.js.map +1 -1
  55. package/dist/linters/house/common.d.ts +2 -0
  56. package/dist/linters/house/common.js +2 -0
  57. package/dist/linters/house/common.js.map +1 -1
  58. package/dist/linters/house/configs.d.ts +3 -29
  59. package/dist/linters/house/configs.js +24 -51
  60. package/dist/linters/house/configs.js.map +1 -1
  61. package/dist/linters/house/const-class-values.rule.js.map +1 -1
  62. package/dist/linters/house/effect-cleanup-consistency.rule.js +2 -1
  63. package/dist/linters/house/effect-cleanup-consistency.rule.js.map +1 -1
  64. package/dist/linters/house/hook-support.js.map +1 -1
  65. package/dist/linters/house/index.d.ts +2 -1
  66. package/dist/linters/house/index.js +4 -1
  67. package/dist/linters/house/index.js.map +1 -1
  68. package/dist/linters/house/max-params-own.rule.d.ts +3 -1
  69. package/dist/linters/house/max-params-own.rule.js +1 -1
  70. package/dist/linters/house/max-params-own.rule.js.map +1 -1
  71. package/dist/linters/house/no-async-hook-callback.rule.js.map +1 -1
  72. package/dist/linters/house/no-await-promise-chain.rule.js +2 -3
  73. package/dist/linters/house/no-await-promise-chain.rule.js.map +1 -1
  74. package/dist/linters/house/no-leaked-render.rule.js.map +1 -1
  75. package/dist/linters/house/no-return-await.rule.js +2 -8
  76. package/dist/linters/house/no-return-await.rule.js.map +1 -1
  77. package/dist/linters/house/no-silent-catch.rule.js +1 -1
  78. package/dist/linters/house/no-silent-catch.rule.js.map +1 -1
  79. package/dist/linters/house/no-unbraced-case.rule.d.ts +15 -0
  80. package/dist/linters/house/no-unbraced-case.rule.js +45 -0
  81. package/dist/linters/house/no-unbraced-case.rule.js.map +1 -0
  82. package/dist/linters/house/plugin.js +2 -0
  83. package/dist/linters/house/plugin.js.map +1 -1
  84. package/dist/linters/house/promise-chain-support.js.map +1 -1
  85. package/dist/linters/ignore.js.map +1 -1
  86. package/dist/linters/index.d.ts +1 -0
  87. package/dist/linters/index.js +1 -0
  88. package/dist/linters/index.js.map +1 -1
  89. package/dist/linters/oxlint.d.ts +6 -1
  90. package/dist/linters/oxlint.js.map +1 -1
  91. package/dist/linters/padding.d.ts +8 -0
  92. package/dist/linters/padding.js +25 -0
  93. package/dist/linters/padding.js.map +1 -0
  94. package/dist/linters/rules/eqeqeq.rule.js.map +1 -1
  95. package/dist/linters/rules/index.d.ts +2 -0
  96. package/dist/linters/rules/index.js +2 -0
  97. package/dist/linters/rules/index.js.map +1 -1
  98. package/dist/linters/rules/lines-between-class-members.rule.d.ts +14 -0
  99. package/dist/linters/rules/lines-between-class-members.rule.js +17 -0
  100. package/dist/linters/rules/lines-between-class-members.rule.js.map +1 -0
  101. package/dist/linters/rules/naming-convention.rule.js.map +1 -1
  102. package/dist/linters/rules/no-restricted-imports.rule.js.map +1 -1
  103. package/dist/linters/rules/no-restricted-properties.rule.js.map +1 -1
  104. package/dist/linters/rules/no-unused-vars.rule.d.ts +6 -1
  105. package/dist/linters/rules/no-unused-vars.rule.js +1 -1
  106. package/dist/linters/rules/no-unused-vars.rule.js.map +1 -1
  107. package/dist/linters/rules/padding-line-between-statements.rule.d.ts +16 -0
  108. package/dist/linters/rules/padding-line-between-statements.rule.js +25 -0
  109. package/dist/linters/rules/padding-line-between-statements.rule.js.map +1 -0
  110. package/dist/linters/rules/prefer-nullish-coalescing.rule.js.map +1 -1
  111. package/dist/linters/rules/switch-case-braces.rule.js.map +1 -1
  112. package/dist/testing/rejection.helper.d.ts +1 -0
  113. package/dist/testing/rejection.helper.js +1 -0
  114. package/dist/testing/rejection.helper.js.map +1 -1
  115. package/dist/testing/repo-tmp.d.ts +1 -0
  116. package/dist/testing/repo-tmp.js +1 -0
  117. package/dist/testing/repo-tmp.js.map +1 -1
  118. package/dist/testing/spawn.helper.d.ts +1 -0
  119. package/dist/testing/spawn.helper.js +1 -0
  120. package/dist/testing/spawn.helper.js.map +1 -1
  121. package/package.json +3 -5
  122. package/dist/checks/catalog.d.ts.map +0 -1
  123. package/dist/checks/index.d.ts.map +0 -1
  124. package/dist/checks/module-cycles.d.ts.map +0 -1
  125. package/dist/checks/purity/manifest.d.ts.map +0 -1
  126. package/dist/checks/purity/probe.d.ts.map +0 -1
  127. package/dist/checks/purity/run.d.ts.map +0 -1
  128. package/dist/checks/split-report.d.ts.map +0 -1
  129. package/dist/checks/test-controls.d.ts.map +0 -1
  130. package/dist/checks/test-dead-code.d.ts.map +0 -1
  131. package/dist/checks/test-mutate.d.ts.map +0 -1
  132. package/dist/checks/test-weight.d.ts.map +0 -1
  133. package/dist/cli/check.d.ts.map +0 -1
  134. package/dist/cli/clean.d.ts.map +0 -1
  135. package/dist/cli/codemod/async-style.d.ts.map +0 -1
  136. package/dist/cli/codemod/connector-imports.d.ts.map +0 -1
  137. package/dist/cli/codemod/const-classes.d.ts.map +0 -1
  138. package/dist/cli/codemod/drop-redundant-casts.d.ts.map +0 -1
  139. package/dist/cli/codemod/files.d.ts.map +0 -1
  140. package/dist/cli/codemod/index.d.ts.map +0 -1
  141. package/dist/cli/codemod/namespace-functions/index.d.ts.map +0 -1
  142. package/dist/cli/codemod/namespace-functions/logger-scope.d.ts.map +0 -1
  143. package/dist/cli/codemod/namespace-functions/mapping.d.ts.map +0 -1
  144. package/dist/cli/codemod/namespace-functions/mappings/boot.d.ts.map +0 -1
  145. package/dist/cli/codemod/namespace-functions/mappings/connectors.d.ts.map +0 -1
  146. package/dist/cli/codemod/namespace-functions/mappings/core-server.d.ts.map +0 -1
  147. package/dist/cli/codemod/namespace-functions/mappings/core-worker.d.ts.map +0 -1
  148. package/dist/cli/codemod/namespace-functions/mappings/dev-configs.d.ts.map +0 -1
  149. package/dist/cli/codemod/namespace-functions/mappings/filter.d.ts.map +0 -1
  150. package/dist/cli/codemod/namespace-functions/mappings/helpers.d.ts.map +0 -1
  151. package/dist/cli/codemod/namespace-functions/mappings/index.d.ts.map +0 -1
  152. package/dist/cli/codemod/namespace-functions/mappings/inversion.d.ts.map +0 -1
  153. package/dist/cli/codemod/namespace-functions/mappings/kernel.d.ts.map +0 -1
  154. package/dist/cli/codemod/namespace-functions/rewriter.d.ts.map +0 -1
  155. package/dist/cli/index.d.ts.map +0 -1
  156. package/dist/cli/lint.d.ts.map +0 -1
  157. package/dist/compilers/bun.d.ts.map +0 -1
  158. package/dist/compilers/index.d.ts.map +0 -1
  159. package/dist/index.d.ts.map +0 -1
  160. package/dist/linters/browser.d.ts.map +0 -1
  161. package/dist/linters/eslint.d.ts.map +0 -1
  162. package/dist/linters/house/await-support.d.ts.map +0 -1
  163. package/dist/linters/house/common.d.ts.map +0 -1
  164. package/dist/linters/house/configs.d.ts.map +0 -1
  165. package/dist/linters/house/const-class-values.rule.d.ts.map +0 -1
  166. package/dist/linters/house/effect-cleanup-consistency.rule.d.ts.map +0 -1
  167. package/dist/linters/house/hook-support.d.ts.map +0 -1
  168. package/dist/linters/house/index.d.ts.map +0 -1
  169. package/dist/linters/house/max-params-own.rule.d.ts.map +0 -1
  170. package/dist/linters/house/no-async-hook-callback.rule.d.ts.map +0 -1
  171. package/dist/linters/house/no-await-promise-chain.rule.d.ts.map +0 -1
  172. package/dist/linters/house/no-inline-await.rule.d.ts.map +0 -1
  173. package/dist/linters/house/no-leaked-render.rule.d.ts.map +0 -1
  174. package/dist/linters/house/no-new-error.rule.d.ts.map +0 -1
  175. package/dist/linters/house/no-return-await.rule.d.ts.map +0 -1
  176. package/dist/linters/house/no-silent-catch.rule.d.ts.map +0 -1
  177. package/dist/linters/house/plugin.d.ts.map +0 -1
  178. package/dist/linters/house/promise-chain-support.d.ts.map +0 -1
  179. package/dist/linters/ignore.d.ts.map +0 -1
  180. package/dist/linters/index.d.ts.map +0 -1
  181. package/dist/linters/jsx-files.d.ts.map +0 -1
  182. package/dist/linters/oxlint-presets.d.ts.map +0 -1
  183. package/dist/linters/oxlint.d.ts.map +0 -1
  184. package/dist/linters/react-eslint.d.ts.map +0 -1
  185. package/dist/linters/react-oxlint.d.ts.map +0 -1
  186. package/dist/linters/rules/common.d.ts.map +0 -1
  187. package/dist/linters/rules/eqeqeq.rule.d.ts.map +0 -1
  188. package/dist/linters/rules/index.d.ts.map +0 -1
  189. package/dist/linters/rules/naming-convention.rule.d.ts.map +0 -1
  190. package/dist/linters/rules/no-restricted-imports.rule.d.ts.map +0 -1
  191. package/dist/linters/rules/no-restricted-properties.rule.d.ts.map +0 -1
  192. package/dist/linters/rules/no-unused-vars.rule.d.ts.map +0 -1
  193. package/dist/linters/rules/prefer-nullish-coalescing.rule.d.ts.map +0 -1
  194. package/dist/linters/rules/switch-case-braces.rule.d.ts.map +0 -1
  195. package/dist/testing/index.d.ts.map +0 -1
  196. package/dist/testing/rejection.helper.d.ts.map +0 -1
  197. package/dist/testing/repo-tmp.d.ts.map +0 -1
  198. package/dist/testing/spawn.helper.d.ts.map +0 -1
  199. package/dist/testing/tmpdir-preload.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"eslint.js","sourceRoot":"","sources":["../../src/linters/eslint.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA4B;AAE5B,0CAA6C;AAC7C,sEAAgC;AAChC,kFAA4C;AAC5C,0EAAyC;AACzC,mCAKiB;AAEjB,mCAAmC;AACn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EAAE;YACP,kBAAkB;YAClB,WAAW;YACX,WAAW;YACX,UAAU;YACV,aAAa;YACb,mBAAmB;YACnB,eAAe;YACf,oBAAoB;YACpB,gBAAgB;SACjB;KACF;CACF,CAAC,CAAC;AAEH;;;;;;;;;;GAUG;AACU,QAAA,uBAAuB,GAAoB;IACtD,6FAA6F;IAC7F,EAAE,OAAO,EAAE,CAAC,YAAY,EAAE,aAAa,EAAE,gBAAgB,EAAE,WAAW,EAAE,mBAAmB,CAAC,EAAE;IAC9F;QACE,KAAK,EAAE,CAAC,uBAAuB,CAAC;QAChC,eAAe,EAAE,EAAE,MAAM,EAAE,2BAAQ,CAAC,MAAuB,EAAE;QAC7D,OAAO,EAAE,EAAE,oBAAoB,EAAE,2BAAQ,CAAC,MAAe,EAAE;QAC3D,4FAA4F;QAC5F,aAAa,EAAE,EAAE,6BAA6B,EAAE,KAAK,EAAE;QACvD,KAAK,EAAE,EAAE,CAAC,4BAAoB,CAAC,IAAI,CAAC,EAAE,4BAAoB,CAAC,KAAK,EAAE,EAAE;KACrE;CACF,CAAC","sourcesContent":["import js from '@eslint/js';\nimport type { Linter } from 'eslint';\nimport { defineConfig } from 'eslint/config';\nimport n from 'eslint-plugin-n';\nimport unicorn from 'eslint-plugin-unicorn';\nimport tseslint from 'typescript-eslint';\nimport {\n NamingConventionRule,\n NoRestrictedImportsRule,\n NoUnusedVarsRule,\n SwitchCaseBracesRule,\n} from './rules';\n\n/** Every file the preset lints. */\nconst SOURCE_FILES = [\n '**/*.js',\n '**/*.cjs',\n '**/*.mjs',\n '**/*.jsx',\n '**/*.ts',\n '**/*.cts',\n '**/*.mts',\n '**/*.tsx',\n];\n\n/** Rules that stay off: the type checker, the formatter or the framework's own style covers them. */\nconst OFF_RULES: Linter.RulesRecord = {\n 'no-constant-condition': 'off',\n 'no-undef': 'off',\n 'no-unused-vars': 'off',\n 'no-mixed-operators': 'off',\n 'no-inner-declarations': 'off',\n 'no-dupe-class-members': 'off',\n 'no-redeclare': 'off',\n 'no-invalid-this': 'off',\n 'no-shadow': 'off',\n 'no-return-await': 'off',\n camelcase: 'off',\n '@typescript-eslint/no-explicit-any': 'off',\n '@typescript-eslint/no-unsafe-function-type': 'off',\n '@typescript-eslint/no-this-alias': 'off',\n '@typescript-eslint/no-empty-object-type': 'off',\n '@typescript-eslint/no-invalid-void-type': 'off',\n '@typescript-eslint/no-confusing-void-expression': 'off',\n '@typescript-eslint/no-extraneous-class': 'off',\n '@typescript-eslint/no-require-imports': 'off',\n '@typescript-eslint/strict-boolean-expressions': 'off',\n '@typescript-eslint/explicit-function-return-type': 'off',\n '@typescript-eslint/explicit-member-accessibility': 'off',\n '@typescript-eslint/explicit-module-boundary-types': 'off',\n '@typescript-eslint/array-type': 'off',\n '@typescript-eslint/no-non-null-assertion': 'off',\n '@typescript-eslint/no-empty-function': 'off',\n '@typescript-eslint/consistent-type-assertions': 'off',\n '@typescript-eslint/no-misused-promises': 'off',\n};\n\n/** The LoopBack 4 rule set, on top of the recommended presets. */\nconst STRICT_RULES: Linter.RulesRecord = {\n 'prefer-const': 'error',\n 'no-var': 'error',\n curly: ['error', 'all'],\n 'no-new-wrappers': 'error',\n 'no-throw-literal': 'error',\n 'no-unused-expressions': 'error',\n eqeqeq: ['error', 'smart'],\n 'no-void': 'error',\n 'no-useless-escape': 'warn',\n 'no-caller': 'error',\n 'n/prefer-node-protocol': ['error'],\n '@typescript-eslint/adjacent-overload-signatures': 'error',\n '@typescript-eslint/prefer-for-of': 'error',\n '@typescript-eslint/unified-signatures': 'error',\n '@typescript-eslint/no-invalid-this': ['error'],\n '@typescript-eslint/no-use-before-define': 'error',\n '@typescript-eslint/no-shadow': 'error',\n '@typescript-eslint/ban-ts-comment': 'error',\n '@typescript-eslint/no-namespace': 'error',\n '@typescript-eslint/await-thenable': 'error',\n '@typescript-eslint/no-floating-promises': 'error',\n '@typescript-eslint/prefer-optional-chain': 'error',\n '@typescript-eslint/prefer-nullish-coalescing': [\n 'error',\n { allowRuleToRunWithoutStrictNullChecksIKnowWhatIAmDoing: true },\n ],\n '@typescript-eslint/return-await': 'error',\n};\n\n/**\n * The full ESLint preset, owned here: the LoopBack 4 rule set on the ESLint and typescript-eslint\n * recommended presets, type-aware through the project service. A project on oxlint uses\n * `oxlintConfigs` + `namingConventionConfigs` instead.\n */\nexport const eslintConfigs: Linter.Config[] = defineConfig([\n js.configs.recommended,\n tseslint.configs.recommended,\n {\n files: SOURCE_FILES,\n languageOptions: {\n parserOptions: {\n // Finds each file's tsconfig; the default project covers root-level scripts and configs.\n projectService: { allowDefaultProject: ['*.js', '*.cjs', '*.mjs', '.*.js'] },\n },\n },\n plugins: { n, unicorn },\n rules: {\n ...OFF_RULES,\n ...STRICT_RULES,\n '@typescript-eslint/no-unused-vars': NoUnusedVarsRule.build() as Linter.RuleEntry,\n [NoRestrictedImportsRule.NAME]: NoRestrictedImportsRule.build() as Linter.RuleEntry,\n [SwitchCaseBracesRule.NAME]: SwitchCaseBracesRule.build() as Linter.RuleEntry,\n [NamingConventionRule.NAME]: NamingConventionRule.build(),\n },\n },\n {\n ignores: [\n '**/node_modules/',\n '**/*.d.ts',\n '**/build/',\n '**/dist/',\n '**/release/',\n '**/babel.config.*',\n '**/.babelrc.*',\n '**/eslint.config.*',\n '**/.eslintrc.*',\n ],\n },\n]);\n\n/**\n * The one rule of `eslintConfigs` that oxlint cannot run yet, as a standalone ESLint preset to run\n * next to `oxlintConfigs`. It needs no type information, so ESLint stays fast.\n *\n * ```js\n * // .configs/lints/eslint.config.mjs\n * import { namingConventionConfigs } from '@venizia/dev-configs/linters';\n *\n * export default namingConventionConfigs;\n * ```\n */\nexport const namingConventionConfigs: Linter.Config[] = [\n // Global: ESLint does not read .gitignore, and still walks plain .js files no config claims.\n { ignores: ['**/dist/**', '**/build/**', '**/coverage/**', '**/*.d.ts', '**/*.{js,cjs,mjs}'] },\n {\n files: ['**/*.{ts,tsx,mts,cts}'],\n languageOptions: { parser: tseslint.parser as Linter.Parser },\n plugins: { '@typescript-eslint': tseslint.plugin as never },\n // oxlint owns every other rule, so the disable comments for them are not ESLint's to judge.\n linterOptions: { reportUnusedDisableDirectives: 'off' },\n rules: { [NamingConventionRule.NAME]: NamingConventionRule.build() },\n },\n];\n"]}
1
+ {"version":3,"file":"eslint.js","sourceRoot":"","sources":["../../src/linters/eslint.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA4B;AAE5B,0CAA6C;AAC7C,0EAAyC;AACzC,2CAAwD;AACxD,yEAAmE;AACnE,2CAAmD;AACnD,uCAA2C;AAC3C,mCAA0F;AAE1F,mCAAmC;AACnC,MAAM,YAAY,GAAG;IACnB,SAAS;IACT,UAAU;IACV,UAAU;IACV,UAAU;IACV,SAAS;IACT,UAAU;IACV,UAAU;IACV,UAAU;CACX,CAAC;AAEF,qGAAqG;AACrG,MAAM,SAAS,GAAuB;IACpC,uBAAuB,EAAE,KAAK;IAC9B,UAAU,EAAE,KAAK;IACjB,gBAAgB,EAAE,KAAK;IACvB,oBAAoB,EAAE,KAAK;IAC3B,uBAAuB,EAAE,KAAK;IAC9B,uBAAuB,EAAE,KAAK;IAC9B,cAAc,EAAE,KAAK;IACrB,iBAAiB,EAAE,KAAK;IACxB,WAAW,EAAE,KAAK;IAClB,iBAAiB,EAAE,KAAK;IACxB,SAAS,EAAE,KAAK;IAChB,oCAAoC,EAAE,KAAK;IAC3C,4CAA4C,EAAE,KAAK;IACnD,kCAAkC,EAAE,KAAK;IACzC,yCAAyC,EAAE,KAAK;IAChD,yCAAyC,EAAE,KAAK;IAChD,iDAAiD,EAAE,KAAK;IACxD,wCAAwC,EAAE,KAAK;IAC/C,uCAAuC,EAAE,KAAK;IAC9C,+CAA+C,EAAE,KAAK;IACtD,kDAAkD,EAAE,KAAK;IACzD,kDAAkD,EAAE,KAAK;IACzD,mDAAmD,EAAE,KAAK;IAC1D,+BAA+B,EAAE,KAAK;IACtC,0CAA0C,EAAE,KAAK;IACjD,sCAAsC,EAAE,KAAK;IAC7C,+CAA+C,EAAE,K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AAS;YACZ,GAAG,YAAY;YACf,CAAC,0CAAkB,CAAC,IAAI,CAAC,EAAE,0CAAkB,CAAC,KAAK,EAAE;YACrD,mCAAmC,EAAE,wBAAgB,CAAC,KAAK,EAAsB;YACjF,CAAC,+BAAuB,CAAC,IAAI,CAAC,EAAE,+BAAuB,CAAC,KAAK,EAAsB;YACnF,CAAC,4BAAoB,CAAC,IAAI,CAAC,EAAE,4BAAoB,CAAC,KAAK,EAAE;SAC1D;KACF;IACD,GAAG,wBAAc;IACjB;QACE,OAAO,EAAE;YACP,kBAAkB;YAClB,WAAW;YACX,WAAW;YACX,UAAU;YACV,aAAa;YACb,mBAAmB;YACnB,eAAe;YACf,oBAAoB;YACpB,gBAAgB;SACjB;KACF;CACF,CAAC,CAAC;AAEH;;;;;;;;;;GAUG;AACU,QAAA,uBAAuB,GAAoB;IACtD,6FAA6F;IAC7F,EAAE,OAAO,EAAE,CAAC,YAAY,EAAE,aAAa,EAAE,gBAAgB,EAAE,WAAW,EAAE,mBAAmB,CAAC,EAAE;IAC9F;QACE,KAAK,EAAE,CAAC,uBAAuB,CAAC;QAChC,eAAe,EAAE,EAAE,MAAM,EAAE,2BAAQ,CAAC,MAAuB,EAAE;QAC7D,OAAO,EAAE,EAAE,oBAAoB,EAAE,2BAAQ,CAAC,MAAe,EAAE;QAC3D,4FAA4F;QAC5F,aAAa,EAAE,EAAE,6BAA6B,EAAE,KAAK,EAAE;QACvD,KAAK,EAAE,EAAE,CAAC,4BAAoB,CAAC,IAAI,CAAC,EAAE,4BAAoB,CAAC,KAAK,EAAE,EAAE;KACrE;CACF,CAAC","sourcesContent":["import js from '@eslint/js';\nimport type { Linter } from 'eslint';\nimport { defineConfig } from 'eslint/config';\nimport tseslint from 'typescript-eslint';\nimport { HOUSE_PLUGIN_NAMESPACE } from './house/common';\nimport { NoUnbracedCaseRule } from './house/no-unbraced-case.rule';\nimport { houseEslintPlugin } from './house/plugin';\nimport { paddingConfigs } from './padding';\nimport { NamingConventionRule, NoRestrictedImportsRule, NoUnusedVarsRule } from './rules';\n\n/** Every file the preset lints. */\nconst SOURCE_FILES = [\n '**/*.js',\n '**/*.cjs',\n '**/*.mjs',\n '**/*.jsx',\n '**/*.ts',\n '**/*.cts',\n '**/*.mts',\n '**/*.tsx',\n];\n\n/** Rules that stay off: the type checker, the formatter or the framework's own style covers them. */\nconst OFF_RULES: Linter.RulesRecord = {\n 'no-constant-condition': 'off',\n 'no-undef': 'off',\n 'no-unused-vars': 'off',\n 'no-mixed-operators': 'off',\n 'no-inner-declarations': 'off',\n 'no-dupe-class-members': 'off',\n 'no-redeclare': 'off',\n 'no-invalid-this': 'off',\n 'no-shadow': 'off',\n 'no-return-await': 'off',\n camelcase: 'off',\n '@typescript-eslint/no-explicit-any': 'off',\n '@typescript-eslint/no-unsafe-function-type': 'off',\n '@typescript-eslint/no-this-alias': 'off',\n '@typescript-eslint/no-empty-object-type': 'off',\n '@typescript-eslint/no-invalid-void-type': 'off',\n '@typescript-eslint/no-confusing-void-expression': 'off',\n '@typescript-eslint/no-extraneous-class': 'off',\n '@typescript-eslint/no-require-imports': 'off',\n '@typescript-eslint/strict-boolean-expressions': 'off',\n '@typescript-eslint/explicit-function-return-type': 'off',\n '@typescript-eslint/explicit-member-accessibility': 'off',\n '@typescript-eslint/explicit-module-boundary-types': 'off',\n '@typescript-eslint/array-type': 'off',\n '@typescript-eslint/no-non-null-assertion': 'off',\n '@typescript-eslint/no-empty-function': 'off',\n '@typescript-eslint/consistent-type-assertions': 'off',\n '@typescript-eslint/no-misused-promises': 'off',\n};\n\n/** The LoopBack 4 rule set, on top of the recommended presets. */\nconst STRICT_RULES: Linter.RulesRecord = {\n 'prefer-const': 'error',\n 'no-var': 'error',\n curly: ['error', 'all'],\n 'no-new-wrappers': 'error',\n 'no-throw-literal': 'error',\n 'no-unused-expressions': 'error',\n eqeqeq: ['error', 'smart'],\n 'no-void': 'error',\n 'no-useless-escape': 'warn',\n 'no-caller': 'error',\n '@typescript-eslint/adjacent-overload-signatures': 'error',\n '@typescript-eslint/prefer-for-of': 'error',\n '@typescript-eslint/unified-signatures': 'error',\n '@typescript-eslint/no-invalid-this': ['error'],\n '@typescript-eslint/no-use-before-define': 'error',\n '@typescript-eslint/no-shadow': 'error',\n '@typescript-eslint/ban-ts-comment': 'error',\n '@typescript-eslint/no-namespace': 'error',\n '@typescript-eslint/await-thenable': 'error',\n '@typescript-eslint/no-floating-promises': 'error',\n '@typescript-eslint/prefer-optional-chain': 'error',\n '@typescript-eslint/prefer-nullish-coalescing': [\n 'error',\n { allowRuleToRunWithoutStrictNullChecksIKnowWhatIAmDoing: true },\n ],\n '@typescript-eslint/return-await': 'error',\n};\n\n/**\n * The full ESLint preset, owned here: the LoopBack 4 rule set on the ESLint and typescript-eslint\n * recommended presets, type-aware through the project service. A project on oxlint uses\n * `oxlintConfigs` + `namingConventionConfigs` instead.\n */\nexport const eslintConfigs: Linter.Config[] = defineConfig([\n js.configs.recommended,\n tseslint.configs.recommended,\n {\n files: SOURCE_FILES,\n languageOptions: {\n parserOptions: {\n // Finds each file's tsconfig; the default project covers root-level scripts and configs.\n projectService: { allowDefaultProject: ['*.js', '*.cjs', '*.mjs', '.*.js'] },\n },\n },\n plugins: { [HOUSE_PLUGIN_NAMESPACE]: houseEslintPlugin },\n rules: {\n ...OFF_RULES,\n ...STRICT_RULES,\n [NoUnbracedCaseRule.NAME]: NoUnbracedCaseRule.build(),\n '@typescript-eslint/no-unused-vars': NoUnusedVarsRule.build() as Linter.RuleEntry,\n [NoRestrictedImportsRule.NAME]: NoRestrictedImportsRule.build() as Linter.RuleEntry,\n [NamingConventionRule.NAME]: NamingConventionRule.build(),\n },\n },\n ...paddingConfigs,\n {\n ignores: [\n '**/node_modules/',\n '**/*.d.ts',\n '**/build/',\n '**/dist/',\n '**/release/',\n '**/babel.config.*',\n '**/.babelrc.*',\n '**/eslint.config.*',\n '**/.eslintrc.*',\n ],\n },\n]);\n\n/**\n * The one rule of `eslintConfigs` that oxlint cannot run yet, as a standalone ESLint preset to run\n * next to `oxlintConfigs`. It needs no type information, so ESLint stays fast.\n *\n * ```js\n * // .configs/lints/eslint.config.mjs\n * import { namingConventionConfigs } from '@venizia/dev-configs/linters';\n *\n * export default namingConventionConfigs;\n * ```\n */\nexport const namingConventionConfigs: Linter.Config[] = [\n // Global: ESLint does not read .gitignore, and still walks plain .js files no config claims.\n { ignores: ['**/dist/**', '**/build/**', '**/coverage/**', '**/*.d.ts', '**/*.{js,cjs,mjs}'] },\n {\n files: ['**/*.{ts,tsx,mts,cts}'],\n languageOptions: { parser: tseslint.parser as Linter.Parser },\n plugins: { '@typescript-eslint': tseslint.plugin as never },\n // oxlint owns every other rule, so the disable comments for them are not ESLint's to judge.\n linterOptions: { reportUnusedDisableDirectives: 'off' },\n rules: { [NamingConventionRule.NAME]: NamingConventionRule.build() },\n },\n];\n"]}
@@ -0,0 +1,10 @@
1
+ import type { Linter } from 'eslint';
2
+ /**
3
+ * The async style rules: `await` stands alone as a statement or as the whole initializer of a declaration
4
+ * (`no-inline-await`), a function returns the promise instead of `return await` (`no-return-await`), an `await`
5
+ * never takes a promise chain (`no-await-promise-chain`), and a caught error leaves a trace (`no-silent-catch`).
6
+ * They apply to test files too. Not exported from the package: `houseConfigs` and `reactHouseConfigs` carry them, and
7
+ * `devz codemod async-style` runs them alone.
8
+ */
9
+ export declare const asyncRuleConfigs: Linter.Config[];
10
+ //# sourceMappingURL=async-rules.d.ts.map
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.asyncRuleConfigs = void 0;
4
+ const common_1 = require("./common");
5
+ const no_await_promise_chain_rule_1 = require("./no-await-promise-chain.rule");
6
+ const no_inline_await_rule_1 = require("./no-inline-await.rule");
7
+ const no_return_await_rule_1 = require("./no-return-await.rule");
8
+ const no_silent_catch_rule_1 = require("./no-silent-catch.rule");
9
+ const plugin_1 = require("./plugin");
10
+ /**
11
+ * The async style rules: `await` stands alone as a statement or as the whole initializer of a declaration
12
+ * (`no-inline-await`), a function returns the promise instead of `return await` (`no-return-await`), an `await`
13
+ * never takes a promise chain (`no-await-promise-chain`), and a caught error leaves a trace (`no-silent-catch`).
14
+ * They apply to test files too. Not exported from the package: `houseConfigs` and `reactHouseConfigs` carry them, and
15
+ * `devz codemod async-style` runs them alone.
16
+ */
17
+ exports.asyncRuleConfigs = [
18
+ {
19
+ files: ['**/*.{ts,tsx,mts,cts}'],
20
+ plugins: { [common_1.HOUSE_PLUGIN_NAMESPACE]: plugin_1.houseEslintPlugin },
21
+ rules: {
22
+ [no_inline_await_rule_1.NoInlineAwaitRule.NAME]: no_inline_await_rule_1.NoInlineAwaitRule.build(),
23
+ [no_return_await_rule_1.NoReturnAwaitRule.NAME]: no_return_await_rule_1.NoReturnAwaitRule.build(),
24
+ [no_await_promise_chain_rule_1.NoAwaitPromiseChainRule.NAME]: no_await_promise_chain_rule_1.NoAwaitPromiseChainRule.build(),
25
+ [no_silent_catch_rule_1.NoSilentCatchRule.NAME]: no_silent_catch_rule_1.NoSilentCatchRule.build(),
26
+ },
27
+ },
28
+ ];
29
+ //# sourceMappingURL=async-rules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"async-rules.js","sourceRoot":"","sources":["../../../src/linters/house/async-rules.ts"],"names":[],"mappings":";;;AACA,qCAAkD;AAClD,+EAAwE;AACxE,iEAA2D;AAC3D,iEAA2D;AAC3D,iEAA2D;AAC3D,qCAA6C;AAE7C;;;;;;GAMG;AACU,QAAA,gBAAgB,GAAoB;IAC/C;QACE,KAAK,EAAE,CAAC,uBAAuB,CAAC;QAChC,OAAO,EAAE,EAAE,CAAC,+BAAsB,CAAC,EAAE,0BAAiB,EAAE;QACxD,KAAK,EAAE;YACL,CAAC,wCAAiB,CAAC,IAAI,CAAC,EAAE,wCAAiB,CAAC,KAAK,EAAE;YACnD,CAAC,wCAAiB,CAAC,IAAI,CAAC,EAAE,wCAAiB,CAAC,KAAK,EAAE;YACnD,CAAC,qDAAuB,CAAC,IAAI,CAAC,EAAE,qDAAuB,CAAC,KAAK,EAAE;YAC/D,CAAC,wCAAiB,CAAC,IAAI,CAAC,EAAE,wCAAiB,CAAC,KAAK,EAAE;SACpD;KACF;CACF,CAAC","sourcesContent":["import type { Linter } from 'eslint';\nimport { HOUSE_PLUGIN_NAMESPACE } from './common';\nimport { NoAwaitPromiseChainRule } from './no-await-promise-chain.rule';\nimport { NoInlineAwaitRule } from './no-inline-await.rule';\nimport { NoReturnAwaitRule } from './no-return-await.rule';\nimport { NoSilentCatchRule } from './no-silent-catch.rule';\nimport { houseEslintPlugin } from './plugin';\n\n/**\n * The async style rules: `await` stands alone as a statement or as the whole initializer of a declaration\n * (`no-inline-await`), a function returns the promise instead of `return await` (`no-return-await`), an `await`\n * never takes a promise chain (`no-await-promise-chain`), and a caught error leaves a trace (`no-silent-catch`).\n * They apply to test files too. Not exported from the package: `houseConfigs` and `reactHouseConfigs` carry them, and\n * `devz codemod async-style` runs them alone.\n */\nexport const asyncRuleConfigs: Linter.Config[] = [\n {\n files: ['**/*.{ts,tsx,mts,cts}'],\n plugins: { [HOUSE_PLUGIN_NAMESPACE]: houseEslintPlugin },\n rules: {\n [NoInlineAwaitRule.NAME]: NoInlineAwaitRule.build(),\n [NoReturnAwaitRule.NAME]: NoReturnAwaitRule.build(),\n [NoAwaitPromiseChainRule.NAME]: NoAwaitPromiseChainRule.build(),\n [NoSilentCatchRule.NAME]: NoSilentCatchRule.build(),\n },\n },\n];\n"]}
@@ -1,4 +1,6 @@
1
1
  import type { Rule, SourceCode } from 'eslint';
2
+ export declare const STATEMENT_LISTS: Set<string>;
3
+ export declare const FUNCTION_TYPES: Set<string>;
2
4
  /** The shared parts of the two `await` rules: where a statement can go before another, what may run first, fresh names. */
3
5
  export declare class AwaitSupport {
4
6
  static parentOf(opts: {
@@ -1,12 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AwaitSupport = void 0;
3
+ exports.AwaitSupport = exports.FUNCTION_TYPES = exports.STATEMENT_LISTS = void 0;
4
4
  const common_1 = require("./common");
5
- const STATEMENT_LISTS = new Set(['BlockStatement', 'Program', 'StaticBlock', 'SwitchCase']);
6
- const FUNCTION_TYPES = new Set([
7
- 'FunctionDeclaration',
8
- 'FunctionExpression',
9
- 'ArrowFunctionExpression',
5
+ exports.STATEMENT_LISTS = new Set([
6
+ common_1.AstNodeTypes.BLOCK_STATEMENT,
7
+ 'Program',
8
+ 'StaticBlock',
9
+ common_1.AstNodeTypes.SWITCH_CASE,
10
+ ]);
11
+ exports.FUNCTION_TYPES = new Set([
12
+ common_1.AstNodeTypes.FUNCTION_DECLARATION,
13
+ common_1.AstNodeTypes.FUNCTION_EXPRESSION,
14
+ common_1.AstNodeTypes.ARROW_FUNCTION_EXPRESSION,
10
15
  ]);
11
16
  /** The child of a statement that runs exactly once, before anything else of that statement. */
12
17
  const HEAD_FIELD = {
@@ -64,7 +69,7 @@ class AwaitSupport {
64
69
  let ancestor = AwaitSupport.parentOf({ node: child });
65
70
  while (ancestor) {
66
71
  const type = common_1.AstNode.getType({ node: ancestor }) ?? '';
67
- if (FUNCTION_TYPES.has(type) || type === 'ChainExpression') {
72
+ if (exports.FUNCTION_TYPES.has(type) || type === 'ChainExpression') {
68
73
  return undefined;
69
74
  }
70
75
  if (type === 'ConditionalExpression' &&
@@ -85,7 +90,7 @@ class AwaitSupport {
85
90
  const isHead = type === 'VariableDeclaration' ||
86
91
  common_1.AstNode.readField({ node: ancestor, key: head }) === child;
87
92
  const outer = AwaitSupport.parentOf({ node: ancestor });
88
- const isListed = STATEMENT_LISTS.has(common_1.AstNode.getType({ node: outer }) ?? '') &&
93
+ const isListed = exports.STATEMENT_LISTS.has(common_1.AstNode.getType({ node: outer }) ?? '') &&
89
94
  (type === 'VariableDeclaration' || head !== undefined);
90
95
  return isHead && isListed && AwaitSupport.isNode(ancestor) ? ancestor : undefined;
91
96
  }
@@ -163,7 +168,7 @@ class AwaitSupport {
163
168
  static scopeNodeOf(opts) {
164
169
  let current = opts.node;
165
170
  let parent = AwaitSupport.parentOf({ node: current });
166
- while (parent && !FUNCTION_TYPES.has(common_1.AstNode.getType({ node: parent }) ?? '')) {
171
+ while (parent && !exports.FUNCTION_TYPES.has(common_1.AstNode.getType({ node: parent }) ?? '')) {
167
172
  if (!AwaitSupport.isNode(parent)) {
168
173
  break;
169
174
  }
@@ -181,7 +186,7 @@ class AwaitSupport {
181
186
  let outermost;
182
187
  let current = opts.node;
183
188
  while (AwaitSupport.isNode(current)) {
184
- if (FUNCTION_TYPES.has(common_1.AstNode.getType({ node: current }) ?? '')) {
189
+ if (exports.FUNCTION_TYPES.has(common_1.AstNode.getType({ node: current }) ?? '')) {
185
190
  outermost = current;
186
191
  }
187
192
  current = AwaitSupport.parentOf({ node: current });
@@ -1 +1 @@
1
- {"version":3,"file":"await-support.js","sourceRoot":"","sources":["../../../src/linters/house/await-support.ts"],"names":[],"mappings":";;;AACA,qCAAmC;AAEnC,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC,CAAC,gBAAgB,EAAE,SAAS,EAAE,aAAa,EAAE,YAAY,CAAC,CAAC,CAAC;AAC5F,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC;IAC7B,qBAAqB;IACrB,oBAAoB;IACpB,yBAAyB;CAC1B,CAAC,CAAC;AACH,+FAA+F;AAC/F,MAAM,UAAU,GAA2B;IACzC,WAAW,EAAE,MAAM;IACnB,eAAe,EAAE,cAAc;IAC/B,cAAc,EAAE,OAAO;IACvB,cAAc,EAAE,OAAO;IACvB,mBAAmB,EAAE,YAAY;IACjC,eAAe,EAAE,UAAU;IAC3B,cAAc,EAAE,UAAU;CAC3B,CAAC;AACF,oHAAoH;AACpH,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC;IAC1B,YAAY;IACZ,SAAS;IACT,gBAAgB;IAChB,yBAAyB;IACzB,oBAAoB;IACpB,mBAAmB;CACpB,CAAC,CAAC;AACH,gGAAgG;AAChG,MA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AAC;IACH,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,cAAc,CAAC,IAAsD;QAC1E,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC;QACvC,MAAM,MAAM,GAAG,UAAU,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;QACpD,MAAM,KAAK,GAAG,UAAU,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;QAClD,MAAM,UAAU,GAAG,gBAAO,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,YAAY,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC;QAC/F,MAAM,MAAM,GACV,UAAU,KAAK,gBAAgB;YAC/B,gBAAO,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,YAAY,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC;gBACpF,SAAS,CAAC;QAEd,IACE,MAAM,EAAE,KAAK,KAAK,GAAG;YACrB,KAAK,EAAE,KAAK,KAAK,GAAG;YACpB,CAAC,gBAAgB,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,MAAM,CAAC,EAC5C,CAAC;YACD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3C,CAAC;QAED,OAAO,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,SAAS,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IAChE,CAAC;;AAxPH,oCAyPC","sourcesContent":["import type { Rule, SourceCode } from 'eslint';\nimport { AstNode } from './common';\n\nconst STATEMENT_LISTS = new Set(['BlockStatement', 'Program', 'StaticBlock', 'SwitchCase']);\nconst FUNCTION_TYPES = new Set([\n 'FunctionDeclaration',\n 'FunctionExpression',\n 'ArrowFunctionExpression',\n]);\n/** The child of a statement that runs exactly once, before anything else of that statement. */\nconst HEAD_FIELD: Record<string, string> = {\n IfStatement: 'test',\n SwitchStatement: 'discriminant',\n ForOfStatement: 'right',\n ForInStatement: 'right',\n ExpressionStatement: 'expression',\n ReturnStatement: 'argument',\n ThrowStatement: 'argument',\n};\n/** Nodes that evaluate to a value without doing anything else, so running them later or earlier changes nothing. */\nconst PURE_LEAVES = new Set([\n 'Identifier',\n 'Literal',\n 'ThisExpression',\n 'ArrowFunctionExpression',\n 'FunctionExpression',\n 'PrivateIdentifier',\n]);\n/** Wrappers whose parentheses around an `await` carry no meaning once the `await` is a name. */\nconst GROUPING_PARENTS = new Set([\n 'MemberExpression',\n 'TSAsExpression',\n 'TSSatisfiesExpression',\n 'TSNonNullExpression',\n 'UnaryExpression',\n 'BinaryExpression',\n 'SpreadElement',\n 'ArrayExpression',\n]);\n\n/** The shared parts of the two `await` rules: where a statement can go before another, what may run first, fresh names. */\nexport class AwaitSupport {\n static parentOf(opts: { node: unknown }): unknown {\n return AstNode.readField({ node: opts.node, key: 'parent' });\n }\n\n /** An ESTree node of the lint run: it has a `type` and a `range`. */\n static isNode(value: unknown): value is Rule.Node {\n return (\n AstNode.getType({ node: value }) !== undefined &&\n AwaitSupport.rangeOf({ node: value }) !== undefined\n );\n }\n\n static rangeOf(opts: { node: unknown }): [number, number] | undefined {\n const range = AstNode.readField({ node: opts.node, key: 'range' });\n return Array.isArray(range) && typeof range[0] === 'number' && typeof range[1] === 'number'\n ? [range[0], range[1]]\n : undefined;\n }\n\n /**\n * The statement that can take a `const` in front of it so that `awaitNode` is evaluated first, or `undefined`\n * when hoisting would change what runs: the `await` sits in a branch (`?:`, the right of `&&`, `||`, `??`),\n * in a loop test or update, in an unbraced `if` branch, in an optional chain, or in an arrow expression body.\n */\n static hoistTarget(opts: { awaitNode: unknown }): Rule.Node | undefined {\n let child: unknown = opts.awaitNode;\n let ancestor = AwaitSupport.parentOf({ node: child });\n\n while (ancestor) {\n const type = AstNode.getType({ node: ancestor }) ?? '';\n\n if (FUNCTION_TYPES.has(type) || type === 'ChainExpression') {\n return undefined;\n }\n if (\n type === 'ConditionalExpression' &&\n AstNode.readField({ node: ancestor, key: 'test' }) !== child\n ) {\n return undefined;\n }\n if (\n type === 'LogicalExpression' &&\n AstNode.readField({ node: ancestor, key: 'left' }) !== child\n ) {\n return undefined;\n }\n if (\n type === 'AssignmentExpression' &&\n ['??=', '||=', '&&='].includes(\n String(AstNode.readField({ node: ancestor, key: 'operator' })),\n ) &&\n AstNode.readField({ node: ancestor, key: 'right' }) === child\n ) {\n return undefined;\n }\n if (type.endsWith('Statement') || type === 'VariableDeclaration') {\n const head = HEAD_FIELD[type];\n const isHead =\n type === 'VariableDeclaration' ||\n AstNode.readField({ node: ancestor, key: head }) === child;\n const outer = AwaitSupport.parentOf({ node: ancestor });\n\n const isListed =\n STATEMENT_LISTS.has(AstNode.getType({ node: outer }) ?? '') &&\n (type === 'VariableDeclaration' || head !== undefined);\n\n return isHead && isListed && AwaitSupport.isNode(ancestor) ? ancestor : undefined;\n }\n\n child = ancestor;\n ancestor = AwaitSupport.parentOf({ node: child });\n }\n\n return undefined;\n }\n\n static isPure(opts: { node: unknown }): boolean {\n const { node } = opts;\n const type = AstNode.getType({ node }) ?? '';\n const pure = (child: unknown) => AwaitSupport.isPure({ node: child });\n const field = (key: string) => AstNode.readField({ node, key });\n const all = (key: string) => {\n const list = AstNode.readField({ node, key });\n return Array.isArray(list) && list.every((entry) => entry === null || pure(entry));\n };\n\n if (\n PURE_LEAVES.has(type) ||\n (type.startsWith('TS') &&\n !['TSAsExpression', 'TSNonNullExpression', 'TSSatisfiesExpression'].includes(type))\n ) {\n return true;\n }\n\n const parts = new Map<string, () => boolean>([\n ['TemplateLiteral', () => all('expressions')],\n ['MemberExpression', () => pure(field('object')) && pure(field('property'))],\n ['ArrayExpression', () => all('elements')],\n ['ObjectExpression', () => all('properties')],\n ['Property', () => pure(field('key')) && pure(field('value'))],\n ['SpreadElement', () => pure(field('argument'))],\n ['UnaryExpression', () => field('operator') !== 'delete' && pure(field('argument'))],\n ['BinaryExpression', () => pure(field('left')) && pure(field('right'))],\n ['LogicalExpression', () => pure(field('left')) && pure(field('right'))],\n [\n 'ConditionalExpression',\n () => ['test', 'consequent', 'alternate'].every((key) => pure(field(key))),\n ],\n ['TSAsExpression', () => pure(field('expression'))],\n ['TSNonNullExpression', () => pure(field('expression'))],\n ['TSSatisfiesExpression', () => pure(field('expression'))],\n ]);\n\n return parts.get(type)?.() ?? false;\n }\n\n /**\n * Whether something that does more than read a value runs, inside `statement`, before `awaitNode` does.\n * Hoisting the `await` in front of the statement would then run it first.\n */\n static hasEffectBefore(opts: {\n statement: Rule.Node;\n awaitNode: unknown;\n sourceCode: SourceCode;\n }): boolean {\n const target = AwaitSupport.rangeOf({ node: opts.awaitNode });\n if (!target) {\n return true;\n }\n\n const visit = (node: unknown): boolean => {\n const range = AwaitSupport.rangeOf({ node });\n if (!range) {\n return false;\n }\n if (range[0] <= target[0] && target[1] <= range[1]) {\n const keys = opts.sourceCode.visitorKeys[AstNode.getType({ node }) ?? ''] ?? [];\n\n return keys.some((key) => {\n const value = AstNode.readField({ node, key });\n const entries = Array.isArray(value) ? value : [value];\n\n return entries.some((entry) => entry && entry !== opts.awaitNode && visit(entry));\n });\n }\n\n return range[1] <= target[0] && !AwaitSupport.isPure({ node });\n };\n\n return visit(opts.statement);\n }\n\n /** The leading whitespace of the line a node starts on. */\n static indentOf(opts: { node: Rule.Node; sourceCode: SourceCode }): string {\n const line = opts.sourceCode.lines[(opts.node.loc?.start.line ?? 1) - 1] ?? '';\n return /^\\s*/.exec(line)?.[0] ?? '';\n }\n\n /** The nearest function or the program that holds `node`: the scope a new name must be free in. */\n static scopeNodeOf(opts: { node: Rule.Node }): Rule.Node {\n let current: Rule.Node = opts.node;\n let parent = AwaitSupport.parentOf({ node: current });\n\n while (parent && !FUNCTION_TYPES.has(AstNode.getType({ node: parent }) ?? '')) {\n if (!AwaitSupport.isNode(parent)) {\n break;\n }\n current = parent;\n parent = AwaitSupport.parentOf({ node: current });\n }\n\n return AwaitSupport.isNode(parent) ? parent : current;\n }\n\n /**\n * The outermost function that holds `node` (the program when no function does): the one namespace a hoisted name\n * must be unique in. A name that is free in the nearest function only could still shadow, or be shadowed by, the\n * name another fix hoisted in a function around it or a block inside it.\n */\n static outermostScopeOf(opts: { node: Rule.Node }): Rule.Node {\n let outermost: Rule.Node | undefined;\n let current: unknown = opts.node;\n\n while (AwaitSupport.isNode(current)) {\n if (FUNCTION_TYPES.has(AstNode.getType({ node: current }) ?? '')) {\n outermost = current;\n }\n current = AwaitSupport.parentOf({ node: current });\n }\n\n return outermost ?? AwaitSupport.scopeNodeOf({ node: opts.node });\n }\n\n /**\n * The names handed out in this lint pass, per outermost scope. They are shared by every rule that hoists a name: the\n * rules run in the same pass over the same text and their fixes are applied together, so two rules that each\n * remembered their own names both handed out `result`. A `SourceCode` lasts for one pass of one file.\n */\n private static readonly PASS_NAMES = new WeakMap<SourceCode, Map<unknown, Set<string>>>();\n\n /**\n * `base`, or `base2`, `base3`... the first word that does not appear in the outermost function (or program) holding\n * `node` and that no rule has handed out already in this lint pass: no two fixes of one pass declare the same name,\n * and none declares a name that is in scope anywhere around or inside the place it is hoisted to.\n */\n static freshName(opts: { node: Rule.Node; base: string; sourceCode: SourceCode }): string {\n const scope = AwaitSupport.outermostScopeOf({ node: opts.node });\n const text = opts.sourceCode.getText(scope);\n const pass = AwaitSupport.PASS_NAMES.get(opts.sourceCode) ?? new Map<unknown, Set<string>>();\n const reserved = pass.get(scope) ?? new Set<string>();\n\n AwaitSupport.PASS_NAMES.set(opts.sourceCode, pass);\n\n for (let index = 1; ; index += 1) {\n const candidate = index === 1 ? opts.base : `${opts.base}${index}`;\n if (!reserved.has(candidate) && !new RegExp(`\\\\b${candidate}\\\\b`).test(text)) {\n reserved.add(candidate);\n pass.set(scope, reserved);\n\n return candidate;\n }\n }\n }\n\n /**\n * The range to replace with the name that stands for an `await`: the `await` itself, widened over the parentheses\n * around it when they only grouped it (`(await f()).x`, `!(await f())`).\n */\n static replaceRangeOf(opts: { awaitNode: Rule.Node; sourceCode: SourceCode }): [number, number] {\n const { awaitNode, sourceCode } = opts;\n const before = sourceCode.getTokenBefore(awaitNode);\n const after = sourceCode.getTokenAfter(awaitNode);\n const parentType = AstNode.getType({ node: AwaitSupport.parentOf({ node: awaitNode }) }) ?? '';\n const callee =\n parentType === 'CallExpression' &&\n AstNode.readField({ node: AwaitSupport.parentOf({ node: awaitNode }), key: 'callee' }) ===\n awaitNode;\n\n if (\n before?.value === '(' &&\n after?.value === ')' &&\n (GROUPING_PARENTS.has(parentType) || callee)\n ) {\n return [before.range[0], after.range[1]];\n }\n\n return [awaitNode.range?.[0] ?? 0, awaitNode.range?.[1] ?? 0];\n }\n}\n"]}
1
+ {"version":3,"file":"await-support.js","sourceRoot":"","sources":["../../../src/linters/house/await-support.ts"],"names":[],"mappings":";;;AACA,qCAAiD;AAEpC,QAAA,eAAe,GAAG,IAAI,GAAG,CAAS;IAC7C,qBAAY,CAAC,eAAe;IAC5B,SAAS;IACT,aAAa;IACb,qBAAY,CAAC,WAAW;CACzB,CAAC,CAAC;AACU,QAAA,cAAc,GAAG,IAAI,GAAG,CAAS;IAC5C,qBAAY,CAAC,oBAAoB;IACjC,qBAAY,CAAC,mBAAmB;IAChC,qBAAY,CAAC,yBAAyB;CACvC,CAAC,CAAC;AACH,+FAA+F;AAC/F,MAAM,UAAU,GAA2B;IACzC,WAAW,EAAE,MAAM;IACnB,eAAe,EAAE,cAAc;IAC/B,cAAc,EAAE,OAAO;IACvB,cAAc,EAAE,OAAO;IACvB,mBAAmB,EAAE,YAAY;IACjC,eAAe,EAAE,UAAU;IAC3B,cAAc,EAAE,UAAU;CAC3B,CAAC;AACF,oHAAoH;AACpH,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC;IAC1B,YAAY;IACZ,SAA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ode, AstNodeTypes } from './common';\n\nexport const STATEMENT_LISTS = new Set<string>([\n AstNodeTypes.BLOCK_STATEMENT,\n 'Program',\n 'StaticBlock',\n AstNodeTypes.SWITCH_CASE,\n]);\nexport const FUNCTION_TYPES = new Set<string>([\n AstNodeTypes.FUNCTION_DECLARATION,\n AstNodeTypes.FUNCTION_EXPRESSION,\n AstNodeTypes.ARROW_FUNCTION_EXPRESSION,\n]);\n/** The child of a statement that runs exactly once, before anything else of that statement. */\nconst HEAD_FIELD: Record<string, string> = {\n IfStatement: 'test',\n SwitchStatement: 'discriminant',\n ForOfStatement: 'right',\n ForInStatement: 'right',\n ExpressionStatement: 'expression',\n ReturnStatement: 'argument',\n ThrowStatement: 'argument',\n};\n/** Nodes that evaluate to a value without doing anything else, so running them later or earlier changes nothing. */\nconst PURE_LEAVES = new Set([\n 'Identifier',\n 'Literal',\n 'ThisExpression',\n 'ArrowFunctionExpression',\n 'FunctionExpression',\n 'PrivateIdentifier',\n]);\n/** Wrappers whose parentheses around an `await` carry no meaning once the `await` is a name. */\nconst GROUPING_PARENTS = new Set([\n 'MemberExpression',\n 'TSAsExpression',\n 'TSSatisfiesExpression',\n 'TSNonNullExpression',\n 'UnaryExpression',\n 'BinaryExpression',\n 'SpreadElement',\n 'ArrayExpression',\n]);\n\n/** The shared parts of the two `await` rules: where a statement can go before another, what may run first, fresh names. */\nexport class AwaitSupport {\n static parentOf(opts: { node: unknown }): unknown {\n return AstNode.readField({ node: opts.node, key: 'parent' });\n }\n\n /** An ESTree node of the lint run: it has a `type` and a `range`. */\n static isNode(value: unknown): value is Rule.Node {\n return (\n AstNode.getType({ node: value }) !== undefined &&\n AwaitSupport.rangeOf({ node: value }) !== undefined\n );\n }\n\n static rangeOf(opts: { node: unknown }): [number, number] | undefined {\n const range = AstNode.readField({ node: opts.node, key: 'range' });\n\n return Array.isArray(range) && typeof range[0] === 'number' && typeof range[1] === 'number'\n ? [range[0], range[1]]\n : undefined;\n }\n\n /**\n * The statement that can take a `const` in front of it so that `awaitNode` is evaluated first, or `undefined`\n * when hoisting would change what runs: the `await` sits in a branch (`?:`, the right of `&&`, `||`, `??`),\n * in a loop test or update, in an unbraced `if` branch, in an optional chain, or in an arrow expression body.\n */\n static hoistTarget(opts: { awaitNode: unknown }): Rule.Node | undefined {\n let child: unknown = opts.awaitNode;\n let ancestor = AwaitSupport.parentOf({ node: child });\n\n while (ancestor) {\n const type = AstNode.getType({ node: ancestor }) ?? '';\n\n if (FUNCTION_TYPES.has(type) || type === 'ChainExpression') {\n return undefined;\n }\n\n if (\n type === 'ConditionalExpression' &&\n AstNode.readField({ node: ancestor, key: 'test' }) !== child\n ) {\n return undefined;\n }\n\n if (\n type === 'LogicalExpression' &&\n AstNode.readField({ node: ancestor, key: 'left' }) !== child\n ) {\n return undefined;\n }\n\n if (\n type === 'AssignmentExpression' &&\n ['??=', '||=', '&&='].includes(\n String(AstNode.readField({ node: ancestor, key: 'operator' })),\n ) &&\n AstNode.readField({ node: ancestor, key: 'right' }) === child\n ) {\n return undefined;\n }\n\n if (type.endsWith('Statement') || type === 'VariableDeclaration') {\n const head = HEAD_FIELD[type];\n const isHead =\n type === 'VariableDeclaration' ||\n AstNode.readField({ node: ancestor, key: head }) === child;\n const outer = AwaitSupport.parentOf({ node: ancestor });\n\n const isListed =\n STATEMENT_LISTS.has(AstNode.getType({ node: outer }) ?? '') &&\n (type === 'VariableDeclaration' || head !== undefined);\n\n return isHead && isListed && AwaitSupport.isNode(ancestor) ? ancestor : undefined;\n }\n\n child = ancestor;\n ancestor = AwaitSupport.parentOf({ node: child });\n }\n\n return undefined;\n }\n\n static isPure(opts: { node: unknown }): boolean {\n const { node } = opts;\n const type = AstNode.getType({ node }) ?? '';\n const pure = (child: unknown) => AwaitSupport.isPure({ node: child });\n const field = (key: string) => AstNode.readField({ node, key });\n\n const all = (key: string) => {\n const list = AstNode.readField({ node, key });\n\n return Array.isArray(list) && list.every((entry) => entry === null || pure(entry));\n };\n\n if (\n PURE_LEAVES.has(type) ||\n (type.startsWith('TS') &&\n !['TSAsExpression', 'TSNonNullExpression', 'TSSatisfiesExpression'].includes(type))\n ) {\n return true;\n }\n\n const parts = new Map<string, () => boolean>([\n ['TemplateLiteral', () => all('expressions')],\n ['MemberExpression', () => pure(field('object')) && pure(field('property'))],\n ['ArrayExpression', () => all('elements')],\n ['ObjectExpression', () => all('properties')],\n ['Property', () => pure(field('key')) && pure(field('value'))],\n ['SpreadElement', () => pure(field('argument'))],\n ['UnaryExpression', () => field('operator') !== 'delete' && pure(field('argument'))],\n ['BinaryExpression', () => pure(field('left')) && pure(field('right'))],\n ['LogicalExpression', () => pure(field('left')) && pure(field('right'))],\n [\n 'ConditionalExpression',\n () => ['test', 'consequent', 'alternate'].every((key) => pure(field(key))),\n ],\n ['TSAsExpression', () => pure(field('expression'))],\n ['TSNonNullExpression', () => pure(field('expression'))],\n ['TSSatisfiesExpression', () => pure(field('expression'))],\n ]);\n\n return parts.get(type)?.() ?? false;\n }\n\n /**\n * Whether something that does more than read a value runs, inside `statement`, before `awaitNode` does.\n * Hoisting the `await` in front of the statement would then run it first.\n */\n static hasEffectBefore(opts: {\n statement: Rule.Node;\n awaitNode: unknown;\n sourceCode: SourceCode;\n }): boolean {\n const target = AwaitSupport.rangeOf({ node: opts.awaitNode });\n\n if (!target) {\n return true;\n }\n\n const visit = (node: unknown): boolean => {\n const range = AwaitSupport.rangeOf({ node });\n\n if (!range) {\n return false;\n }\n\n if (range[0] <= target[0] && target[1] <= range[1]) {\n const keys = opts.sourceCode.visitorKeys[AstNode.getType({ node }) ?? ''] ?? [];\n\n return keys.some((key) => {\n const value = AstNode.readField({ node, key });\n const entries = Array.isArray(value) ? value : [value];\n\n return entries.some((entry) => entry && entry !== opts.awaitNode && visit(entry));\n });\n }\n\n return range[1] <= target[0] && !AwaitSupport.isPure({ node });\n };\n\n return visit(opts.statement);\n }\n\n /** The leading whitespace of the line a node starts on. */\n static indentOf(opts: { node: Rule.Node; sourceCode: SourceCode }): string {\n const line = opts.sourceCode.lines[(opts.node.loc?.start.line ?? 1) - 1] ?? '';\n\n return /^\\s*/.exec(line)?.[0] ?? '';\n }\n\n /** The nearest function or the program that holds `node`: the scope a new name must be free in. */\n static scopeNodeOf(opts: { node: Rule.Node }): Rule.Node {\n let current: Rule.Node = opts.node;\n let parent = AwaitSupport.parentOf({ node: current });\n\n while (parent && !FUNCTION_TYPES.has(AstNode.getType({ node: parent }) ?? '')) {\n if (!AwaitSupport.isNode(parent)) {\n break;\n }\n\n current = parent;\n parent = AwaitSupport.parentOf({ node: current });\n }\n\n return AwaitSupport.isNode(parent) ? parent : current;\n }\n\n /**\n * The outermost function that holds `node` (the program when no function does): the one namespace a hoisted name\n * must be unique in. A name that is free in the nearest function only could still shadow, or be shadowed by, the\n * name another fix hoisted in a function around it or a block inside it.\n */\n static outermostScopeOf(opts: { node: Rule.Node }): Rule.Node {\n let outermost: Rule.Node | undefined;\n let current: unknown = opts.node;\n\n while (AwaitSupport.isNode(current)) {\n if (FUNCTION_TYPES.has(AstNode.getType({ node: current }) ?? '')) {\n outermost = current;\n }\n\n current = AwaitSupport.parentOf({ node: current });\n }\n\n return outermost ?? AwaitSupport.scopeNodeOf({ node: opts.node });\n }\n\n /**\n * The names handed out in this lint pass, per outermost scope. They are shared by every rule that hoists a name: the\n * rules run in the same pass over the same text and their fixes are applied together, so two rules that each\n * remembered their own names both handed out `result`. A `SourceCode` lasts for one pass of one file.\n */\n private static readonly PASS_NAMES = new WeakMap<SourceCode, Map<unknown, Set<string>>>();\n\n /**\n * `base`, or `base2`, `base3`... the first word that does not appear in the outermost function (or program) holding\n * `node` and that no rule has handed out already in this lint pass: no two fixes of one pass declare the same name,\n * and none declares a name that is in scope anywhere around or inside the place it is hoisted to.\n */\n static freshName(opts: { node: Rule.Node; base: string; sourceCode: SourceCode }): string {\n const scope = AwaitSupport.outermostScopeOf({ node: opts.node });\n const text = opts.sourceCode.getText(scope);\n const pass = AwaitSupport.PASS_NAMES.get(opts.sourceCode) ?? new Map<unknown, Set<string>>();\n const reserved = pass.get(scope) ?? new Set<string>();\n\n AwaitSupport.PASS_NAMES.set(opts.sourceCode, pass);\n\n for (let index = 1; ; index += 1) {\n const candidate = index === 1 ? opts.base : `${opts.base}${index}`;\n\n if (!reserved.has(candidate) && !new RegExp(`\\\\b${candidate}\\\\b`).test(text)) {\n reserved.add(candidate);\n pass.set(scope, reserved);\n\n return candidate;\n }\n }\n }\n\n /**\n * The range to replace with the name that stands for an `await`: the `await` itself, widened over the parentheses\n * around it when they only grouped it (`(await f()).x`, `!(await f())`).\n */\n static replaceRangeOf(opts: { awaitNode: Rule.Node; sourceCode: SourceCode }): [number, number] {\n const { awaitNode, sourceCode } = opts;\n const before = sourceCode.getTokenBefore(awaitNode);\n const after = sourceCode.getTokenAfter(awaitNode);\n const parentType = AstNode.getType({ node: AwaitSupport.parentOf({ node: awaitNode }) }) ?? '';\n const callee =\n parentType === 'CallExpression' &&\n AstNode.readField({ node: AwaitSupport.parentOf({ node: awaitNode }), key: 'callee' }) ===\n awaitNode;\n\n if (\n before?.value === '(' &&\n after?.value === ')' &&\n (GROUPING_PARENTS.has(parentType) || callee)\n ) {\n return [before.range[0], after.range[1]];\n }\n\n return [awaitNode.range?.[0] ?? 0, awaitNode.range?.[1] ?? 0];\n }\n}\n"]}
@@ -10,6 +10,8 @@ export declare class AstNodeTypes {
10
10
  static readonly AWAIT_EXPRESSION = "AwaitExpression";
11
11
  static readonly RETURN_STATEMENT = "ReturnStatement";
12
12
  static readonly CATCH_CLAUSE = "CatchClause";
13
+ static readonly SWITCH_CASE = "SwitchCase";
14
+ static readonly BLOCK_STATEMENT = "BlockStatement";
13
15
  }
14
16
  /** The ESLint namespace the house rules live under: `venizia/<rule>`. */
15
17
  export declare const HOUSE_PLUGIN_NAMESPACE = "venizia";
@@ -13,6 +13,8 @@ class AstNodeTypes {
13
13
  static { this.AWAIT_EXPRESSION = 'AwaitExpression'; }
14
14
  static { this.RETURN_STATEMENT = 'ReturnStatement'; }
15
15
  static { this.CATCH_CLAUSE = 'CatchClause'; }
16
+ static { this.SWITCH_CASE = 'SwitchCase'; }
17
+ static { this.BLOCK_STATEMENT = 'BlockStatement'; }
16
18
  }
17
19
  exports.AstNodeTypes = AstNodeTypes;
18
20
  /** The ESLint namespace the house rules live under: `venizia/<rule>`. */
@@ -1 +1 @@
1
- {"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/linters/house/common.ts"],"names":[],"mappings":";;;AAAA,8HAA8H;AAC9H,MAAa,YAAY;aACP,mBAAc,GAAG,eAAe,CAAC;aACjC,oBAAe,GAAG,gBAAgB,CAAC;aACnC,yBAAoB,GAAG,qBAAqB,CAAC;aAC7C,wBAAmB,GAAG,oBAAoB,CAAC;aAC3C,8BAAyB,GAAG,yBAAyB,CAAC;aACtD,6BAAwB,GAAG,wBAAwB,CAAC;aACpD,eAAU,GAAG,aAAa,CAAC;aAC3B,qBAAgB,GAAG,iBAAiB,CAAC;aACrC,qBAAgB,GAAG,iBAAiB,CAAC;aACrC,iBAAY,GAAG,aAAa,CAAC;;AAV/C,oCAWC;AAED,yEAAyE;AAC5D,QAAA,sBAAsB,GAAG,SAAS,CAAC;AAEhD,0GAA0G;AAC1G,MAAa,OAAO;IAClB,8BAA8B;IAC9B,MAAM,CAAC,SAAS,CAAC,IAAoC;QACnD,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;QAC3B,OAAO,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,IAAI,GAAG,IAAI,IAAI;YAC7D,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC;YACxB,CAAC,CAAC,SAAS,CAAC;IAChB,CAAC;IAED,8EAA8E;IAC9E,MAAM,CAAC,OAAO,CAAC,IAAuB;QACpC,MAAM,IAAI,GAAG,OAAO,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,CAAC;QACjE,OAAO,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;IACrD,CAAC;CACF;AAdD,0BAcC","sourcesContent":["/** The estree node types the house rules visit - computed visitor keys, so the names stay PascalCase as ESLint needs them. */\nexport class AstNodeTypes {\n static readonly NEW_EXPRESSION = 'NewExpression';\n static readonly CALL_EXPRESSION = 'CallExpression';\n static readonly FUNCTION_DECLARATION = 'FunctionDeclaration';\n static readonly FUNCTION_EXPRESSION = 'FunctionExpression';\n static readonly ARROW_FUNCTION_EXPRESSION = 'ArrowFunctionExpression';\n static readonly EXPORT_NAMED_DECLARATION = 'ExportNamedDeclaration';\n static readonly UNION_TYPE = 'TSUnionType';\n static readonly AWAIT_EXPRESSION = 'AwaitExpression';\n static readonly RETURN_STATEMENT = 'ReturnStatement';\n static readonly CATCH_CLAUSE = 'CatchClause';\n}\n\n/** The ESLint namespace the house rules live under: `venizia/<rule>`. */\nexport const HOUSE_PLUGIN_NAMESPACE = 'venizia';\n\n/** Reads an AST node without trusting its type: TypeScript nodes carry fields estree does not declare. */\nexport class AstNode {\n /** A field of an AST node. */\n static readField(opts: { node: unknown; key: string }): unknown {\n const { node, key } = opts;\n return typeof node === 'object' && node !== null && key in node\n ? Reflect.get(node, key)\n : undefined;\n }\n\n /** The node's `type`, or `undefined` for anything that is not an AST node. */\n static getType(opts: { node: unknown }): string | undefined {\n const type = AstNode.readField({ node: opts.node, key: 'type' });\n return typeof type === 'string' ? type : undefined;\n }\n}\n"]}
1
+ {"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/linters/house/common.ts"],"names":[],"mappings":";;;AAAA,8HAA8H;AAC9H,MAAa,YAAY;aACP,mBAAc,GAAG,eAAe,CAAC;aACjC,oBAAe,GAAG,gBAAgB,CAAC;aACnC,yBAAoB,GAAG,qBAAqB,CAAC;aAC7C,wBAAmB,GAAG,oBAAoB,CAAC;aAC3C,8BAAyB,GAAG,yBAAyB,CAAC;aACtD,6BAAwB,GAAG,wBAAwB,CAAC;aACpD,eAAU,GAAG,aAAa,CAAC;aAC3B,qBAAgB,GAAG,iBAAiB,CAAC;aACrC,qBAAgB,GAAG,iBAAiB,CAAC;aACrC,iBAAY,GAAG,aAAa,CAAC;aAC7B,gBAAW,GAAG,YAAY,CAAC;aAC3B,oBAAe,GAAG,gBAAgB,CAAC;;AAZrD,oCAaC;AAED,yEAAyE;AAC5D,QAAA,sBAAsB,GAAG,SAAS,CAAC;AAEhD,0GAA0G;AAC1G,MAAa,OAAO;IAClB,8BAA8B;IAC9B,MAAM,CAAC,SAAS,CAAC,IAAoC;QACnD,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;QAE3B,OAAO,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,IAAI,GAAG,IAAI,IAAI;YAC7D,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC;YACxB,CAAC,CAAC,SAAS,CAAC;IAChB,CAAC;IAED,8EAA8E;IAC9E,MAAM,CAAC,OAAO,CAAC,IAAuB;QACpC,MAAM,IAAI,GAAG,OAAO,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,CAAC;QAEjE,OAAO,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;IACrD,CAAC;CACF;AAhBD,0BAgBC","sourcesContent":["/** The estree node types the house rules visit - computed visitor keys, so the names stay PascalCase as ESLint needs them. */\nexport class AstNodeTypes {\n static readonly NEW_EXPRESSION = 'NewExpression';\n static readonly CALL_EXPRESSION = 'CallExpression';\n static readonly FUNCTION_DECLARATION = 'FunctionDeclaration';\n static readonly FUNCTION_EXPRESSION = 'FunctionExpression';\n static readonly ARROW_FUNCTION_EXPRESSION = 'ArrowFunctionExpression';\n static readonly EXPORT_NAMED_DECLARATION = 'ExportNamedDeclaration';\n static readonly UNION_TYPE = 'TSUnionType';\n static readonly AWAIT_EXPRESSION = 'AwaitExpression';\n static readonly RETURN_STATEMENT = 'ReturnStatement';\n static readonly CATCH_CLAUSE = 'CatchClause';\n static readonly SWITCH_CASE = 'SwitchCase';\n static readonly BLOCK_STATEMENT = 'BlockStatement';\n}\n\n/** The ESLint namespace the house rules live under: `venizia/<rule>`. */\nexport const HOUSE_PLUGIN_NAMESPACE = 'venizia';\n\n/** Reads an AST node without trusting its type: TypeScript nodes carry fields estree does not declare. */\nexport class AstNode {\n /** A field of an AST node. */\n static readField(opts: { node: unknown; key: string }): unknown {\n const { node, key } = opts;\n\n return typeof node === 'object' && node !== null && key in node\n ? Reflect.get(node, key)\n : undefined;\n }\n\n /** The node's `type`, or `undefined` for anything that is not an AST node. */\n static getType(opts: { node: unknown }): string | undefined {\n const type = AstNode.readField({ node: opts.node, key: 'type' });\n\n return typeof type === 'string' ? type : undefined;\n }\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  import type { Linter } from 'eslint';
2
2
  /**
3
- * The ESLint side of a project that lints with oxlint: the naming convention plus the house rules -
4
- * everything oxlint cannot express. Run it next to `oxlintConfigs`.
3
+ * The ESLint side of a project that lints with oxlint: the naming convention, the house rules and the async style
4
+ * rules - everything oxlint cannot express. Run it next to `oxlintConfigs`.
5
5
  *
6
6
  * ```js
7
7
  * // .configs/lints/eslint.config.mjs
@@ -11,32 +11,6 @@ import type { Linter } from 'eslint';
11
11
  * ```
12
12
  */
13
13
  export declare const houseConfigs: Linter.Config[];
14
- /** `houseConfigs` for a React project: `reactNamingConventionConfigs`, the house rules and `no-leaked-render`. */
14
+ /** `houseConfigs` for a React project: `reactNamingConventionConfigs`, the house rules, the async style rules, `no-leaked-render` and the hook rules. */
15
15
  export declare const reactHouseConfigs: Linter.Config[];
16
- /**
17
- * The async style rules, opt-in until every Venizia repository has been swept (the owner's rollout: the option in
18
- * one release, the default in the next). Spread it next to `houseConfigs`:
19
- *
20
- * ```js
21
- * export default [...houseConfigs, ...asyncStyleConfigs];
22
- * ```
23
- *
24
- * `await` stands alone as a statement or as the whole initializer of a declaration (`no-inline-await`), a
25
- * function returns the promise instead of `return await` (`no-return-await`), an `await` never takes a promise
26
- * chain (`no-await-promise-chain`), and a caught error leaves a trace (`no-silent-catch`). They apply to test
27
- * files too.
28
- */
29
- export declare const asyncStyleConfigs: Linter.Config[];
30
- /**
31
- * The hook async rules, opt-in like `asyncStyleConfigs`. Spread it next to `reactHouseConfigs`:
32
- *
33
- * ```js
34
- * export default [...reactHouseConfigs, ...reactAsyncStyleConfigs];
35
- * ```
36
- *
37
- * A hook never gets an async function (`no-async-hook-callback`), and an effect callback returns a cleanup on every
38
- * path or on none (`effect-cleanup-consistency`). Hooks live in `.ts` files too, so it covers all source files.
39
- * It also carries `no-await-promise-chain` and `no-silent-catch`: a hook body is where a promise chain lives.
40
- */
41
- export declare const reactAsyncStyleConfigs: Linter.Config[];
42
16
  //# sourceMappingURL=configs.d.ts.map
@@ -1,20 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.reactAsyncStyleConfigs = exports.asyncStyleConfigs = exports.reactHouseConfigs = exports.houseConfigs = void 0;
3
+ exports.reactHouseConfigs = exports.houseConfigs = void 0;
4
4
  const eslint_1 = require("../eslint");
5
5
  const jsx_files_1 = require("../jsx-files");
6
+ const padding_1 = require("../padding");
6
7
  const react_eslint_1 = require("../react-eslint");
8
+ const async_rules_1 = require("./async-rules");
7
9
  const common_1 = require("./common");
8
10
  const const_class_values_rule_1 = require("./const-class-values.rule");
9
11
  const effect_cleanup_consistency_rule_1 = require("./effect-cleanup-consistency.rule");
10
12
  const max_params_own_rule_1 = require("./max-params-own.rule");
11
13
  const no_async_hook_callback_rule_1 = require("./no-async-hook-callback.rule");
12
- const no_await_promise_chain_rule_1 = require("./no-await-promise-chain.rule");
13
- const no_inline_await_rule_1 = require("./no-inline-await.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_return_await_rule_1 = require("./no-return-await.rule");
17
- const no_silent_catch_rule_1 = require("./no-silent-catch.rule");
18
16
  const plugin_1 = require("./plugin");
19
17
  const SOURCE_FILES = ['**/*.{ts,tsx,mts,cts}'];
20
18
  const TEST_FILES = ['**/__tests__/**', '**/*.test.{ts,tsx}', '**/*.spec.{ts,tsx}'];
@@ -53,8 +51,8 @@ const houseRuleConfigs = [
53
51
  },
54
52
  ];
55
53
  /**
56
- * The ESLint side of a project that lints with oxlint: the naming convention plus the house rules -
57
- * everything oxlint cannot express. Run it next to `oxlintConfigs`.
54
+ * The ESLint side of a project that lints with oxlint: the naming convention, the house rules and the async style
55
+ * rules - everything oxlint cannot express. Run it next to `oxlintConfigs`.
58
56
  *
59
57
  * ```js
60
58
  * // .configs/lints/eslint.config.mjs
@@ -63,7 +61,12 @@ const houseRuleConfigs = [
63
61
  * export default houseConfigs;
64
62
  * ```
65
63
  */
66
- exports.houseConfigs = [...eslint_1.namingConventionConfigs, ...houseRuleConfigs];
64
+ exports.houseConfigs = [
65
+ ...eslint_1.namingConventionConfigs,
66
+ ...houseRuleConfigs,
67
+ ...async_rules_1.asyncRuleConfigs,
68
+ ...padding_1.paddingConfigs,
69
+ ];
67
70
  /**
68
71
  * The React house rule: a JSX child is drawn with `cond ? <X /> : null`, never `cond && <X />`, which
69
72
  * draws `0` when `cond` is `0`.
@@ -75,58 +78,28 @@ const reactRuleConfigs = [
75
78
  rules: { [no_leaked_render_rule_1.NoLeakedRenderRule.NAME]: no_leaked_render_rule_1.NoLeakedRenderRule.build() },
76
79
  },
77
80
  ];
78
- /** `houseConfigs` for a React project: `reactNamingConventionConfigs`, the house rules and `no-leaked-render`. */
79
- exports.reactHouseConfigs = [
80
- ...react_eslint_1.reactNamingConventionConfigs,
81
- ...houseRuleConfigs,
82
- ...reactRuleConfigs,
83
- ];
84
81
  /**
85
- * The async style rules, opt-in until every Venizia repository has been swept (the owner's rollout: the option in
86
- * one release, the default in the next). Spread it next to `houseConfigs`:
87
- *
88
- * ```js
89
- * export default [...houseConfigs, ...asyncStyleConfigs];
90
- * ```
91
- *
92
- * `await` stands alone as a statement or as the whole initializer of a declaration (`no-inline-await`), a
93
- * function returns the promise instead of `return await` (`no-return-await`), an `await` never takes a promise
94
- * chain (`no-await-promise-chain`), and a caught error leaves a trace (`no-silent-catch`). They apply to test
95
- * files too.
82
+ * The hook rules: a hook never gets an async function (`no-async-hook-callback`), and an effect callback returns a
83
+ * cleanup on every path or on none (`effect-cleanup-consistency`). Hooks live in `.ts` files too, so it covers all
84
+ * source files.
96
85
  */
97
- exports.asyncStyleConfigs = [
98
- {
99
- files: SOURCE_FILES,
100
- plugins: { [common_1.HOUSE_PLUGIN_NAMESPACE]: plugin_1.houseEslintPlugin },
101
- rules: {
102
- [no_inline_await_rule_1.NoInlineAwaitRule.NAME]: no_inline_await_rule_1.NoInlineAwaitRule.build(),
103
- [no_return_await_rule_1.NoReturnAwaitRule.NAME]: no_return_await_rule_1.NoReturnAwaitRule.build(),
104
- [no_await_promise_chain_rule_1.NoAwaitPromiseChainRule.NAME]: no_await_promise_chain_rule_1.NoAwaitPromiseChainRule.build(),
105
- [no_silent_catch_rule_1.NoSilentCatchRule.NAME]: no_silent_catch_rule_1.NoSilentCatchRule.build(),
106
- },
107
- },
108
- ];
109
- /**
110
- * The hook async rules, opt-in like `asyncStyleConfigs`. Spread it next to `reactHouseConfigs`:
111
- *
112
- * ```js
113
- * export default [...reactHouseConfigs, ...reactAsyncStyleConfigs];
114
- * ```
115
- *
116
- * A hook never gets an async function (`no-async-hook-callback`), and an effect callback returns a cleanup on every
117
- * path or on none (`effect-cleanup-consistency`). Hooks live in `.ts` files too, so it covers all source files.
118
- * It also carries `no-await-promise-chain` and `no-silent-catch`: a hook body is where a promise chain lives.
119
- */
120
- exports.reactAsyncStyleConfigs = [
86
+ const reactHookRuleConfigs = [
121
87
  {
122
88
  files: SOURCE_FILES,
123
89
  plugins: { [common_1.HOUSE_PLUGIN_NAMESPACE]: plugin_1.houseEslintPlugin },
124
90
  rules: {
125
91
  [no_async_hook_callback_rule_1.NoAsyncHookCallbackRule.NAME]: no_async_hook_callback_rule_1.NoAsyncHookCallbackRule.build(),
126
92
  [effect_cleanup_consistency_rule_1.EffectCleanupConsistencyRule.NAME]: effect_cleanup_consistency_rule_1.EffectCleanupConsistencyRule.build(),
127
- [no_await_promise_chain_rule_1.NoAwaitPromiseChainRule.NAME]: no_await_promise_chain_rule_1.NoAwaitPromiseChainRule.build(),
128
- [no_silent_catch_rule_1.NoSilentCatchRule.NAME]: no_silent_catch_rule_1.NoSilentCatchRule.build(),
129
93
  },
130
94
  },
131
95
  ];
96
+ /** `houseConfigs` for a React project: `reactNamingConventionConfigs`, the house rules, the async style rules, `no-leaked-render` and the hook rules. */
97
+ exports.reactHouseConfigs = [
98
+ ...react_eslint_1.reactNamingConventionConfigs,
99
+ ...houseRuleConfigs,
100
+ ...async_rules_1.asyncRuleConfigs,
101
+ ...padding_1.paddingConfigs,
102
+ ...reactRuleConfigs,
103
+ ...reactHookRuleConfigs,
104
+ ];
132
105
  //# sourceMappingURL=configs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"configs.js","sourceRoot":"","sources":["../../../src/linters/house/configs.ts"],"names":[],"mappings":";;;AACA,sCAAoD;AACpD,4CAAyC;AACzC,kDAA+D;AAC/D,qCAAkD;AAClD,uEAAiE;AACjE,uFAAiF;AACjF,+DAAyD;AACzD,+EAAwE;AACxE,+EAAwE;AACxE,iEAA2D;AAC3D,mEAA6D;AAC7D,2DAAqD;AACrD,iEAA2D;AAC3D,iEAA2D;AAC3D,qCAA6C;AAE7C,MAAM,YAAY,GAAG,CAAC,uBAAuB,CAAC,CAAC;AAC/C,MAAM,UAAU,GAAG,CAAC,iBAAiB,EAAE,oBAAoB,EAAE,oBAAoB,CAAC,CAAC;AAEn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;;;;;;GAYG;AACU,QAAA,iBAAiB,GAAoB;IAChD;QACE,KAAK,EAAE,YAAY;QACnB,OAAO,EAAE,EAAE,CAAC,+BAAsB,CAAC,EAAE,0BAAiB,EAAE;QACxD,KAAK,EAAE;YACL,CAAC,wCAAiB,CAAC,IAAI,CAAC,EAAE,wCAAiB,CAAC,KAAK,EAAE;YACnD,CAAC,wCAAiB,CAAC,IAAI,CAAC,EAAE,wCAAiB,CAAC,KAAK,EAAE;YACnD,CAAC,qDAAuB,CAAC,IAAI,CAAC,EAAE,qDAAuB,CAAC,KAAK,EAAE;YAC/D,CAAC,wCAAiB,CAAC,IAAI,CAAC,EAAE,wCAAiB,CAAC,KAAK,EAAE;SACpD;KACF;CACF,CAAC;AAEF;;;;;;;;;;GAUG;AACU,QAAA,sBAAsB,GAAoB;IACrD;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;YACzE,CAAC,qDAAuB,CAAC,IAAI,CAAC,EAAE,qDAAuB,CAAC,KAAK,EAAE;YAC/D,CAAC,wCAAiB,CAAC,IAAI,CAAC,EAAE,wCAAiB,CAAC,KAAK,EAAE;SACpD;KACF;CACF,CAAC","sourcesContent":["import type { Linter } from 'eslint';\nimport { namingConventionConfigs } from '../eslint';\nimport { JSX_FILES } from '../jsx-files';\nimport { reactNamingConventionConfigs } from '../react-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 { 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 { NoReturnAwaitRule } from './no-return-await.rule';\nimport { NoSilentCatchRule } from './no-silent-catch.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 [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 [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 plus the house rules -\n * 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[] = [...namingConventionConfigs, ...houseRuleConfigs];\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/** `houseConfigs` for a React project: `reactNamingConventionConfigs`, the house rules and `no-leaked-render`. */\nexport const reactHouseConfigs: Linter.Config[] = [\n ...reactNamingConventionConfigs,\n ...houseRuleConfigs,\n ...reactRuleConfigs,\n];\n\n/**\n * The async style rules, opt-in until every Venizia repository has been swept (the owner's rollout: the option in\n * one release, the default in the next). Spread it next to `houseConfigs`:\n *\n * ```js\n * export default [...houseConfigs, ...asyncStyleConfigs];\n * ```\n *\n * `await` stands alone as a statement or as the whole initializer of a declaration (`no-inline-await`), a\n * function returns the promise instead of `return await` (`no-return-await`), an `await` never takes a promise\n * chain (`no-await-promise-chain`), and a caught error leaves a trace (`no-silent-catch`). They apply to test\n * files too.\n */\nexport const asyncStyleConfigs: Linter.Config[] = [\n {\n files: SOURCE_FILES,\n plugins: { [HOUSE_PLUGIN_NAMESPACE]: houseEslintPlugin },\n rules: {\n [NoInlineAwaitRule.NAME]: NoInlineAwaitRule.build(),\n [NoReturnAwaitRule.NAME]: NoReturnAwaitRule.build(),\n [NoAwaitPromiseChainRule.NAME]: NoAwaitPromiseChainRule.build(),\n [NoSilentCatchRule.NAME]: NoSilentCatchRule.build(),\n },\n },\n];\n\n/**\n * The hook async rules, opt-in like `asyncStyleConfigs`. Spread it next to `reactHouseConfigs`:\n *\n * ```js\n * export default [...reactHouseConfigs, ...reactAsyncStyleConfigs];\n * ```\n *\n * A hook never gets an async function (`no-async-hook-callback`), and an effect callback returns a cleanup on every\n * path or on none (`effect-cleanup-consistency`). Hooks live in `.ts` files too, so it covers all source files.\n * It also carries `no-await-promise-chain` and `no-silent-catch`: a hook body is where a promise chain lives.\n */\nexport const reactAsyncStyleConfigs: 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 [NoAwaitPromiseChainRule.NAME]: NoAwaitPromiseChainRule.build(),\n [NoSilentCatchRule.NAME]: NoSilentCatchRule.build(),\n },\n },\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,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,8CAAoB,CAAC,IAAI,CAAC,EAA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G,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 { 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 [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 [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];\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 +1 @@
1
- {"version":3,"file":"const-class-values.rule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,KAAK,CAAC,OAA2D,EAAE;QACxE,MAAM,EAAE,QAAQ,GAAG,OAAO,EAAE,WAAW,EAAE,GAAG,IAAI,CAAC;QACjD,OAAO,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,EAAE,WAAW,EAAE,CAAC,CAAC;IAC9E,CAAC;;AAjEH,oDAkEC","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 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 }) === 'TSMappedType') {\n return true;\n }\n\n if (AstNode.getType({ node: parent }) !== 'TSTypeParameterInstantiation') {\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 return (\n AstNode.getType({ node: reference }) === 'TSTypeReference' && 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 if (AstNode.getType({ node: parent }) === 'Program') {\n return current;\n }\n current = parent;\n }\n\n return undefined;\n};\n\nconst isStringLiteral = (opts: { member: unknown }): boolean => {\n const { member } = opts;\n return (\n AstNode.getType({ node: member }) === 'TSLiteralType' &&\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 return type === 'TSNullKeyword' || type === 'TSUndefinedKeyword';\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 }) === 'TSTypeAliasDeclaration' &&\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 if (!Array.isArray(members)) {\n return;\n }\n\n const values = members.filter((member) => !isNullish({ member }));\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 === 'ExportDefaultDeclaration';\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 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,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,cAAc,EAAE,CAAC;QACzD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,gBAAO,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,KAAK,8BAA8B,EAAE,CAAC;QACzE,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,IAAI,GAAG,gBAAO,CAAC,SAAS,CAAC;QAC7B,IAAI,EAAE,gBAA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,qBAAY,CAAC,wBAAwB;wBACvD,aAAa,KAAK,0BAA0B,CAAC;oBAE/C,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 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 }) === 'TSMappedType') {\n return true;\n }\n\n if (AstNode.getType({ node: parent }) !== 'TSTypeParameterInstantiation') {\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 }) === 'TSTypeReference' && 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 }) === '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 }) === 'TSLiteralType' &&\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 === 'TSNullKeyword' || type === 'TSUndefinedKeyword';\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 }) === 'TSTypeAliasDeclaration' &&\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 === 'ExportDefaultDeclaration';\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"]}
@@ -26,7 +26,8 @@ class EffectCleanupConsistencyRule {
26
26
  const checkExit = (node) => {
27
27
  const current = frame;
28
28
  if (!current?.hook ||
29
- common_1.AstNode.getType({ node: common_1.AstNode.readField({ node, key: 'body' }) }) !== 'BlockStatement') {
29
+ common_1.AstNode.getType({ node: common_1.AstNode.readField({ node, key: 'body' }) }) !==
30
+ common_1.AstNodeTypes.BLOCK_STATEMENT) {
30
31
  return;
31
32
  }
32
33
  const endIsReachable = [...current.segments].some((segment) => segment.reachable);