Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add plugin for syncpack #629

Merged
merged 1 commit into from
May 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions packages/knip/fixtures/plugins/syncpack/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "@fixtures/syncpack",
"version": "*",
"devDependencies": {
"syncpack": "*"
}
}
4 changes: 4 additions & 0 deletions packages/knip/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,10 @@
"title": "svelte plugin configuration (https://github.com/webpro/knip/blob/main/src/plugins/svelte/README.md)",
"$ref": "#/definitions/plugin"
},
"syncpack": {
"title": "syncpack plugin configuration (https://github.com/webpro/knip/blob/main/src/plugins/syncpack/README.md)",
"$ref": "#/definitions/plugin"
},
"tailwind": {
"title": "tailwind plugin configuration (https://github.com/webpro/knip/blob/main/src/plugins/tailwind/README.md)",
"$ref": "#/definitions/plugin"
Expand Down
1 change: 1 addition & 0 deletions packages/knip/src/ConfigurationValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ const pluginsSchema = z.object({
stryker: pluginSchema,
stylelint: pluginSchema,
svelte: pluginSchema,
syncpack: pluginSchema,
tailwind: pluginSchema,
tsup: pluginSchema,
typedoc: pluginSchema,
Expand Down
1 change: 1 addition & 0 deletions packages/knip/src/plugins/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export { default as storybook } from './storybook/index.js';
export { default as stryker } from './stryker/index.js';
export { default as stylelint } from './stylelint/index.js';
export { default as svelte } from './svelte/index.js';
export { default as syncpack } from './syncpack/index.js';
export { default as tailwind } from './tailwind/index.js';
export { default as tsup } from './tsup/index.js';
export { default as typedoc } from './typedoc/index.js';
Expand Down
20 changes: 20 additions & 0 deletions packages/knip/src/plugins/syncpack/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import type { EnablerPatterns } from '#p/types/config.js';
import type { IsPluginEnabled, Plugin } from '#p/types/plugins.js';
import { hasDependency } from '#p/util/plugin.js';

// link to syncpack docs https://jamiemason.github.io/syncpack/config/syncpackrc/

const title = 'Syncpack';

const enablers: EnablerPatterns = ['syncpack'];

const isEnabled: IsPluginEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);

const config = ['.syncpackrc', '.syncpackrc.{json,yaml,yml,js,cjs}', '.syncpack.config.{js,cjs}'];

export default {
title,
enablers,
isEnabled,
config,
} satisfies Plugin;
22 changes: 22 additions & 0 deletions packages/knip/test/plugins/syncpack.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { test } from 'bun:test';
import assert from 'node:assert/strict';
import { main } from '../../src/index.js';
import { resolve } from '../../src/util/path.js';
import baseArguments from '../helpers/baseArguments.js';
import baseCounters from '../helpers/baseCounters.js';

const cwd = resolve('fixtures/plugins/syncpack');

test('Find dependencies with the Syncpack plugin', async () => {
const { counters } = await main({
...baseArguments,
cwd,
});

assert.deepEqual(counters, {
...baseCounters,
devDependencies: 1,
processed: 0,
total: 0,
});
});
Loading