File tree 9 files changed +74
-0
lines changed
9 files changed +74
-0
lines changed Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " @fixtures/yarn" ,
3
+ "version" : " *" ,
4
+ "devDependencies" : {
5
+ "@yarnpkg/types" : " latest"
6
+ }
7
+ }
Original file line number Diff line number Diff line change
1
+ // https://yarnpkg.com/features/constraints
2
+
3
+ /** @type {import('@yarnpkg/types') } */
4
+ const { defineConfig } = require ( '@yarnpkg/types' ) ;
5
+
6
+ module . exports = defineConfig ( {
7
+ async constraints ( { Yarn} ) {
8
+ // `Yarn` is now well-typed ✨
9
+ } ,
10
+ } ) ;
Original file line number Diff line number Diff line change
1
+ # This file is generated by running "yarn install" inside your project.
2
+ # Manual changes might be lost - proceed with caution!
3
+
4
+ __metadata :
5
+ version : 8
6
+ cacheKey : 10
Original file line number Diff line number Diff line change 612
612
"title" : " xo plugin configuration (https://knip.dev/reference/plugins/xo)" ,
613
613
"$ref" : " #/definitions/plugin"
614
614
},
615
+ "yarn" : {
616
+ "title" : " yarn plugin configuration (https://knip.dev/reference/plugins/yarn)" ,
617
+ "$ref" : " #/definitions/plugin"
618
+ },
615
619
"yorkie" : {
616
620
"title" : " yorkie plugin configuration (https://knip.dev/reference/plugins/yorkie)" ,
617
621
"$ref" : " #/definitions/plugin"
Original file line number Diff line number Diff line change @@ -84,6 +84,7 @@ import { default as webpack } from './webpack/index.js';
84
84
import { default as wireit } from './wireit/index.js' ;
85
85
import { default as wrangler } from './wrangler/index.js' ;
86
86
import { default as xo } from './xo/index.js' ;
87
+ import { default as yarn } from './yarn/index.js' ;
87
88
import { default as yorkie } from './yorkie/index.js' ;
88
89
89
90
export const Plugins = {
@@ -172,5 +173,6 @@ export const Plugins = {
172
173
wireit,
173
174
wrangler,
174
175
xo,
176
+ yarn,
175
177
yorkie,
176
178
} ;
Original file line number Diff line number Diff line change
1
+ import type { IsPluginEnabled , Plugin } from '../../types/config.js' ;
2
+ import { _firstGlob } from '../../util/glob.js' ;
3
+
4
+ // https://yarnpkg.com/features/constraints
5
+
6
+ const title = 'Yarn' ;
7
+
8
+ const enablers = 'This plugin is enabled when a `yarn.lock` file is found in the root folder.' ;
9
+
10
+ const isEnabled : IsPluginEnabled = async ( { cwd } ) => Boolean ( await _firstGlob ( { cwd, patterns : [ 'yarn.lock' ] } ) ) ;
11
+
12
+ const entry : string [ ] = [ 'yarn.config.cjs' ] ;
13
+
14
+ export default {
15
+ title,
16
+ enablers,
17
+ isEnabled,
18
+ entry,
19
+ } satisfies Plugin ;
Original file line number Diff line number Diff line change @@ -98,5 +98,6 @@ export const pluginsSchema = z.object({
98
98
wireit : pluginSchema ,
99
99
wrangler : pluginSchema ,
100
100
xo : pluginSchema ,
101
+ yarn : pluginSchema ,
101
102
yorkie : pluginSchema ,
102
103
} ) ;
Original file line number Diff line number Diff line change @@ -85,6 +85,7 @@ export type PluginName =
85
85
| 'wireit'
86
86
| 'wrangler'
87
87
| 'xo'
88
+ | 'yarn'
88
89
| 'yorkie' ;
89
90
90
91
export const pluginNames = [
@@ -173,5 +174,6 @@ export const pluginNames = [
173
174
'wireit' ,
174
175
'wrangler' ,
175
176
'xo' ,
177
+ 'yarn' ,
176
178
'yorkie' ,
177
179
] as const ;
Original file line number Diff line number Diff line change
1
+ import { test } from 'bun:test' ;
2
+ import assert from 'node:assert/strict' ;
3
+ import { main } from '../../src/index.js' ;
4
+ import { resolve } from '../../src/util/path.js' ;
5
+ import baseArguments from '../helpers/baseArguments.js' ;
6
+ import baseCounters from '../helpers/baseCounters.js' ;
7
+
8
+ const cwd = resolve ( 'fixtures/plugins/yarn' ) ;
9
+
10
+ test ( 'Find dependencies with the yarn plugin' , async ( ) => {
11
+ const { issues, counters } = await main ( {
12
+ ...baseArguments ,
13
+ cwd,
14
+ } ) ;
15
+
16
+ assert ( issues . files . size === 0 ) ;
17
+
18
+ assert . deepEqual ( counters , {
19
+ ...baseCounters ,
20
+ processed : 1 ,
21
+ total : 1 ,
22
+ } ) ;
23
+ } ) ;
You can’t perform that action at this time.
0 commit comments