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

Unused deps with knip #23993

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
23 changes: 23 additions & 0 deletions build-tools/packages/build-cli/knip.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*!
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
* Licensed under the MIT License.
*/

// Import the shared config from the root of the repo.
const sharedConfig = require("../../../knip.base.js");

module.exports = {
include: [...sharedConfig.include],
ignoreDependencies: [
...sharedConfig.ignoreDependencies,

// Oclif plugins are used dynamically at runtime.
"@oclif/plugin-*",
// Danger is used at runtime in the dangerfile.
"danger",
// Types from this package are used in markdown.ts.
"mdast",
// This is needed by the fluid-build task integration in policy-check.
"tslib",
],
};
2 changes: 2 additions & 0 deletions build-tools/packages/build-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"build:test:esm": "tsc --project ./src/test/tsconfig.json",
"check:biome": "biome check .",
"check:format": "npm run check:biome",
"check:knip": "knip",
"ci:build:docs": "api-extractor run",
"clean": "rimraf --glob dist lib oclif.manifest.json \"**/*.tsbuildinfo\" \"**/*.build.log\" _api-extractor-temp nyc",
"clean:manifest": "rimraf --glob oclif.manifest.json",
Expand Down Expand Up @@ -173,6 +174,7 @@
"eslint-config-oclif-typescript": "^3.1.12",
"eslint-config-prettier": "~9.1.0",
"jssm-viz-cli": "^5.101.0",
"knip": "^5.45.0",
"mocha": "^10.7.3",
"mocha-multi-reporters": "^1.5.1",
"mocked-env": "^1.3.5",
Expand Down
9 changes: 8 additions & 1 deletion fluidBuild.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ module.exports = {
script: false,
},
"checks": {
dependsOn: ["check:format"],
dependsOn: ["check:format", "check:knip"],
script: false,
},
"checks:fix": {
Expand Down Expand Up @@ -129,6 +129,7 @@ module.exports = {
},
"check:biome": [],
"check:prettier": [],
"check:knip": [],
// ADO #7297: Review why the direct dependency on 'build:esm:test' is necessary.
// Should 'compile' be enough? compile -> build:test -> build:test:esm
"eslint": ["compile", "build:test:esm"],
Expand Down Expand Up @@ -160,6 +161,11 @@ module.exports = {

multiCommandExecutables: ["oclif", "syncpack"],
declarativeTasks: {
"knip": {
inputGlobs: ["*.*", "src/**"],
outputGlobs: ["*.*", "src/**"],
gitignore: ["input", "output"],
},
// fluid-build lowercases the executable name, so we need to use buildversion instead of buildVersion.
"flub check buildversion": {
inputGlobs: [
Expand Down Expand Up @@ -533,6 +539,7 @@ module.exports = {
["flub", "@fluid-tools/build-cli"],
["fluid-build", "@fluidframework/build-tools"],
["gf", "good-fences"],
["knip", "knip"],
["mocha", "mocha"],
["nyc", "nyc"],
["oclif", "oclif"],
Expand Down
31 changes: 31 additions & 0 deletions knip.base.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*!
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
* Licensed under the MIT License.
*/

// Enable TypeScript type-checking for this file.
// See https://www.typescriptlang.org/docs/handbook/intro-to-js-ts.html#ts-check
// @ts-check

const config = {
include: ["dependencies"],
ignoreDependencies: [
// The following deps are actually in use, but depcheck reports them unused.

// These packages are used in the CI pipelines.
"mocha-multi-reporters",
"moment",

// The following deps are reported as missing, but they are available.

// We use a 'hack' to make plugins from the shared eslint config available to our packages, those these deps are not
// directly needed in the package.
"@typescript-eslint/eslint-plugin",
"eslint-config-prettier",
"eslint-import-resolver-typescript",
"eslint-plugin-tsdoc",
"eslint-plugin-unicorn",
],
};

module.exports = config;
10 changes: 9 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@
"danger": "^11.3.0",
"eslint": "~8.55.0",
"jest": "^29.6.2",
"knip": "^5.45.0",
"mocha": "^10.8.2",
"prettier": "~3.0.3",
"pretty-quick": "^4.0.0",
Expand Down Expand Up @@ -259,6 +260,12 @@
],
"script": false
},
"check:knip": {
"dependsOn": [
"^check:knip"
],
"script": false
},
"checks": {
"dependsOn": [
"check:format",
Expand All @@ -267,7 +274,8 @@
"layer-check",
"syncpack:deps",
"syncpack:versions",
"check:versions"
"check:versions",
"check:knip"
],
"script": false
},
Expand Down
Loading
Loading