question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

special/eslint: bad calculation of preset dependencies

See original GitHub issue

Bug Description

In a monorepo project managed by yarn, I have a package containing my eslint configuration. Every eslint needed dependency is set as a dependency (not dev!) of this package.

This is currently working because of 2 bugs, one masking the other:

  • the method requireConfig of eslint.js only searches for configuration dependency in the current directory, therefore ignoring structures like yarn workspaces; it should use the new utils.loadMetadata function to use the real node resolution mechanism;
  • when analyzing eslint configuration dependencies, it does not look at this dependencies’ dependencies.

In a normal environment (if I had a configuration package apart), the process would fail because it would be able to analyse the project configuration file, see that a lot of packages are needed, but not see that they already are integrated because dependencies of this configuration package, so displaying a lot of “missing dependencies”.

Code snippets

In the package @my-project/eslint-config:

File .eslintrc.yaml:

plugins:
  - react-hooks

File package.json:

  "dependencies": {
    "eslint-plugin-react-hooks": "2.2.0"
  }

In the package @my-project/other-package

File .eslintrc.yaml:

extends:
  - '@my-project'

File package.json:

  "devDependencies": {
    "@my-project/eslint-config": "0.0.1"
  }

Execution

In the directory of other-package:

depcheck --specials=eslint

Expected result

No error.

Actual result

  • with a yarn workspace, no error because hoist eslint-config is not seen by the analyzer;
  • with npm and lerna, missing dependencies: eslint-plugin-react-hooks because the analyzer sees the eslint-config but does not read its included dependencies.

Versions

  • node -v: 12.13.0
  • npm -v: 6.12.0
  • yarn -v: 1.19.1
  • depcheck --version: 0.9.1

Extra info

Sorry for not publishing a PR, but I can’t really spend more time on depcheck.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
rumplcommented, Nov 13, 2019

🎉

I’ll buy you a beer next time you come to Paris 😃

0reactions
sveyretcommented, Nov 13, 2019

Finally, I’m working on it… 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

depcheck - npm
Depcheck is a tool for analyzing the dependencies in a project to see: how each dependency is used, which dependencies are useless, and...
Read more >
depcheck | Yarn - Package Manager
Depcheck is a tool for analyzing the dependencies in a project to see: how each dependency is used, which dependencies are useless, and...
Read more >
depcheck - UNPKG
144, - eslint: dependency wrongly mark as unused [\#500](https://github.com/depcheck/depcheck/issues/500). 145, - special/eslint: bad calculation of preset ...
Read more >
https://raw.githubusercontent.com/depcheck/depchec...
... dependency wrongly mark as unused [\#500](https://github.com/depcheck/depcheck/issues/500) - special/eslint: bad calculation of preset dependencies ...
Read more >
Check Your NPM Module for Unused Dependencies: depcheck
--skip-missing=[true|false] : A flag to indicate if depcheck skips calculation of missing dependencies. The default value is false . --json : Output results...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found