Skip to content

Commit cfc5088

Browse files
feat(stryker): add ts extensions (#1910)
1 parent d04aa04 commit cfc5088

4 files changed

Lines changed: 21 additions & 5 deletions

File tree

packages/knip/fixtures/plugins/stryker/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"name": "@plugins/stryker",
33
"scripts": {
4-
"stryker": "stryker"
4+
"stryker": "stryker",
5+
"stryker:custom": "stryker run --incremental stryker.custom.conf.ts"
56
},
67
"type": "module",
78
"dependencies": {
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
const config = {
2+
testRunner: 'tap',
3+
checkers: ['typescript'],
4+
};
5+
6+
export default config;

packages/knip/src/plugins/stryker/index.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
import type { Args } from '../../types/args.ts';
12
import type { IsPluginEnabled, Plugin, ResolveConfig } from '../../types/config.ts';
2-
import { toDeferResolve } from '../../util/input.ts';
3+
import { toConfig, toDeferResolve } from '../../util/input.ts';
34
import { hasDependency } from '../../util/plugin.ts';
45
import type { StrykerConfig } from './types.ts';
56

@@ -23,12 +24,18 @@ const resolveConfig: ResolveConfig<StrykerConfig> = localConfig => {
2324
return [...runners, ...checkers, ...plugins].map(id => toDeferResolve(id));
2425
};
2526

27+
const args: Args = {
28+
boolean: ['allowEmpty', 'disableBail', 'dryRunOnly', 'force', 'ignoreStatic', 'incremental', 'inPlace'],
29+
resolveInputs: parsed => (parsed._[0] === 'run' && parsed._[1] ? [toConfig('stryker', parsed._[1])] : []),
30+
};
31+
2632
const plugin: Plugin = {
2733
title,
2834
enablers,
2935
isEnabled,
3036
config,
3137
resolveConfig,
38+
args,
3239
};
3340

3441
export default plugin;

packages/knip/test/plugins/stryker.test.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,16 @@ test('Find dependencies with the Stryker plugin', async () => {
2626
assert(issues.unlisted['stryker.conf.mjs']['@stryker-mutator/typescript-checker']);
2727
assert(issues.unlisted['stryker.conf.mjs']['@stryker-mutator/jasmine-framework']);
2828
assert(issues.unlisted['stryker.conf.mjs']['@stryker-mutator/karma-runner']);
29+
assert(issues.unlisted['stryker.custom.conf.ts']['@stryker-mutator/tap-runner']);
30+
assert(issues.unlisted['stryker.custom.conf.ts']['@stryker-mutator/typescript-checker']);
2931
assert(issues.binaries['package.json']['stryker']);
3032

3133
assert.deepEqual(counters, {
3234
...baseCounters,
3335
binaries: 1,
3436
dependencies: 1,
35-
unlisted: 14,
36-
processed: 3,
37-
total: 3,
37+
unlisted: 16,
38+
processed: 4,
39+
total: 4,
3840
});
3941
});

0 commit comments

Comments
 (0)