From a4795b41c358ca1defe4d37369b2e3ac6895cf0b Mon Sep 17 00:00:00 2001 From: Lars Kappert Date: Mon, 9 Jan 2023 16:55:28 +0100 Subject: [PATCH] chore: update knip & config (#48963) * Re-add knip to manifest devDependencies * Move updated config to root folder * Move knip back to `npx y` in npm script Also see https://github.com/freeCodeCamp/freeCodeCamp/pull/48963#pullrequestreview-1239748056 * Bump knip to fix dependency issue --- config/knip/knip.dev.json | 27 ------------------------- config/knip/knip.json | 27 ------------------------- knip.jsonc | 42 +++++++++++++++++++++++++++++++++++++++ package.json | 4 ++-- 4 files changed, 44 insertions(+), 56 deletions(-) delete mode 100644 config/knip/knip.dev.json delete mode 100644 config/knip/knip.json create mode 100644 knip.jsonc diff --git a/config/knip/knip.dev.json b/config/knip/knip.dev.json deleted file mode 100644 index 7970a93f04711c..00000000000000 --- a/config/knip/knip.dev.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "client":{ - "dev": true, - "exclude": ["dependencies"], - "entryFiles": [ - "gatsby-*.js", - "src/pages/*.tsx", - "src/templates/Challenges/**/{s,S}how.tsx", - "src/templates/Introduction/**/{intro,super-block-intro}.tsx", - "src/**/*.test.{js,ts,tsx}" - ], - "projectFiles": [ - "src/**/*.{js,ts,tsx}", - "!static/misc/*.js", - "!i18n/schema-validation.ts", - "!plugins/**", - "!postcss.config.js", - "!src/client/frame-runner.ts", - "!src/client/workers/**", - "!webpack-workers.js", - "!**/i18n/config-for-tests.ts", - "!**/__mocks__/**", - "!**/__fixtures/**", - "!**/node_modules/**" - ] - } -} diff --git a/config/knip/knip.json b/config/knip/knip.json deleted file mode 100644 index bb0962d27512ee..00000000000000 --- a/config/knip/knip.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "client":{ - "exclude": ["dependencies"], - "entryFiles": [ - "gatsby-*.js", - "src/html.tsx", - "src/pages/*.tsx", - "src/templates/Challenges/**/{s,S}how.tsx", - "src/templates/Introduction/**/{intro,super-block-intro}.tsx", - "**/*.test.{js,ts,tsx}" - ], - "projectFiles": [ - "**/*.{js,ts,tsx}", - "!static/misc/*.js", - "!i18n/schema-validation.ts", - "!plugins/**", - "!postcss.config.js", - "!src/client/frame-runner.ts", - "!src/client/workers/**", - "!webpack-workers.js", - "!**/__mocks__/**", - "!**/__fixtures/**", - "!**/node_modules/**", - "!**/*.d.ts" - ] - } -} diff --git a/knip.jsonc b/knip.jsonc new file mode 100644 index 00000000000000..05a44e748506ce --- /dev/null +++ b/knip.jsonc @@ -0,0 +1,42 @@ +{ + "$schema": "https://unpkg.com/knip@next/schema.json", + + "ignore": "**/*.d.ts", + "ignoreBinaries": ["cd", "echo", "sh"], + + // Only workspaces with a configuration below are analyzed by Knip + "workspaces": { + ".": { + "entry": [], + // Configuration options can be overridden individually (necessary here as the default is `cypress/e2e/**/*.cy.{js,jsx,ts,tsx}`). + "cypress": ["cypress.config.js", "cypress/e2e/**/*.{js,ts}"] + }, + "client": { + // Files used by Gatsby are handled by Knip's Gatsby plugin (https://github.com/webpro/knip/blob/next/src/plugins/gatsby/README.md) + // The rest are `webpack.entry` files. + "entry": [], + "project": ["**/*.{js,ts,tsx}"], + "webpack": { + "config": "webpack-workers.js", + "entry": [ + "src/client/frame-runner.ts", + "src/client/workers/sass-compile.ts", + "src/client/workers/test-evaluator.ts" + ] + }, + "ignore": ["i18n/schema-validation.*", "**/__mocks__", "**/__fixtures__"] + }, + "client/plugins/*": { + "entry": "gatsby-node.js" + }, + // This monospace gives a few unused files, so as not to make the node.js-find-unused workflow fail this is still commented out + // Also try --production to find more unused files. + // "tools/ui-components": { + // "entry": ["src/index.ts!", "utils/gen-component-script.ts"], + // "project": ["src/**/*.{ts,tsx}!", "utils/*.ts"] + // }, + "tools/scripts/build": { + "entry": ["*.ts"] + } + } +} diff --git a/package.json b/package.json index fe431d45f03b1b..8702e1153a56dc 100644 --- a/package.json +++ b/package.json @@ -81,8 +81,8 @@ "format:prettier": "prettier --write .", "hooks:install": "node node_modules/husky/husky.js install", "hooks:uninstall": "node node_modules/husky/husky.js uninstall", - "knip": "npx -y knip -c config/knip/knip.json --dir client --include files", - "knip:client": "npx -y knip -c config/knip/knip.json --dir client", + "knip": "npx -y knip@^1.0.0-beta.10 --include files", + "knip:all": "npx -y knip@^1.0.0-beta.10", "prelint": "npm run -w=client predevelop", "lint": "npm-run-all create:* -p lint:*", "lint:challenges": "cd ./curriculum && npm run lint",