Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extension for VScode to find unused public function in the nodejs application

I need the VScode extension to find the un-used public function in my Nodejs application.

like image 525
Sanket Avatar asked Sep 15 '25 23:09

Sanket


1 Answers

Answer is already accepted. If someone is looking for more detailed steps then read below:

STEP 1: Add this ESLint plugin to your VS code.

STEP 2: Install eslint and eslint-plugin-node as dev dependencies using below command.

npm install eslint eslint-plugin-node --save-dev

STEP 3: Add below json file in your project root directory where package.json file sits. (Below configuration in JSON file is what I am using. You can customize/rewrite it to your requirement).

File name: .eslintrc.json

{
    "extends": [
        "eslint:recommended",
        "plugin:node/recommended"
    ],
    "parserOptions": {
        "ecmaVersion": 2018
    },
    "rules": {
        "no-console": "warn",
        "no-self-assign": "warn",
        "no-self-compare":"warn",
        "complexity": ["error", { "max": 15 }],
        "indent": ["error", 2, { "SwitchCase": 1 }],
        "no-dupe-keys": "error",
        "no-invalid-regexp": "error",
        "no-undef": "error",
        "no-return-assign": "error",
        "no-redeclare": "error",
        "no-empty": "error",
        "no-await-in-loop": "error",
        "node/exports-style": ["error", "module.exports"],
        "node/file-extension-in-import": ["error", "always"],
        "node/prefer-global/buffer": ["error", "always"],
        "node/prefer-global/console": ["error", "always"],
        "node/prefer-global/process": ["error", "always"],
        "node/prefer-global/url-search-params": ["error", "always"],
        "node/prefer-global/url": ["error", "always"],
        "node/prefer-promises/dns": "error",
        "node/prefer-promises/fs": "error"
    }
}

STEP 4: Whenever you open a file you will see below errors in PROBLEMS tab enter image description here

like image 194
Dheemanth Bhat Avatar answered Sep 17 '25 19:09

Dheemanth Bhat