Skip to content

Commit 8a91488

Browse files
committed
Detect dead code in spec/dummy as well
1 parent 458c74e commit 8a91488

File tree

5 files changed

+63
-53
lines changed

5 files changed

+63
-53
lines changed

.github/workflows/lint-js-and-ruby.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ jobs:
4949
run: bundle check --path=vendor/bundle || bundle _2.5.9_ install --path=vendor/bundle --jobs=4 --retry=3
5050
- name: Lint Ruby
5151
run: bundle exec rubocop
52+
- name: Install Node modules with Yarn for dummy app
53+
run: cd spec/dummy && yarn install --ignore-scripts --no-progress --no-emoji
54+
- name: generate file system-based packs
55+
run: cd spec/dummy && RAILS_ENV=test bundle exec rake react_on_rails:generate_packs
5256
- name: Detect dead code
5357
run: |
5458
yarn run knip

knip.ts

Lines changed: 56 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,62 @@ import type { KnipConfig } from 'knip';
22

33
const config: KnipConfig = {
44
// ! at the end means files are used in production
5-
entry: ['node_package/src/ReactOnRails.ts!', 'node_package/src/ReactOnRails.node.ts!'],
6-
project: ['node_package/src/**/*.[jt]s!', 'node_package/tests/**/*.[jt]s'],
7-
ignoreBinaries: [
8-
// Knip fails to detect it's declared in devDependencies
9-
'nps',
10-
// local scripts
11-
'node_package/scripts/.*',
12-
],
13-
ignoreDependencies: [
14-
// Required for TypeScript compilation, but we don't depend on Turbolinks itself.
15-
'@types/turbolinks',
16-
// used in package-scripts.yml
17-
'concurrently',
18-
// The Knip ESLint plugin fails to detect it's transitively required by a config,
19-
// though we don't actually use its rules anywhere.
20-
'eslint-plugin-jsx-a11y',
21-
],
22-
babel: {
23-
config: ['node_package/babel.config.js', 'package.json'],
5+
workspaces: {
6+
'.': {
7+
entry: ['node_package/src/ReactOnRails.ts!', 'node_package/src/ReactOnRails.node.ts!'],
8+
project: ['node_package/src/**/*.[jt]s!', 'node_package/tests/**/*.[jt]s'],
9+
ignoreBinaries: [
10+
// Knip fails to detect it's declared in devDependencies
11+
'nps',
12+
// local scripts
13+
'node_package/scripts/.*',
14+
],
15+
ignoreDependencies: [
16+
// Required for TypeScript compilation, but we don't depend on Turbolinks itself.
17+
'@types/turbolinks',
18+
// used in package-scripts.yml
19+
'concurrently',
20+
// The Knip ESLint plugin fails to detect it's transitively required by a config,
21+
// though we don't actually use its rules anywhere.
22+
'eslint-plugin-jsx-a11y',
23+
],
24+
babel: {
25+
config: ['node_package/babel.config.js'],
26+
},
27+
},
28+
'spec/dummy': {
29+
entry: [
30+
'app/assets/config/manifest.js!',
31+
'client/app/packs/**/*.js!',
32+
// Not sure why this isn't detected as a dependency of client/app/packs/server-bundle.js
33+
'client/app/generated/server-bundle-generated.js!',
34+
'spec/fixtures/automated_packs_generation/**/*.js{x,}',
35+
'config/webpack/{production,development,test}.js',
36+
// Declaring this as webpack.config instead doesn't work correctly
37+
'config/webpack/webpack.config.js',
38+
],
39+
project: [
40+
'**/*.{js,cjs,mjs,jsx,ts,cts,mts,tsx}!',
41+
'config/webpack/*.js',
42+
],
43+
paths: {
44+
'Assets/*': ['client/app/assets/*'],
45+
},
46+
ignoreBinaries: [
47+
// Has to be installed globally
48+
'yalc',
49+
// Local binaries
50+
'bin/.*',
51+
],
52+
ignoreDependencies: [
53+
// There's no ReScript plugin for Knip
54+
'@rescript/react',
55+
// The Babel plugin fails to detect it
56+
'babel-plugin-transform-react-remove-prop-types',
57+
// Temporary!
58+
'.*',
59+
],
60+
},
2461
},
2562
};
2663

spec/dummy/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
"create-react-class": "^15.6.3",
2424
"css-loader": "^6.5.1",
2525
"css-minimizer-webpack-plugin": "^3.1.3",
26-
"eslint-plugin-prettier": "^3.1.0",
2726
"expose-loader": "^1.0.3",
2827
"file-loader": "^6.2.0",
2928
"history": "^4.6.3",
@@ -45,6 +44,7 @@
4544
"react-router-dom": "^5.2.0",
4645
"redux": "^4.0.1",
4746
"redux-thunk": "^2.2.0",
47+
"regenerator-runtime": "^0.13.4",
4848
"rescript": "^11.1.4",
4949
"resolve-url-loader": "^3.1.1",
5050
"sass": "^1.43.4",
@@ -74,8 +74,8 @@
7474
"preinstall": "yarn run link-source && yalc add --link react-on-rails",
7575
"link-source": "cd ../.. && yarn run build && yalc publish",
7676
"lint": "cd ../.. && yarn run lint",
77-
"format": "cd ../.. && yarn start format",
78-
"test": "yarn run build:test && yarn run lint && rspec",
77+
"format": "cd ../.. && yarn run nps format",
78+
"test": "yarn run build:test && yarn run lint && bin/rspec",
7979
"build:test": "rm -rf public/webpack/test && yarn build:rescript && RAILS_ENV=test NODE_ENV=test bin/shakapacker",
8080
"build:dev": "rm -rf public/webpack/development && yarn build:rescript && RAILS_ENV=development NODE_ENV=development bin/shakapacker",
8181
"build:dev:server": "rm -rf public/webpack/development && yarn build:rescript && RAILS_ENV=development NODE_ENV=development bin/shakapacker --watch",

spec/dummy/postcss.config.js

Lines changed: 0 additions & 12 deletions
This file was deleted.

spec/dummy/yarn.lock

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4037,13 +4037,6 @@ escape-string-regexp@^1.0.5:
40374037
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4"
40384038
integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=
40394039

4040-
eslint-plugin-prettier@^3.1.0:
4041-
version "3.1.2"
4042-
resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-3.1.2.tgz#432e5a667666ab84ce72f945c72f77d996a5c9ba"
4043-
integrity sha512-GlolCC9y3XZfv3RQfwGew7NnuFDKsfI4lbvRK+PIIo23SFH+LemGs4cKwzAaRa+Mdb+lQO/STaIayno8T5sJJA==
4044-
dependencies:
4045-
prettier-linter-helpers "^1.0.0"
4046-
40474040
eslint-scope@5.1.1:
40484041
version "5.1.1"
40494042
resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.1.1.tgz#e786e59a66cb92b3f6c1fb0d508aab174848f48c"
@@ -4239,11 +4232,6 @@ fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3:
42394232
resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525"
42404233
integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==
42414234

4242-
fast-diff@^1.1.2:
4243-
version "1.2.0"
4244-
resolved "https://registry.yarnpkg.com/fast-diff/-/fast-diff-1.2.0.tgz#73ee11982d86caaf7959828d519cfe927fac5f03"
4245-
integrity sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w==
4246-
42474235
fast-json-stable-stringify@^2.0.0:
42484236
version "2.1.0"
42494237
resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633"
@@ -6278,13 +6266,6 @@ prefix-matches@^1.0.1:
62786266
is-object "^1.0.1"
62796267
starts-with "^1.0.2"
62806268

6281-
prettier-linter-helpers@^1.0.0:
6282-
version "1.0.0"
6283-
resolved "https://registry.yarnpkg.com/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz#d23d41fe1375646de2d0104d3454a3008802cf7b"
6284-
integrity sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==
6285-
dependencies:
6286-
fast-diff "^1.1.2"
6287-
62886269
private@^0.1.8:
62896270
version "0.1.8"
62906271
resolved "https://registry.yarnpkg.com/private/-/private-0.1.8.tgz#2381edb3689f7a53d653190060fcf822d2f368ff"

0 commit comments

Comments
 (0)