@venizia/dev-configs 0.4.7-5 → 0.4.8-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/checks/catalog.js.map +1 -1
- package/dist/checks/module-cycles.js.map +1 -1
- package/dist/checks/purity/manifest.js.map +1 -1
- package/dist/checks/purity/probe.js.map +1 -1
- package/dist/checks/purity/run.js.map +1 -1
- package/dist/checks/split-report.js.map +1 -1
- package/dist/checks/test-controls.js.map +1 -1
- package/dist/checks/test-dead-code.js.map +1 -1
- package/dist/checks/test-mutate.js.map +1 -1
- package/dist/checks/test-weight.js.map +1 -1
- package/dist/cli/check.js.map +1 -1
- package/dist/cli/clean.js.map +1 -1
- package/dist/cli/codemod/async-style.d.ts +1 -1
- package/dist/cli/codemod/async-style.js +3 -3
- package/dist/cli/codemod/async-style.js.map +1 -1
- package/dist/cli/codemod/connector-imports.js.map +1 -1
- package/dist/cli/codemod/const-classes.js.map +1 -1
- package/dist/cli/codemod/drop-redundant-casts.js.map +1 -1
- package/dist/cli/codemod/files.js.map +1 -1
- package/dist/cli/codemod/index.js.map +1 -1
- package/dist/cli/codemod/namespace-functions/index.js.map +1 -1
- package/dist/cli/codemod/namespace-functions/logger-scope.js.map +1 -1
- package/dist/cli/codemod/namespace-functions/mapping.js.map +1 -1
- package/dist/cli/codemod/namespace-functions/rewriter.js.map +1 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/lint.js.map +1 -1
- package/dist/linters/eslint.js +7 -5
- package/dist/linters/eslint.js.map +1 -1
- package/dist/linters/house/async-rules.d.ts +10 -0
- package/dist/linters/house/async-rules.js +29 -0
- package/dist/linters/house/async-rules.js.map +1 -0
- package/dist/linters/house/await-support.d.ts +2 -0
- package/dist/linters/house/await-support.js +15 -10
- package/dist/linters/house/await-support.js.map +1 -1
- package/dist/linters/house/common.d.ts +2 -0
- package/dist/linters/house/common.js +2 -0
- package/dist/linters/house/common.js.map +1 -1
- package/dist/linters/house/configs.d.ts +3 -29
- package/dist/linters/house/configs.js +24 -51
- package/dist/linters/house/configs.js.map +1 -1
- package/dist/linters/house/const-class-values.rule.js.map +1 -1
- package/dist/linters/house/effect-cleanup-consistency.rule.js +2 -1
- package/dist/linters/house/effect-cleanup-consistency.rule.js.map +1 -1
- package/dist/linters/house/hook-support.js.map +1 -1
- package/dist/linters/house/index.d.ts +2 -1
- package/dist/linters/house/index.js +4 -1
- package/dist/linters/house/index.js.map +1 -1
- package/dist/linters/house/max-params-own.rule.js.map +1 -1
- package/dist/linters/house/no-async-hook-callback.rule.js.map +1 -1
- package/dist/linters/house/no-await-promise-chain.rule.js +2 -3
- package/dist/linters/house/no-await-promise-chain.rule.js.map +1 -1
- package/dist/linters/house/no-leaked-render.rule.js.map +1 -1
- package/dist/linters/house/no-return-await.rule.js +2 -8
- package/dist/linters/house/no-return-await.rule.js.map +1 -1
- package/dist/linters/house/no-silent-catch.rule.js +1 -1
- package/dist/linters/house/no-silent-catch.rule.js.map +1 -1
- package/dist/linters/house/no-unbraced-case.rule.d.ts +15 -0
- package/dist/linters/house/no-unbraced-case.rule.js +45 -0
- package/dist/linters/house/no-unbraced-case.rule.js.map +1 -0
- package/dist/linters/house/plugin.js +2 -0
- package/dist/linters/house/plugin.js.map +1 -1
- package/dist/linters/house/promise-chain-support.js.map +1 -1
- package/dist/linters/ignore.js.map +1 -1
- package/dist/linters/index.d.ts +1 -0
- package/dist/linters/index.js +1 -0
- package/dist/linters/index.js.map +1 -1
- package/dist/linters/padding.d.ts +8 -0
- package/dist/linters/padding.js +25 -0
- package/dist/linters/padding.js.map +1 -0
- package/dist/linters/rules/eqeqeq.rule.js.map +1 -1
- package/dist/linters/rules/index.d.ts +2 -0
- package/dist/linters/rules/index.js +2 -0
- package/dist/linters/rules/index.js.map +1 -1
- package/dist/linters/rules/lines-between-class-members.rule.d.ts +14 -0
- package/dist/linters/rules/lines-between-class-members.rule.js +17 -0
- package/dist/linters/rules/lines-between-class-members.rule.js.map +1 -0
- package/dist/linters/rules/naming-convention.rule.js.map +1 -1
- package/dist/linters/rules/no-restricted-imports.rule.js.map +1 -1
- package/dist/linters/rules/no-restricted-properties.rule.js.map +1 -1
- package/dist/linters/rules/no-unused-vars.rule.js.map +1 -1
- package/dist/linters/rules/padding-line-between-statements.rule.d.ts +16 -0
- package/dist/linters/rules/padding-line-between-statements.rule.js +25 -0
- package/dist/linters/rules/padding-line-between-statements.rule.js.map +1 -0
- package/dist/linters/rules/prefer-nullish-coalescing.rule.js.map +1 -1
- package/dist/linters/rules/switch-case-braces.rule.js.map +1 -1
- package/dist/testing/repo-tmp.js.map +1 -1
- package/package.json +3 -5
- package/dist/checks/catalog.d.ts.map +0 -1
- package/dist/checks/index.d.ts.map +0 -1
- package/dist/checks/module-cycles.d.ts.map +0 -1
- package/dist/checks/purity/manifest.d.ts.map +0 -1
- package/dist/checks/purity/probe.d.ts.map +0 -1
- package/dist/checks/purity/run.d.ts.map +0 -1
- package/dist/checks/split-report.d.ts.map +0 -1
- package/dist/checks/test-controls.d.ts.map +0 -1
- package/dist/checks/test-dead-code.d.ts.map +0 -1
- package/dist/checks/test-mutate.d.ts.map +0 -1
- package/dist/checks/test-weight.d.ts.map +0 -1
- package/dist/cli/check.d.ts.map +0 -1
- package/dist/cli/clean.d.ts.map +0 -1
- package/dist/cli/codemod/async-style.d.ts.map +0 -1
- package/dist/cli/codemod/connector-imports.d.ts.map +0 -1
- package/dist/cli/codemod/const-classes.d.ts.map +0 -1
- package/dist/cli/codemod/drop-redundant-casts.d.ts.map +0 -1
- package/dist/cli/codemod/files.d.ts.map +0 -1
- package/dist/cli/codemod/index.d.ts.map +0 -1
- package/dist/cli/codemod/namespace-functions/index.d.ts.map +0 -1
- package/dist/cli/codemod/namespace-functions/logger-scope.d.ts.map +0 -1
- package/dist/cli/codemod/namespace-functions/mapping.d.ts.map +0 -1
- package/dist/cli/codemod/namespace-functions/mappings/boot.d.ts.map +0 -1
- package/dist/cli/codemod/namespace-functions/mappings/connectors.d.ts.map +0 -1
- package/dist/cli/codemod/namespace-functions/mappings/core-server.d.ts.map +0 -1
- package/dist/cli/codemod/namespace-functions/mappings/core-worker.d.ts.map +0 -1
- package/dist/cli/codemod/namespace-functions/mappings/dev-configs.d.ts.map +0 -1
- package/dist/cli/codemod/namespace-functions/mappings/filter.d.ts.map +0 -1
- package/dist/cli/codemod/namespace-functions/mappings/helpers.d.ts.map +0 -1
- package/dist/cli/codemod/namespace-functions/mappings/index.d.ts.map +0 -1
- package/dist/cli/codemod/namespace-functions/mappings/inversion.d.ts.map +0 -1
- package/dist/cli/codemod/namespace-functions/mappings/kernel.d.ts.map +0 -1
- package/dist/cli/codemod/namespace-functions/rewriter.d.ts.map +0 -1
- package/dist/cli/index.d.ts.map +0 -1
- package/dist/cli/lint.d.ts.map +0 -1
- package/dist/compilers/bun.d.ts.map +0 -1
- package/dist/compilers/index.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/linters/browser.d.ts.map +0 -1
- package/dist/linters/eslint.d.ts.map +0 -1
- package/dist/linters/house/await-support.d.ts.map +0 -1
- package/dist/linters/house/common.d.ts.map +0 -1
- package/dist/linters/house/configs.d.ts.map +0 -1
- package/dist/linters/house/const-class-values.rule.d.ts.map +0 -1
- package/dist/linters/house/effect-cleanup-consistency.rule.d.ts.map +0 -1
- package/dist/linters/house/hook-support.d.ts.map +0 -1
- package/dist/linters/house/index.d.ts.map +0 -1
- package/dist/linters/house/max-params-own.rule.d.ts.map +0 -1
- package/dist/linters/house/no-async-hook-callback.rule.d.ts.map +0 -1
- package/dist/linters/house/no-await-promise-chain.rule.d.ts.map +0 -1
- package/dist/linters/house/no-inline-await.rule.d.ts.map +0 -1
- package/dist/linters/house/no-leaked-render.rule.d.ts.map +0 -1
- package/dist/linters/house/no-new-error.rule.d.ts.map +0 -1
- package/dist/linters/house/no-return-await.rule.d.ts.map +0 -1
- package/dist/linters/house/no-silent-catch.rule.d.ts.map +0 -1
- package/dist/linters/house/plugin.d.ts.map +0 -1
- package/dist/linters/house/promise-chain-support.d.ts.map +0 -1
- package/dist/linters/ignore.d.ts.map +0 -1
- package/dist/linters/index.d.ts.map +0 -1
- package/dist/linters/jsx-files.d.ts.map +0 -1
- package/dist/linters/oxlint-presets.d.ts.map +0 -1
- package/dist/linters/oxlint.d.ts.map +0 -1
- package/dist/linters/react-eslint.d.ts.map +0 -1
- package/dist/linters/react-oxlint.d.ts.map +0 -1
- package/dist/linters/rules/common.d.ts.map +0 -1
- package/dist/linters/rules/eqeqeq.rule.d.ts.map +0 -1
- package/dist/linters/rules/index.d.ts.map +0 -1
- package/dist/linters/rules/naming-convention.rule.d.ts.map +0 -1
- package/dist/linters/rules/no-restricted-imports.rule.d.ts.map +0 -1
- package/dist/linters/rules/no-restricted-properties.rule.d.ts.map +0 -1
- package/dist/linters/rules/no-unused-vars.rule.d.ts.map +0 -1
- package/dist/linters/rules/prefer-nullish-coalescing.rule.d.ts.map +0 -1
- package/dist/linters/rules/switch-case-braces.rule.d.ts.map +0 -1
- package/dist/testing/index.d.ts.map +0 -1
- package/dist/testing/rejection.helper.d.ts.map +0 -1
- package/dist/testing/repo-tmp.d.ts.map +0 -1
- package/dist/testing/spawn.helper.d.ts.map +0 -1
- package/dist/testing/tmpdir-preload.d.ts.map +0 -1
package/dist/cli/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";;;AACA,mCAAuC;AACvC,mCAAuC;AACvC,uCAA2C;AAC3C,iCAAqC;AAErC,MAAM,KAAK,GAAG;;;;;;;;;;;;;8EAagE,CAAC;AAE/E,MAAM,IAAI,GAAG,KAAK,EAAE,IAAwB,EAAmB,EAAE;IAC/D,MAAM,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC;IAErC,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,KAAK,QAAQ,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AC;IAED,OAAO,CAAC,KAAK,CAAC,0BAA0B,OAAO,IAAI,EAAE,MAAM,KAAK,EAAE,CAAC,CAAC;IAEpE,OAAO,CAAC,CAAC;AACX,CAAC,CAAC;AAEF,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CACxC,CAAC,QAAQ,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,EACpC,CAAC,KAAc,EAAE,EAAE;IACjB,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACrB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CACF,CAAC","sourcesContent":["#!/usr/bin/env bun\nimport { CheckCommand } from './check';\nimport { CleanCommand } from './clean';\nimport { CodemodCommand } from './codemod';\nimport { LintCommand } from './lint';\n\nconst USAGE = `Usage: devz <command> [options]\n\nCommands:\n lint [--fix] [files] oxlint, ESLint and the formatter; --fix writes\n check purity --claims <file> [package] [--json] probe every entry claimed browser-pure (needs a build)\n check module-cycles | split-report | catalog shared repository gates; devz check --help lists their options\n clean remove dist, node_modules/.cache and *.tsbuildinfo\n codemod drop-redundant-casts [paths...] remove \\`as X\\` casts the compiler no longer needs (dry run unless --write)\n codemod const-classes [paths...] turn a string-literal union into a const class (dry run unless --write)\n codemod async-style [paths...] apply the async-style lint fixers and list the rest (dry run unless --write)\n codemod namespace-functions [paths...] move calls of a function that moved into a class to the class form (dry run unless --write)\n codemod connector-imports [paths...] move @venizia/ignis/<connector sub-path> imports to @venizia/ignis-connectors (dry run unless --write)\n\nRun \\`devz clean --help\\` or \\`devz codemod --help\\` for a command's options.`;\n\nconst main = async (opts: { argv: string[] }): Promise<number> => {\n const [command, ...args] = opts.argv;\n\n if (command === undefined || command === '--help' || command === '-h') {\n console.log(USAGE);\n\n return 0;\n }\n\n if (command === 'lint') {\n return LintCommand.run({ root: process.cwd(), args });\n }\n\n if (command === 'check') {\n return CheckCommand.run({ root: process.cwd(), args });\n }\n\n if (command === 'clean') {\n return CleanCommand.run({ root: process.cwd(), args });\n }\n\n if (command === 'codemod') {\n return CodemodCommand.run({ root: process.cwd(), args });\n }\n\n console.error(`devz: unknown command \"${command ?? ''}\"\\n${USAGE}`);\n\n return 1;\n};\n\nmain({ argv: process.argv.slice(2) }).then(\n (exitCode) => process.exit(exitCode),\n (error: unknown) => {\n console.error(error);\n process.exit(1);\n },\n);\n"]}
|
package/dist/cli/lint.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lint.js","sourceRoot":"","sources":["../../src/cli/lint.ts"],"names":[],"mappings":";;;AAAA,qCAAmD;AACnD,yCAAmD;AAEnD,MAAM,WAAW,GAAG,kCAAkC,CAAC;AACvD,MAAM,aAAa,GAAG,kCAAkC,CAAC;AACzD,MAAM,gBAAgB,GAAG,wBAAwB,CAAC;AAClD,MAAM,kBAAkB,GAAG,6BAA6B,CAAC;AACzD,MAAM,YAAY,GAAG,CAAC,SAAS,EAAE,kBAAkB,EAAE,6BAA6B,CAAC,CAAC;AACpF,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;AAC1E,qHAAqH;AACrH,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC;IACnC,GAAG,iBAAiB;IACpB,OAAO;IACP,QAAQ;IACR,MAAM;IACN,OAAO;IACP,MAAM;IACN,OAAO;IACP,MAAM;CACP,CAAC,CAAC;AACH,MAAM,WAAW,GAAG,2DAA2D,CAAC;AAChF,MAAM,QAAQ,GAAG,OAAO,CAAC;AAQzB;;;;;GAKG;AACH,MAAa,WAAW;IACtB;;;;OAIG;IACH,MAAM,CAAC,UAAU,CAAC,IAAoC;QACpD,MAAM,IAAI,GAAG,IAAA,gBAAI,EAAC,IAAI,CAAC,IAAI,EAA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AC;YAClB,CAAC;QACH,CAAC;QAED,OAAO,CAAC,CAAC;IACX,CAAC;CACF;AA3HD,kCA2HC","sourcesContent":["import { existsSync, readFileSync } from 'node:fs';\nimport { dirname, extname, join } from 'node:path';\n\nconst LINT_CONFIG = '.configs/lints/oxlint.config.mts';\nconst ESLINT_CONFIG = '.configs/lints/eslint.config.mjs';\nconst LINT_IGNORE_FILE = '.configs/lints/.ignore';\nconst FORMAT_IGNORE_FILE = '.configs/formatters/.ignore';\nconst ESLINT_CACHE = ['--cache', '--cache-location', 'node_modules/.cache/eslint/'];\nconst LINTED_EXTENSIONS = new Set(['.ts', '.tsx', '.mts', '.js', '.mjs']);\n/** What `bun fmt` formats: the code, JSON (package.json keys are sorted), YAML, CSS, HTML and Vue - not Markdown. */\nconst FORMATTED_EXTENSIONS = new Set([\n ...LINTED_EXTENSIONS,\n '.json',\n '.jsonc',\n '.yml',\n '.yaml',\n '.css',\n '.html',\n '.vue',\n]);\nconst FORMAT_GLOB = '**/*.{ts,mts,tsx,js,mjs,json,jsonc,yml,yaml,css,html,vue}';\nconst FIX_FLAG = '--fix';\n\n/** One tool call: the tool name and its arguments, run from the project root. */\nexport interface ILintStep {\n tool: string;\n args: string[];\n}\n\n/**\n * `devz lint [--fix] [files]`: oxlint, then ESLint, then `bun fmt`, from the project's\n * `.configs/lints/` and `.configs/formatters/.ignore`. `bun fmt` takes its options from the `[fmt]` table\n * of the nearest `bunfig.toml`. With no file it checks the whole project; with files it handles only\n * those, as a pre-commit hook passes them.\n */\nexport class LintCommand {\n /**\n * The patterns of an ignore file, one per line, `#` comments and blank lines skipped. An ignore\n * file resolves its patterns from its own folder, so they go on the command line instead, which\n * resolves from the project root.\n */\n static readIgnore(opts: { root: string; file: string }): string[] {\n const path = join(opts.root, opts.file);\n\n if (!existsSync(path)) {\n return [];\n }\n\n return readFileSync(path, 'utf8')\n .split('\\n')\n .map((line) => line.trim())\n .filter((line) => line !== '' && !line.startsWith('#'));\n }\n\n /**\n * The tool calls for these arguments, in order; empty when a file list holds nothing to lint or\n * format. oxlint and ESLint take the code files; `bun fmt` takes those and the other formatted types.\n */\n static plan(opts: { root: string; args: string[] }): ILintStep[] {\n const fix = opts.args[0] === FIX_FLAG;\n const paths = fix ? opts.args.slice(1) : opts.args;\n const whole = paths.length === 0;\n const files = paths.filter((path) => LINTED_EXTENSIONS.has(extname(path)));\n const formatted = paths.filter((path) => FORMATTED_EXTENSIONS.has(extname(path)));\n\n if (!whole && formatted.length === 0) {\n return [];\n }\n\n const targets = whole ? ['.'] : files;\n const lintIgnore = LintCommand.readIgnore({ root: opts.root, file: LINT_IGNORE_FILE }).flatMap(\n (pattern) => ['--ignore-pattern', pattern],\n );\n const formatIgnore = LintCommand.readIgnore({\n root: opts.root,\n file: FORMAT_IGNORE_FILE,\n }).flatMap((pattern) => ['--ignore-pattern', pattern]);\n const unmatched = whole ? [] : ['--no-error-on-unmatched-pattern'];\n const eslintQuiet = whole ? [] : ['--no-warn-ignored'];\n\n const linters: ILintStep[] = [\n {\n tool: 'oxlint',\n args: [\n '-c',\n LINT_CONFIG,\n ...lintIgnore,\n ...unmatched,\n fix ? FIX_FLAG : '--deny-warnings',\n ...targets,\n ],\n },\n {\n tool: 'eslint',\n args: [\n '-c',\n ESLINT_CONFIG,\n ...ESLINT_CACHE,\n ...eslintQuiet,\n ...lintIgnore,\n ...(fix ? [FIX_FLAG] : []),\n ...targets,\n ],\n },\n ];\n const formatter: ILintStep = {\n tool: 'bun',\n args: [\n 'fmt',\n '--no-script',\n ...unmatched,\n ...formatIgnore,\n ...(fix ? [] : ['--check']),\n ...(whole ? [FORMAT_GLOB] : formatted),\n ],\n };\n\n return whole || files.length > 0 ? [...linters, formatter] : [formatter];\n }\n\n /** The tool's binary in the nearest `node_modules/.bin`, else its bare name for PATH to find. */\n static resolveTool(opts: { root: string; tool: string }): string {\n let dir = opts.root;\n\n while (true) {\n const candidate = join(dir, 'node_modules', '.bin', opts.tool);\n\n if (existsSync(candidate)) {\n return candidate;\n }\n\n const parent = dirname(dir);\n\n if (parent === dir) {\n return opts.tool;\n }\n\n dir = parent;\n }\n }\n\n /** Runs the plan in order and stops at the first tool that fails; returns the exit code. */\n static async run(opts: { root: string; args: string[] }): Promise<number> {\n for (const step of LintCommand.plan(opts)) {\n const child = Bun.spawn({\n cmd: [LintCommand.resolveTool({ root: opts.root, tool: step.tool }), ...step.args],\n cwd: opts.root,\n stdio: ['inherit', 'inherit', 'inherit'],\n });\n const exitCode = await child.exited;\n\n if (exitCode !== 0) {\n return exitCode;\n }\n }\n\n return 0;\n }\n}\n"]}
|
package/dist/linters/eslint.js
CHANGED
|
@@ -6,9 +6,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.namingConventionConfigs = exports.eslintConfigs = void 0;
|
|
7
7
|
const js_1 = __importDefault(require("@eslint/js"));
|
|
8
8
|
const config_1 = require("eslint/config");
|
|
9
|
-
const eslint_plugin_n_1 = __importDefault(require("eslint-plugin-n"));
|
|
10
|
-
const eslint_plugin_unicorn_1 = __importDefault(require("eslint-plugin-unicorn"));
|
|
11
9
|
const typescript_eslint_1 = __importDefault(require("typescript-eslint"));
|
|
10
|
+
const common_1 = require("./house/common");
|
|
11
|
+
const no_unbraced_case_rule_1 = require("./house/no-unbraced-case.rule");
|
|
12
|
+
const plugin_1 = require("./house/plugin");
|
|
13
|
+
const padding_1 = require("./padding");
|
|
12
14
|
const rules_1 = require("./rules");
|
|
13
15
|
/** Every file the preset lints. */
|
|
14
16
|
const SOURCE_FILES = [
|
|
@@ -64,7 +66,6 @@ const STRICT_RULES = {
|
|
|
64
66
|
'no-void': 'error',
|
|
65
67
|
'no-useless-escape': 'warn',
|
|
66
68
|
'no-caller': 'error',
|
|
67
|
-
'n/prefer-node-protocol': ['error'],
|
|
68
69
|
'@typescript-eslint/adjacent-overload-signatures': 'error',
|
|
69
70
|
'@typescript-eslint/prefer-for-of': 'error',
|
|
70
71
|
'@typescript-eslint/unified-signatures': 'error',
|
|
@@ -98,16 +99,17 @@ exports.eslintConfigs = (0, config_1.defineConfig)([
|
|
|
98
99
|
projectService: { allowDefaultProject: ['*.js', '*.cjs', '*.mjs', '.*.js'] },
|
|
99
100
|
},
|
|
100
101
|
},
|
|
101
|
-
plugins: {
|
|
102
|
+
plugins: { [common_1.HOUSE_PLUGIN_NAMESPACE]: plugin_1.houseEslintPlugin },
|
|
102
103
|
rules: {
|
|
103
104
|
...OFF_RULES,
|
|
104
105
|
...STRICT_RULES,
|
|
106
|
+
[no_unbraced_case_rule_1.NoUnbracedCaseRule.NAME]: no_unbraced_case_rule_1.NoUnbracedCaseRule.build(),
|
|
105
107
|
'@typescript-eslint/no-unused-vars': rules_1.NoUnusedVarsRule.build(),
|
|
106
108
|
[rules_1.NoRestrictedImportsRule.NAME]: rules_1.NoRestrictedImportsRule.build(),
|
|
107
|
-
[rules_1.SwitchCaseBracesRule.NAME]: rules_1.SwitchCaseBracesRule.build(),
|
|
108
109
|
[rules_1.NamingConventionRule.NAME]: rules_1.NamingConventionRule.build(),
|
|
109
110
|
},
|
|
110
111
|
},
|
|
112
|
+
...padding_1.paddingConfigs,
|
|
111
113
|
{
|
|
112
114
|
ignores: [
|
|
113
115
|
'**/node_modules/',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eslint.js","sourceRoot":"","sources":["../../src/linters/eslint.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA4B;AAE5B,0CAA6C;AAC7C,
|
|
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,UA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C,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
|
-
|
|
6
|
-
|
|
7
|
-
'
|
|
8
|
-
'
|
|
9
|
-
|
|
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;CAC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,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,OAA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,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,SAAS,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IAChE,CAAC;;AAtQH,oCAuQC","sourcesContent":["import type { Rule, SourceCode } from 'eslint';\nimport { AstNode, 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;;
|
|
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
|
|
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
|
|
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.
|
|
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
|
|
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 = [
|
|
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
|
|
86
|
-
*
|
|
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
|
-
|
|
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
|