@checkdigit/eslint-plugin 6.6.0-PR.75-4a28 → 6.6.0-PR.75-aede
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/dist-cjs/index.cjs +934 -759
- package/dist-cjs/metafile.json +43 -9
- package/dist-mjs/agent/agent-test-wiring.mjs +172 -0
- package/dist-mjs/index.mjs +12 -3
- package/dist-types/agent/agent-test-wiring.d.ts +4 -0
- package/dist-types/index.d.ts +22 -2
- package/package.json +1 -1
- package/src/agent/agent-test-wiring.ts +204 -0
- package/src/index.ts +9 -0
package/dist-cjs/metafile.json
CHANGED
|
@@ -12208,6 +12208,27 @@
|
|
|
12208
12208
|
],
|
|
12209
12209
|
"format": "esm"
|
|
12210
12210
|
},
|
|
12211
|
+
"src/agent/agent-test-wiring.ts": {
|
|
12212
|
+
"bytes": 8619,
|
|
12213
|
+
"imports": [
|
|
12214
|
+
{
|
|
12215
|
+
"path": "node_modules/@typescript-eslint/utils/dist/index.js",
|
|
12216
|
+
"kind": "import-statement",
|
|
12217
|
+
"original": "@typescript-eslint/utils"
|
|
12218
|
+
},
|
|
12219
|
+
{
|
|
12220
|
+
"path": "node:assert",
|
|
12221
|
+
"kind": "import-statement",
|
|
12222
|
+
"external": true
|
|
12223
|
+
},
|
|
12224
|
+
{
|
|
12225
|
+
"path": "src/get-documentation-url.ts",
|
|
12226
|
+
"kind": "import-statement",
|
|
12227
|
+
"original": "../get-documentation-url"
|
|
12228
|
+
}
|
|
12229
|
+
],
|
|
12230
|
+
"format": "esm"
|
|
12231
|
+
},
|
|
12211
12232
|
"src/agent/fetch-response-body-json.ts": {
|
|
12212
12233
|
"bytes": 2631,
|
|
12213
12234
|
"imports": [
|
|
@@ -12751,13 +12772,18 @@
|
|
|
12751
12772
|
"format": "esm"
|
|
12752
12773
|
},
|
|
12753
12774
|
"src/index.ts": {
|
|
12754
|
-
"bytes":
|
|
12775
|
+
"bytes": 8901,
|
|
12755
12776
|
"imports": [
|
|
12756
12777
|
{
|
|
12757
12778
|
"path": "src/agent/add-url-domain.ts",
|
|
12758
12779
|
"kind": "import-statement",
|
|
12759
12780
|
"original": "./agent/add-url-domain"
|
|
12760
12781
|
},
|
|
12782
|
+
{
|
|
12783
|
+
"path": "src/agent/agent-test-wiring.ts",
|
|
12784
|
+
"kind": "import-statement",
|
|
12785
|
+
"original": "./agent/agent-test-wiring"
|
|
12786
|
+
},
|
|
12761
12787
|
{
|
|
12762
12788
|
"path": "src/agent/fetch-response-body-json.ts",
|
|
12763
12789
|
"kind": "import-statement",
|
|
@@ -13450,6 +13476,11 @@
|
|
|
13450
13476
|
"kind": "require-call",
|
|
13451
13477
|
"external": true
|
|
13452
13478
|
},
|
|
13479
|
+
{
|
|
13480
|
+
"path": "node:assert",
|
|
13481
|
+
"kind": "require-call",
|
|
13482
|
+
"external": true
|
|
13483
|
+
},
|
|
13453
13484
|
{
|
|
13454
13485
|
"path": "node:assert",
|
|
13455
13486
|
"kind": "require-call",
|
|
@@ -13490,7 +13521,7 @@
|
|
|
13490
13521
|
"bytesInOutput": 507
|
|
13491
13522
|
},
|
|
13492
13523
|
"node_modules/@typescript-eslint/types/dist/generated/ast-spec.js": {
|
|
13493
|
-
"bytesInOutput":
|
|
13524
|
+
"bytesInOutput": 11922
|
|
13494
13525
|
},
|
|
13495
13526
|
"node_modules/@typescript-eslint/types/dist/lib.js": {
|
|
13496
13527
|
"bytesInOutput": 189
|
|
@@ -15707,7 +15738,7 @@
|
|
|
15707
15738
|
"bytesInOutput": 2219
|
|
15708
15739
|
},
|
|
15709
15740
|
"src/index.ts": {
|
|
15710
|
-
"bytesInOutput":
|
|
15741
|
+
"bytesInOutput": 5418
|
|
15711
15742
|
},
|
|
15712
15743
|
"src/agent/url.ts": {
|
|
15713
15744
|
"bytesInOutput": 745
|
|
@@ -15721,6 +15752,9 @@
|
|
|
15721
15752
|
"src/agent/add-url-domain.ts": {
|
|
15722
15753
|
"bytesInOutput": 1915
|
|
15723
15754
|
},
|
|
15755
|
+
"src/agent/agent-test-wiring.ts": {
|
|
15756
|
+
"bytesInOutput": 7629
|
|
15757
|
+
},
|
|
15724
15758
|
"src/agent/fetch-response-body-json.ts": {
|
|
15725
15759
|
"bytesInOutput": 2311
|
|
15726
15760
|
},
|
|
@@ -15734,7 +15768,7 @@
|
|
|
15734
15768
|
"bytesInOutput": 1206
|
|
15735
15769
|
},
|
|
15736
15770
|
"src/library/format.ts": {
|
|
15737
|
-
"bytesInOutput":
|
|
15771
|
+
"bytesInOutput": 383
|
|
15738
15772
|
},
|
|
15739
15773
|
"src/library/variable.ts": {
|
|
15740
15774
|
"bytesInOutput": 118
|
|
@@ -15761,10 +15795,10 @@
|
|
|
15761
15795
|
"bytesInOutput": 2095
|
|
15762
15796
|
},
|
|
15763
15797
|
"src/agent/no-full-response.ts": {
|
|
15764
|
-
"bytesInOutput":
|
|
15798
|
+
"bytesInOutput": 2009
|
|
15765
15799
|
},
|
|
15766
15800
|
"src/agent/no-mapped-response.ts": {
|
|
15767
|
-
"bytesInOutput":
|
|
15801
|
+
"bytesInOutput": 2425
|
|
15768
15802
|
},
|
|
15769
15803
|
"src/no-promise-instance-method.ts": {
|
|
15770
15804
|
"bytesInOutput": 1277
|
|
@@ -15773,10 +15807,10 @@
|
|
|
15773
15807
|
"bytesInOutput": 8944
|
|
15774
15808
|
},
|
|
15775
15809
|
"src/agent/no-status-code.ts": {
|
|
15776
|
-
"bytesInOutput":
|
|
15810
|
+
"bytesInOutput": 2044
|
|
15777
15811
|
},
|
|
15778
15812
|
"src/agent/no-unused-function-argument.ts": {
|
|
15779
|
-
"bytesInOutput":
|
|
15813
|
+
"bytesInOutput": 2869
|
|
15780
15814
|
},
|
|
15781
15815
|
"src/agent/no-unused-imports.ts": {
|
|
15782
15816
|
"bytesInOutput": 3007
|
|
@@ -15821,7 +15855,7 @@
|
|
|
15821
15855
|
"bytesInOutput": 3362
|
|
15822
15856
|
}
|
|
15823
15857
|
},
|
|
15824
|
-
"bytes":
|
|
15858
|
+
"bytes": 4386803
|
|
15825
15859
|
}
|
|
15826
15860
|
}
|
|
15827
15861
|
}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
// src/agent/agent-test-wiring.ts
|
|
2
|
+
import { AST_TOKEN_TYPES, ESLintUtils, TSESTree } from "@typescript-eslint/utils";
|
|
3
|
+
import { strict as assert } from "node:assert";
|
|
4
|
+
import getDocumentationUrl from "../get-documentation-url.mjs";
|
|
5
|
+
var ruleId = "agent-test-wiring";
|
|
6
|
+
var createRule = ESLintUtils.RuleCreator((name) => getDocumentationUrl(name));
|
|
7
|
+
var rule = createRule({
|
|
8
|
+
name: ruleId,
|
|
9
|
+
meta: {
|
|
10
|
+
type: "suggestion",
|
|
11
|
+
docs: {
|
|
12
|
+
description: "Update test wiring."
|
|
13
|
+
},
|
|
14
|
+
messages: {
|
|
15
|
+
updateTestWiring: "Updating test wiring.",
|
|
16
|
+
unknownError: 'Unknown error occurred in file "{{fileName}}": {{ error }}.'
|
|
17
|
+
},
|
|
18
|
+
fixable: "code",
|
|
19
|
+
schema: []
|
|
20
|
+
},
|
|
21
|
+
defaultOptions: [],
|
|
22
|
+
create(context) {
|
|
23
|
+
const sourceCode = context.sourceCode;
|
|
24
|
+
const importDeclarations = /* @__PURE__ */ new Map();
|
|
25
|
+
let beforeAllCallExpression;
|
|
26
|
+
let afterAllCallExpression;
|
|
27
|
+
return {
|
|
28
|
+
ImportDeclaration(importDeclaration) {
|
|
29
|
+
const moduleName = importDeclaration.source.value;
|
|
30
|
+
importDeclarations.set(moduleName, importDeclaration);
|
|
31
|
+
},
|
|
32
|
+
'CallExpression[callee.name="beforeAll"]': (callExpression) => {
|
|
33
|
+
beforeAllCallExpression = callExpression;
|
|
34
|
+
},
|
|
35
|
+
'CallExpression[callee.name="afterAll"]': (callExpression) => {
|
|
36
|
+
afterAllCallExpression = callExpression;
|
|
37
|
+
},
|
|
38
|
+
"Program:exit"(program) {
|
|
39
|
+
try {
|
|
40
|
+
let jestImportFixer;
|
|
41
|
+
let agentImportFixer;
|
|
42
|
+
let fixturePluginImportFixer;
|
|
43
|
+
let agentDeclarationFixer;
|
|
44
|
+
let beforeAllFixer;
|
|
45
|
+
let afterAllFixer;
|
|
46
|
+
const lastImportDeclaration = [...importDeclarations.values()].at(-1);
|
|
47
|
+
assert.ok(lastImportDeclaration);
|
|
48
|
+
const jestImportDeclaration = importDeclarations.get("@jest/globals");
|
|
49
|
+
if (jestImportDeclaration && !jestImportDeclaration.specifiers.some(
|
|
50
|
+
(specifier) => specifier.type === TSESTree.AST_NODE_TYPES.ImportSpecifier && specifier.imported.name === "afterAll"
|
|
51
|
+
)) {
|
|
52
|
+
const firstImportSpecifier = jestImportDeclaration.specifiers[0];
|
|
53
|
+
assert.ok(firstImportSpecifier);
|
|
54
|
+
jestImportFixer = (fixer) => fixer.insertTextBefore(firstImportSpecifier, "afterAll, ");
|
|
55
|
+
}
|
|
56
|
+
const agentImportDeclaration = importDeclarations.get("@checkdigit/agent");
|
|
57
|
+
if (!agentImportDeclaration) {
|
|
58
|
+
agentImportFixer = (fixer) => fixer.insertTextAfter(
|
|
59
|
+
lastImportDeclaration,
|
|
60
|
+
`
|
|
61
|
+
import createAgent, { type Agent } from '@checkdigit/agent';`
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
const fixturePluginImportDeclaration = importDeclarations.get("../../plugin/fixture.test");
|
|
65
|
+
if (!fixturePluginImportDeclaration) {
|
|
66
|
+
fixturePluginImportFixer = (fixer) => fixer.insertTextAfter(lastImportDeclaration, `
|
|
67
|
+
import fixturePlugin from '../../plugin/fixture.test';`);
|
|
68
|
+
}
|
|
69
|
+
if (beforeAllCallExpression !== void 0) {
|
|
70
|
+
const beforeAllArrowFunctionExpression = beforeAllCallExpression.arguments[0];
|
|
71
|
+
assert.ok(
|
|
72
|
+
beforeAllArrowFunctionExpression !== void 0 && beforeAllArrowFunctionExpression.type === TSESTree.AST_NODE_TYPES.ArrowFunctionExpression
|
|
73
|
+
);
|
|
74
|
+
const arrowFunctionBody = beforeAllArrowFunctionExpression.body;
|
|
75
|
+
assert.ok(arrowFunctionBody.type === TSESTree.AST_NODE_TYPES.BlockStatement);
|
|
76
|
+
const targetStatement = arrowFunctionBody.body.find(
|
|
77
|
+
(statement) => sourceCode.getText(statement) === "await fixture.reset();"
|
|
78
|
+
);
|
|
79
|
+
if (targetStatement !== void 0) {
|
|
80
|
+
const beforeAllBodyText = sourceCode.getText(arrowFunctionBody);
|
|
81
|
+
if (!beforeAllBodyText.includes("agent = await createAgent();")) {
|
|
82
|
+
beforeAllFixer = (fixer) => fixer.replaceText(
|
|
83
|
+
targetStatement,
|
|
84
|
+
[
|
|
85
|
+
"agent = await createAgent();",
|
|
86
|
+
"agent.register(await fixturePlugin(fixture));",
|
|
87
|
+
"agent.enable();",
|
|
88
|
+
"await fixture.reset();"
|
|
89
|
+
].join("\n")
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
if (!beforeAllBodyText.includes("let agent: Agent;")) {
|
|
93
|
+
agentDeclarationFixer = (fixer) => (
|
|
94
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
95
|
+
fixer.insertTextBefore(beforeAllCallExpression, "let agent: Agent;\n")
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
if (afterAllCallExpression !== void 0) {
|
|
101
|
+
const afterAllArrowFunctionExpression = afterAllCallExpression.arguments[0];
|
|
102
|
+
assert.ok(
|
|
103
|
+
afterAllArrowFunctionExpression !== void 0 && afterAllArrowFunctionExpression.type === TSESTree.AST_NODE_TYPES.ArrowFunctionExpression
|
|
104
|
+
);
|
|
105
|
+
const arrowFunctionBody = afterAllArrowFunctionExpression.body;
|
|
106
|
+
assert.ok(arrowFunctionBody.type === TSESTree.AST_NODE_TYPES.BlockStatement);
|
|
107
|
+
const afterAllBodyText = sourceCode.getText(arrowFunctionBody);
|
|
108
|
+
if (!afterAllBodyText.includes("await agent[Symbol.asyncDispose]();")) {
|
|
109
|
+
const lastStatement = arrowFunctionBody.body.at(-1);
|
|
110
|
+
assert.ok(lastStatement);
|
|
111
|
+
afterAllFixer = (fixer) => fixer.insertTextAfter(lastStatement, "await agent[Symbol.asyncDispose]();");
|
|
112
|
+
}
|
|
113
|
+
} else if (beforeAllCallExpression !== void 0) {
|
|
114
|
+
const nextToken = sourceCode.getTokenAfter(beforeAllCallExpression);
|
|
115
|
+
afterAllFixer = (fixer) => fixer.insertTextAfter(
|
|
116
|
+
nextToken !== null && nextToken.type === AST_TOKEN_TYPES.Punctuator ? nextToken : (
|
|
117
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
118
|
+
beforeAllCallExpression
|
|
119
|
+
),
|
|
120
|
+
`
|
|
121
|
+
afterAll(async () => {
|
|
122
|
+
await agent[Symbol.asyncDispose]();
|
|
123
|
+
});`
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
if (jestImportFixer !== void 0 || agentImportFixer !== void 0 || fixturePluginImportFixer !== void 0 || agentDeclarationFixer !== void 0 || beforeAllFixer !== void 0 || afterAllFixer !== void 0) {
|
|
127
|
+
context.report({
|
|
128
|
+
messageId: "updateTestWiring",
|
|
129
|
+
node: program,
|
|
130
|
+
*fix(fixer) {
|
|
131
|
+
if (jestImportFixer !== void 0) {
|
|
132
|
+
yield jestImportFixer(fixer);
|
|
133
|
+
}
|
|
134
|
+
if (agentImportFixer !== void 0) {
|
|
135
|
+
yield agentImportFixer(fixer);
|
|
136
|
+
}
|
|
137
|
+
if (fixturePluginImportFixer !== void 0) {
|
|
138
|
+
yield fixturePluginImportFixer(fixer);
|
|
139
|
+
}
|
|
140
|
+
if (agentDeclarationFixer !== void 0) {
|
|
141
|
+
yield agentDeclarationFixer(fixer);
|
|
142
|
+
}
|
|
143
|
+
if (beforeAllFixer !== void 0) {
|
|
144
|
+
yield beforeAllFixer(fixer);
|
|
145
|
+
}
|
|
146
|
+
if (afterAllFixer !== void 0) {
|
|
147
|
+
yield afterAllFixer(fixer);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
} catch (error) {
|
|
153
|
+
console.error(`Failed to apply ${ruleId} rule for file "${context.filename}":`, error);
|
|
154
|
+
context.report({
|
|
155
|
+
node: program,
|
|
156
|
+
messageId: "unknownError",
|
|
157
|
+
data: {
|
|
158
|
+
fileName: context.filename,
|
|
159
|
+
error: error instanceof Error ? error.toString() : JSON.stringify(error)
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
var agent_test_wiring_default = rule;
|
|
168
|
+
export {
|
|
169
|
+
agent_test_wiring_default as default,
|
|
170
|
+
ruleId
|
|
171
|
+
};
|
|
172
|
+
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiLi4vLi4vc3JjL2FnZW50L2FnZW50LXRlc3Qtd2lyaW5nLnRzIl0sCiAgIm1hcHBpbmdzIjogIjtBQVFBLFNBQVMsaUJBQWlCLGFBQWEsZ0JBQWdCO0FBRXZELFNBQVMsVUFBVSxjQUFjO0FBQ2pDLE9BQU8seUJBQXlCO0FBRXpCLElBQU0sU0FBUztBQUV0QixJQUFNLGFBQWEsWUFBWSxZQUFZLENBQUMsU0FBUyxvQkFBb0IsSUFBSSxDQUFDO0FBRTlFLElBQU0sT0FBTyxXQUFXO0FBQUEsRUFDdEIsTUFBTTtBQUFBLEVBQ04sTUFBTTtBQUFBLElBQ0osTUFBTTtBQUFBLElBQ04sTUFBTTtBQUFBLE1BQ0osYUFBYTtBQUFBLElBQ2Y7QUFBQSxJQUNBLFVBQVU7QUFBQSxNQUNSLGtCQUFrQjtBQUFBLE1BQ2xCLGNBQWM7QUFBQSxJQUNoQjtBQUFBLElBQ0EsU0FBUztBQUFBLElBQ1QsUUFBUSxDQUF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0YsQ0FBQztBQUVELElBQU8sNEJBQVE7IiwKICAibmFtZXMiOiBbXQp9Cg==
|
package/dist-mjs/index.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
2
|
import addUrlDomain, { ruleId as addUrlDomainRuleId } from "./agent/add-url-domain.mjs";
|
|
3
|
+
import agentTestWiring, { ruleId as agentTestWiringRuleId } from "./agent/agent-test-wiring.mjs";
|
|
3
4
|
import fetchResponseBodyJson, { ruleId as fetchResponseBodyJsonRuleId } from "./agent/fetch-response-body-json.mjs";
|
|
4
5
|
import fetchResponseHeaderGetter, {
|
|
5
6
|
ruleId as fetchResponseHeaderGetterRuleId
|
|
@@ -68,7 +69,8 @@ var src_default = {
|
|
|
68
69
|
[noUnusedFunctionArgumentsRuleId]: noUnusedFunctionArguments,
|
|
69
70
|
[noUnusedServiceVariablesRuleId]: noUnusedServiceVariables,
|
|
70
71
|
[noUnusedImportsRuleId]: noUnusedImports,
|
|
71
|
-
[fixFunctionCallArgumentsRuleId]: fixFunctionCallArguments
|
|
72
|
+
[fixFunctionCallArgumentsRuleId]: fixFunctionCallArguments,
|
|
73
|
+
[agentTestWiringRuleId]: agentTestWiring
|
|
72
74
|
},
|
|
73
75
|
configs: {
|
|
74
76
|
all: {
|
|
@@ -101,7 +103,8 @@ var src_default = {
|
|
|
101
103
|
[`@checkdigit/${noUnusedFunctionArgumentsRuleId}`]: "off",
|
|
102
104
|
[`@checkdigit/${noUnusedServiceVariablesRuleId}`]: "off",
|
|
103
105
|
[`@checkdigit/${noUnusedImportsRuleId}`]: "off",
|
|
104
|
-
[`@checkdigit/${fixFunctionCallArgumentsRuleId}`]: "off"
|
|
106
|
+
[`@checkdigit/${fixFunctionCallArgumentsRuleId}`]: "off",
|
|
107
|
+
[`@checkdigit/${agentTestWiringRuleId}`]: "off"
|
|
105
108
|
// --- agent rules END ---
|
|
106
109
|
}
|
|
107
110
|
},
|
|
@@ -138,6 +141,12 @@ var src_default = {
|
|
|
138
141
|
[`@checkdigit/${noUnusedImportsRuleId}`]: "error",
|
|
139
142
|
[`@checkdigit/${fixFunctionCallArgumentsRuleId}`]: "error"
|
|
140
143
|
}
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
files: ["*.spec.ts"],
|
|
147
|
+
rules: {
|
|
148
|
+
[`@checkdigit/${agentTestWiringRuleId}`]: "error"
|
|
149
|
+
}
|
|
141
150
|
}
|
|
142
151
|
]
|
|
143
152
|
},
|
|
@@ -168,4 +177,4 @@ var src_default = {
|
|
|
168
177
|
export {
|
|
169
178
|
src_default as default
|
|
170
179
|
};
|
|
171
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
180
|
+
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiLi4vc3JjL2luZGV4LnRzIl0sCiAgIm1hcHBpbmdzIjogIjtBQVFBLE9BQU8sZ0JBQWdCLFVBQVUsMEJBQTBCO0FBQzNELE9BQU8sbUJBQW1CLFVBQVUsNkJBQTZCO0FBQ2pFLE9BQU8seUJBQXlCLFVBQVUsbUNBQW1DO0FBQzdFLE9BQU87QUFBQSxFQUNMLFVBQVU7QUFBQSxPQUNMO0FBQ1AsT0FBTyxhQUFhLFVBQVUsdUJBQXVCO0FBQ3JELE9BQU87QUFBQSxFQUNMLFVBQVU7QUFBQSxPQUNMO0FBQ1AsT0FBTyx3QkFBd0IsVUFBVSxrQ0FBa0M7QUFDM0UsT0FBTyx1QkFBdUIsVUFBVSxpQ0FBaUM7QUFDekUsT0FBTyxhQUFhLFVBQVUsdUJBQXVCO0FBQ3JELE9BQU8sa0JBQWtCLFVBQVUsNEJBQTRCO0FBQy9ELE9BQU8sb0JBQW9CLFVBQVUsOEJBQThCO0FBQ25FLE9BQU8sMkJBQTJCLFVBQVUscUNBQXFDO0FBQ2pGLE9BQU8sb0JBQW9CLFVBQVUsOEJBQThCO0FBQ25FLE9BQU8sZ0JBQWdCLFVBQVUsMEJ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BQ0EsNEJBQTRCO0FBQUEsTUFDMUIsV0FBVztBQUFBLFFBQ1Q7QUFBQSxVQUNFLE9BQU8sQ0FBQyxNQUFNO0FBQUEsVUFDZCxlQUFlLENBQUMsYUFBYSxXQUFXO0FBQUEsVUFDeEMsT0FBTztBQUFBLFlBQ0wsQ0FBQyxlQUFlLHNCQUFzQixFQUFFLEdBQUc7QUFBQSxZQUMzQyxDQUFDLGVBQWUsa0JBQWtCLEVBQUUsR0FBRztBQUFBLFlBQ3ZDLENBQUMsZUFBZSxlQUFlLEVBQUUsR0FBRztBQUFBLFlBQ3BDLENBQUMsZUFBZSxzQkFBc0IsRUFBRSxHQUFHO0FBQUEsWUFDM0MsQ0FBQyxlQUFlLGtCQUFrQixFQUFFLEdBQUc7QUFBQSxZQUN2QyxDQUFDLGVBQWUsMkJBQTJCLEVBQUUsR0FBRztBQUFBLFlBQ2hELENBQUMsZUFBZSwrQkFBK0IsRUFBRSxHQUFHO0FBQUEsWUFDcEQsQ0FBQyxlQUFlLGVBQWUsRUFBRSxHQUFHO0FBQUEsWUFDcEMsQ0FBQyxlQUFlLCtCQUErQixFQUFFLEdBQUc7QUFBQSxZQUNwRCxDQUFDLGVBQWUsOEJBQThCLEVBQUUsR0FBRztBQUFBLFlBQ25ELENBQUMsZUFBZSxxQkFBcUIsRUFBRSxHQUFHO0FBQUEsWUFDMUMsQ0FBQyxlQUFlLDhCQUE4QixFQUFFLEdBQUc7QUFBQSxVQUNyRDtBQUFBLFFBQ0Y7QUFBQSxNQUNGO0FBQUEsSUFDRjtBQUFBLEVBQ0Y7QUFDRjsiLAogICJuYW1lcyI6IFtdCn0K
|
package/dist-types/index.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ declare const _default: {
|
|
|
30
30
|
"fix-function-call-arguments": import("@typescript-eslint/utils/ts-eslint").RuleModule<"unknownError" | "removeIncompatibleFunctionArguments", {
|
|
31
31
|
typesToCheck: string[];
|
|
32
32
|
}[], import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
33
|
+
"agent-test-wiring": import("@typescript-eslint/utils/ts-eslint").RuleModule<"unknownError" | "updateTestWiring", never[], import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
33
34
|
};
|
|
34
35
|
configs: {
|
|
35
36
|
all: {
|
|
@@ -62,6 +63,7 @@ declare const _default: {
|
|
|
62
63
|
"@checkdigit/no-unused-service-variable": string;
|
|
63
64
|
"@checkdigit/no-unused-imports": string;
|
|
64
65
|
"@checkdigit/fix-function-call-arguments": string;
|
|
66
|
+
"@checkdigit/agent-test-wiring": string;
|
|
65
67
|
};
|
|
66
68
|
};
|
|
67
69
|
recommended: {
|
|
@@ -80,7 +82,7 @@ declare const _default: {
|
|
|
80
82
|
};
|
|
81
83
|
};
|
|
82
84
|
'agent-phase-1-test': {
|
|
83
|
-
overrides: {
|
|
85
|
+
overrides: ({
|
|
84
86
|
files: string[];
|
|
85
87
|
rules: {
|
|
86
88
|
"@checkdigit/no-mapped-response": string;
|
|
@@ -95,8 +97,26 @@ declare const _default: {
|
|
|
95
97
|
"@checkdigit/no-unused-service-variable": string;
|
|
96
98
|
"@checkdigit/no-unused-imports": string;
|
|
97
99
|
"@checkdigit/fix-function-call-arguments": string;
|
|
100
|
+
"@checkdigit/agent-test-wiring"?: never;
|
|
98
101
|
};
|
|
99
|
-
}
|
|
102
|
+
} | {
|
|
103
|
+
files: string[];
|
|
104
|
+
rules: {
|
|
105
|
+
"@checkdigit/agent-test-wiring": string;
|
|
106
|
+
"@checkdigit/no-mapped-response"?: never;
|
|
107
|
+
"@checkdigit/add-url-domain"?: never;
|
|
108
|
+
"@checkdigit/no-fixture"?: never;
|
|
109
|
+
"@checkdigit/no-service-wrapper"?: never;
|
|
110
|
+
"@checkdigit/no-status-code"?: never;
|
|
111
|
+
"@checkdigit/fetch-response-body-json"?: never;
|
|
112
|
+
"@checkdigit/fetch-response-header-getter-ts"?: never;
|
|
113
|
+
"@checkdigit/fetch-then"?: never;
|
|
114
|
+
"@checkdigit/no-unused-function-argument"?: never;
|
|
115
|
+
"@checkdigit/no-unused-service-variable"?: never;
|
|
116
|
+
"@checkdigit/no-unused-imports"?: never;
|
|
117
|
+
"@checkdigit/fix-function-call-arguments"?: never;
|
|
118
|
+
};
|
|
119
|
+
})[];
|
|
100
120
|
};
|
|
101
121
|
'agent-phase-2-production': {
|
|
102
122
|
overrides: {
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@checkdigit/eslint-plugin","version":"6.6.0-PR.75-
|
|
1
|
+
{"name":"@checkdigit/eslint-plugin","version":"6.6.0-PR.75-aede","description":"Check Digit eslint plugins","keywords":["eslint","eslintplugin"],"homepage":"https://github.com/checkdigit/eslint-plugin#readme","bugs":{"url":"https://github.com/checkdigit/eslint-plugin/issues"},"repository":{"type":"git","url":"https://github.com/checkdigit/eslint-plugin"},"license":"MIT","author":"Check Digit, LLC","sideEffects":false,"type":"module","exports":{".":{"types":"./dist-types/index.d.ts","require":"./dist-cjs/index.cjs","import":"./dist-mjs/index.mjs","default":"./dist-mjs/index.mjs"}},"files":["src","dist-types","dist-cjs","dist-mjs","!src/**/*.test.ts","!src/**/*.spec.ts","!dist-types/**/*.test.d.ts","!dist-types/**/*.spec.d.ts","!dist-cjs/**/*.test.cjs","!dist-cjs/**/*.spec.cjs","!dist-mjs/**/*.test.mjs","!dist-mjs/**/*.spec.mjs","SECURITY.md"],"scripts":{"build:dist-cjs":"rimraf dist-cjs && npx builder --type=commonjs --sourceMap --entryPoint=index.ts --outDir=dist-cjs --outFile=index.cjs --external=espree && echo \"module.exports = module.exports.default;\" >> dist-cjs/index.cjs","build:dist-mjs":"rimraf dist-mjs && npx builder --type=module --sourceMap --outDir=dist-mjs && node dist-mjs/index.mjs","build:dist-types":"rimraf dist-types && npx builder --type=types --outDir=dist-types","ci:compile":"tsc --noEmit","ci:coverage":"NODE_OPTIONS=\"--disable-warning ExperimentalWarning --experimental-vm-modules\" jest --coverage=true","ci:lint":"npm run lint","ci:style":"npm run prettier","ci:test":"NODE_OPTIONS=\"--disable-warning ExperimentalWarning --experimental-vm-modules\" jest --coverage=false","lint":"eslint --max-warnings 0 --ignore-path .gitignore .","lint:fix":"eslint --ignore-path .gitignore . --fix","prepublishOnly":"npm run build:dist-types && npm run build:dist-cjs && npm run build:dist-mjs","prettier":"prettier --ignore-path .gitignore --list-different .","prettier:fix":"prettier --ignore-path .gitignore --write .","test":"npm run ci:compile && npm run ci:test && npm run ci:lint && npm run ci:style"},"prettier":"@checkdigit/prettier-config","jest":{"preset":"@checkdigit/jest-config"},"dependencies":{"@typescript-eslint/type-utils":"7.18.0","@typescript-eslint/utils":"7.18.0","debug":"^4.3.7","ts-api-utils":"^1.3.0"},"devDependencies":{"@checkdigit/jest-config":"^6.0.2","@checkdigit/prettier-config":"^5.5.0","@checkdigit/typescript-config":"6.0.0","@types/debug":"^4.1.12","@types/eslint":"8.56.10","@typescript-eslint/eslint-plugin":"7.18.0","@typescript-eslint/parser":"7.18.0","@typescript-eslint/rule-tester":"7.18.0","eslint-config-prettier":"^9.1.0","eslint-plugin-eslint-plugin":"^6.2.0","eslint-plugin-import":"^2.29.1","eslint-plugin-no-only-tests":"^3.1.0","eslint-plugin-no-secrets":"^1.0.2","eslint-plugin-node":"^11.1.0","eslint-plugin-sonarjs":"0.24.0","http-status-codes":"^2.3.0"},"peerDependencies":{"eslint":">=8 <9"},"engines":{"node":">=20.14"}}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
// agent/agent-test-wiring.ts
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Copyright (c) 2021-2024 Check Digit, LLC
|
|
5
|
+
*
|
|
6
|
+
* This code is licensed under the MIT license (see LICENSE.txt for details).
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { AST_TOKEN_TYPES, ESLintUtils, TSESTree } from '@typescript-eslint/utils';
|
|
10
|
+
import type { RuleFix, RuleFixer } from '@typescript-eslint/utils/ts-eslint';
|
|
11
|
+
import { strict as assert } from 'node:assert';
|
|
12
|
+
import getDocumentationUrl from '../get-documentation-url';
|
|
13
|
+
|
|
14
|
+
export const ruleId = 'agent-test-wiring';
|
|
15
|
+
|
|
16
|
+
const createRule = ESLintUtils.RuleCreator((name) => getDocumentationUrl(name));
|
|
17
|
+
|
|
18
|
+
const rule = createRule({
|
|
19
|
+
name: ruleId,
|
|
20
|
+
meta: {
|
|
21
|
+
type: 'suggestion',
|
|
22
|
+
docs: {
|
|
23
|
+
description: 'Update test wiring.',
|
|
24
|
+
},
|
|
25
|
+
messages: {
|
|
26
|
+
updateTestWiring: 'Updating test wiring.',
|
|
27
|
+
unknownError: 'Unknown error occurred in file "{{fileName}}": {{ error }}.',
|
|
28
|
+
},
|
|
29
|
+
fixable: 'code',
|
|
30
|
+
schema: [],
|
|
31
|
+
},
|
|
32
|
+
defaultOptions: [],
|
|
33
|
+
create(context) {
|
|
34
|
+
const sourceCode = context.sourceCode;
|
|
35
|
+
const importDeclarations = new Map<string, TSESTree.ImportDeclaration>();
|
|
36
|
+
let beforeAllCallExpression: TSESTree.CallExpression | undefined;
|
|
37
|
+
let afterAllCallExpression: TSESTree.CallExpression | undefined;
|
|
38
|
+
|
|
39
|
+
return {
|
|
40
|
+
ImportDeclaration(importDeclaration) {
|
|
41
|
+
const moduleName = importDeclaration.source.value;
|
|
42
|
+
importDeclarations.set(moduleName, importDeclaration);
|
|
43
|
+
},
|
|
44
|
+
'CallExpression[callee.name="beforeAll"]': (callExpression: TSESTree.CallExpression) => {
|
|
45
|
+
beforeAllCallExpression = callExpression;
|
|
46
|
+
},
|
|
47
|
+
'CallExpression[callee.name="afterAll"]': (callExpression: TSESTree.CallExpression) => {
|
|
48
|
+
afterAllCallExpression = callExpression;
|
|
49
|
+
},
|
|
50
|
+
'Program:exit'(program) {
|
|
51
|
+
try {
|
|
52
|
+
let jestImportFixer: ((fixer: RuleFixer) => RuleFix) | undefined;
|
|
53
|
+
let agentImportFixer: ((fixer: RuleFixer) => RuleFix) | undefined;
|
|
54
|
+
let fixturePluginImportFixer: ((fixer: RuleFixer) => RuleFix) | undefined;
|
|
55
|
+
let agentDeclarationFixer: ((fixer: RuleFixer) => RuleFix) | undefined;
|
|
56
|
+
let beforeAllFixer: ((fixer: RuleFixer) => RuleFix) | undefined;
|
|
57
|
+
let afterAllFixer: ((fixer: RuleFixer) => RuleFix) | undefined;
|
|
58
|
+
|
|
59
|
+
const lastImportDeclaration = [...importDeclarations.values()].at(-1);
|
|
60
|
+
assert.ok(lastImportDeclaration);
|
|
61
|
+
|
|
62
|
+
const jestImportDeclaration = importDeclarations.get('@jest/globals');
|
|
63
|
+
if (
|
|
64
|
+
jestImportDeclaration &&
|
|
65
|
+
!jestImportDeclaration.specifiers.some(
|
|
66
|
+
(specifier) =>
|
|
67
|
+
specifier.type === TSESTree.AST_NODE_TYPES.ImportSpecifier && specifier.imported.name === 'afterAll',
|
|
68
|
+
)
|
|
69
|
+
) {
|
|
70
|
+
const firstImportSpecifier = jestImportDeclaration.specifiers[0];
|
|
71
|
+
assert.ok(firstImportSpecifier);
|
|
72
|
+
jestImportFixer = (fixer: RuleFixer) => fixer.insertTextBefore(firstImportSpecifier, 'afterAll, ');
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const agentImportDeclaration = importDeclarations.get('@checkdigit/agent');
|
|
76
|
+
if (!agentImportDeclaration) {
|
|
77
|
+
agentImportFixer = (fixer: RuleFixer) =>
|
|
78
|
+
fixer.insertTextAfter(
|
|
79
|
+
lastImportDeclaration,
|
|
80
|
+
`\nimport createAgent, { type Agent } from '@checkdigit/agent';`,
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const fixturePluginImportDeclaration = importDeclarations.get('../../plugin/fixture.test');
|
|
85
|
+
if (!fixturePluginImportDeclaration) {
|
|
86
|
+
fixturePluginImportFixer = (fixer: RuleFixer) =>
|
|
87
|
+
fixer.insertTextAfter(lastImportDeclaration, `\nimport fixturePlugin from '../../plugin/fixture.test';`);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (beforeAllCallExpression !== undefined) {
|
|
91
|
+
const beforeAllArrowFunctionExpression = beforeAllCallExpression.arguments[0];
|
|
92
|
+
assert.ok(
|
|
93
|
+
beforeAllArrowFunctionExpression !== undefined &&
|
|
94
|
+
beforeAllArrowFunctionExpression.type === TSESTree.AST_NODE_TYPES.ArrowFunctionExpression,
|
|
95
|
+
);
|
|
96
|
+
const arrowFunctionBody = beforeAllArrowFunctionExpression.body;
|
|
97
|
+
assert.ok(arrowFunctionBody.type === TSESTree.AST_NODE_TYPES.BlockStatement);
|
|
98
|
+
|
|
99
|
+
const targetStatement = arrowFunctionBody.body.find(
|
|
100
|
+
(statement) => sourceCode.getText(statement) /*?*/ === 'await fixture.reset();',
|
|
101
|
+
);
|
|
102
|
+
if (targetStatement !== undefined) {
|
|
103
|
+
const beforeAllBodyText = sourceCode.getText(arrowFunctionBody);
|
|
104
|
+
if (!beforeAllBodyText.includes('agent = await createAgent();')) {
|
|
105
|
+
beforeAllFixer = (fixer: RuleFixer) =>
|
|
106
|
+
fixer.replaceText(
|
|
107
|
+
targetStatement,
|
|
108
|
+
[
|
|
109
|
+
'agent = await createAgent();',
|
|
110
|
+
'agent.register(await fixturePlugin(fixture));',
|
|
111
|
+
'agent.enable();',
|
|
112
|
+
'await fixture.reset();',
|
|
113
|
+
].join('\n'),
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
if (!beforeAllBodyText.includes('let agent: Agent;')) {
|
|
117
|
+
agentDeclarationFixer = (fixer: RuleFixer) =>
|
|
118
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
119
|
+
fixer.insertTextBefore(beforeAllCallExpression!, 'let agent: Agent;\n');
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (afterAllCallExpression !== undefined) {
|
|
125
|
+
const afterAllArrowFunctionExpression = afterAllCallExpression.arguments[0];
|
|
126
|
+
assert.ok(
|
|
127
|
+
afterAllArrowFunctionExpression !== undefined &&
|
|
128
|
+
afterAllArrowFunctionExpression.type === TSESTree.AST_NODE_TYPES.ArrowFunctionExpression,
|
|
129
|
+
);
|
|
130
|
+
const arrowFunctionBody = afterAllArrowFunctionExpression.body;
|
|
131
|
+
assert.ok(arrowFunctionBody.type === TSESTree.AST_NODE_TYPES.BlockStatement);
|
|
132
|
+
|
|
133
|
+
const afterAllBodyText = sourceCode.getText(arrowFunctionBody);
|
|
134
|
+
if (!afterAllBodyText.includes('await agent[Symbol.asyncDispose]();')) {
|
|
135
|
+
const lastStatement = arrowFunctionBody.body.at(-1);
|
|
136
|
+
assert.ok(lastStatement);
|
|
137
|
+
afterAllFixer = (fixer: RuleFixer) =>
|
|
138
|
+
fixer.insertTextAfter(lastStatement, 'await agent[Symbol.asyncDispose]();');
|
|
139
|
+
}
|
|
140
|
+
} else if (beforeAllCallExpression !== undefined) {
|
|
141
|
+
const nextToken = sourceCode.getTokenAfter(beforeAllCallExpression);
|
|
142
|
+
afterAllFixer = (fixer: RuleFixer) =>
|
|
143
|
+
fixer.insertTextAfter(
|
|
144
|
+
nextToken !== null && nextToken.type === AST_TOKEN_TYPES.Punctuator
|
|
145
|
+
? nextToken
|
|
146
|
+
: // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
147
|
+
beforeAllCallExpression!,
|
|
148
|
+
`\nafterAll(async () => {
|
|
149
|
+
await agent[Symbol.asyncDispose]();
|
|
150
|
+
});`,
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (
|
|
155
|
+
jestImportFixer !== undefined ||
|
|
156
|
+
agentImportFixer !== undefined ||
|
|
157
|
+
fixturePluginImportFixer !== undefined ||
|
|
158
|
+
agentDeclarationFixer !== undefined ||
|
|
159
|
+
beforeAllFixer !== undefined ||
|
|
160
|
+
afterAllFixer !== undefined
|
|
161
|
+
) {
|
|
162
|
+
context.report({
|
|
163
|
+
messageId: 'updateTestWiring',
|
|
164
|
+
node: program,
|
|
165
|
+
*fix(fixer) {
|
|
166
|
+
if (jestImportFixer !== undefined) {
|
|
167
|
+
yield jestImportFixer(fixer);
|
|
168
|
+
}
|
|
169
|
+
if (agentImportFixer !== undefined) {
|
|
170
|
+
yield agentImportFixer(fixer);
|
|
171
|
+
}
|
|
172
|
+
if (fixturePluginImportFixer !== undefined) {
|
|
173
|
+
yield fixturePluginImportFixer(fixer);
|
|
174
|
+
}
|
|
175
|
+
if (agentDeclarationFixer !== undefined) {
|
|
176
|
+
yield agentDeclarationFixer(fixer);
|
|
177
|
+
}
|
|
178
|
+
if (beforeAllFixer !== undefined) {
|
|
179
|
+
yield beforeAllFixer(fixer);
|
|
180
|
+
}
|
|
181
|
+
if (afterAllFixer !== undefined) {
|
|
182
|
+
yield afterAllFixer(fixer);
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
} catch (error) {
|
|
188
|
+
// eslint-disable-next-line no-console
|
|
189
|
+
console.error(`Failed to apply ${ruleId} rule for file "${context.filename}":`, error);
|
|
190
|
+
context.report({
|
|
191
|
+
node: program,
|
|
192
|
+
messageId: 'unknownError',
|
|
193
|
+
data: {
|
|
194
|
+
fileName: context.filename,
|
|
195
|
+
error: error instanceof Error ? error.toString() : JSON.stringify(error),
|
|
196
|
+
},
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
};
|
|
201
|
+
},
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
export default rule;
|