DEV Community

Taylor Beseda
Taylor Beseda

Posted on

1

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)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay