• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

satisfactory-dev / ajv-utilities / 25249984834

02 May 2026 10:33AM UTC coverage: 98.808% (-0.2%) from 99.005%
25249984834

push

github

SignpostMarv
clean up known imports

591 of 609 branches covered (97.04%)

Branch coverage included in aggregate %.

5 of 5 new or added lines in 3 files covered. (100.0%)

44 existing lines in 3 files now uncovered.

4882 of 4930 relevant lines covered (99.03%)

22553.33 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

91.53
/src/TypeScriptify/preprocessors/SpecifyTypes.ts
1
import type {
2✔
2
        EmptyStatement,
2✔
3
        FunctionDeclaration,
2✔
4
        Identifier,
2✔
5
        KeywordToken,
2✔
6
        NodeArray,
2✔
7
        VariableDeclaration,
2✔
8
        VariableDeclarationList,
2✔
9
        VariableStatement,
2✔
10
} from 'typescript';
2✔
11
import {
2✔
12
        isEmptyStatement,
2✔
13
        isFunctionDeclaration,
2✔
14
        isIdentifier,
2✔
15
        isVariableStatement,
2✔
16
        SyntaxKind,
2✔
17
} from 'typescript';
2✔
18

2✔
19
import {
2✔
20
        ConditionalPreprocessor,
2✔
21
} from '../abstracts.ts';
2✔
22

2✔
23
import type {
2✔
24
        Config,
2✔
25
        specify_types_instance,
2✔
26
} from '../types.ts';
2✔
27

2✔
28
import type {
2✔
29
        prepend_with_imports,
2✔
30
} from '../TypeReferences.ts';
2✔
31
import {
2✔
32
        Types,
2✔
33
} from '../TypeReferences.ts';
2✔
34

2✔
35
type SpecifyTypesCandidate = (
2✔
36
        & EmptyStatement
2✔
37
        & {
2✔
38
                parent: (
2✔
39
                        & Node
2✔
40
                        & {
2✔
41
                                parent: (
2✔
42
                                        & FunctionDeclaration
2✔
43
                                        & {
2✔
44
                                                name: (
2✔
45
                                                        & Identifier
2✔
46
                                                        & {
2✔
47
                                                                text: `validate${number}`,
2✔
48
                                                        }
2✔
49
                                                ),
2✔
50
                                        }
2✔
51
                                ),
2✔
52
                        }
2✔
53
                ),
2✔
54
        }
2✔
55
);
2✔
56

2✔
57
type config = (
2✔
58
        & Omit<Partial<Config>, 'specify_types'>
2✔
59
        & Pick<Config, 'specify_types'>
2✔
60
);
2✔
61

2✔
62
export class SpecifyTypesBySourceURL extends ConditionalPreprocessor<
2✔
63
        SpecifyTypesCandidate,
2✔
64
        config
2✔
65
> {
2✔
66
        #configEntry(
2✔
67
                config: config['specify_types'],
25✔
68
                node: EmptyStatement,
25✔
69
        ): Config['specify_types'][string] | undefined {
25✔
70
                const keys = Object.keys(config);
25✔
71

25✔
72
                if (0 === keys.length) {
25✔
73
                        return;
1✔
74
                }
1✔
75

24✔
76
                const code = node.getFullText();
24✔
77

24✔
78
                const has_match = new RegExp(
24✔
79
                        `\\/\\*# sourceURL="(${
24✔
80
                                keys.map((key) => RegExp.escape(key)).join('|')
24✔
81
                        })" \\*\\/`,
24✔
82
                );
24✔
83

24✔
84
                const maybe = has_match.exec(code);
24✔
85

24✔
86
                if (maybe && maybe[1] in config) {
25✔
87
                        return config[maybe[1]];
24✔
88
                }
24✔
89
        }
25✔
90

2✔
91
        constructor(
2✔
92
                prepend_with_imports: prepend_with_imports,
33✔
93
                specify_types: specify_types_instance,
33✔
94
        ) {
33✔
95
                super(
33✔
96
                        (node, config): node is SpecifyTypesCandidate => (
33✔
97
                                !!config
286,051✔
98
                                && !!config.specify_types
286,051✔
99
                                && isEmptyStatement(node)
286,051✔
100
                                && isFunctionDeclaration(node.parent.parent)
286,051✔
101
                                && !!node.parent.parent.name
286,051✔
102
                                && this.validate_function_name.test(
286,051✔
103
                                        node.parent.parent.name.text,
25✔
104
                                )
25✔
105
                        ),
33✔
106
                        (node, config) => {
33✔
107
                                const maybe = this.#configEntry(config.specify_types, node);
25✔
108

25✔
109
                                if (maybe) {
25✔
110
                                        if (!(maybe[1] in prepend_with_imports)) {
24✔
111
                                                prepend_with_imports[maybe[1]] = new Types();
16✔
112
                                        }
16✔
113

24✔
114
                                        specify_types[
24✔
115
                                                node.parent.parent.name.text
24✔
116
                                        ] = prepend_with_imports[maybe[1]].add(maybe[0]);
24✔
117
                                }
24✔
118
                        },
33✔
119
                );
33✔
120
        }
33✔
121
}
2✔
122

2✔
123
export class SpecifyTypesByValidateFunction extends ConditionalPreprocessor<
2✔
124
        SpecifyTypesCandidate['parent']['parent']
2✔
125
> {
2✔
126
        constructor(
2✔
127
                prepend_with_imports: prepend_with_imports,
30✔
128
                specify_types: specify_types_instance,
30✔
129
        ) {
30✔
130
                super(
30✔
131
                        (maybe): maybe is SpecifyTypesCandidate['parent']['parent'] => (
30✔
132
                                isFunctionDeclaration(maybe)
286,051✔
133
                                && !!maybe.name
286,051✔
134
                                && this.validate_function_name.test(
286,051✔
135
                                        maybe.name.text,
86✔
136
                                )
86✔
137
                        ),
30✔
138
                        (node, config) => {
30✔
139
                                if (
86✔
140
                                        !config.specify_types_by_validate_function_name
86✔
141

86✔
142
                                        // oxlint-disable-next-line @stylistic/max-len
86✔
143
                                        || !(node.name.text in config.specify_types_by_validate_function_name)
86✔
144
                                ) {
86✔
145
                                        return;
40✔
146
                                }
40✔
147

46✔
148
                                // oxlint-disable-next-line @stylistic/max-len
46✔
149
                                const type_config = config.specify_types_by_validate_function_name[
46✔
150
                                        node.name.text
46✔
151
                                ];
46✔
152

46✔
153
                                if (!(type_config[1] in prepend_with_imports)) {
86✔
154
                                        prepend_with_imports[type_config[1]] = new Types();
4✔
155
                                }
4✔
156

46✔
157
                                specify_types[
46✔
158
                                        node.name.text
46✔
159
                                ] = prepend_with_imports[type_config[1]].add(type_config[0]);
46✔
160
                        },
30✔
161
                );
30✔
162
        }
30✔
163
}
2✔
164

2✔
165
type SpecifyTypesByExportNameCandidate = (
2✔
166
        & VariableStatement
2✔
167
        & {
2✔
168
                modifiers: [
2✔
169
                        KeywordToken<SyntaxKind.ExportKeyword>,
2✔
170
                ],
2✔
171
                declarationList: (
2✔
172
                        & VariableDeclarationList
2✔
173
                        & {
2✔
174
                                declarations: (
2✔
175
                                        & NodeArray<VariableDeclaration>
2✔
176
                                        & {
2✔
177
                                                length: 1,
2✔
178
                                                0: (
2✔
179
                                                        & VariableDeclaration
2✔
180
                                                        & {
2✔
181
                                                                name: Identifier,
2✔
182
                                                                initializer: (
2✔
183
                                                                        & Identifier
2✔
184
                                                                        & {
2✔
185
                                                                                text: `validate${number}`,
2✔
186
                                                                        }
2✔
187
                                                                ),
2✔
188
                                                        }
2✔
189
                                                ),
2✔
190
                                        }
2✔
191
                                ),
2✔
192
                        }
2✔
193
                ),
2✔
194
        }
2✔
195
);
2✔
196

2✔
197
export class SpecifyTypesByExportName extends ConditionalPreprocessor<
2✔
198
        SpecifyTypesByExportNameCandidate
2✔
199
> {
2✔
200
        constructor(
2✔
201
                prepend_with_imports: prepend_with_imports,
30✔
202
                specify_types: specify_types_instance,
30✔
203
        ) {
30✔
204
                super(
30✔
205
                        (maybe): maybe is SpecifyTypesByExportNameCandidate => {
30✔
206
                                const result = (
286,051✔
207
                                        isVariableStatement(maybe)
286,051✔
208
                                        && !!maybe.modifiers
286,051✔
209
                                        && 1 === maybe.modifiers.length
286,051✔
210
                                        && SyntaxKind.ExportKeyword === maybe.modifiers[0].kind
286,051✔
211
                                        && 1 === maybe.declarationList.declarations.length
286,051✔
212
                                        && isIdentifier(maybe.declarationList.declarations[0].name)
286,051✔
213
                                        && !!maybe.declarationList.declarations[0].initializer
286,051✔
214
                                        && isIdentifier(
286,051✔
215
                                                maybe.declarationList.declarations[0].initializer,
30✔
216
                                        )
30✔
217
                                        && this.validate_function_name.test(
286,051✔
218
                                                maybe.declarationList.declarations[0].initializer.text,
30✔
219
                                        )
30✔
220
                                );
286,051✔
221

286,051✔
222
                                return result;
286,051✔
223
                        },
30✔
224
                        (node, config) => {
30✔
225
                                if (
30✔
226
                                        !config.specify_types_by_export_name
30✔
227
                                        || !(node.declarationList.declarations[
30!
UNCOV
228
                                                0
×
UNCOV
229
                                        ].name.text in config.specify_types_by_export_name)
×
230
                                ) {
30✔
231
                                        return;
30✔
232
                                }
30!
UNCOV
233

×
UNCOV
234
                                const export_name = node.declarationList.declarations[
×
UNCOV
235
                                        0
×
UNCOV
236
                                ].name.text;
×
UNCOV
237

×
UNCOV
238
                                const function_name = node.declarationList.declarations[
×
UNCOV
239
                                        0
×
UNCOV
240
                                ].initializer.text;
×
UNCOV
241

×
UNCOV
242
                                // oxlint-disable-next-line @stylistic/max-len
×
UNCOV
243
                                const type_config = config.specify_types_by_export_name[
×
UNCOV
244
                                        export_name
×
UNCOV
245
                                ];
×
UNCOV
246

×
UNCOV
247
                                if (!(type_config[1] in prepend_with_imports)) {
×
248
                                        prepend_with_imports[type_config[1]] = new Types();
×
249
                                }
×
UNCOV
250

×
UNCOV
251
                                specify_types[
×
UNCOV
252
                                        function_name
×
UNCOV
253
                                ] = prepend_with_imports[type_config[1]].add(type_config[0]);
×
254
                        },
30✔
255
                );
30✔
256
        }
30✔
257
}
2✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc