-
-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix up rules in issue collector and reporter (resolves #713)
- Loading branch information
Showing
9 changed files
with
115 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
export const used = 1; | ||
export const unused = 1; | ||
|
||
export type UsedType = unknown; | ||
export type UnusedType = unknown; | ||
|
||
export default used; | ||
|
||
export class MyClass { | ||
unused: 1; | ||
} | ||
|
||
export enum MyEnum { | ||
used = 1, | ||
unused = 1, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import 'used'; | ||
import '@dev/used'; | ||
import 'optional-peer-dep'; | ||
import './unresolved'; | ||
import 'unlisted'; | ||
import * as NS from './ns'; | ||
import default_, { used, type UsedType, MyClass, MyEnum } from './exports'; | ||
|
||
const x: UsedType | NS.UsedType = [default_, used, MyEnum.used, NS.used]; | ||
const y = new MyClass(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export const used = 1; | ||
export const unused = 1; | ||
|
||
export type UsedType = unknown; | ||
export type UnusedType = unknown; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{ | ||
"name": "@fixtures/rules", | ||
"dependencies": { | ||
"used": "*", | ||
"unused": "*" | ||
}, | ||
"devDependencies": { | ||
"@dev/used": "*", | ||
"@dev/unused": "*" | ||
}, | ||
"peerDependencies": { | ||
"optional-peer-dep": "*" | ||
}, | ||
"peerDependenciesMeta": { | ||
"optional-peer-dep": { | ||
"optional": true | ||
} | ||
}, | ||
"scripts": { | ||
"unlisted-binary": "unlisted" | ||
}, | ||
"knip": { | ||
"include": ["classMembers", "nsExports", "nsTypes"], | ||
"rules": { | ||
"files": "warn", | ||
"dependencies": "warn", | ||
"devDependencies": "warn", | ||
"optionalPeerDependencies": "warn", | ||
"unlisted": "warn", | ||
"binaries": "warn", | ||
"unresolved": "warn", | ||
"exports": "warn", | ||
"types": "warn", | ||
"nsExports": "warn", | ||
"nsTypes": "warn", | ||
"duplicates": "warn", | ||
"enumMembers": "warn", | ||
"classMembers": "warn" | ||
} | ||
} | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { test } from 'bun:test'; | ||
import assert from 'node:assert/strict'; | ||
import { main } from '../src/index.js'; | ||
import { getValuesByKeyDeep } from '../src/util/object.js'; | ||
import { resolve } from '../src/util/path.js'; | ||
import baseArguments from './helpers/baseArguments.js'; | ||
import baseCounters from './helpers/baseCounters.js'; | ||
|
||
const cwd = resolve('fixtures/rules'); | ||
|
||
test('Respect warnings in rules', async () => { | ||
const { issues, counters } = await main({ | ||
...baseArguments, | ||
cwd, | ||
}); | ||
|
||
const severities = getValuesByKeyDeep(issues, 'severity'); | ||
|
||
assert(severities.every(severity => severity === 'warn')); | ||
|
||
assert.deepEqual(counters, { | ||
...baseCounters, | ||
files: 1, | ||
dependencies: 1, | ||
devDependencies: 1, | ||
optionalPeerDependencies: 1, | ||
unlisted: 1, | ||
binaries: 1, | ||
unresolved: 1, | ||
exports: 2, | ||
types: 2, | ||
duplicates: 1, | ||
enumMembers: 1, | ||
classMembers: 1, | ||
processed: 4, | ||
total: 4, | ||
}); | ||
}); |