@venizia/dev-configs 0.5.0-1 → 0.5.0-10
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 +18 -13
- package/dist/checks/purity/manifest.js +11 -3
- package/dist/checks/purity/manifest.js.map +1 -1
- package/dist/checks/purity/probe.js +19 -2
- package/dist/checks/purity/probe.js.map +1 -1
- package/dist/checks/split-report.js +2 -1
- package/dist/checks/split-report.js.map +1 -1
- package/dist/checks/test-controls.d.ts +9 -1
- package/dist/checks/test-controls.js +9 -3
- package/dist/checks/test-controls.js.map +1 -1
- package/dist/checks/test-dead-code.d.ts +9 -1
- package/dist/checks/test-dead-code.js +13 -2
- package/dist/checks/test-dead-code.js.map +1 -1
- package/dist/checks/test-mutate.d.ts +9 -1
- package/dist/checks/test-mutate.js +12 -6
- package/dist/checks/test-mutate.js.map +1 -1
- package/dist/cli/check.js +42 -38
- package/dist/cli/check.js.map +1 -1
- package/dist/cli/clean.js +3 -2
- package/dist/cli/clean.js.map +1 -1
- package/dist/cli/codemod/any-aliases.d.ts +1 -1
- package/dist/cli/codemod/any-aliases.js +14 -13
- package/dist/cli/codemod/any-aliases.js.map +1 -1
- package/dist/cli/codemod/async-style.d.ts +1 -1
- package/dist/cli/codemod/async-style.js +18 -17
- package/dist/cli/codemod/async-style.js.map +1 -1
- package/dist/cli/codemod/binding-keys.d.ts +32 -1
- package/dist/cli/codemod/binding-keys.js +238 -58
- package/dist/cli/codemod/binding-keys.js.map +1 -1
- package/dist/cli/codemod/class-renames.d.ts +39 -0
- package/dist/cli/codemod/class-renames.js +297 -0
- package/dist/cli/codemod/class-renames.js.map +1 -0
- package/dist/cli/codemod/connector-imports.d.ts +1 -1
- package/dist/cli/codemod/connector-imports.js +13 -12
- package/dist/cli/codemod/connector-imports.js.map +1 -1
- package/dist/cli/codemod/const-class-sets.d.ts +55 -0
- package/dist/cli/codemod/const-class-sets.js +219 -0
- package/dist/cli/codemod/const-class-sets.js.map +1 -0
- package/dist/cli/codemod/const-classes.d.ts +21 -3
- package/dist/cli/codemod/const-classes.js +151 -36
- package/dist/cli/codemod/const-classes.js.map +1 -1
- package/dist/cli/codemod/drop-redundant-casts.d.ts +6 -1
- package/dist/cli/codemod/drop-redundant-casts.js +27 -19
- package/dist/cli/codemod/drop-redundant-casts.js.map +1 -1
- package/dist/cli/codemod/env-get.d.ts +3 -3
- package/dist/cli/codemod/env-get.js +19 -18
- package/dist/cli/codemod/env-get.js.map +1 -1
- package/dist/cli/codemod/files.d.ts +4 -2
- package/dist/cli/codemod/files.js +7 -8
- package/dist/cli/codemod/files.js.map +1 -1
- package/dist/cli/codemod/function-to-arrow.d.ts +76 -0
- package/dist/cli/codemod/function-to-arrow.js +357 -0
- package/dist/cli/codemod/function-to-arrow.js.map +1 -0
- package/dist/cli/codemod/index.js +25 -4
- package/dist/cli/codemod/index.js.map +1 -1
- package/dist/cli/codemod/namespace-functions/index.d.ts +1 -1
- package/dist/cli/codemod/namespace-functions/index.js +14 -13
- package/dist/cli/codemod/namespace-functions/index.js.map +1 -1
- package/dist/cli/codemod/namespace-functions/mappings/dev-configs.js +3 -3
- package/dist/cli/codemod/namespace-functions/mappings/dev-configs.js.map +1 -1
- package/dist/cli/codemod/namespace-functions/mappings/helpers.js +1 -1
- package/dist/cli/codemod/namespace-functions/mappings/helpers.js.map +1 -1
- package/dist/cli/codemod/typed-route-context.d.ts +58 -0
- package/dist/cli/codemod/typed-route-context.js +918 -0
- package/dist/cli/codemod/typed-route-context.js.map +1 -0
- package/dist/cli/index.js +5 -4
- package/dist/cli/index.js.map +1 -1
- package/dist/common/cli-output.d.ts +16 -0
- package/dist/common/cli-output.js +49 -0
- package/dist/common/cli-output.js.map +1 -0
- package/dist/compilers/bun.js +1 -1
- package/dist/compilers/bun.js.map +1 -1
- package/dist/linters/eslint.js +1 -1
- package/dist/linters/eslint.js.map +1 -1
- package/dist/linters/house/browser-api-patterns.d.ts +43 -0
- package/dist/linters/house/browser-api-patterns.js +87 -0
- package/dist/linters/house/browser-api-patterns.js.map +1 -0
- package/dist/linters/house/common.d.ts +17 -2
- package/dist/linters/house/common.js +18 -2
- package/dist/linters/house/common.js.map +1 -1
- package/dist/linters/house/configs.js +25 -0
- package/dist/linters/house/configs.js.map +1 -1
- package/dist/linters/house/const-class-values.rule.d.ts +2 -2
- package/dist/linters/house/const-class-values.rule.js +14 -5
- package/dist/linters/house/const-class-values.rule.js.map +1 -1
- package/dist/linters/house/effect-cleanup-consistency.rule.d.ts +2 -2
- package/dist/linters/house/effect-cleanup-consistency.rule.js +1 -1
- package/dist/linters/house/effect-cleanup-consistency.rule.js.map +1 -1
- package/dist/linters/house/framework-api-patterns.d.ts +54 -0
- package/dist/linters/house/framework-api-patterns.js +62 -0
- package/dist/linters/house/framework-api-patterns.js.map +1 -0
- package/dist/linters/house/framework-exports.d.ts +62 -0
- package/dist/linters/house/framework-exports.js +325 -0
- package/dist/linters/house/framework-exports.js.map +1 -0
- package/dist/linters/house/import-support.d.ts +56 -0
- package/dist/linters/house/import-support.js +179 -0
- package/dist/linters/house/import-support.js.map +1 -0
- package/dist/linters/house/index.d.ts +12 -0
- package/dist/linters/house/index.js +15 -1
- package/dist/linters/house/index.js.map +1 -1
- package/dist/linters/house/max-params-own.rule.d.ts +2 -2
- package/dist/linters/house/max-params-own.rule.js +1 -1
- package/dist/linters/house/max-params-own.rule.js.map +1 -1
- package/dist/linters/house/no-async-hook-callback.rule.d.ts +2 -2
- package/dist/linters/house/no-async-hook-callback.rule.js +1 -1
- package/dist/linters/house/no-async-hook-callback.rule.js.map +1 -1
- package/dist/linters/house/no-await-new-chain.rule.d.ts +2 -2
- package/dist/linters/house/no-await-new-chain.rule.js +1 -1
- package/dist/linters/house/no-await-new-chain.rule.js.map +1 -1
- package/dist/linters/house/no-await-promise-chain.rule.d.ts +2 -2
- package/dist/linters/house/no-await-promise-chain.rule.js +5 -5
- package/dist/linters/house/no-await-promise-chain.rule.js.map +1 -1
- package/dist/linters/house/no-inline-await.rule.d.ts +2 -2
- package/dist/linters/house/no-inline-await.rule.js +1 -1
- package/dist/linters/house/no-inline-await.rule.js.map +1 -1
- package/dist/linters/house/no-leaked-render.rule.d.ts +2 -2
- package/dist/linters/house/no-leaked-render.rule.js +1 -1
- package/dist/linters/house/no-leaked-render.rule.js.map +1 -1
- package/dist/linters/house/no-new-error.rule.d.ts +2 -2
- package/dist/linters/house/no-new-error.rule.js +2 -2
- package/dist/linters/house/no-new-error.rule.js.map +1 -1
- package/dist/linters/house/no-parent-import.rule.d.ts +45 -0
- package/dist/linters/house/no-parent-import.rule.js +176 -0
- package/dist/linters/house/no-parent-import.rule.js.map +1 -0
- package/dist/linters/house/no-return-await.rule.d.ts +2 -2
- package/dist/linters/house/no-return-await.rule.js +1 -1
- package/dist/linters/house/no-return-await.rule.js.map +1 -1
- package/dist/linters/house/no-shadow-framework-type.rule.d.ts +24 -0
- package/dist/linters/house/no-shadow-framework-type.rule.js +100 -0
- package/dist/linters/house/no-shadow-framework-type.rule.js.map +1 -0
- package/dist/linters/house/no-silent-catch.rule.d.ts +2 -2
- package/dist/linters/house/no-silent-catch.rule.js +3 -3
- package/dist/linters/house/no-silent-catch.rule.js.map +1 -1
- package/dist/linters/house/no-unbraced-case.rule.d.ts +2 -2
- package/dist/linters/house/no-unbraced-case.rule.js +1 -1
- package/dist/linters/house/no-unbraced-case.rule.js.map +1 -1
- package/dist/linters/house/plugin.d.ts +1 -1
- package/dist/linters/house/plugin.js +18 -2
- package/dist/linters/house/plugin.js.map +1 -1
- package/dist/linters/house/prefer-framework-api.rule.d.ts +83 -0
- package/dist/linters/house/prefer-framework-api.rule.js +562 -0
- package/dist/linters/house/prefer-framework-api.rule.js.map +1 -0
- package/dist/linters/house/prefer-http-method.rule.d.ts +22 -0
- package/dist/linters/house/prefer-http-method.rule.js +182 -0
- package/dist/linters/house/prefer-http-method.rule.js.map +1 -0
- package/dist/linters/house/prefer-promise-sleep.rule.d.ts +26 -0
- package/dist/linters/house/prefer-promise-sleep.rule.js +155 -0
- package/dist/linters/house/prefer-promise-sleep.rule.js.map +1 -0
- package/dist/linters/house/prefer-tnullable.rule.d.ts +25 -0
- package/dist/linters/house/prefer-tnullable.rule.js +124 -0
- package/dist/linters/house/prefer-tnullable.rule.js.map +1 -0
- package/dist/linters/house/typed-route-context.rule.d.ts +19 -0
- package/dist/linters/house/typed-route-context.rule.js +334 -0
- package/dist/linters/house/typed-route-context.rule.js.map +1 -0
- package/dist/linters/house/zod-schema-convention.rule.d.ts +82 -0
- package/dist/linters/house/zod-schema-convention.rule.js +477 -0
- package/dist/linters/house/zod-schema-convention.rule.js.map +1 -0
- package/dist/linters/oxlint.js +11 -1
- package/dist/linters/oxlint.js.map +1 -1
- package/dist/linters/react-eslint.js.map +1 -1
- package/dist/linters/rules/naming-convention.rule.d.ts +4 -1
- package/dist/linters/rules/naming-convention.rule.js +30 -1
- package/dist/linters/rules/naming-convention.rule.js.map +1 -1
- package/dist/linters/rules/no-restricted-properties.rule.js +1 -1
- package/dist/linters/rules/no-restricted-properties.rule.js.map +1 -1
- package/dist/testing/index.d.ts +2 -2
- package/dist/testing/index.js +2 -2
- package/dist/testing/index.js.map +1 -1
- package/dist/testing/{rejection.helper.d.ts → rejection.utility.d.ts} +4 -4
- package/dist/testing/{rejection.helper.js → rejection.utility.js} +7 -7
- package/dist/testing/rejection.utility.js.map +1 -0
- package/dist/testing/{spawn.helper.d.ts → spawn.utility.d.ts} +2 -2
- package/dist/testing/{spawn.helper.js → spawn.utility.js} +6 -6
- package/dist/testing/spawn.utility.js.map +1 -0
- package/package.json +7 -7
- package/dist/testing/rejection.helper.js.map +0 -1
- package/dist/testing/spawn.helper.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-return-await.rule.js","sourceRoot":"","sources":["../../../src/linters/house/no-return-await.rule.ts"],"names":[],"mappings":";;;AAEA,mDAAgF;AAChF,qCAAyE;AAEzE,4EAA4E;AAC5E,MAAM,OAAO,GA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,CAAC,IAAe,EAAE,EAAE;oBACnD,MAAM,QAAQ,GAAG,gBAAO,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,UAAU,EAAE,CAAC,CAAC;oBAE9D,IACE,4BAAY,CAAC,MAAM,CAAC,QAAQ,CAAC;wBAC7B,gBAAO,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,KAAK,qBAAY,CAAC,gBAAgB,EACrE,CAAC;wBACD,WAAW,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;oBACxE,CAAC;gBACH,CAAC;gBACD,CAAC,qBAAY,CAAC,yBAAyB,CAAC,EAAE,CAAC,IAAe,EAAE,EAAE;oBAC5D,MAAM,IAAI,GAAG,gBAAO,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,CAAC;oBAEtD,IACE,4BAAY,CAAC,MAAM,CAAC,IAAI,CAAC;wBACzB,gBAAO,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,KAAK,qBAAY,CAAC,gBAAgB,EACjE,CAAC;wBACD,WAAW,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;oBACnD,CAAC;gBACH,CAAC;aACF,CAAC;QACJ,CAAC;KACF,CAAC;IAEF,MAAM,CAAC,KAAK,CAAC,OAAqC,EAAE;QAClD,OAAO,IAAI,CAAC,QAAQ,IAAI,OAAO,CAAC;IAClC,CAAC;;AAvFH,8CAwFC","sourcesContent":["import type { Rule } from 'eslint';\nimport type { TRuleSeverity } from '../rules/common';\nimport { AwaitSupport, FUNCTION_TYPES, STATEMENT_LISTS } from './await-support';\nimport { AstNode, AstNodeTypes, HOUSE_PLUGIN_NAMESPACE } from './common';\n\n/** `node` sits inside a `try`, `catch` or `finally` of its own function. */\nconst isInTry = (node: unknown): boolean => {\n let current = AwaitSupport.parentOf({ node });\n\n while (current && !FUNCTION_TYPES.has(AstNode.getType({ node: current }) ?? '')) {\n if (AstNode.getType({ node: current }) === AstNodeTypes.TRY_STATEMENT) {\n return true;\n }\n\n current = AwaitSupport.parentOf({ node: current });\n }\n\n return false;\n};\n\n/**\n *
|
|
1
|
+
{"version":3,"file":"no-return-await.rule.js","sourceRoot":"","sources":["../../../src/linters/house/no-return-await.rule.ts"],"names":[],"mappings":";;;AAEA,mDAAgF;AAChF,qCAAyE;AAEzE,4EAA4E;AAC5E,MAAM,OAAO,GAAG,CAAC,IAAa,EAAW,EAAE;IACzC,IAAI,OAAO,GAAG,4BAAY,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;IAE9C,OAAO,OAAO,IAAI,CAAC,8BAAc,CAAC,GAAG,CAAC,gBAAO,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC;QAChF,IAAI,gBAAO,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,KAAK,qBAAY,CAAC,aAAa,EAAE,CAAC;YACtE,OAAO,IAAI,CAAC;QACd,CAAC;QAED,OAAO,GAAG,4BAAY,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;IACrD,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAa,iBAAiB;aACZ,SAAI,GAAG,GAAG,+BAAsB,kBAAkB,CAAC;aAEnD,SAAI,GAAoB;QACtC,IAAI,EAAE;YACJ,IAAI,EAAE,YAAY;YAClB,OAAO,EAAE,MAAM;YACf,MAAM,EAAE,EAAE;YACV,QAAQ,EAAE;gBACR,WAAW,EACT,qKAAqK;aACxK;SACF;QACD,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE;YAClB,MAAM,EAAE,UAAU,EAAE,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,CAAC;gBACH,CAAC;aACF,CAAC;QACJ,CAAC;KACF,CAAC;IAEF,MAAM,CAAC,KAAK,CAAC,OAAqC,EAAE;QAClD,OAAO,IAAI,CAAC,QAAQ,IAAI,OAAO,CAAC;IAClC,CAAC;;AAvFH,8CAwFC","sourcesContent":["import type { Rule } from 'eslint';\nimport type { TRuleSeverity } from '../rules/common';\nimport { AwaitSupport, FUNCTION_TYPES, STATEMENT_LISTS } from './await-support';\nimport { AstNode, AstNodeTypes, HOUSE_PLUGIN_NAMESPACE } from './common';\n\n/** `node` sits inside a `try`, `catch` or `finally` of its own function. */\nconst isInTry = (node: unknown): boolean => {\n let current = AwaitSupport.parentOf({ node });\n\n while (current && !FUNCTION_TYPES.has(AstNode.getType({ node: current }) ?? '')) {\n if (AstNode.getType({ node: current }) === AstNodeTypes.TRY_STATEMENT) {\n return true;\n }\n\n current = AwaitSupport.parentOf({ node: current });\n }\n\n return false;\n};\n\n/**\n * `@venizia/no-return-await`. A function returns the promise (`return f()`), never `return await f()`. Where the\n * `await` matters (inside `try`, `catch` or `finally`) it is written on its own line:\n * `const result = await f(); return result;`. An arrow whose body is an `await` is the same: `() => f()`.\n */\nexport class NoReturnAwaitRule {\n static readonly NAME = `${HOUSE_PLUGIN_NAMESPACE}/no-return-await`;\n\n static readonly RULE: Rule.RuleModule = {\n meta: {\n type: 'suggestion',\n fixable: 'code',\n schema: [],\n messages: {\n returnAwait:\n 'Return the promise (`return f()`), not `return await f()`; where the await matters (inside try, catch or finally) write `const result = await f(); return result;`.',\n },\n },\n create: (context) => {\n const { sourceCode } = context;\n\n const reportAwait = (opts: {\n reported: Rule.Node;\n awaitNode: Rule.Node;\n statement?: Rule.Node;\n }) => {\n const argument = AstNode.readField({ node: opts.awaitNode, key: 'argument' });\n const argumentText =\n AwaitSupport.isNode(argument) &&\n AstNode.getType({ node: argument }) !== AstNodeTypes.SEQUENCE_EXPRESSION\n ? sourceCode.getText(argument)\n : undefined;\n\n context.report({\n node: opts.reported,\n messageId: 'returnAwait',\n fix:\n argumentText === undefined\n ? null\n : (fixer) => {\n if (!opts.statement || !isInTry(opts.statement)) {\n return fixer.replaceText(opts.awaitNode, argumentText);\n }\n\n const outer = AwaitSupport.parentOf({ node: opts.statement });\n\n if (!STATEMENT_LISTS.has(AstNode.getType({ node: outer }) ?? '')) {\n return null;\n }\n\n const name = AwaitSupport.freshName({\n node: opts.statement,\n base: 'result',\n sourceCode,\n });\n const indent = AwaitSupport.indentOf({ node: opts.statement, sourceCode });\n\n return fixer.replaceText(\n opts.statement,\n `const ${name} = await ${argumentText};\\n${indent}return ${name};`,\n );\n },\n });\n };\n\n return {\n [AstNodeTypes.RETURN_STATEMENT]: (node: Rule.Node) => {\n const argument = AstNode.readField({ node, key: 'argument' });\n\n if (\n AwaitSupport.isNode(argument) &&\n AstNode.getType({ node: argument }) === AstNodeTypes.AWAIT_EXPRESSION\n ) {\n reportAwait({ reported: node, awaitNode: argument, statement: node });\n }\n },\n [AstNodeTypes.ARROW_FUNCTION_EXPRESSION]: (node: Rule.Node) => {\n const body = AstNode.readField({ node, key: 'body' });\n\n if (\n AwaitSupport.isNode(body) &&\n AstNode.getType({ node: body }) === AstNodeTypes.AWAIT_EXPRESSION\n ) {\n reportAwait({ reported: node, awaitNode: body });\n }\n },\n };\n },\n };\n\n static build(opts: { severity?: TRuleSeverity } = {}): TRuleSeverity {\n return opts.severity ?? 'error';\n }\n}\n"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Linter, Rule } from 'eslint';
|
|
2
|
+
import type { TRuleSeverity } from '../rules/common';
|
|
3
|
+
/**
|
|
4
|
+
* `@venizia/no-shadow-framework-type`. A type alias or interface written in your project under the name a `@venizia/*`
|
|
5
|
+
* package already exports (`ValueOrPromise`, `TNullable`, `TConstValue`) is a copy of the framework's: import it.
|
|
6
|
+
*
|
|
7
|
+
* The names come from the installed packages' `.d.ts` files (see `FrameworkExports`), for the packages your nearest
|
|
8
|
+
* `package.json` depends on. Not reported: a name the file imports, a name shorter than `minLength` (default 4, so a
|
|
9
|
+
* generic `T` never matches), a name in `allow`, anything inside `declare module` or `declare global` (an augmentation),
|
|
10
|
+
* a declaration file, and a package's own declarations of what it exports. There is no fix: a copy may differ from the
|
|
11
|
+
* original, so the replacement is the author's to check.
|
|
12
|
+
*/
|
|
13
|
+
export declare class NoShadowFrameworkTypeRule {
|
|
14
|
+
static readonly NAME = "@venizia/no-shadow-framework-type";
|
|
15
|
+
static readonly DEFAULT_MIN_LENGTH = 4;
|
|
16
|
+
/** Whether an interface lists `name` (bare or through a namespace import) among the types it extends. */
|
|
17
|
+
private static extendsSameName;
|
|
18
|
+
static readonly RULE: Rule.RuleModule;
|
|
19
|
+
static build(opts?: {
|
|
20
|
+
severity?: TRuleSeverity;
|
|
21
|
+
allow?: Array<string>;
|
|
22
|
+
}): Linter.RuleEntry;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=no-shadow-framework-type.rule.d.ts.map
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NoShadowFrameworkTypeRule = void 0;
|
|
4
|
+
const node_path_1 = require("node:path");
|
|
5
|
+
const common_1 = require("./common");
|
|
6
|
+
const framework_exports_1 = require("./framework-exports");
|
|
7
|
+
const import_support_1 = require("./import-support");
|
|
8
|
+
/**
|
|
9
|
+
* `@venizia/no-shadow-framework-type`. A type alias or interface written in your project under the name a `@venizia/*`
|
|
10
|
+
* package already exports (`ValueOrPromise`, `TNullable`, `TConstValue`) is a copy of the framework's: import it.
|
|
11
|
+
*
|
|
12
|
+
* The names come from the installed packages' `.d.ts` files (see `FrameworkExports`), for the packages your nearest
|
|
13
|
+
* `package.json` depends on. Not reported: a name the file imports, a name shorter than `minLength` (default 4, so a
|
|
14
|
+
* generic `T` never matches), a name in `allow`, anything inside `declare module` or `declare global` (an augmentation),
|
|
15
|
+
* a declaration file, and a package's own declarations of what it exports. There is no fix: a copy may differ from the
|
|
16
|
+
* original, so the replacement is the author's to check.
|
|
17
|
+
*/
|
|
18
|
+
class NoShadowFrameworkTypeRule {
|
|
19
|
+
static { this.NAME = `${common_1.HOUSE_PLUGIN_NAMESPACE}/no-shadow-framework-type`; }
|
|
20
|
+
static { this.DEFAULT_MIN_LENGTH = 4; }
|
|
21
|
+
/** Whether an interface lists `name` (bare or through a namespace import) among the types it extends. */
|
|
22
|
+
static extendsSameName(opts) {
|
|
23
|
+
const heritage = common_1.AstNode.readField({ node: opts.declaration, key: 'extends' });
|
|
24
|
+
return (Array.isArray(heritage) &&
|
|
25
|
+
heritage.some((entry) => {
|
|
26
|
+
const expression = common_1.AstNode.readField({ node: entry, key: 'expression' });
|
|
27
|
+
const property = common_1.AstNode.readField({ node: expression, key: 'property' });
|
|
28
|
+
return (common_1.AstNode.readField({ node: expression, key: 'name' }) === opts.name ||
|
|
29
|
+
common_1.AstNode.readField({ node: property, key: 'name' }) === opts.name);
|
|
30
|
+
}));
|
|
31
|
+
}
|
|
32
|
+
static { this.RULE = {
|
|
33
|
+
meta: {
|
|
34
|
+
type: 'problem',
|
|
35
|
+
schema: [
|
|
36
|
+
{
|
|
37
|
+
type: 'object',
|
|
38
|
+
properties: {
|
|
39
|
+
allow: { type: 'array', items: { type: 'string' } },
|
|
40
|
+
minLength: { type: 'integer', minimum: 1 },
|
|
41
|
+
},
|
|
42
|
+
additionalProperties: false,
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
messages: {
|
|
46
|
+
shadow: "`{{name}}` is a framework type, do not declare your own: `import type { {{name}} } from '{{source}}';`",
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
create: (context) => {
|
|
50
|
+
if (context.filename.endsWith('.d.ts')) {
|
|
51
|
+
return {};
|
|
52
|
+
}
|
|
53
|
+
const options = context.options[0];
|
|
54
|
+
const allowed = common_1.AstNode.readField({ node: options, key: 'allow' });
|
|
55
|
+
const configuredLength = common_1.AstNode.readField({ node: options, key: 'minLength' });
|
|
56
|
+
const allow = new Set(Array.isArray(allowed) ? allowed : []);
|
|
57
|
+
const minLength = typeof configuredLength === 'number'
|
|
58
|
+
? configuredLength
|
|
59
|
+
: NoShadowFrameworkTypeRule.DEFAULT_MIN_LENGTH;
|
|
60
|
+
let known;
|
|
61
|
+
return {
|
|
62
|
+
[common_1.AstNodeTypes.PROGRAM]: () => {
|
|
63
|
+
for (const statement of context.sourceCode.ast.body) {
|
|
64
|
+
const declaration = common_1.AstNode.getType({ node: statement }) === common_1.AstNodeTypes.EXPORT_NAMED_DECLARATION
|
|
65
|
+
? common_1.AstNode.readField({ node: statement, key: 'declaration' })
|
|
66
|
+
: statement;
|
|
67
|
+
const type = common_1.AstNode.getType({ node: declaration });
|
|
68
|
+
if (type !== common_1.AstNodeTypes.TYPE_ALIAS_DECLARATION &&
|
|
69
|
+
type !== common_1.AstNodeTypes.INTERFACE_DECLARATION) {
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
const identifier = common_1.AstNode.readField({ node: declaration, key: 'id' });
|
|
73
|
+
const name = common_1.AstNode.readField({ node: identifier, key: 'name' });
|
|
74
|
+
if (typeof name !== 'string' || name.length < minLength || allow.has(name)) {
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
// `interface X extends X` (or `extends H.X`) is the framework's type being extended on purpose.
|
|
78
|
+
if (NoShadowFrameworkTypeRule.extendsSameName({ declaration, name })) {
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
known ??= framework_exports_1.FrameworkExports.of({ directory: (0, node_path_1.dirname)(context.filename) });
|
|
82
|
+
const source = known.get(name);
|
|
83
|
+
if (source === undefined || import_support_1.ImportSupport.isImported({ context, name })) {
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
if (common_1.AstNode.isNode(identifier)) {
|
|
87
|
+
context.report({ node: identifier, messageId: 'shadow', data: { name, source } });
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
},
|
|
93
|
+
}; }
|
|
94
|
+
static build(opts = {}) {
|
|
95
|
+
const { severity = 'error', allow } = opts;
|
|
96
|
+
return allow === undefined ? [severity] : [severity, { allow }];
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
exports.NoShadowFrameworkTypeRule = NoShadowFrameworkTypeRule;
|
|
100
|
+
//# sourceMappingURL=no-shadow-framework-type.rule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-shadow-framework-type.rule.js","sourceRoot":"","sources":["../../../src/linters/house/no-shadow-framework-type.rule.ts"],"names":[],"mappings":";;;AAAA,yCAAoC;AAGpC,qCAAyE;AACzE,2DAAuD;AACvD,qDAAiD;AAEjD;;;;;;;;;GASG;AACH,MAAa,yBAAyB;aACpB,SAAI,GAAG,GAAG,+BAAsB,2BAA2B,CAAC;aAE5D,uBAAkB,GAAG,CAAC,CAAC;IAEvC,yGAAyG;IACjG,MAAM,CAAC,eAAe,CAAC,IAA4C;QACzE,MAAM,QAAQ,GAAY,gBAAO,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,WAAW,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC,CAAC;QAExF,OAAO,CACL,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC;YACvB,QAAQ,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE;gBACtB,MAAM,UAAU,GAAG,gBAAO,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,YAAY,EAAE,CAAC,CAAC;gBACzE,MAAM,QAAQ,GAAG,gBAAO,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE,UAAU,EAAE,CAAC,CAAC;gBAE1E,OAAO,CACL,gBAAO,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,KAAK,IAAI,CA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AC;wBAED,KAAK,KAAK,oCAAgB,CAAC,EAAE,CAAC,EAAE,SAAS,EAAE,IAAA,mBAAO,EAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;wBACxE,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;wBAE/B,IAAI,MAAM,KAAK,SAAS,IAAI,8BAAa,CAAC,UAAU,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;4BACxE,SAAS;wBACX,CAAC;wBAED,IAAI,gBAAO,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC;4BAC/B,OAAO,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;wBACpF,CAAC;oBACH,CAAC;gBACH,CAAC;aACF,CAAC;QACJ,CAAC;KACF,CAAC;IAEF,MAAM,CAAC,KAAK,CAAC,OAA4D,EAAE;QACzE,MAAM,EAAE,QAAQ,GAAG,OAAO,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;QAE3C,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IAClE,CAAC;;AAxGH,8DAyGC","sourcesContent":["import { dirname } from 'node:path';\nimport type { Linter, Rule } from 'eslint';\nimport type { TRuleSeverity } from '../rules/common';\nimport { AstNode, AstNodeTypes, HOUSE_PLUGIN_NAMESPACE } from './common';\nimport { FrameworkExports } from './framework-exports';\nimport { ImportSupport } from './import-support';\n\n/**\n * `@venizia/no-shadow-framework-type`. A type alias or interface written in your project under the name a `@venizia/*`\n * package already exports (`ValueOrPromise`, `TNullable`, `TConstValue`) is a copy of the framework's: import it.\n *\n * The names come from the installed packages' `.d.ts` files (see `FrameworkExports`), for the packages your nearest\n * `package.json` depends on. Not reported: a name the file imports, a name shorter than `minLength` (default 4, so a\n * generic `T` never matches), a name in `allow`, anything inside `declare module` or `declare global` (an augmentation),\n * a declaration file, and a package's own declarations of what it exports. There is no fix: a copy may differ from the\n * original, so the replacement is the author's to check.\n */\nexport class NoShadowFrameworkTypeRule {\n static readonly NAME = `${HOUSE_PLUGIN_NAMESPACE}/no-shadow-framework-type`;\n\n static readonly DEFAULT_MIN_LENGTH = 4;\n\n /** Whether an interface lists `name` (bare or through a namespace import) among the types it extends. */\n private static extendsSameName(opts: { declaration: unknown; name: string }): boolean {\n const heritage: unknown = AstNode.readField({ node: opts.declaration, key: 'extends' });\n\n return (\n Array.isArray(heritage) &&\n heritage.some((entry) => {\n const expression = AstNode.readField({ node: entry, key: 'expression' });\n const property = AstNode.readField({ node: expression, key: 'property' });\n\n return (\n AstNode.readField({ node: expression, key: 'name' }) === opts.name ||\n AstNode.readField({ node: property, key: 'name' }) === opts.name\n );\n })\n );\n }\n\n static readonly RULE: Rule.RuleModule = {\n meta: {\n type: 'problem',\n schema: [\n {\n type: 'object',\n properties: {\n allow: { type: 'array', items: { type: 'string' } },\n minLength: { type: 'integer', minimum: 1 },\n },\n additionalProperties: false,\n },\n ],\n messages: {\n shadow:\n \"`{{name}}` is a framework type, do not declare your own: `import type { {{name}} } from '{{source}}';`\",\n },\n },\n create: (context) => {\n if (context.filename.endsWith('.d.ts')) {\n return {};\n }\n\n const options: unknown = context.options[0];\n const allowed = AstNode.readField({ node: options, key: 'allow' });\n const configuredLength = AstNode.readField({ node: options, key: 'minLength' });\n const allow = new Set(Array.isArray(allowed) ? allowed : []);\n const minLength =\n typeof configuredLength === 'number'\n ? configuredLength\n : NoShadowFrameworkTypeRule.DEFAULT_MIN_LENGTH;\n let known: Map<string, string> | undefined;\n\n return {\n [AstNodeTypes.PROGRAM]: () => {\n for (const statement of context.sourceCode.ast.body) {\n const declaration =\n AstNode.getType({ node: statement }) === AstNodeTypes.EXPORT_NAMED_DECLARATION\n ? AstNode.readField({ node: statement, key: 'declaration' })\n : statement;\n const type = AstNode.getType({ node: declaration });\n\n if (\n type !== AstNodeTypes.TYPE_ALIAS_DECLARATION &&\n type !== AstNodeTypes.INTERFACE_DECLARATION\n ) {\n continue;\n }\n\n const identifier = AstNode.readField({ node: declaration, key: 'id' });\n const name = AstNode.readField({ node: identifier, key: 'name' });\n\n if (typeof name !== 'string' || name.length < minLength || allow.has(name)) {\n continue;\n }\n\n // `interface X extends X` (or `extends H.X`) is the framework's type being extended on purpose.\n if (NoShadowFrameworkTypeRule.extendsSameName({ declaration, name })) {\n continue;\n }\n\n known ??= FrameworkExports.of({ directory: dirname(context.filename) });\n const source = known.get(name);\n\n if (source === undefined || ImportSupport.isImported({ context, name })) {\n continue;\n }\n\n if (AstNode.isNode(identifier)) {\n context.report({ node: identifier, messageId: 'shadow', data: { name, source } });\n }\n }\n },\n };\n },\n };\n\n static build(opts: { severity?: TRuleSeverity; allow?: Array<string> } = {}): Linter.RuleEntry {\n const { severity = 'error', allow } = opts;\n\n return allow === undefined ? [severity] : [severity, { allow }];\n }\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Rule } from 'eslint';
|
|
2
2
|
import type { TRuleSeverity } from '../rules/common';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* `@venizia/no-silent-catch`. A handled error leaves a trace (V-C-06). Reported: a `.catch(h)` (also `?.catch`,
|
|
5
5
|
* `['catch']`) whose handler is an arrow or function expression that ignores its parameter and whose body is empty
|
|
6
6
|
* or only gives back a constant (`() => null`, `() => undefined`, `() => ({})`, `() => []`, `() => {}`,
|
|
7
7
|
* `function () {}`), and a `catch` block that is empty, holds only a comment, or only assigns or returns a constant
|
|
@@ -13,7 +13,7 @@ import type { TRuleSeverity } from '../rules/common';
|
|
|
13
13
|
* log is a decision. A deliberate silent catch carries an `eslint-disable-next-line` with its reason.
|
|
14
14
|
*/
|
|
15
15
|
export declare class NoSilentCatchRule {
|
|
16
|
-
static readonly NAME = "venizia/no-silent-catch";
|
|
16
|
+
static readonly NAME = "@venizia/no-silent-catch";
|
|
17
17
|
static readonly RULE: Rule.RuleModule;
|
|
18
18
|
static build(opts?: {
|
|
19
19
|
severity?: TRuleSeverity;
|
|
@@ -13,7 +13,7 @@ const isPlainParameter = (opts) => opts.parameter === null ||
|
|
|
13
13
|
opts.parameter === undefined ||
|
|
14
14
|
common_1.AstNode.getType({ node: opts.parameter }) === common_1.AstNodeTypes.IDENTIFIER;
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
16
|
+
* `@venizia/no-silent-catch`. A handled error leaves a trace (V-C-06). Reported: a `.catch(h)` (also `?.catch`,
|
|
17
17
|
* `['catch']`) whose handler is an arrow or function expression that ignores its parameter and whose body is empty
|
|
18
18
|
* or only gives back a constant (`() => null`, `() => undefined`, `() => ({})`, `() => []`, `() => {}`,
|
|
19
19
|
* `function () {}`), and a `catch` block that is empty, holds only a comment, or only assigns or returns a constant
|
|
@@ -31,8 +31,8 @@ class NoSilentCatchRule {
|
|
|
31
31
|
type: 'suggestion',
|
|
32
32
|
schema: [],
|
|
33
33
|
messages: {
|
|
34
|
-
silentHandler:
|
|
35
|
-
silentBlock:
|
|
34
|
+
silentHandler: "This `.catch` handler swallows the error with no trace: rethrow it, wrap it or log it (V-C-06), as in `LoggerFactory.getLogger(['scope']).error('Failed | Error: %o', error)`: `import { LoggerFactory } from '@venizia/ignis-helpers/core';`",
|
|
35
|
+
silentBlock: "This `catch` block swallows the error with no trace: rethrow it, wrap it or log it (V-C-06), as in `LoggerFactory.getLogger(['scope']).error('Failed | Error: %o', error)`: `import { LoggerFactory } from '@venizia/ignis-helpers/core';`",
|
|
36
36
|
},
|
|
37
37
|
},
|
|
38
38
|
create: (context) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-silent-catch.rule.js","sourceRoot":"","sources":["../../../src/linters/house/no-silent-catch.rule.ts"],"names":[],"mappings":";;;AA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,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC,CAAC;oBAChE,CAAC;gBACH,CAAC;gBACD,CAAC,qBAAY,CAAC,YAAY,CAAC,EAAE,CAAC,IAAe,EAAE,EAAE;oBAC/C,IACE,CAAC,gBAAgB,CAAC,EAAE,SAAS,EAAE,gBAAO,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;wBAC3E,eAAe,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,EAC5C,CAAC;wBACD,OAAO;oBACT,CAAC;oBAED,MAAM,IAAI,GAAG,gBAAO,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,CAAC;oBAEtD,IACE,2CAAmB,CAAC,aAAa,CAAC;wBAChC,UAAU,EAAE,gBAAO,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC;qBAC3D,CAAC,EACF,CAAC;wBACD,OAAO,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC,CAAC;oBACrD,CAAC;gBACH,CAAC;aACF,CAAC;QACJ,CAAC;KACF,CAAC;IAEF,MAAM,CAAC,KAAK,CAAC,OAAqC,EAAE;QAClD,OAAO,IAAI,CAAC,QAAQ,IAAI,OAAO,CAAC;IAClC,CAAC;;AAjFH,8CAkFC","sourcesContent":["import type { Rule, SourceCode } from 'eslint';\nimport type { TRuleSeverity } from '../rules/common';\nimport { AwaitSupport } from './await-support';\nimport { AstNode, AstNodeTypes, HOUSE_PLUGIN_NAMESPACE } from './common';\nimport { PromiseChainSupport } from './promise-chain-support';\n\n/** Whether a parameter of `owner` (a function or a catch clause) is read or written anywhere. */\nconst isParameterUsed = (opts: { owner: Rule.Node; sourceCode: SourceCode }): boolean =>\n opts.sourceCode\n .getDeclaredVariables(opts.owner)\n .some(\n (variable) =>\n variable.defs.some((definition) =>\n ['Parameter', AstNodeTypes.CATCH_CLAUSE].includes(definition.type),\n ) && variable.references.length > 0,\n );\n\n/** A parameter that is not a plain name (`({ message }) =>`, `catch ({ message })`) reads the error by itself. */\nconst isPlainParameter = (opts: { parameter: unknown }): boolean =>\n opts.parameter === null ||\n opts.parameter === undefined ||\n AstNode.getType({ node: opts.parameter }) === AstNodeTypes.IDENTIFIER;\n\n/**\n * `@venizia/no-silent-catch`. A handled error leaves a trace (V-C-06). Reported: a `.catch(h)` (also `?.catch`,\n * `['catch']`) whose handler is an arrow or function expression that ignores its parameter and whose body is empty\n * or only gives back a constant (`() => null`, `() => undefined`, `() => ({})`, `() => []`, `() => {}`,\n * `function () {}`), and a `catch` block that is empty, holds only a comment, or only assigns or returns a constant\n * without reading the error. Handled, and not reported: anything that reads the error (logs, wraps or rethrows\n * it), makes any call (a log, a cleanup, a fallback), throws, or reads another variable.\n *\n * It is not ESLint's `no-empty`: `no-empty` reports an empty block only, lets a block that holds a comment pass,\n * and never sees `.catch(() => null)`. Both report `catch {}`, each with its own message. There is no fix: what to\n * log is a decision. A deliberate silent catch carries an `eslint-disable-next-line` with its reason.\n */\nexport class NoSilentCatchRule {\n static readonly NAME = `${HOUSE_PLUGIN_NAMESPACE}/no-silent-catch`;\n\n static readonly RULE: Rule.RuleModule = {\n meta: {\n type: 'suggestion',\n schema: [],\n messages: {\n silentHandler:\n \"This `.catch` handler swallows the error with no trace: rethrow it, wrap it or log it (V-C-06), as in `LoggerFactory.getLogger(['scope']).error('Failed | Error: %o', error)`: `import { LoggerFactory } from '@venizia/ignis-helpers/core';`\",\n silentBlock:\n \"This `catch` block swallows the error with no trace: rethrow it, wrap it or log it (V-C-06), as in `LoggerFactory.getLogger(['scope']).error('Failed | Error: %o', error)`: `import { LoggerFactory } from '@venizia/ignis-helpers/core';`\",\n },\n },\n create: (context) => {\n const { sourceCode } = context;\n\n return {\n [AstNodeTypes.CALL_EXPRESSION]: (node: Rule.Node) => {\n if (PromiseChainSupport.chainMethodOf({ node }) !== 'catch') {\n return;\n }\n\n const args = AstNode.readField({ node, key: 'arguments' });\n const handler: unknown = Array.isArray(args) ? args[0] : undefined;\n const handlerType = AstNode.getType({ node: handler });\n\n if (\n !AwaitSupport.isNode(handler) ||\n (handlerType !== AstNodeTypes.ARROW_FUNCTION_EXPRESSION &&\n handlerType !== AstNodeTypes.FUNCTION_EXPRESSION)\n ) {\n return;\n }\n\n const params = AstNode.readField({ node: handler, key: 'params' });\n\n if (\n !Array.isArray(params) ||\n !params.every((parameter) => isPlainParameter({ parameter })) ||\n isParameterUsed({ owner: handler, sourceCode })\n ) {\n return;\n }\n\n const body = AstNode.readField({ node: handler, key: 'body' });\n const isSilent =\n AstNode.getType({ node: body }) === AstNodeTypes.BLOCK_STATEMENT\n ? PromiseChainSupport.isSilentBlock({\n statements: AstNode.readField({ node: body, key: 'body' }),\n })\n : PromiseChainSupport.isConstant({ node: body });\n\n if (isSilent) {\n context.report({ node: handler, messageId: 'silentHandler' });\n }\n },\n [AstNodeTypes.CATCH_CLAUSE]: (node: Rule.Node) => {\n if (\n !isPlainParameter({ parameter: AstNode.readField({ node, key: 'param' }) }) ||\n isParameterUsed({ owner: node, sourceCode })\n ) {\n return;\n }\n\n const body = AstNode.readField({ node, key: 'body' });\n\n if (\n PromiseChainSupport.isSilentBlock({\n statements: AstNode.readField({ node: body, key: 'body' }),\n })\n ) {\n context.report({ node, messageId: 'silentBlock' });\n }\n },\n };\n },\n };\n\n static build(opts: { severity?: TRuleSeverity } = {}): TRuleSeverity {\n return opts.severity ?? 'error';\n }\n}\n"]}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { Linter, Rule } from 'eslint';
|
|
2
2
|
import type { TRuleSeverity } from '../rules/common';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* `@venizia/no-unbraced-case`: the statements of a `case` or `default` sit in one block, `case 'a': { ... }`.
|
|
5
5
|
* It is the ESLint twin of oxlint's `unicorn/switch-case-braces` (`SwitchCaseBracesRule`, mode `always`).
|
|
6
6
|
* Stacked labels with no statements stay as written. The fix wraps the statements in `{ }`.
|
|
7
7
|
*/
|
|
8
8
|
export declare class NoUnbracedCaseRule {
|
|
9
|
-
static readonly NAME = "venizia/no-unbraced-case";
|
|
9
|
+
static readonly NAME = "@venizia/no-unbraced-case";
|
|
10
10
|
static readonly RULE: Rule.RuleModule;
|
|
11
11
|
static build(opts?: {
|
|
12
12
|
severity?: TRuleSeverity;
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.NoUnbracedCaseRule = void 0;
|
|
4
4
|
const common_1 = require("./common");
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* `@venizia/no-unbraced-case`: the statements of a `case` or `default` sit in one block, `case 'a': { ... }`.
|
|
7
7
|
* It is the ESLint twin of oxlint's `unicorn/switch-case-braces` (`SwitchCaseBracesRule`, mode `always`).
|
|
8
8
|
* Stacked labels with no statements stay as written. The fix wraps the statements in `{ }`.
|
|
9
9
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-unbraced-case.rule.js","sourceRoot":"","sources":["../../../src/linters/house/no-unbraced-case.rule.ts"],"names":[],"mappings":";;;AAEA,qCAAyE;AAEzE;;;;GAIG;AACH,MAAa,kBAAkB;aACb,SAAI,GAAG,GAAG,+BAAsB,mBAAmB,CAAC;aAEpD,SAAI,GAAoB;QACtC,IAAI,EAAE;YACJ,IAAI,EAAE,YAAY;YAClB,OAAO,EAAE,MAAM;YACf,MAAM,EAAE,EAAE;YACV,QAAQ,EAAE,EAAE,QAAQ,EAAE,iEAAiE,EAAE;SAC1F;QACD,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;YACpB,CAAC,qBAAY,CAAC,WAAW,CAAC,EAAE,CAAC,IAAe,EAAE,EAAE;gBAC9C,MAAM,UAAU,GAAY,gBAAO,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,CAAC,CAAC;gBAE3E,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;oBAC1D,OAAO;gBACT,CAAC;gBAED,MAAM,CAAC,KAAK,CAAC,GAAG,UAAU,CAAC;gBAC3B,MAAM,IAAI,GAAG,UAAU,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;gBAE/C,IACE,UAAU,CAAC,MAAM,KAAK,CAAC;oBACvB,gBAAO,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,KAAK,qBAAY,CAAC,eAAe,EACjE,CAAC;oBACD,OAAO;gBACT,CAAC;gBAED,OAAO,CAAC,MAAM,CAAC;oBACb,IAAI;oBACJ,SAAS,EAAE,UAAU;oBACrB,GAAG,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,gBAAgB,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE,KAAK,CAAC,eAAe,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;iBACzF,CAAC,CAAC;YACL,CAAC;SACF,CAAC;KACH,CAAC;IAEF,MAAM,CAAC,KAAK,CAAC,OAAqC,EAAE;QAClD,MAAM,EAAE,QAAQ,GAAG,OAAO,EAAE,GAAG,IAAI,CAAC;QAEpC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACpB,CAAC;;AAzCH,gDA0CC","sourcesContent":["import type { Linter, Rule } from 'eslint';\nimport type { TRuleSeverity } from '../rules/common';\nimport { AstNode, AstNodeTypes, HOUSE_PLUGIN_NAMESPACE } from './common';\n\n/**\n *
|
|
1
|
+
{"version":3,"file":"no-unbraced-case.rule.js","sourceRoot":"","sources":["../../../src/linters/house/no-unbraced-case.rule.ts"],"names":[],"mappings":";;;AAEA,qCAAyE;AAEzE;;;;GA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AAM,EAAE,QAAQ,GAAG,OAAO,EAAE,GAAG,IAAI,CAAC;QAEpC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACpB,CAAC;;AAzCH,gDA0CC","sourcesContent":["import type { Linter, Rule } from 'eslint';\nimport type { TRuleSeverity } from '../rules/common';\nimport { AstNode, AstNodeTypes, HOUSE_PLUGIN_NAMESPACE } from './common';\n\n/**\n * `@venizia/no-unbraced-case`: the statements of a `case` or `default` sit in one block, `case 'a': { ... }`.\n * It is the ESLint twin of oxlint's `unicorn/switch-case-braces` (`SwitchCaseBracesRule`, mode `always`).\n * Stacked labels with no statements stay as written. The fix wraps the statements in `{ }`.\n */\nexport class NoUnbracedCaseRule {\n static readonly NAME = `${HOUSE_PLUGIN_NAMESPACE}/no-unbraced-case`;\n\n static readonly RULE: Rule.RuleModule = {\n meta: {\n type: 'suggestion',\n fixable: 'code',\n schema: [],\n messages: { unbraced: 'Wrap the statements of this case in a block: `case x: { ... }`.' },\n },\n create: (context) => ({\n [AstNodeTypes.SWITCH_CASE]: (node: Rule.Node) => {\n const statements: unknown = AstNode.readField({ node, key: 'consequent' });\n\n if (!Array.isArray(statements) || statements.length === 0) {\n return;\n }\n\n const [first] = statements;\n const last = statements[statements.length - 1];\n\n if (\n statements.length === 1 &&\n AstNode.getType({ node: first }) === AstNodeTypes.BLOCK_STATEMENT\n ) {\n return;\n }\n\n context.report({\n node,\n messageId: 'unbraced',\n fix: (fixer) => [fixer.insertTextBefore(first, '{ '), fixer.insertTextAfter(last, ' }')],\n });\n },\n }),\n };\n\n static build(opts: { severity?: TRuleSeverity } = {}): Linter.RuleEntry {\n const { severity = 'error' } = opts;\n\n return [severity];\n }\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { ESLint } from 'eslint';
|
|
2
|
-
/** The ESLint plugin that carries the house rules oxlint cannot express, registered as
|
|
2
|
+
/** The ESLint plugin that carries the house rules oxlint cannot express, registered as `@venizia`. */
|
|
3
3
|
export declare const houseEslintPlugin: ESLint.Plugin;
|
|
4
4
|
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -11,12 +11,20 @@ const no_await_promise_chain_rule_1 = require("./no-await-promise-chain.rule");
|
|
|
11
11
|
const no_inline_await_rule_1 = require("./no-inline-await.rule");
|
|
12
12
|
const no_leaked_render_rule_1 = require("./no-leaked-render.rule");
|
|
13
13
|
const no_new_error_rule_1 = require("./no-new-error.rule");
|
|
14
|
+
const no_parent_import_rule_1 = require("./no-parent-import.rule");
|
|
14
15
|
const no_return_await_rule_1 = require("./no-return-await.rule");
|
|
16
|
+
const no_shadow_framework_type_rule_1 = require("./no-shadow-framework-type.rule");
|
|
15
17
|
const no_silent_catch_rule_1 = require("./no-silent-catch.rule");
|
|
16
18
|
const no_unbraced_case_rule_1 = require("./no-unbraced-case.rule");
|
|
17
|
-
|
|
19
|
+
const prefer_framework_api_rule_1 = require("./prefer-framework-api.rule");
|
|
20
|
+
const prefer_http_method_rule_1 = require("./prefer-http-method.rule");
|
|
21
|
+
const prefer_promise_sleep_rule_1 = require("./prefer-promise-sleep.rule");
|
|
22
|
+
const prefer_tnullable_rule_1 = require("./prefer-tnullable.rule");
|
|
23
|
+
const typed_route_context_rule_1 = require("./typed-route-context.rule");
|
|
24
|
+
const zod_schema_convention_rule_1 = require("./zod-schema-convention.rule");
|
|
25
|
+
/** The ESLint plugin that carries the house rules oxlint cannot express, registered as `@venizia`. */
|
|
18
26
|
exports.houseEslintPlugin = {
|
|
19
|
-
meta: { name:
|
|
27
|
+
meta: { name: `${common_1.HOUSE_PLUGIN_NAMESPACE}/eslint-plugin` },
|
|
20
28
|
rules: {
|
|
21
29
|
'const-class-values': const_class_values_rule_1.ConstClassValuesRule.RULE,
|
|
22
30
|
'effect-cleanup-consistency': effect_cleanup_consistency_rule_1.EffectCleanupConsistencyRule.RULE,
|
|
@@ -27,9 +35,17 @@ exports.houseEslintPlugin = {
|
|
|
27
35
|
'no-inline-await': no_inline_await_rule_1.NoInlineAwaitRule.RULE,
|
|
28
36
|
'no-leaked-render': no_leaked_render_rule_1.NoLeakedRenderRule.RULE,
|
|
29
37
|
'no-new-error': no_new_error_rule_1.NoNewErrorRule.RULE,
|
|
38
|
+
'no-parent-import': no_parent_import_rule_1.NoParentImportRule.RULE,
|
|
30
39
|
'no-return-await': no_return_await_rule_1.NoReturnAwaitRule.RULE,
|
|
40
|
+
'no-shadow-framework-type': no_shadow_framework_type_rule_1.NoShadowFrameworkTypeRule.RULE,
|
|
31
41
|
'no-silent-catch': no_silent_catch_rule_1.NoSilentCatchRule.RULE,
|
|
32
42
|
'no-unbraced-case': no_unbraced_case_rule_1.NoUnbracedCaseRule.RULE,
|
|
43
|
+
'prefer-framework-api': prefer_framework_api_rule_1.PreferFrameworkApiRule.RULE,
|
|
44
|
+
'prefer-http-method': prefer_http_method_rule_1.PreferHttpMethodRule.RULE,
|
|
45
|
+
'prefer-promise-sleep': prefer_promise_sleep_rule_1.PreferPromiseSleepRule.RULE,
|
|
46
|
+
'prefer-tnullable': prefer_tnullable_rule_1.PreferTNullableRule.RULE,
|
|
47
|
+
'typed-route-context': typed_route_context_rule_1.TypedRouteContextRule.RULE,
|
|
48
|
+
'zod-schema-convention': zod_schema_convention_rule_1.ZodSchemaConventionRule.RULE,
|
|
33
49
|
},
|
|
34
50
|
};
|
|
35
51
|
//# sourceMappingURL=plugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../../src/linters/house/plugin.ts"],"names":[],"mappings":";;;AACA,qCAAkD;AAClD,uEAAiE;AACjE,uFAAiF;AACjF,+DAAyD;AACzD,+EAAwE;AACxE,uEAAgE;AAChE,+EAAwE;AACxE,iEAA2D;AAC3D,mEAA6D;AAC7D,2DAAqD;AACrD,iEAA2D;AAC3D,iEAA2D;AAC3D,mEAA6D;
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../../src/linters/house/plugin.ts"],"names":[],"mappings":";;;AACA,q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AAE,oDAAuB,CAAC,IAAI;KACtD;CACF,CAAC","sourcesContent":["import type { ESLint } from 'eslint';\nimport { HOUSE_PLUGIN_NAMESPACE } from './common';\nimport { ConstClassValuesRule } from './const-class-values.rule';\nimport { EffectCleanupConsistencyRule } from './effect-cleanup-consistency.rule';\nimport { MaxParamsOwnRule } from './max-params-own.rule';\nimport { NoAsyncHookCallbackRule } from './no-async-hook-callback.rule';\nimport { NoAwaitNewChainRule } from './no-await-new-chain.rule';\nimport { NoAwaitPromiseChainRule } from './no-await-promise-chain.rule';\nimport { NoInlineAwaitRule } from './no-inline-await.rule';\nimport { NoLeakedRenderRule } from './no-leaked-render.rule';\nimport { NoNewErrorRule } from './no-new-error.rule';\nimport { NoParentImportRule } from './no-parent-import.rule';\nimport { NoReturnAwaitRule } from './no-return-await.rule';\nimport { NoShadowFrameworkTypeRule } from './no-shadow-framework-type.rule';\nimport { NoSilentCatchRule } from './no-silent-catch.rule';\nimport { NoUnbracedCaseRule } from './no-unbraced-case.rule';\nimport { PreferFrameworkApiRule } from './prefer-framework-api.rule';\nimport { PreferHttpMethodRule } from './prefer-http-method.rule';\nimport { PreferPromiseSleepRule } from './prefer-promise-sleep.rule';\nimport { PreferTNullableRule } from './prefer-tnullable.rule';\nimport { TypedRouteContextRule } from './typed-route-context.rule';\nimport { ZodSchemaConventionRule } from './zod-schema-convention.rule';\n\n/** The ESLint plugin that carries the house rules oxlint cannot express, registered as `@venizia`. */\nexport const houseEslintPlugin: ESLint.Plugin = {\n meta: { name: `${HOUSE_PLUGIN_NAMESPACE}/eslint-plugin` },\n rules: {\n 'const-class-values': ConstClassValuesRule.RULE,\n 'effect-cleanup-consistency': EffectCleanupConsistencyRule.RULE,\n 'max-params-own': MaxParamsOwnRule.RULE,\n 'no-async-hook-callback': NoAsyncHookCallbackRule.RULE,\n 'no-await-new-chain': NoAwaitNewChainRule.RULE,\n 'no-await-promise-chain': NoAwaitPromiseChainRule.RULE,\n 'no-inline-await': NoInlineAwaitRule.RULE,\n 'no-leaked-render': NoLeakedRenderRule.RULE,\n 'no-new-error': NoNewErrorRule.RULE,\n 'no-parent-import': NoParentImportRule.RULE,\n 'no-return-await': NoReturnAwaitRule.RULE,\n 'no-shadow-framework-type': NoShadowFrameworkTypeRule.RULE,\n 'no-silent-catch': NoSilentCatchRule.RULE,\n 'no-unbraced-case': NoUnbracedCaseRule.RULE,\n 'prefer-framework-api': PreferFrameworkApiRule.RULE,\n 'prefer-http-method': PreferHttpMethodRule.RULE,\n 'prefer-promise-sleep': PreferPromiseSleepRule.RULE,\n 'prefer-tnullable': PreferTNullableRule.RULE,\n 'typed-route-context': TypedRouteContextRule.RULE,\n 'zod-schema-convention': ZodSchemaConventionRule.RULE,\n },\n};\n"]}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { Linter, Rule } from 'eslint';
|
|
2
|
+
import type { TRuleSeverity } from '../rules/common';
|
|
3
|
+
import type { IFrameworkApiPattern } from './framework-api-patterns';
|
|
4
|
+
/**
|
|
5
|
+
* `@venizia/prefer-framework-api`. A browser API that `@venizia/ardor-react` wraps in a hook (`window.matchMedia`, a
|
|
6
|
+
* `ResizeObserver`, `navigator.onLine`, a `beforeunload` listener, `navigator.clipboard.writeText`, `window.confirm`...) is
|
|
7
|
+
* used through the hook, which owns the subscribe and cleanup. The rows are `BrowserApiPatterns.TABLE`; the message names
|
|
8
|
+
* the hook. The rule is for apps: the package that ships the hooks (the nearest `package.json` is named
|
|
9
|
+
* `@venizia/ardor-react`) is not reported.
|
|
10
|
+
*
|
|
11
|
+
* The rows of `FrameworkApiPatterns.TABLE` and of the `extra` option are not about React: they report anywhere in a file,
|
|
12
|
+
* with their own message, in a package their `dependsOn` and `owner` allow.
|
|
13
|
+
*
|
|
14
|
+
* For the hook rows, only a reference to the global is reported: a `window`, `navigator` or `document` the file binds itself is not. And only
|
|
15
|
+
* where a hook can be called: in a component (a PascalCase function that draws JSX) or a hook (`useX`), see `isInReact`. A
|
|
16
|
+
* module function, a class and an event handler making a one-off call are left alone. Hooks the author wants to bypass on
|
|
17
|
+
* purpose take an `eslint-disable-next-line` with the reason, or `ignore` lists pattern ids.
|
|
18
|
+
*/
|
|
19
|
+
export declare class PreferFrameworkApiRule {
|
|
20
|
+
static readonly NAME = "@venizia/prefer-framework-api";
|
|
21
|
+
/** The dotted text of `a.b.c` (identifiers only), or `undefined` for anything else. */
|
|
22
|
+
private static pathOf;
|
|
23
|
+
/** `window.navigator.onLine` is `navigator.onLine`. */
|
|
24
|
+
private static withoutGlobalRoot;
|
|
25
|
+
/** Whether the root identifier of `path` is the global one: no scope of the file binds it. */
|
|
26
|
+
private static isGlobal;
|
|
27
|
+
private static readonly FUNCTIONS;
|
|
28
|
+
/** Whether a function has JSX anywhere in it: with a PascalCase name, that is a component. */
|
|
29
|
+
private static readonly jsxCache;
|
|
30
|
+
private static containsJsx;
|
|
31
|
+
/** The name a function is known by: its own, or the variable it is assigned to (through one `memo(...)` / `forwardRef(...)`). */
|
|
32
|
+
private static nameOf;
|
|
33
|
+
/** A hook (`useX`), or a component: a PascalCase function that draws JSX. */
|
|
34
|
+
private static isReactFunction;
|
|
35
|
+
/** Whether `fn` is an argument of a hook call (`useEffect(() => ...)`): the callback runs for the component or the hook. */
|
|
36
|
+
private static isHookCallback;
|
|
37
|
+
/**
|
|
38
|
+
* Whether `node` is in a component or a hook, which is where a hook can be called. A subscription (a listener, an
|
|
39
|
+
* observer) counts through any handler or helper on the way up: it belongs in a hook. A plain read (`window.innerWidth`,
|
|
40
|
+
* `window.confirm`) counts only in the body of the component or the hook, or in a callback it hands to a hook
|
|
41
|
+
* (`useEffect`, `useMemo`): inside an event handler, or outside every component (a module function, a class), it is a
|
|
42
|
+
* one-off call a hook cannot make.
|
|
43
|
+
*/
|
|
44
|
+
private static isInReact;
|
|
45
|
+
/** A dev tool's own configuration: what it names never reaches a browser or a deployment (a dev server's proxy target). */
|
|
46
|
+
private static readonly DEV_TOOL_CONFIG;
|
|
47
|
+
/** The rows that apply in a file of this package: the table and `extra`, less the ignored ones. */
|
|
48
|
+
private static rowsFor;
|
|
49
|
+
/** The listeners the rows outside React need, by node type or selector. */
|
|
50
|
+
private static rowListeners;
|
|
51
|
+
/** The name of `a.name` or `a['name']`; empty for `a[name]`, whose name the file does not state. */
|
|
52
|
+
private static memberName;
|
|
53
|
+
/** The field each type of an `extra` row cannot do without. */
|
|
54
|
+
private static readonly ROW_FIELDS;
|
|
55
|
+
/** Whether an `extra` entry is a row this rule can run. The option schema refuses the others before it gets here. */
|
|
56
|
+
private static isRow;
|
|
57
|
+
/** The schema of the `match` of an `extra` row: one shape per type, each with its own field required. */
|
|
58
|
+
private static matchSchema;
|
|
59
|
+
/**
|
|
60
|
+
* Whether `node` is assigned to or deleted, rather than read. A member that a destructuring pattern writes
|
|
61
|
+
* (`[process.env.APP_ENV_A] = values`) counts as a read and is reported.
|
|
62
|
+
*/
|
|
63
|
+
private static isWritten;
|
|
64
|
+
private static readonly FALLBACK_KEYS;
|
|
65
|
+
/** Whether `node` is the value used when another is missing. */
|
|
66
|
+
private static isFallback;
|
|
67
|
+
/** Whether an import declaration brings in types only. */
|
|
68
|
+
private static isTypeOnly;
|
|
69
|
+
/** One listener object: two rows that visit the same node both run. */
|
|
70
|
+
private static merge;
|
|
71
|
+
static readonly RULE: Rule.RuleModule;
|
|
72
|
+
/**
|
|
73
|
+
* `hooks: false` leaves out the rows of `BrowserApiPatterns`, for code that is not React: a `use...` function of another
|
|
74
|
+
* library reads as a hook. An entry that sets options replaces the earlier ones, so it states `hooks` again.
|
|
75
|
+
*/
|
|
76
|
+
static build(opts?: {
|
|
77
|
+
severity?: TRuleSeverity;
|
|
78
|
+
hooks?: boolean;
|
|
79
|
+
ignore?: ReadonlyArray<string>;
|
|
80
|
+
extra?: ReadonlyArray<IFrameworkApiPattern>;
|
|
81
|
+
}): Linter.RuleEntry;
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=prefer-framework-api.rule.d.ts.map
|