Skip to content

Commit

Permalink
Detect dead code in spec/dummy as well
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeyr committed Jan 23, 2025
1 parent 458c74e commit 5765b58
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 53 deletions.
75 changes: 56 additions & 19 deletions knip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,62 @@ import type { KnipConfig } from 'knip';

const config: KnipConfig = {
// ! at the end means files are used in production
entry: ['node_package/src/ReactOnRails.ts!', 'node_package/src/ReactOnRails.node.ts!'],
project: ['node_package/src/**/*.[jt]s!', 'node_package/tests/**/*.[jt]s'],
ignoreBinaries: [
// Knip fails to detect it's declared in devDependencies
'nps',
// local scripts
'node_package/scripts/.*',
],
ignoreDependencies: [
// Required for TypeScript compilation, but we don't depend on Turbolinks itself.
'@types/turbolinks',
// used in package-scripts.yml
'concurrently',
// The Knip ESLint plugin fails to detect it's transitively required by a config,
// though we don't actually use its rules anywhere.
'eslint-plugin-jsx-a11y',
],
babel: {
config: ['node_package/babel.config.js', 'package.json'],
workspaces: {
'.': {
entry: ['node_package/src/ReactOnRails.ts!', 'node_package/src/ReactOnRails.node.ts!'],
project: ['node_package/src/**/*.[jt]s!', 'node_package/tests/**/*.[jt]s'],
ignoreBinaries: [
// Knip fails to detect it's declared in devDependencies
'nps',
// local scripts
'node_package/scripts/.*',
],
ignoreDependencies: [
// Required for TypeScript compilation, but we don't depend on Turbolinks itself.
'@types/turbolinks',
// used in package-scripts.yml
'concurrently',
// The Knip ESLint plugin fails to detect it's transitively required by a config,
// though we don't actually use its rules anywhere.
'eslint-plugin-jsx-a11y',
],
babel: {
config: ['node_package/babel.config.js'],
},
},
'spec/dummy': {
entry: [
'app/assets/config/manifest.js!',
'client/app/packs/**/*.js!',
// Not sure why this isn't detected as a dependency of client/app/packs/server-bundle.js
'client/app/generated/server-bundle-generated.js!',
'spec/fixtures/automated_packs_generation/**/*.js{x,}',
'config/webpack/{production,development,test}.js',
// Declaring this as webpack.config instead doesn't work correctly
'config/webpack/webpack.config.js',
],
project: [
'**/*.{js,cjs,mjs,jsx,ts,cts,mts,tsx}!',
'config/webpack/*.js',
],
paths: {
'Assets/*': ['client/app/assets/*'],
},
ignoreBinaries: [
// Has to be installed globally
'yalc',
// Local binaries
'bin/.*',
],
ignoreDependencies: [
// There's no ReScript plugin for Knip
'@rescript/react',
// The Babel plugin fails to detect it
'babel-plugin-transform-react-remove-prop-types',
// Temporary!
'.*',
],
},
},
};

Expand Down
6 changes: 3 additions & 3 deletions spec/dummy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"create-react-class": "^15.6.3",
"css-loader": "^6.5.1",
"css-minimizer-webpack-plugin": "^3.1.3",
"eslint-plugin-prettier": "^3.1.0",
"expose-loader": "^1.0.3",
"file-loader": "^6.2.0",
"history": "^4.6.3",
Expand All @@ -45,6 +44,7 @@
"react-router-dom": "^5.2.0",
"redux": "^4.0.1",
"redux-thunk": "^2.2.0",
"regenerator-runtime": "^0.13.4",
"rescript": "^11.1.4",
"resolve-url-loader": "^3.1.1",
"sass": "^1.43.4",
Expand Down Expand Up @@ -74,8 +74,8 @@
"preinstall": "yarn run link-source && yalc add --link react-on-rails",
"link-source": "cd ../.. && yarn run build && yalc publish",
"lint": "cd ../.. && yarn run lint",
"format": "cd ../.. && yarn start format",
"test": "yarn run build:test && yarn run lint && rspec",
"format": "cd ../.. && yarn run nps format",
"test": "yarn run build:test && yarn run lint && bin/rspec",
"build:test": "rm -rf public/webpack/test && yarn build:rescript && RAILS_ENV=test NODE_ENV=test bin/shakapacker",
"build:dev": "rm -rf public/webpack/development && yarn build:rescript && RAILS_ENV=development NODE_ENV=development bin/shakapacker",
"build:dev:server": "rm -rf public/webpack/development && yarn build:rescript && RAILS_ENV=development NODE_ENV=development bin/shakapacker --watch",
Expand Down
12 changes: 0 additions & 12 deletions spec/dummy/postcss.config.js

This file was deleted.

19 changes: 0 additions & 19 deletions spec/dummy/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4037,13 +4037,6 @@ escape-string-regexp@^1.0.5:
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4"
integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=

eslint-plugin-prettier@^3.1.0:
version "3.1.2"
resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-3.1.2.tgz#432e5a667666ab84ce72f945c72f77d996a5c9ba"
integrity sha512-GlolCC9y3XZfv3RQfwGew7NnuFDKsfI4lbvRK+PIIo23SFH+LemGs4cKwzAaRa+Mdb+lQO/STaIayno8T5sJJA==
dependencies:
prettier-linter-helpers "^1.0.0"

[email protected]:
version "5.1.1"
resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.1.1.tgz#e786e59a66cb92b3f6c1fb0d508aab174848f48c"
Expand Down Expand Up @@ -4239,11 +4232,6 @@ fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3:
resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525"
integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==

fast-diff@^1.1.2:
version "1.2.0"
resolved "https://registry.yarnpkg.com/fast-diff/-/fast-diff-1.2.0.tgz#73ee11982d86caaf7959828d519cfe927fac5f03"
integrity sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w==

fast-json-stable-stringify@^2.0.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633"
Expand Down Expand Up @@ -6278,13 +6266,6 @@ prefix-matches@^1.0.1:
is-object "^1.0.1"
starts-with "^1.0.2"

prettier-linter-helpers@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz#d23d41fe1375646de2d0104d3454a3008802cf7b"
integrity sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==
dependencies:
fast-diff "^1.1.2"

private@^0.1.8:
version "0.1.8"
resolved "https://registry.yarnpkg.com/private/-/private-0.1.8.tgz#2381edb3689f7a53d653190060fcf822d2f368ff"
Expand Down

0 comments on commit 5765b58

Please sign in to comment.