Skip to content

Instantly share code, notes, and snippets.

@travishorn
Last active July 11, 2024 13:28
Show Gist options
  • Save travishorn/67d66ad896f31274c1c4c727c74992ea to your computer and use it in GitHub Desktop.
Save travishorn/67d66ad896f31274c1c4c727c74992ea to your computer and use it in GitHub Desktop.
Set up project with ESLint and Prettier

Install the VS Code extensions:

  1. Open VS Code
  2. Ctrl + Shift + X
  3. Search for "ESLint"
  4. Click the blue "Install" button
  5. Search for "Prettier"
  6. Click the blue "Install" button

In your project directory (the one containing package.json), install the development dependencies:

npm i -D @eslint/js eslint eslint-config-prettier globals prettier

Create .prettierrc containing only {} or the configuration you want to use.

Create eslint.config.js with the contents below or the configuration you want to use.

Add the scripts below to package.json.

import globals from "globals";
import pluginJs from "@eslint/js";
import eslintConfigPrettier from "eslint-config-prettier";
export default [
{ languageOptions: { globals: globals.node } },
pluginJs.configs.recommended,
eslintConfigPrettier,
];
{
"scripts": {
"lint": "eslint .",
"format": "prettier --write ."
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment