DEV Community

Cover image for no dislocation = no-undef
Peter Vivo
Peter Vivo

Posted on

2 1

no dislocation = no-undef



{ "rules": { "no-unused" : "warn"}}


Enter fullscreen mode Exit fullscreen mode

My dislocation lead me so many times to type wrong variable names in code. In Javascript that is don't cause immediately error, because thats name use as undeclared global. My solution is really simple under vs-code. With esLint no-unused rule help to mark red underline the typing errors.
This setup also show console.log, console.warn, which is also don't good to stay in product code. You can choose this rule set as warn or error, by own taste.

This method also good for alert outer dependency.

esLint json with no-unused example ::



{
  "parser": "babel-eslint",
  "plugins": ["unused-imports", "react", "react-hooks"],
  "rules": {
    "unused-imports/no-unused-imports": "warn",
    "unused-imports/no-unused-vars": [
        "warn",
        { "vars": "all", "varsIgnorePattern": "^_", "args": "after-used", "argsIgnorePattern": "^_" }
    ],
    "no-undef" : "error",
    "react/jsx-uses-vars": "warn",
    "react/jsx-uses-react": "warn"
  }
}


Enter fullscreen mode Exit fullscreen mode

Do your career a big favor. Join DEV. (The website you're on right now)

It takes one minute, it's free, and is worth it for your career.

Get started

Community matters

Top comments (0)

Visualizing Promises and Async/Await 🤓

async await

☝️ Check out this all-time classic DEV post on visualizing Promises and Async/Await 🤓

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay