Skip to content

Commit

Permalink
PR review
Browse files Browse the repository at this point in the history
  • Loading branch information
jmcpeak authored and webpro committed Mar 14, 2024
1 parent a1e6d50 commit 213aa6e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
2 changes: 1 addition & 1 deletion packages/docs/scripts/generate-plugin-docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import remarkStringify from 'remark-stringify';
import { unified } from 'unified';
import { u } from 'unist-builder';
import { base } from '../config.js';
import type { Plugin } from '../../knip/src/types/plugins.js';
import type { Plugin } from 'knip/dist/types/plugins.ts';
import type { Root } from 'mdast';
import type { Node } from 'unist';

Expand Down
14 changes: 4 additions & 10 deletions packages/knip/src/plugins/msw/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// eslint-disable-next-line n/no-restricted-import
import path from 'node:path';
import { basename } from '../../util/path.js';
import { hasDependency } from '../../util/plugin.js';
import { toEntryPattern } from '../../util/protocols.js';
Expand All @@ -14,15 +16,7 @@ const isEnabled: IsPluginEnabledCallback = ({ dependencies }) => hasDependency(d
const CONFIG_FILE_PATTERNS = ['package.json'];

const ENTRY_FILE_PATTERNS = [
'**/mockServiceWorker.{js,ts}',
'mocks/browser.{js,ts}',
'mocks/handlers.{js,ts}"',
'mocks/index.{js,ts}"',
'mocks/server.{js,ts}"',
'src/mocks/browser.{js,ts}',
'src/mocks/handlers.{js,ts}"',
'src/mocks/index.{js,ts}"',
'src/mocks/server.{js,ts}"',
'mockServiceWorker.js',
];

const findDependencies: GenericPluginCallback = async (configFilePath, options) => {
Expand All @@ -34,7 +28,7 @@ const findDependencies: GenericPluginCallback = async (configFilePath, options)
const workerDirectory = localConfig?.workerDirectory;

if (workerDirectory) {
ENTRY_FILE_PATTERNS.push(`${workerDirectory}/mockServiceWorker.{js,ts}`)
return [toEntryPattern(path.join(workerDirectory, '/mockServiceWorker.js'))];
}

const entryPatterns = ENTRY_FILE_PATTERNS.map(toEntryPattern);
Expand Down
4 changes: 2 additions & 2 deletions packages/knip/test/plugins/msw.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ test('Should not see the msw files in issues', async () => {
isStrict: true,
});

assert.equal(issues.files.size, 3);
assert.equal(issues.files.size, 13);
assert(issues.files.has(join(cwd, 'junk.js')));
assert(issues.files.has(join(cwd, 'mocks/junk.js')));
assert(issues.files.has(join(cwd, 'src/mocks/junk.js')));

assert.deepEqual(counters, {
...baseCounters,
devDependencies: 1,
files: 3,
files: 13,
total: 14,
processed: 14,
});
Expand Down

0 comments on commit 213aa6e

Please sign in to comment.