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

False positives when using multiple package.json files #441

Closed
geraintwhite opened this issue Oct 31, 2019 · 1 comment
Closed

False positives when using multiple package.json files #441

geraintwhite opened this issue Oct 31, 2019 · 1 comment

Comments

@geraintwhite
Copy link

Bug Description

When using multiple package.json files in folders of a project depcheck cannot properly check imports within those folders.

I am using multiple package.json files to achieve absolute import paths (because babel-plugin-module-resolver doesn't work well with react-native).

  • I have my main package.json in the project root containing all my dependencies.
  • I also have a package.json in the app directory (which is where most of the code is), containing only { "name": "app" }.
  • This allows me to import files using the import from 'app/modules/...' syntax anywhere in the project.

The problem is that running depcheck in the root of the project reports that every dependency used in the app folder is unused, but when I remove app/package.json it reports the dependency usage correctly.

Versions

  • node -v: v12.4.0
  • npm -v: 6.9.0
  • depcheck --version: 0.8.4

JSON Output

With app/package.json file

{
  "dependencies": [
    "@bt-fv/react-native-liblinphone",
    "@react-native-community/push-notification-ios",
    "color",
    "jail-monkey",
    "libphonenumber-js",
    "moment",
    "react-dom",
    "react-native-action-sheet",
    "react-native-adobe-analytics",
    "react-native-android-open-settings",
    "react-native-audio-record",
    "react-native-audiowaveform",
    "react-native-callkeep",
    "react-native-collapsible",
    "react-native-contacts",
    "react-native-device-info",
    "react-native-fs",
    "react-native-gesture-handler",
    "react-native-keyboard-aware-scroll-view",
    "react-native-material-dropdown",
    "react-native-modal",
    "react-native-offline",
    "react-native-push-notification",
    "react-native-reanimated",
    "react-native-share",
    "react-native-slider",
    "react-native-splash-screen",
    "react-native-swipeable",
    "react-native-tab-view",
    "react-native-voip-push-notification",
    "react-native-web",
    "react-native-web-modal",
    "react-native-webview",
    "react-native-xml2js",
    "react-navigation",
    "react-navigation-stack",
    "react-navigation-tabs",
    "react-redux",
    "redux",
    "redux-persist",
    "redux-thunk",
    "uuid",
    "wavesurfer.js"
  ],
  "devDependencies": [
    "@babel/core",
    "@svgr/webpack",
    "babel-loader",
    "babel-preset-react-app",
    "buffer",
    "case-sensitive-paths-webpack-plugin",
    "chalk",
    "copy-webpack-plugin",
    "dotenv",
    "dotenv-expand",
    "electron-devtools-installer",
    "eslint-loader",
    "file-loader",
    "fs-extra",
    "html-webpack-plugin",
    "husky",
    "metro-react-native-babel-preset",
    "node-loader",
    "object-assign",
    "progress-bar-webpack-plugin",
    "promise",
    "raf",
    "react-dev-utils",
    "react-shallow-testutils",
    "react-test-renderer",
    "redux-devtools-extension",
    "terser-webpack-plugin",
    "url-loader",
    "wait-on",
    "webpack",
    "webpack-dev-server",
    "webpack-merge",
    "whatwg-fetch"
  ],
  "missing": {
    "app": [...],
    "metro-config": [...]
  },
  "using": {
    "babel-eslint": [...],
    "eslint-plugin-jest": [...],
    "eslint-plugin-react": [...],
    "eslint-plugin-react-native": [...],
    "eslint-plugin-import": [...],
    "eslint-plugin-flowtype": [...],
    "eslint": [...],
    "@react-native-community/async-storage": [...],
    "react": [...],
    "react-native": [...],
    "react-native-permissions": [...],
    "react-native-sentry": [...],
    "app": [...],
    "react-native-config": [...],
    "metro-config": [...],
    "react-native-svg-transformer": [...],
    "react-native-svg": [...],
    "check-node-version": [...],
    "concurrently": [...],
    "electron": [...],
    "electron-packager": [...],
    "electron-rebuild": [...],
    "eslint-watch": [...],
    "flow-bin": [...],
    "flow-watch": [...],
    "jest": [...],
    "jetifier": [...],
    "react-native-version": [...],
    "@bsft/mock-data-seed": [...]
  }
}

Without app/package.json file

{
  "dependencies": [],
  "devDependencies": [
    "buffer",
    "husky",
    "metro-react-native-babel-preset",
    "wait-on"
  ],
  "missing": {
    "app": [...],
    "prop-types": [...],
    "raven-js": [...],
    "metro-config": [...]
  },
  "using": {
    "babel-eslint": [...],
    "eslint-plugin-jest": [...],
    "eslint-plugin-react": [...],
    "eslint-plugin-react-native": [...],
    "eslint-plugin-import": [...],
    "eslint-plugin-flowtype": [...],
    "eslint": [...],
    "@react-native-community/async-storage": [...],
    "react": [...],
    "react-native": [...],
    "react-native-permissions": [...],
    "react-test-renderer": [...],
    "app": [...],
    "react-shallow-testutils": [...],
    "react-native-config": [...],
    "react-navigation": [...],
    "react-redux": [...],
    "redux": [...],
    "react-native-swipeable": [...],
    "moment": [...],
    "uuid": [...],
    "react-native-keyboard-aware-scroll-view": [...],
    "react-native-collapsible": [...],
    "react-native-tab-view": [...],
    "react-native-gesture-handler": [...],
    "react-native-reanimated": [...],
    "react-native-adobe-analytics": [...],
    "react-native-action-sheet": [...],
    "react-native-webview": [...],
    "react-native-share": [...],
    "react-native-material-dropdown": [...],
    "color": [...],
    "react-dom": [...],
    "wavesurfer.js": [...],
    "react-native-audiowaveform": [...],
    "react-native-audio-record": [...],
    "react-native-modal": [...],
    "react-native-slider": [...],
    "react-native-svg": [...],
    "jail-monkey": [...],
    "prop-types": [...],
    "react-native-offline": [...],
    "redux-persist": [...],
    "react-native-splash-screen": [...],
    "react-native-callkeep": [...],
    "react-native-contacts": [...],
    "react-native-sentry": [...],
    "react-native-voip-push-notification": [...],
    "react-native-push-notification": [...],
    "@react-native-community/push-notification-ios": [...],
    "@bt-fv/react-native-liblinphone": [...],
    "react-native-fs": [...],
    "react-navigation-stack": [...],
    "react-navigation-tabs": [...],
    "redux-devtools-extension": [...],
    "redux-thunk": [...],
    "react-native-device-info": [...],
    "react-native-xml2js": [...],
    "react-native-android-open-settings": [...],
    "libphonenumber-js": [...],
    "electron": [...],
    "promise": [...],
    "whatwg-fetch": [...],
    "object-assign": [...],
    "raf": [...],
    "react-dev-utils": [...],
    "webpack": [...],
    "progress-bar-webpack-plugin": [...],
    "url-loader": [...],
    "@svgr/webpack": [...],
    "babel-loader": [...],
    "babel-preset-react-app": [...],
    "file-loader": [...],
    "@babel/core": [...],
    "dotenv-expand": [...],
    "dotenv": [...],
    "webpack-merge": [...],
    "case-sensitive-paths-webpack-plugin": [...],
    "html-webpack-plugin": [...],
    "node-loader": [...],
    "terser-webpack-plugin": [...],
    "copy-webpack-plugin": [...],
    "eslint-loader": [...],
    "react-native-web": [...],
    "react-native-web-modal": [...],
    "fs-extra": [...],
    "raven-js": [...],
    "electron-devtools-installer": [...],
    "chalk": [...],
    "webpack-dev-server": [...],
    "metro-config": [...],
    "react-native-svg-transformer": [...],
    "check-node-version": [...],
    "concurrently": [...],
    "electron-packager": [...],
    "electron-rebuild": [...],
    "eslint-watch": [...],
    "flow-bin": [...],
    "flow-watch": [...],
    "jest": [...],
    "jetifier": [...],
    "react-native-version": [...],
    "@bsft/mock-data-seed": [...]
  }
}
@rumpl
Copy link
Member

rumpl commented Oct 31, 2019

Hi @grit96 thanks for reporting this.

To be honest I don't think I'll work on this. It's a hack for making some babel plugin work, it would be better if the babel plugin fixed this issue so that you don't have to create random pakage.json files in your project.

@rumpl rumpl closed this as completed Nov 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants