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 positive with colon in multi-line comment #889

Open
Eprince-hub opened this issue May 17, 2024 · 0 comments
Open

False positive with colon in multi-line comment #889

Eprince-hub opened this issue May 17, 2024 · 0 comments
Labels

Comments

@Eprince-hub
Copy link

Eprince-hub commented May 17, 2024

Bug Description

Depcheck reports an unused dependency when there is a colon inside a multi-line comment

Code snippets

Where the dependency is used:

import randomColor from "randomcolor";

const color = randomColor();
/* : */

Where the dependency is listed in package.json:

{
  "name": "nodejs-sandbox",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "depcheck": "depcheck"
  },
  "devDependencies": {},
  "dependencies": {
    "depcheck": "^1.4.7",
    "randomcolor": "^0.6.2"
  }
}

Using a colon inside a single-line comment or in a ternary shows no false positive

import randomColor from "randomcolor";

const color = randomColor();
// :
color ? 'a' : 'b';

Versions

  • node -v: v20.12.0
  • npm -v: 10.5.0
  • depcheck --version: 1.4.7

Extra info

Repro link: https://codesandbox.io/p/devbox/serverless-browser-g3trm3

Screenshot 2024-05-17 at 19 17 49

BONUS POINTS: If you wish to help us debug further, the depcheck --json option will show more information. Check here in the README for documentation on json output.

{"dependencies":["randomcolor"],"devDependencies":[],"missing":{},"using":{"depcheck":["/workspaces/workspace/package.json"]},"invalidFiles":{"/workspaces/workspace/index.js":"SyntaxError: Unexpected token (4:3)\n    at constructor (/workspaces/workspace/node_modules/@babel/parser/lib/index.js:351:19)\n    at FlowParserMixin.raise (/workspaces/workspace/node_modules/@babel/parser/lib/index.js:3281:19)\n    at FlowParserMixin.unexpected (/workspaces/workspace/node_modules/@babel/parser/lib/index.js:3301:16)\n    at FlowParserMixin.parseExprAtom (/workspaces/workspace/node_modules/@babel/parser/lib/index.js:10991:16)\n    at FlowParserMixin.parseExprAtom (/workspaces/workspace/node_modules/@babel/parser/lib/index.js:6829:20)\n    at FlowParserMixin.parseExprSubscripts (/workspaces/workspace/node_modules/@babel/parser/lib/index.js:10607:23)\n    at FlowParserMixin.parseUpdate (/workspaces/workspace/node_modules/@babel/parser/lib/index.js:10590:21)\n    at FlowParserMixin.parseMaybeUnary (/workspaces/workspace/node_modules/@babel/parser/lib/index.js:10568:23)\n    at FlowParserMixin.parseMaybeUnaryOrPrivate (/workspaces/workspace/node_modules/@babel/parser/lib/index.js:10422:61)\n    at FlowParserMixin.parseExprOps (/workspaces/workspace/node_modules/@babel/parser/lib/index.js:10427:23)"},"invalidDirs":{}}
@Eprince-hub Eprince-hub changed the title False positive with multi-line comment inside curly brackets of JSX expression False positive with colon in multi-line comment May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant