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

satisfactory-dev / ajv-utilities / 25193107391

30 Apr 2026 10:47PM UTC coverage: 98.998% (-0.8%) from 99.774%
25193107391

push

github

SignpostMarv
satisfying oxlint for in-progress refactor

553 of 569 branches covered (97.19%)

Branch coverage included in aggregate %.

25 of 25 new or added lines in 1 file covered. (100.0%)

2 existing lines in 1 file now uncovered.

4586 of 4622 relevant lines covered (99.22%)

22956.77 hits per line

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

98.99
/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
289,267✔
98
                                && !!config.specify_types
289,267✔
99
                                && isEmptyStatement(node)
289,267✔
100
                                && isFunctionDeclaration(node.parent.parent)
289,267✔
101
                                && !!node.parent.parent.name
289,267✔
102
                                && this.validate_function_name.test(
289,267✔
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)
289,267✔
133
                                && !!maybe.name
289,267✔
134
                                && this.validate_function_name.test(
289,267✔
135
                                        maybe.name.text,
88✔
136
                                )
88✔
137
                        ),
30✔
138
                        (node, config) => {
30✔
139
                                if (
88✔
140
                                        !config.specify_types_by_validate_function_name
88✔
141

88✔
142
                                        // oxlint-disable-next-line @stylistic/max-len
88✔
143
                                        || !(node.name.text in config.specify_types_by_validate_function_name)
88✔
144
                                ) {
88✔
145
                                        return;
42✔
146
                                }
42✔
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)) {
88✔
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 = (
289,267✔
207
                                        isVariableStatement(maybe)
289,267✔
208
                                        && !!maybe.modifiers
289,267✔
209
                                        && 1 === maybe.modifiers.length
289,267✔
210
                                        && SyntaxKind.ExportKeyword === maybe.modifiers[0].kind
289,267✔
211
                                        && 1 === maybe.declarationList.declarations.length
289,267✔
212
                                        && isIdentifier(maybe.declarationList.declarations[0].name)
289,267✔
213
                                        && !!maybe.declarationList.declarations[0].initializer
289,267✔
214
                                        && isIdentifier(
289,267✔
215
                                                maybe.declarationList.declarations[0].initializer,
32✔
216
                                        )
32✔
217
                                        && this.validate_function_name.test(
289,267✔
218
                                                maybe.declarationList.declarations[0].initializer.text,
32✔
219
                                        )
32✔
220
                                );
289,267✔
221

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

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

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

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

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

2✔
251
                                specify_types[
2✔
252
                                        function_name
2✔
253
                                ] = prepend_with_imports[type_config[1]].add(type_config[0]);
2✔
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