DEV Community

Taylor Beseda
Taylor Beseda

Posted on

Eslint Fix An Existing JavaScript Project

Need some syntax sanity after creating a mess or inheriting one? Quickly format an entire project (or select files) with eslint:

Add your preferred eslint config (mine is Airbnb's) as a development dependency:

npx install-peerdeps --dev eslint-config-airbnb

an .eslintrc file to your project root:

{
  "extends": "airbnb"
}

a couple commands to your project's package.json:

  "scripts": {
    ...
    "lint": "eslint . --ext .js",
    "lint-fix": "eslint . --ext .js --fix"
  },

Note: the above entries look at your entire project!

Run npm run lint for a report and npm run lint-fix to format all .js files.

Top comments (0)