@venizia/dev-configs 0.4.7-0 → 0.4.7-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +1 -3
- package/README.md +1 -1
- package/dist/checks/catalog.d.ts +4 -2
- package/dist/checks/catalog.d.ts.map +1 -1
- package/dist/checks/catalog.js +72 -70
- package/dist/checks/catalog.js.map +1 -1
- package/dist/checks/module-cycles.d.ts +11 -9
- package/dist/checks/module-cycles.d.ts.map +1 -1
- package/dist/checks/module-cycles.js +32 -30
- package/dist/checks/module-cycles.js.map +1 -1
- package/dist/checks/purity/manifest.d.ts +44 -38
- package/dist/checks/purity/manifest.d.ts.map +1 -1
- package/dist/checks/purity/manifest.js +121 -115
- package/dist/checks/purity/manifest.js.map +1 -1
- package/dist/checks/purity/probe.d.ts +22 -18
- package/dist/checks/purity/probe.d.ts.map +1 -1
- package/dist/checks/purity/probe.js +99 -98
- package/dist/checks/purity/probe.js.map +1 -1
- package/dist/checks/purity/run.d.ts +18 -16
- package/dist/checks/purity/run.d.ts.map +1 -1
- package/dist/checks/purity/run.js +90 -86
- package/dist/checks/purity/run.js.map +1 -1
- package/dist/checks/test-controls.d.ts +17 -15
- package/dist/checks/test-controls.d.ts.map +1 -1
- package/dist/checks/test-controls.js +71 -70
- package/dist/checks/test-controls.js.map +1 -1
- package/dist/checks/test-dead-code.d.ts +5 -3
- package/dist/checks/test-dead-code.d.ts.map +1 -1
- package/dist/checks/test-dead-code.js +23 -21
- package/dist/checks/test-dead-code.js.map +1 -1
- package/dist/checks/test-mutate.d.ts +12 -7
- package/dist/checks/test-mutate.d.ts.map +1 -1
- package/dist/checks/test-mutate.js +59 -56
- package/dist/checks/test-mutate.js.map +1 -1
- package/dist/checks/test-weight.d.ts +11 -8
- package/dist/checks/test-weight.d.ts.map +1 -1
- package/dist/checks/test-weight.js +98 -94
- package/dist/checks/test-weight.js.map +1 -1
- package/dist/cli/check.d.ts.map +1 -1
- package/dist/cli/check.js +11 -8
- package/dist/cli/check.js.map +1 -1
- package/dist/cli/codemod/async-style.d.ts +29 -8
- package/dist/cli/codemod/async-style.d.ts.map +1 -1
- package/dist/cli/codemod/async-style.js +102 -20
- package/dist/cli/codemod/async-style.js.map +1 -1
- package/dist/cli/codemod/index.d.ts.map +1 -1
- package/dist/cli/codemod/index.js +6 -2
- package/dist/cli/codemod/index.js.map +1 -1
- package/dist/cli/codemod/model-settings.d.ts +7 -5
- package/dist/cli/codemod/model-settings.d.ts.map +1 -1
- package/dist/cli/codemod/model-settings.js +293 -291
- package/dist/cli/codemod/model-settings.js.map +1 -1
- package/dist/cli/codemod/namespace-functions/index.d.ts +20 -0
- package/dist/cli/codemod/namespace-functions/index.d.ts.map +1 -0
- package/dist/cli/codemod/namespace-functions/index.js +182 -0
- package/dist/cli/codemod/namespace-functions/index.js.map +1 -0
- package/dist/cli/codemod/namespace-functions/logger-scope.d.ts +32 -0
- package/dist/cli/codemod/namespace-functions/logger-scope.d.ts.map +1 -0
- package/dist/cli/codemod/namespace-functions/logger-scope.js +128 -0
- package/dist/cli/codemod/namespace-functions/logger-scope.js.map +1 -0
- package/dist/cli/codemod/namespace-functions/mapping.d.ts +66 -0
- package/dist/cli/codemod/namespace-functions/mapping.d.ts.map +1 -0
- package/dist/cli/codemod/namespace-functions/mapping.js +99 -0
- package/dist/cli/codemod/namespace-functions/mapping.js.map +1 -0
- package/dist/cli/codemod/namespace-functions/mappings/boot.d.ts +7 -0
- package/dist/cli/codemod/namespace-functions/mappings/boot.d.ts.map +1 -0
- package/dist/cli/codemod/namespace-functions/mappings/boot.js +28 -0
- package/dist/cli/codemod/namespace-functions/mappings/boot.js.map +1 -0
- package/dist/cli/codemod/namespace-functions/mappings/connectors.d.ts +4 -0
- package/dist/cli/codemod/namespace-functions/mappings/connectors.d.ts.map +1 -0
- package/dist/cli/codemod/namespace-functions/mappings/connectors.js +218 -0
- package/dist/cli/codemod/namespace-functions/mappings/connectors.js.map +1 -0
- package/dist/cli/codemod/namespace-functions/mappings/core-server.d.ts +7 -0
- package/dist/cli/codemod/namespace-functions/mappings/core-server.d.ts.map +1 -0
- package/dist/cli/codemod/namespace-functions/mappings/core-server.js +162 -0
- package/dist/cli/codemod/namespace-functions/mappings/core-server.js.map +1 -0
- package/dist/cli/codemod/namespace-functions/mappings/core-worker.d.ts +7 -0
- package/dist/cli/codemod/namespace-functions/mappings/core-worker.d.ts.map +1 -0
- package/dist/cli/codemod/namespace-functions/mappings/core-worker.js +18 -0
- package/dist/cli/codemod/namespace-functions/mappings/core-worker.js.map +1 -0
- package/dist/cli/codemod/namespace-functions/mappings/dev-configs.d.ts +7 -0
- package/dist/cli/codemod/namespace-functions/mappings/dev-configs.d.ts.map +1 -0
- package/dist/cli/codemod/namespace-functions/mappings/dev-configs.js +192 -0
- package/dist/cli/codemod/namespace-functions/mappings/dev-configs.js.map +1 -0
- package/dist/cli/codemod/namespace-functions/mappings/filter.d.ts +7 -0
- package/dist/cli/codemod/namespace-functions/mappings/filter.d.ts.map +1 -0
- package/dist/cli/codemod/namespace-functions/mappings/filter.js +30 -0
- package/dist/cli/codemod/namespace-functions/mappings/filter.js.map +1 -0
- package/dist/cli/codemod/namespace-functions/mappings/helpers.d.ts +16 -0
- package/dist/cli/codemod/namespace-functions/mappings/helpers.d.ts.map +1 -0
- package/dist/cli/codemod/namespace-functions/mappings/helpers.js +535 -0
- package/dist/cli/codemod/namespace-functions/mappings/helpers.js.map +1 -0
- package/dist/cli/codemod/namespace-functions/mappings/index.d.ts +4 -0
- package/dist/cli/codemod/namespace-functions/mappings/index.d.ts.map +1 -0
- package/dist/cli/codemod/namespace-functions/mappings/index.js +25 -0
- package/dist/cli/codemod/namespace-functions/mappings/index.js.map +1 -0
- package/dist/cli/codemod/namespace-functions/mappings/inversion.d.ts +10 -0
- package/dist/cli/codemod/namespace-functions/mappings/inversion.d.ts.map +1 -0
- package/dist/cli/codemod/namespace-functions/mappings/inversion.js +81 -0
- package/dist/cli/codemod/namespace-functions/mappings/inversion.js.map +1 -0
- package/dist/cli/codemod/namespace-functions/mappings/kernel.d.ts +17 -0
- package/dist/cli/codemod/namespace-functions/mappings/kernel.d.ts.map +1 -0
- package/dist/cli/codemod/namespace-functions/mappings/kernel.js +229 -0
- package/dist/cli/codemod/namespace-functions/mappings/kernel.js.map +1 -0
- package/dist/cli/codemod/namespace-functions/rewriter.d.ts +61 -0
- package/dist/cli/codemod/namespace-functions/rewriter.d.ts.map +1 -0
- package/dist/cli/codemod/namespace-functions/rewriter.js +564 -0
- package/dist/cli/codemod/namespace-functions/rewriter.js.map +1 -0
- package/dist/cli/index.js +2 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/compilers/bun.d.ts +1 -1
- package/dist/compilers/bun.js +1 -1
- package/dist/compilers/bun.js.map +1 -1
- package/dist/linters/house/await-support.d.ts +17 -3
- package/dist/linters/house/await-support.d.ts.map +1 -1
- package/dist/linters/house/await-support.js +52 -23
- package/dist/linters/house/await-support.js.map +1 -1
- package/dist/linters/house/common.d.ts +13 -9
- package/dist/linters/house/common.d.ts.map +1 -1
- package/dist/linters/house/common.js +18 -15
- package/dist/linters/house/common.js.map +1 -1
- package/dist/linters/house/configs.d.ts +5 -2
- package/dist/linters/house/configs.d.ts.map +1 -1
- package/dist/linters/house/configs.js +11 -2
- package/dist/linters/house/configs.js.map +1 -1
- package/dist/linters/house/const-class-values.rule.d.ts.map +1 -1
- package/dist/linters/house/const-class-values.rule.js +27 -19
- package/dist/linters/house/const-class-values.rule.js.map +1 -1
- package/dist/linters/house/effect-cleanup-consistency.rule.js +3 -3
- package/dist/linters/house/effect-cleanup-consistency.rule.js.map +1 -1
- package/dist/linters/house/hook-support.d.ts.map +1 -1
- package/dist/linters/house/hook-support.js +17 -14
- package/dist/linters/house/hook-support.js.map +1 -1
- package/dist/linters/house/index.d.ts +3 -0
- package/dist/linters/house/index.d.ts.map +1 -1
- package/dist/linters/house/index.js +3 -0
- package/dist/linters/house/index.js.map +1 -1
- package/dist/linters/house/max-params-own.rule.d.ts.map +1 -1
- package/dist/linters/house/max-params-own.rule.js +33 -24
- package/dist/linters/house/max-params-own.rule.js.map +1 -1
- 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-promise-chain.rule.d.ts +24 -0
- package/dist/linters/house/no-await-promise-chain.rule.d.ts.map +1 -0
- package/dist/linters/house/no-await-promise-chain.rule.js +298 -0
- package/dist/linters/house/no-await-promise-chain.rule.js.map +1 -0
- package/dist/linters/house/no-inline-await.rule.d.ts.map +1 -1
- package/dist/linters/house/no-inline-await.rule.js +6 -12
- package/dist/linters/house/no-inline-await.rule.js.map +1 -1
- package/dist/linters/house/no-new-error.rule.js +4 -4
- package/dist/linters/house/no-new-error.rule.js.map +1 -1
- package/dist/linters/house/no-return-await.rule.d.ts.map +1 -1
- package/dist/linters/house/no-return-await.rule.js +11 -11
- package/dist/linters/house/no-return-await.rule.js.map +1 -1
- package/dist/linters/house/no-silent-catch.rule.d.ts +22 -0
- package/dist/linters/house/no-silent-catch.rule.d.ts.map +1 -0
- package/dist/linters/house/no-silent-catch.rule.js +88 -0
- package/dist/linters/house/no-silent-catch.rule.js.map +1 -0
- package/dist/linters/house/plugin.d.ts.map +1 -1
- package/dist/linters/house/plugin.js +4 -0
- package/dist/linters/house/plugin.js.map +1 -1
- package/dist/linters/house/promise-chain-support.d.ts +49 -0
- package/dist/linters/house/promise-chain-support.d.ts.map +1 -0
- package/dist/linters/house/promise-chain-support.js +188 -0
- package/dist/linters/house/promise-chain-support.js.map +1 -0
- 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/rejection.helper.d.ts +25 -20
- package/dist/testing/rejection.helper.d.ts.map +1 -1
- package/dist/testing/rejection.helper.js +33 -31
- package/dist/testing/rejection.helper.js.map +1 -1
- package/dist/testing/repo-tmp.d.ts +19 -9
- package/dist/testing/repo-tmp.d.ts.map +1 -1
- package/dist/testing/repo-tmp.js +50 -48
- package/dist/testing/repo-tmp.js.map +1 -1
- package/dist/testing/spawn.helper.d.ts +12 -10
- package/dist/testing/spawn.helper.d.ts.map +1 -1
- package/dist/testing/spawn.helper.js +22 -16
- package/dist/testing/spawn.helper.js.map +1 -1
- package/dist/testing/tmpdir-preload.js +1 -1
- package/dist/testing/tmpdir-preload.js.map +1 -1
- package/package.json +2 -3
|
@@ -26,18 +26,17 @@ class NoInlineAwaitRule {
|
|
|
26
26
|
},
|
|
27
27
|
create: (context) => {
|
|
28
28
|
const { sourceCode } = context;
|
|
29
|
-
const taken = new Map();
|
|
30
29
|
return {
|
|
31
30
|
[common_1.AstNodeTypes.AWAIT_EXPRESSION]: (node) => {
|
|
32
31
|
const parent = await_support_1.AwaitSupport.parentOf({ node });
|
|
33
|
-
const parentType =
|
|
32
|
+
const parentType = common_1.AstNode.getType({ node: parent });
|
|
34
33
|
const isWhole = (parentType === 'ExpressionStatement' &&
|
|
35
|
-
|
|
34
|
+
common_1.AstNode.readField({ node: parent, key: 'expression' }) === node) ||
|
|
36
35
|
(parentType === 'VariableDeclarator' &&
|
|
37
|
-
|
|
36
|
+
common_1.AstNode.readField({ node: parent, key: 'init' }) === node);
|
|
38
37
|
const isReturned = (parentType === 'ReturnStatement' || parentType === 'ArrowFunctionExpression') &&
|
|
39
|
-
(
|
|
40
|
-
|
|
38
|
+
(common_1.AstNode.readField({ node: parent, key: 'argument' }) === node ||
|
|
39
|
+
common_1.AstNode.readField({ node: parent, key: 'body' }) === node);
|
|
41
40
|
if (isWhole || isReturned) {
|
|
42
41
|
return;
|
|
43
42
|
}
|
|
@@ -49,12 +48,7 @@ class NoInlineAwaitRule {
|
|
|
49
48
|
messageId: 'inline',
|
|
50
49
|
fix: canFix
|
|
51
50
|
? (fixer) => {
|
|
52
|
-
const name = await_support_1.AwaitSupport.freshName({
|
|
53
|
-
node,
|
|
54
|
-
base: 'result',
|
|
55
|
-
sourceCode,
|
|
56
|
-
taken,
|
|
57
|
-
});
|
|
51
|
+
const name = await_support_1.AwaitSupport.freshName({ node, base: 'result', sourceCode });
|
|
58
52
|
const [start, end] = await_support_1.AwaitSupport.replaceRangeOf({ awaitNode: node, sourceCode });
|
|
59
53
|
const indent = await_support_1.AwaitSupport.indentOf({ node: statement, sourceCode });
|
|
60
54
|
return [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-inline-await.rule.js","sourceRoot":"","sources":["../../../src/linters/house/no-inline-await.rule.ts"],"names":[],"mappings":";;;AAEA,mDAA+C;AAC/C,
|
|
1
|
+
{"version":3,"file":"no-inline-await.rule.js","sourceRoot":"","sources":["../../../src/linters/house/no-inline-await.rule.ts"],"names":[],"mappings":";;;AAEA,mDAA+C;AAC/C,qCAAyE;AAEzE;;;;;;;;;GASG;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,MAAM,EACJ,2IAA2I;aAC9I;SACF;QACD,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE;YAClB,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;YAE/B,OAAO;gBACL,CAAC,qBAAY,CAAC,gBAAgB,CAAC,EAAE,CAAC,IAAe,EAAE,EAAE;oBACnD,MAAM,MAAM,GAAG,4BAAY,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;oBAC/C,MAAM,UAAU,GAAG,gBAAO,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;oBACrD,MAAM,OAAO,GACX,CAAC,UAAU,KAAK,qBAAqB;wBACnC,gBAAO,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAA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AC,QAAQ,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC,CAAC;gCAEtE,OAAO;oCACL,KAAK,CAAC,gBAAgB,CACpB,SAAS,EACT,SAAS,IAAI,MAAM,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,MAAM,EAAE,CAC1D;oCACD,KAAK,CAAC,gBAAgB,CAAC,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,IAAI,CAAC;iCAC3C,CAAC;4BACJ,CAAC;4BACH,CAAC,CAAC,IAAI;qBACT,CAAC,CAAC;gBACL,CAAC;aACF,CAAC;QACJ,CAAC;KACF,CAAC;IAEF,MAAM,CAAC,KAAK,CAAC,OAAqC,EAAE;QAClD,OAAO,IAAI,CAAC,QAAQ,IAAI,OAAO,CAAC;IAClC,CAAC;;AAjEH,8CAkEC","sourcesContent":["import type { Rule } from 'eslint';\nimport type { TRuleSeverity } from '../rules/common';\nimport { AwaitSupport } from './await-support';\nimport { AstNode, AstNodeTypes, HOUSE_PLUGIN_NAMESPACE } from './common';\n\n/**\n * `venizia/no-inline-await`. `await` stands alone: as a whole statement (`await f();`) or as the whole initializer\n * of a declaration (`const result = await f();`). Inside any other expression - a call argument, a spread, an\n * array or object, a ternary, a logical operator, a template literal, a member access, an assignment - it is\n * reported, and `return g(await f())` is the same report. `return await f()` is `no-return-await`'s.\n *\n * The fix moves the `await` into a `const` in front of the statement. It is made only when nothing that does more\n * than read a value runs before the `await` inside the statement, and when the `await` is not in a branch, a loop\n * test, an unbraced `if` branch or an arrow expression body; those cases are reported and left alone.\n */\nexport class NoInlineAwaitRule {\n static readonly NAME = `${HOUSE_PLUGIN_NAMESPACE}/no-inline-await`;\n\n static readonly RULE: Rule.RuleModule = {\n meta: {\n type: 'suggestion',\n fixable: 'code',\n schema: [],\n messages: {\n inline:\n '`await` stands alone as a statement or as the whole initializer of a declaration (`const result = await f();`), not inside an expression.',\n },\n },\n create: (context) => {\n const { sourceCode } = context;\n\n return {\n [AstNodeTypes.AWAIT_EXPRESSION]: (node: Rule.Node) => {\n const parent = AwaitSupport.parentOf({ node });\n const parentType = AstNode.getType({ node: parent });\n const isWhole =\n (parentType === 'ExpressionStatement' &&\n AstNode.readField({ node: parent, key: 'expression' }) === node) ||\n (parentType === 'VariableDeclarator' &&\n AstNode.readField({ node: parent, key: 'init' }) === node);\n const isReturned =\n (parentType === 'ReturnStatement' || parentType === 'ArrowFunctionExpression') &&\n (AstNode.readField({ node: parent, key: 'argument' }) === node ||\n AstNode.readField({ node: parent, key: 'body' }) === node);\n\n if (isWhole || isReturned) {\n return;\n }\n\n const statement = AwaitSupport.hoistTarget({ awaitNode: node });\n const canFix =\n statement !== undefined &&\n !AwaitSupport.hasEffectBefore({ statement, awaitNode: node, sourceCode });\n\n context.report({\n node,\n messageId: 'inline',\n fix: canFix\n ? (fixer) => {\n const name = AwaitSupport.freshName({ node, base: 'result', sourceCode });\n const [start, end] = AwaitSupport.replaceRangeOf({ awaitNode: node, sourceCode });\n const indent = AwaitSupport.indentOf({ node: statement, sourceCode });\n\n return [\n fixer.insertTextBefore(\n statement,\n `const ${name} = ${sourceCode.getText(node)};\\n${indent}`,\n ),\n fixer.replaceTextRange([start, end], name),\n ];\n }\n : null,\n });\n },\n };\n },\n };\n\n static build(opts: { severity?: TRuleSeverity } = {}): TRuleSeverity {\n return opts.severity ?? 'error';\n }\n}\n"]}
|
|
@@ -19,16 +19,16 @@ class NoNewErrorRule {
|
|
|
19
19
|
},
|
|
20
20
|
create: (context) => {
|
|
21
21
|
const report = (opts) => context.report({ node: opts.node, messageId: 'newError', data: { form: opts.form } });
|
|
22
|
-
const isErrorIdentifier = (callee) =>
|
|
23
|
-
|
|
22
|
+
const isErrorIdentifier = (callee) => common_1.AstNode.getType({ node: callee }) === 'Identifier' &&
|
|
23
|
+
common_1.AstNode.readField({ node: callee, key: 'name' }) === 'Error';
|
|
24
24
|
return {
|
|
25
25
|
[common_1.AstNodeTypes.NEW_EXPRESSION]: (node) => {
|
|
26
|
-
if (isErrorIdentifier(
|
|
26
|
+
if (isErrorIdentifier(common_1.AstNode.readField({ node, key: 'callee' }))) {
|
|
27
27
|
report({ node, form: 'new Error(...)' });
|
|
28
28
|
}
|
|
29
29
|
},
|
|
30
30
|
[common_1.AstNodeTypes.CALL_EXPRESSION]: (node) => {
|
|
31
|
-
if (isErrorIdentifier(
|
|
31
|
+
if (isErrorIdentifier(common_1.AstNode.readField({ node, key: 'callee' }))) {
|
|
32
32
|
report({ node, form: 'Error(...)' });
|
|
33
33
|
}
|
|
34
34
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-new-error.rule.js","sourceRoot":"","sources":["../../../src/linters/house/no-new-error.rule.ts"],"names":[],"mappings":";;;AAEA,
|
|
1
|
+
{"version":3,"file":"no-new-error.rule.js","sourceRoot":"","sources":["../../../src/linters/house/no-new-error.rule.ts"],"names":[],"mappings":";;;AAEA,qCAAyE;AAEzE;;;;GAIG;AACH,MAAa,cAAc;aACT,SAAI,GAAG,GAAG,+BAAsB,eAAe,CAAC;aAEhD,SAAI,GAAoB;QACtC,IAAI,EAAE;YACJ,IAAI,EAAE,SAAS;YACf,MAAM,EAAE,EAAE;YACV,QAAQ,EAAE;gBACR,QAAQ,EACN,2IAA2I;aAC9I;SACF;QACD,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE;YAClB,MAAM,MAAM,GAAG,CAAC,IAAuC,EAAE,EAAE,CACzD,OAAO,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YAExF,MAAM,iBAAiB,GAAG,CAAC,MAAe,EAAE,EAAE,CAC5C,gBAAO,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,KAAK,YAAY;gBAClD,gBAAO,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,KAAK,OAAO,CAAC;YAE/D,OAAO;gBACL,CAAC,qBAAY,CAAC,cAAc,CAAC,EAAE,CAAC,IAAe,EAAE,EAAE;oBACjD,IAAI,iBAAiB,CAAC,gBAAO,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC;wBAClE,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,gBAAgB,EAAE,CAAC,CAAC;oBAC3C,CAAC;gBACH,CAAC;gBACD,CAAC,qBAAY,CAAC,eAAe,CAAC,EAAE,CAAC,IAAe,EAAE,EAAE;oBAClD,IAAI,iBAAiB,CAAC,gBAAO,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC;wBAClE,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC,CAAC;oBACvC,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;;AArCH,wCAsCC","sourcesContent":["import type { Rule } from 'eslint';\nimport type { TRuleSeverity } from '../rules/common';\nimport { AstNode, AstNodeTypes, HOUSE_PLUGIN_NAMESPACE } from './common';\n\n/**\n * `venizia/no-new-error`. An error is thrown through `getError({ message })` (or an `ApplicationError`),\n * never `new Error(...)` or `Error(...)`: only an ApplicationError carries the status, the message code and\n * args, and the `extra` every IGNIS layer reads.\n */\nexport class NoNewErrorRule {\n static readonly NAME = `${HOUSE_PLUGIN_NAMESPACE}/no-new-error`;\n\n static readonly RULE: Rule.RuleModule = {\n meta: {\n type: 'problem',\n schema: [],\n messages: {\n newError:\n 'Throw through getError({ message }) (or an ApplicationError), not `{{form}}`: only an ApplicationError carries the status, code and args.',\n },\n },\n create: (context) => {\n const report = (opts: { node: Rule.Node; form: string }) =>\n context.report({ node: opts.node, messageId: 'newError', data: { form: opts.form } });\n\n const isErrorIdentifier = (callee: unknown) =>\n AstNode.getType({ node: callee }) === 'Identifier' &&\n AstNode.readField({ node: callee, key: 'name' }) === 'Error';\n\n return {\n [AstNodeTypes.NEW_EXPRESSION]: (node: Rule.Node) => {\n if (isErrorIdentifier(AstNode.readField({ node, key: 'callee' }))) {\n report({ node, form: 'new Error(...)' });\n }\n },\n [AstNodeTypes.CALL_EXPRESSION]: (node: Rule.Node) => {\n if (isErrorIdentifier(AstNode.readField({ node, key: 'callee' }))) {\n report({ node, form: 'Error(...)' });\n }\n },\n };\n },\n };\n\n static build(opts: { severity?: TRuleSeverity } = {}): TRuleSeverity {\n return opts.severity ?? 'error';\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-return-await.rule.d.ts","sourceRoot":"","sources":["../../../src/linters/house/no-return-await.rule.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAyBrD;;;;GAIG;AACH,qBAAa,iBAAiB;IAC5B,MAAM,CAAC,QAAQ,CAAC,IAAI,6BAA+C;IAEnE,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,UAAU,
|
|
1
|
+
{"version":3,"file":"no-return-await.rule.d.ts","sourceRoot":"","sources":["../../../src/linters/house/no-return-await.rule.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAyBrD;;;;GAIG;AACH,qBAAa,iBAAiB;IAC5B,MAAM,CAAC,QAAQ,CAAC,IAAI,6BAA+C;IAEnE,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,UAAU,CA0EnC;IAEF,MAAM,CAAC,KAAK,CAAC,IAAI,GAAE;QAAE,QAAQ,CAAC,EAAE,aAAa,CAAA;KAAO,GAAG,aAAa;CAGrE"}
|
|
@@ -12,8 +12,8 @@ const STATEMENT_LISTS = new Set(['BlockStatement', 'Program', 'StaticBlock', 'Sw
|
|
|
12
12
|
/** `node` sits inside a `try`, `catch` or `finally` of its own function. */
|
|
13
13
|
const isInTry = (node) => {
|
|
14
14
|
let current = await_support_1.AwaitSupport.parentOf({ node });
|
|
15
|
-
while (current && !FUNCTION_TYPES.has(
|
|
16
|
-
if (
|
|
15
|
+
while (current && !FUNCTION_TYPES.has(common_1.AstNode.getType({ node: current }) ?? '')) {
|
|
16
|
+
if (common_1.AstNode.getType({ node: current }) === 'TryStatement') {
|
|
17
17
|
return true;
|
|
18
18
|
}
|
|
19
19
|
current = await_support_1.AwaitSupport.parentOf({ node: current });
|
|
@@ -38,10 +38,10 @@ class NoReturnAwaitRule {
|
|
|
38
38
|
},
|
|
39
39
|
create: (context) => {
|
|
40
40
|
const { sourceCode } = context;
|
|
41
|
-
const taken = new Map();
|
|
42
41
|
const reportAwait = (opts) => {
|
|
43
|
-
const argument =
|
|
44
|
-
const argumentText = await_support_1.AwaitSupport.isNode(argument) &&
|
|
42
|
+
const argument = common_1.AstNode.readField({ node: opts.awaitNode, key: 'argument' });
|
|
43
|
+
const argumentText = await_support_1.AwaitSupport.isNode(argument) &&
|
|
44
|
+
common_1.AstNode.getType({ node: argument }) !== 'SequenceExpression'
|
|
45
45
|
? sourceCode.getText(argument)
|
|
46
46
|
: undefined;
|
|
47
47
|
context.report({
|
|
@@ -54,14 +54,13 @@ class NoReturnAwaitRule {
|
|
|
54
54
|
return fixer.replaceText(opts.awaitNode, argumentText);
|
|
55
55
|
}
|
|
56
56
|
const outer = await_support_1.AwaitSupport.parentOf({ node: opts.statement });
|
|
57
|
-
if (!STATEMENT_LISTS.has(
|
|
57
|
+
if (!STATEMENT_LISTS.has(common_1.AstNode.getType({ node: outer }) ?? '')) {
|
|
58
58
|
return null;
|
|
59
59
|
}
|
|
60
60
|
const name = await_support_1.AwaitSupport.freshName({
|
|
61
61
|
node: opts.statement,
|
|
62
62
|
base: 'result',
|
|
63
63
|
sourceCode,
|
|
64
|
-
taken,
|
|
65
64
|
});
|
|
66
65
|
const indent = await_support_1.AwaitSupport.indentOf({ node: opts.statement, sourceCode });
|
|
67
66
|
return fixer.replaceText(opts.statement, `const ${name} = await ${argumentText};\n${indent}return ${name};`);
|
|
@@ -70,14 +69,15 @@ class NoReturnAwaitRule {
|
|
|
70
69
|
};
|
|
71
70
|
return {
|
|
72
71
|
[common_1.AstNodeTypes.RETURN_STATEMENT]: (node) => {
|
|
73
|
-
const argument =
|
|
74
|
-
if (await_support_1.AwaitSupport.isNode(argument) &&
|
|
72
|
+
const argument = common_1.AstNode.readField({ node, key: 'argument' });
|
|
73
|
+
if (await_support_1.AwaitSupport.isNode(argument) &&
|
|
74
|
+
common_1.AstNode.getType({ node: argument }) === 'AwaitExpression') {
|
|
75
75
|
reportAwait({ reported: node, awaitNode: argument, statement: node });
|
|
76
76
|
}
|
|
77
77
|
},
|
|
78
78
|
[common_1.AstNodeTypes.ARROW_FUNCTION_EXPRESSION]: (node) => {
|
|
79
|
-
const body =
|
|
80
|
-
if (await_support_1.AwaitSupport.isNode(body) &&
|
|
79
|
+
const body = common_1.AstNode.readField({ node, key: 'body' });
|
|
80
|
+
if (await_support_1.AwaitSupport.isNode(body) && common_1.AstNode.getType({ node: body }) === 'AwaitExpression') {
|
|
81
81
|
reportAwait({ reported: node, awaitNode: body });
|
|
82
82
|
}
|
|
83
83
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-return-await.rule.js","sourceRoot":"","sources":["../../../src/linters/house/no-return-await.rule.ts"],"names":[],"mappings":";;;AAEA,mDAA+C;AAC/C,
|
|
1
|
+
{"version":3,"file":"no-return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CAAC,OAAqC,EAAE;QAClD,OAAO,IAAI,CAAC,QAAQ,IAAI,OAAO,CAAC;IAClC,CAAC;;AAjFH,8CAkFC","sourcesContent":["import type { Rule } from 'eslint';\nimport type { TRuleSeverity } from '../rules/common';\nimport { AwaitSupport } from './await-support';\nimport { AstNode, AstNodeTypes, HOUSE_PLUGIN_NAMESPACE } from './common';\n\nconst FUNCTION_TYPES = new Set([\n 'FunctionDeclaration',\n 'FunctionExpression',\n 'ArrowFunctionExpression',\n]);\nconst STATEMENT_LISTS = new Set(['BlockStatement', 'Program', 'StaticBlock', 'SwitchCase']);\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 }) === 'TryStatement') {\n return true;\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 }) !== 'SequenceExpression'\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 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 if (\n AwaitSupport.isNode(argument) &&\n AstNode.getType({ node: argument }) === 'AwaitExpression'\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 if (AwaitSupport.isNode(body) && AstNode.getType({ node: body }) === 'AwaitExpression') {\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,22 @@
|
|
|
1
|
+
import type { Rule } from 'eslint';
|
|
2
|
+
import type { TRuleSeverity } from '../rules/common';
|
|
3
|
+
/**
|
|
4
|
+
* `venizia/no-silent-catch`. A handled error leaves a trace (V-C-06). Reported: a `.catch(h)` (also `?.catch`,
|
|
5
|
+
* `['catch']`) whose handler is an arrow or function expression that ignores its parameter and whose body is empty
|
|
6
|
+
* or only gives back a constant (`() => null`, `() => undefined`, `() => ({})`, `() => []`, `() => {}`,
|
|
7
|
+
* `function () {}`), and a `catch` block that is empty, holds only a comment, or only assigns or returns a constant
|
|
8
|
+
* without reading the error. Handled, and not reported: anything that reads the error (logs, wraps or rethrows
|
|
9
|
+
* it), makes any call (a log, a cleanup, a fallback), throws, or reads another variable.
|
|
10
|
+
*
|
|
11
|
+
* It is not ESLint's `no-empty`: `no-empty` reports an empty block only, lets a block that holds a comment pass,
|
|
12
|
+
* and never sees `.catch(() => null)`. Both report `catch {}`, each with its own message. There is no fix: what to
|
|
13
|
+
* log is a decision. A deliberate silent catch carries an `eslint-disable-next-line` with its reason.
|
|
14
|
+
*/
|
|
15
|
+
export declare class NoSilentCatchRule {
|
|
16
|
+
static readonly NAME = "venizia/no-silent-catch";
|
|
17
|
+
static readonly RULE: Rule.RuleModule;
|
|
18
|
+
static build(opts?: {
|
|
19
|
+
severity?: TRuleSeverity;
|
|
20
|
+
}): TRuleSeverity;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=no-silent-catch.rule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-silent-catch.rule.d.ts","sourceRoot":"","sources":["../../../src/linters/house/no-silent-catch.rule.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAc,MAAM,QAAQ,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAsBrD;;;;;;;;;;;GAWG;AACH,qBAAa,iBAAiB;IAC5B,MAAM,CAAC,QAAQ,CAAC,IAAI,6BAA+C;IAEnE,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,UAAU,CAsEnC;IAEF,MAAM,CAAC,KAAK,CAAC,IAAI,GAAE;QAAE,QAAQ,CAAC,EAAE,aAAa,CAAA;KAAO,GAAG,aAAa;CAGrE"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NoSilentCatchRule = void 0;
|
|
4
|
+
const await_support_1 = require("./await-support");
|
|
5
|
+
const common_1 = require("./common");
|
|
6
|
+
const promise_chain_support_1 = require("./promise-chain-support");
|
|
7
|
+
/** Whether a parameter of `owner` (a function or a catch clause) is read or written anywhere. */
|
|
8
|
+
const isParameterUsed = (opts) => opts.sourceCode
|
|
9
|
+
.getDeclaredVariables(opts.owner)
|
|
10
|
+
.some((variable) => variable.defs.some((definition) => ['Parameter', 'CatchClause'].includes(definition.type)) && variable.references.length > 0);
|
|
11
|
+
/** A parameter that is not a plain name (`({ message }) =>`, `catch ({ message })`) reads the error by itself. */
|
|
12
|
+
const isPlainParameter = (opts) => opts.parameter === null ||
|
|
13
|
+
opts.parameter === undefined ||
|
|
14
|
+
common_1.AstNode.getType({ node: opts.parameter }) === 'Identifier';
|
|
15
|
+
/**
|
|
16
|
+
* `venizia/no-silent-catch`. A handled error leaves a trace (V-C-06). Reported: a `.catch(h)` (also `?.catch`,
|
|
17
|
+
* `['catch']`) whose handler is an arrow or function expression that ignores its parameter and whose body is empty
|
|
18
|
+
* or only gives back a constant (`() => null`, `() => undefined`, `() => ({})`, `() => []`, `() => {}`,
|
|
19
|
+
* `function () {}`), and a `catch` block that is empty, holds only a comment, or only assigns or returns a constant
|
|
20
|
+
* without reading the error. Handled, and not reported: anything that reads the error (logs, wraps or rethrows
|
|
21
|
+
* it), makes any call (a log, a cleanup, a fallback), throws, or reads another variable.
|
|
22
|
+
*
|
|
23
|
+
* It is not ESLint's `no-empty`: `no-empty` reports an empty block only, lets a block that holds a comment pass,
|
|
24
|
+
* and never sees `.catch(() => null)`. Both report `catch {}`, each with its own message. There is no fix: what to
|
|
25
|
+
* log is a decision. A deliberate silent catch carries an `eslint-disable-next-line` with its reason.
|
|
26
|
+
*/
|
|
27
|
+
class NoSilentCatchRule {
|
|
28
|
+
static { this.NAME = `${common_1.HOUSE_PLUGIN_NAMESPACE}/no-silent-catch`; }
|
|
29
|
+
static { this.RULE = {
|
|
30
|
+
meta: {
|
|
31
|
+
type: 'suggestion',
|
|
32
|
+
schema: [],
|
|
33
|
+
messages: {
|
|
34
|
+
silentHandler: 'This `.catch` handler swallows the error with no trace: log it, rethrow it or wrap it (V-C-06), or keep it with an `eslint-disable-next-line` and the reason.',
|
|
35
|
+
silentBlock: 'This `catch` block swallows the error with no trace: log it, rethrow it or wrap it (V-C-06), or keep it with an `eslint-disable-next-line` and the reason.',
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
create: (context) => {
|
|
39
|
+
const { sourceCode } = context;
|
|
40
|
+
return {
|
|
41
|
+
[common_1.AstNodeTypes.CALL_EXPRESSION]: (node) => {
|
|
42
|
+
if (promise_chain_support_1.PromiseChainSupport.chainMethodOf({ node }) !== 'catch') {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const args = common_1.AstNode.readField({ node, key: 'arguments' });
|
|
46
|
+
const handler = Array.isArray(args) ? args[0] : undefined;
|
|
47
|
+
const handlerType = common_1.AstNode.getType({ node: handler });
|
|
48
|
+
if (!await_support_1.AwaitSupport.isNode(handler) ||
|
|
49
|
+
(handlerType !== 'ArrowFunctionExpression' && handlerType !== 'FunctionExpression')) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const params = common_1.AstNode.readField({ node: handler, key: 'params' });
|
|
53
|
+
if (!Array.isArray(params) ||
|
|
54
|
+
!params.every((parameter) => isPlainParameter({ parameter })) ||
|
|
55
|
+
isParameterUsed({ owner: handler, sourceCode })) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const body = common_1.AstNode.readField({ node: handler, key: 'body' });
|
|
59
|
+
const isSilent = common_1.AstNode.getType({ node: body }) === 'BlockStatement'
|
|
60
|
+
? promise_chain_support_1.PromiseChainSupport.isSilentBlock({
|
|
61
|
+
statements: common_1.AstNode.readField({ node: body, key: 'body' }),
|
|
62
|
+
})
|
|
63
|
+
: promise_chain_support_1.PromiseChainSupport.isConstant({ node: body });
|
|
64
|
+
if (isSilent) {
|
|
65
|
+
context.report({ node: handler, messageId: 'silentHandler' });
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
[common_1.AstNodeTypes.CATCH_CLAUSE]: (node) => {
|
|
69
|
+
if (!isPlainParameter({ parameter: common_1.AstNode.readField({ node, key: 'param' }) }) ||
|
|
70
|
+
isParameterUsed({ owner: node, sourceCode })) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
const body = common_1.AstNode.readField({ node, key: 'body' });
|
|
74
|
+
if (promise_chain_support_1.PromiseChainSupport.isSilentBlock({
|
|
75
|
+
statements: common_1.AstNode.readField({ node: body, key: 'body' }),
|
|
76
|
+
})) {
|
|
77
|
+
context.report({ node, messageId: 'silentBlock' });
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
},
|
|
82
|
+
}; }
|
|
83
|
+
static build(opts = {}) {
|
|
84
|
+
return opts.severity ?? 'error';
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
exports.NoSilentCatchRule = NoSilentCatchRule;
|
|
88
|
+
//# sourceMappingURL=no-silent-catch.rule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-silent-catch.rule.js","sourceRoot":"","sources":["../../../src/linters/house/no-silent-catch.rule.ts"],"names":[],"mappings":";;;AAEA,mDAA+C;AAC/C,qCAAyE;AACzE,mEAA8D;AAE9D,iGAAiG;AACjG,MAAM,eAAe,GAAG,CAAC,IAAkD,EAAW,EAAE,CACtF,IAAI,CAAC,UAAU;KACZ,oBAAoB,CAAC,IAAI,CAAC,KAAK,CAAC;KAChC,IAAI,CACH,CAAC,QAAQ,EAAE,EAAE,CACX,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE,CAChC,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,CACvD,IAAI,QAAQ,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CACtC,CAAC;AAEN,kHAAkH;AAClH,MAAM,gBAAgB,GAAG,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AAC,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;oBACtD,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;;AA7EH,8CA8EC","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', 'CatchClause'].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 }) === '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: log it, rethrow it or wrap it (V-C-06), or keep it with an `eslint-disable-next-line` and the reason.',\n silentBlock:\n 'This `catch` block swallows the error with no trace: log it, rethrow it or wrap it (V-C-06), or keep it with an `eslint-disable-next-line` and the reason.',\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 if (\n !AwaitSupport.isNode(handler) ||\n (handlerType !== 'ArrowFunctionExpression' && handlerType !== 'FunctionExpression')\n ) {\n return;\n }\n\n const params = AstNode.readField({ node: handler, key: 'params' });\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 }) === 'BlockStatement'\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 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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../src/linters/house/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../src/linters/house/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAarC,qGAAqG;AACrG,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,MActC,CAAC"}
|
|
@@ -6,10 +6,12 @@ const const_class_values_rule_1 = require("./const-class-values.rule");
|
|
|
6
6
|
const effect_cleanup_consistency_rule_1 = require("./effect-cleanup-consistency.rule");
|
|
7
7
|
const max_params_own_rule_1 = require("./max-params-own.rule");
|
|
8
8
|
const no_async_hook_callback_rule_1 = require("./no-async-hook-callback.rule");
|
|
9
|
+
const no_await_promise_chain_rule_1 = require("./no-await-promise-chain.rule");
|
|
9
10
|
const no_inline_await_rule_1 = require("./no-inline-await.rule");
|
|
10
11
|
const no_leaked_render_rule_1 = require("./no-leaked-render.rule");
|
|
11
12
|
const no_new_error_rule_1 = require("./no-new-error.rule");
|
|
12
13
|
const no_return_await_rule_1 = require("./no-return-await.rule");
|
|
14
|
+
const no_silent_catch_rule_1 = require("./no-silent-catch.rule");
|
|
13
15
|
/** The ESLint plugin that carries the house rules oxlint cannot express, registered as `venizia`. */
|
|
14
16
|
exports.houseEslintPlugin = {
|
|
15
17
|
meta: { name: `eslint-plugin-${common_1.HOUSE_PLUGIN_NAMESPACE}` },
|
|
@@ -18,10 +20,12 @@ exports.houseEslintPlugin = {
|
|
|
18
20
|
'effect-cleanup-consistency': effect_cleanup_consistency_rule_1.EffectCleanupConsistencyRule.RULE,
|
|
19
21
|
'max-params-own': max_params_own_rule_1.MaxParamsOwnRule.RULE,
|
|
20
22
|
'no-async-hook-callback': no_async_hook_callback_rule_1.NoAsyncHookCallbackRule.RULE,
|
|
23
|
+
'no-await-promise-chain': no_await_promise_chain_rule_1.NoAwaitPromiseChainRule.RULE,
|
|
21
24
|
'no-inline-await': no_inline_await_rule_1.NoInlineAwaitRule.RULE,
|
|
22
25
|
'no-leaked-render': no_leaked_render_rule_1.NoLeakedRenderRule.RULE,
|
|
23
26
|
'no-new-error': no_new_error_rule_1.NoNewErrorRule.RULE,
|
|
24
27
|
'no-return-await': no_return_await_rule_1.NoReturnAwaitRule.RULE,
|
|
28
|
+
'no-silent-catch': no_silent_catch_rule_1.NoSilentCatchRule.RULE,
|
|
25
29
|
},
|
|
26
30
|
};
|
|
27
31
|
//# 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,iEAA2D;AAC3D,mEAA6D;AAC7D,2DAAqD;AACrD,iEAA2D;AAE3D,qGAAqG;AACxF,QAAA,iBAAiB,GAAkB;IAC9C,IAAI,EAAE,EAAE,IAAI,EAAE,iBAAiB,+BAAsB,EAAE,EAAE;IACzD,KAAK,EAAE;QACL,oBAAoB,EAAE,8CAAoB,CAAC,IAAI;QAC/C,4BAA4B,EAAE,8DAA4B,CAAC,IAAI;QAC/D,gBAAgB,EAAE,sCAAgB,CAAC,IAAI;QACvC,wBAAwB,EAAE,qDAAuB,CAAC,IAAI;QACtD,iBAAiB,EAAE,wCAAiB,CAAC,IAAI;QACzC,kBAAkB,EAAE,0CAAkB,CAAC,IAAI;QAC3C,cAAc,EAAE,kCAAc,CAAC,IAAI;QACnC,iBAAiB,EAAE,wCAAiB,CAAC,IAAI;KAC1C;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 { NoInlineAwaitRule } from './no-inline-await.rule';\nimport { NoLeakedRenderRule } from './no-leaked-render.rule';\nimport { NoNewErrorRule } from './no-new-error.rule';\nimport { NoReturnAwaitRule } from './no-return-await.rule';\n\n/** The ESLint plugin that carries the house rules oxlint cannot express, registered as `venizia`. */\nexport const houseEslintPlugin: ESLint.Plugin = {\n meta: { name: `eslint-plugin-${HOUSE_PLUGIN_NAMESPACE}` },\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-inline-await': NoInlineAwaitRule.RULE,\n 'no-leaked-render': NoLeakedRenderRule.RULE,\n 'no-new-error': NoNewErrorRule.RULE,\n 'no-return-await': NoReturnAwaitRule.RULE,\n },\n};\n"]}
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../../src/linters/house/plugin.ts"],"names":[],"mappings":";;;AACA,qCAAkD;AAClD,uEAAiE;AACjE,uFAAiF;AACjF,+DAAyD;AACzD,+EAAwE;AACxE,+EAAwE;AACxE,iEAA2D;AAC3D,mEAA6D;AAC7D,2DAAqD;AACrD,iEAA2D;AAC3D,iEAA2D;AAE3D,qGAAqG;AACxF,QAAA,iBAAiB,GAAkB;IAC9C,IAAI,EAAE,EAAE,IAAI,EAAE,iBAAiB,+BAAsB,EAAE,EAAE;IACzD,KAAK,EAAE;QACL,oBAAoB,EAAE,8CAAoB,CAAC,IAAI;QAC/C,4BAA4B,EAAE,8DAA4B,CAAC,IAAI;QAC/D,gBAAgB,EAAE,sCAAgB,CAAC,IAAI;QACvC,wBAAwB,EAAE,qDAAuB,CAAC,IAAI;QACtD,wBAAwB,EAAE,qDAAuB,CAAC,IAAI;QACtD,iBAAiB,EAAE,wCAAiB,CAAC,IAAI;QACzC,kBAAkB,EAAE,0CAAkB,CAAC,IAAI;QAC3C,cAAc,EAAE,kCAAc,CAAC,IAAI;QACnC,iBAAiB,EAAE,wCAAiB,CAAC,IAAI;QACzC,iBAAiB,EAAE,wCAAiB,CAAC,IAAI;KAC1C;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 { NoAwaitPromiseChainRule } from './no-await-promise-chain.rule';\nimport { NoInlineAwaitRule } from './no-inline-await.rule';\nimport { NoLeakedRenderRule } from './no-leaked-render.rule';\nimport { NoNewErrorRule } from './no-new-error.rule';\nimport { NoReturnAwaitRule } from './no-return-await.rule';\nimport { NoSilentCatchRule } from './no-silent-catch.rule';\n\n/** The ESLint plugin that carries the house rules oxlint cannot express, registered as `venizia`. */\nexport const houseEslintPlugin: ESLint.Plugin = {\n meta: { name: `eslint-plugin-${HOUSE_PLUGIN_NAMESPACE}` },\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-promise-chain': NoAwaitPromiseChainRule.RULE,\n 'no-inline-await': NoInlineAwaitRule.RULE,\n 'no-leaked-render': NoLeakedRenderRule.RULE,\n 'no-new-error': NoNewErrorRule.RULE,\n 'no-return-await': NoReturnAwaitRule.RULE,\n 'no-silent-catch': NoSilentCatchRule.RULE,\n },\n};\n"]}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/** The shared parts of the promise chain rules: what a chain call is, what a constant is, what a silent handler body is. */
|
|
2
|
+
export declare class PromiseChainSupport {
|
|
3
|
+
/** `node` without the wrappers that do not change its value (`!`, `as`, `satisfies`, `<T>`, an optional chain). */
|
|
4
|
+
static unwrap(opts: {
|
|
5
|
+
node: unknown;
|
|
6
|
+
}): unknown;
|
|
7
|
+
/** The name a member access reads: `a.name`, `a['name']`, ``a[`name`]``; `undefined` for a computed key. */
|
|
8
|
+
static memberName(opts: {
|
|
9
|
+
member: unknown;
|
|
10
|
+
}): string | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* `then`, `catch` or `finally` when `node` (after `unwrap`) is a call of that method - `p.then(f)`, `p?.catch(f)`,
|
|
13
|
+
* `p['finally'](f)` - and `undefined` for anything else. It reads the syntax only, so a thenable counts too.
|
|
14
|
+
*/
|
|
15
|
+
static chainMethodOf(opts: {
|
|
16
|
+
node: unknown;
|
|
17
|
+
}): string | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* Whether a chain call (`.then`, `.catch`, `.finally`) sits anywhere on the spine of `node`: the receivers and
|
|
20
|
+
* callees a call chain is built from (`a.then(f).limit(1)` has one, `a.where(x).limit(1)` has none).
|
|
21
|
+
*/
|
|
22
|
+
static hasChainOnSpine(opts: {
|
|
23
|
+
node: unknown;
|
|
24
|
+
}): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* A value that is the same every time and reads nothing: a literal, `undefined`, a template with no `${}`, `-1`,
|
|
27
|
+
* `void 0`, and an array or object literal built only from those (`[]`, `{}`, `{ items: [] }`).
|
|
28
|
+
*/
|
|
29
|
+
static isConstant(opts: {
|
|
30
|
+
node: unknown;
|
|
31
|
+
}): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Whether the statements of a handler or a `catch` block leave no trace of the error: none at all (a comment does
|
|
34
|
+
* not count), or only `return;`, `return <constant>;` and `<name or member> = <constant>;`. Anything else - a
|
|
35
|
+
* call, a `throw`, a read of a variable - is a decision someone made, and counts as handled.
|
|
36
|
+
*/
|
|
37
|
+
static isSilentBlock(opts: {
|
|
38
|
+
statements: unknown;
|
|
39
|
+
}): boolean;
|
|
40
|
+
/** `name`, `this.name`, `a.b.c`: an assignment target that reads no computed key and calls nothing. */
|
|
41
|
+
static isPlainTarget(opts: {
|
|
42
|
+
node: unknown;
|
|
43
|
+
}): boolean;
|
|
44
|
+
/** `node` without the type-only wrappers (`as`, `satisfies`, `!`, `<T>`), keeping an optional chain. */
|
|
45
|
+
static unwrapTypes(opts: {
|
|
46
|
+
node: unknown;
|
|
47
|
+
}): unknown;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=promise-chain-support.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"promise-chain-support.d.ts","sourceRoot":"","sources":["../../../src/linters/house/promise-chain-support.ts"],"names":[],"mappings":"AAaA,4HAA4H;AAC5H,qBAAa,mBAAmB;IAC9B,mHAAmH;IACnH,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO;IAU/C,4GAA4G;IAC5G,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE;QAAE,MAAM,EAAE,OAAO,CAAA;KAAE,GAAG,MAAM,GAAG,SAAS;IAgChE;;;OAGG;IACH,MAAM,CAAC,aAAa,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,OAAO,CAAA;KAAE,GAAG,MAAM,GAAG,SAAS;IAiBjE;;;OAGG;IACH,MAAM,CAAC,eAAe,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO;IA2BxD;;;OAGG;IACH,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO;IAiDnD;;;;OAIG;IACH,MAAM,CAAC,aAAa,CAAC,IAAI,EAAE;QAAE,UAAU,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO;IAiC5D,uGAAuG;IACvG,MAAM,CAAC,aAAa,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO;IAetD,wGAAwG;IACxG,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO;CAYrD"}
|