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

build: Add depcheck tasks to some packages #23992

Closed
wants to merge 5 commits into from
Closed
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
36 changes: 36 additions & 0 deletions .depcheckrc.base.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*!
* 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

/**
* This base depcheck config is shared by all packages in the repo.
*
* @type {import("depcheck").Config}
*/
const config = {
ignores: [
// 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",
],
ignorePatterns: [],
};

module.exports = config;
36 changes: 36 additions & 0 deletions build-tools/packages/build-cli/.depcheckrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*!
* 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

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

/**
* @type {import("depcheck").Config}
*/
const config = {
ignores: [
...sharedConfig.ignores,

// The following deps are actually in use, but depcheck reports them unused.

// 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",
],
};

module.exports = config;
6 changes: 2 additions & 4 deletions build-tools/packages/build-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"build:readme": "oclif readme --version 0.0.0 --multi --no-aliases",
"build:test:esm": "tsc --project ./src/test/tsconfig.json",
"check:biome": "biome check .",
"check:depcheck": "depcheck",
"check:format": "npm run check:biome",
"ci:build:docs": "api-extractor run",
"clean": "rimraf --glob dist lib oclif.manifest.json \"**/*.tsbuildinfo\" \"**/*.build.log\" _api-extractor-temp nyc",
Expand Down Expand Up @@ -131,7 +132,6 @@
"replace-in-file": "^7.2.0",
"resolve.exports": "^2.0.2",
"semver": "^7.6.3",
"semver-utils": "^1.1.4",
"simple-git": "^3.27.0",
"sort-json": "^2.0.1",
"sort-package-json": "1.57.0",
Expand All @@ -144,7 +144,6 @@
},
"devDependencies": {
"@biomejs/biome": "~1.9.3",
"@fluidframework/build-common": "^2.0.3",
"@fluidframework/eslint-config-fluid": "^5.4.0",
"@oclif/test": "^4.1.0",
"@types/async": "^3.2.24",
Expand All @@ -159,15 +158,14 @@
"@types/prettier": "^2.7.3",
"@types/prompts": "^2.4.9",
"@types/semver": "^7.5.8",
"@types/semver-utils": "^1.1.3",
"@types/sort-json": "^2.0.3",
"@types/unist": "^3.0.3",
"@types/xml2js": "^0.4.14",
"c8": "^7.14.0",
"chai": "^4.5.0",
"chai-arrays": "^2.2.0",
"concurrently": "^8.2.2",
"copyfiles": "^2.4.1",
"depcheck": "^1.4.7",
"eslint": "~8.57.0",
"eslint-config-oclif": "^5.2.1",
"eslint-config-oclif-typescript": "^3.1.12",
Expand Down
10 changes: 9 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:depcheck"],
script: false,
},
"checks:fix": {
Expand Down Expand Up @@ -129,6 +129,7 @@ module.exports = {
},
"check:biome": [],
"check:prettier": [],
"check:depcheck": [],
// 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,12 @@ module.exports = {

multiCommandExecutables: ["oclif", "syncpack"],
declarativeTasks: {
// Depcheck looks at all files in the package, so we need to include all files in the input and output globs.
"depcheck": {
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 @@ -528,6 +535,7 @@ module.exports = {
["concurrently", "concurrently"],
["copyfiles", "copyfiles"],
["cross-env", "cross-env"],
["depcheck", "depcheck"],
["depcruise", "dependency-cruiser"],
["eslint", "eslint"],
["flub", "@fluid-tools/build-cli"],
Expand Down
10 changes: 9 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@
"concurrently": "^8.2.1",
"copyfiles": "^2.4.1",
"danger": "^11.3.0",
"depcheck": "^1.4.7",
"eslint": "~8.55.0",
"jest": "^29.6.2",
"mocha": "^10.2.0",
Expand Down Expand Up @@ -253,6 +254,12 @@
"build:readme": {
"dependsOn": []
},
"check:depcheck": {
"dependsOn": [
"^check:depcheck"
],
"script": false
},
"check:format": {
"dependsOn": [
"check:format:repo"
Expand All @@ -267,7 +274,8 @@
"layer-check",
"syncpack:deps",
"syncpack:versions",
"check:versions"
"check:versions",
"check:depcheck"
],
"script": false
},
Expand Down
27 changes: 27 additions & 0 deletions packages/framework/presence/.depcheckrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*!
* 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

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

/**
* @type {import("depcheck").Config}
*/
const config = {
ignores: [
...sharedConfig.ignores,

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

// This reference is flagged because of an unusual import in ./src/datastorePresenceManagerFactory.ts
"@fluidframework/presence",
],
};

module.exports = config;
2 changes: 2 additions & 0 deletions packages/framework/presence/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"build:test:esm:core-interfaces-no-exactOptionalPropertyTypes": "tsc --project ./src/test/core-interfaces/tsconfig.no-exactOptionalPropertyTypes.json",
"check:are-the-types-wrong": "attw --pack . --profile node16",
"check:biome": "biome check .",
"check:depcheck": "depcheck",
"check:exports": "concurrently \"npm:check:exports:*\"",
"check:exports:bundle-release-tags": "api-extractor run --config api-extractor/api-extractor-lint-bundle.json",
"check:exports:cjs:alpha": "api-extractor run --config api-extractor/api-extractor-lint-alpha.cjs.json",
Expand Down Expand Up @@ -145,6 +146,7 @@
"concurrently": "^8.2.1",
"copyfiles": "^2.4.1",
"cross-env": "^7.0.3",
"depcheck": "^1.4.7",
"eslint": "~8.55.0",
"mocha": "^10.2.0",
"mocha-multi-reporters": "^1.5.1",
Expand Down
18 changes: 18 additions & 0 deletions packages/runtime/container-runtime/.depcheckrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*!
* 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

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

/**
* @type {import("depcheck").Config}
*/
const config = sharedConfig;

module.exports = config;
3 changes: 2 additions & 1 deletion packages/runtime/container-runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
"build:test:esm": "tsc --project ./src/test/tsconfig.json",
"check:are-the-types-wrong": "attw --pack . --exclude-entrypoints ./internal/test/containerRuntime ./internal/test/deltaScheduler ./internal/test/blobManager ./internal/test/summary ./internal/test/gc",
"check:biome": "biome check .",
"check:depcheck": "depcheck",
"check:exports": "concurrently \"npm:check:exports:*\"",
"check:exports:bundle-release-tags": "api-extractor run --config api-extractor/api-extractor-lint-bundle.json",
"check:exports:cjs:legacy": "api-extractor run --config api-extractor/api-extractor-lint-legacy.cjs.json",
Expand Down Expand Up @@ -183,7 +184,6 @@
"@fluidframework/runtime-definitions": "workspace:~",
"@fluidframework/runtime-utils": "workspace:~",
"@fluidframework/telemetry-utils": "workspace:~",
"@tylerbu/sorted-btree-es6": "^1.8.0",
"double-ended-queue": "^2.1.0-0",
"lz4js": "^0.2.0",
"uuid": "^9.0.0"
Expand Down Expand Up @@ -212,6 +212,7 @@
"concurrently": "^8.2.1",
"copyfiles": "^2.4.1",
"cross-env": "^7.0.3",
"depcheck": "^1.4.7",
"eslint": "~8.55.0",
"mocha": "^10.2.0",
"mocha-multi-reporters": "^1.5.1",
Expand Down
Loading
Loading