Commit
chore: configure ESLint and Prettier
Commands
npm install --save-dev eslint prettier \
@typescript-eslint/parser @typescript-eslint/eslint-plugin \
eslint-config-prettier
Update your package.json
to enable ECMAScript modules:
{
"type": "module",
...
}
Create ESLint config (ESLint v9+ compatible)
📄 eslint.config.js
import eslintPluginTs from "@typescript-eslint/eslint-plugin";
import parserTs from "@typescript-eslint/parser";
import prettier from "eslint-config-prettier";
export default [
{
files: ["**/*.ts"],
languageOptions: {
parser: parserTs
},
plugins: {
"@typescript-eslint": eslintPluginTs
},
rules: {
...eslintPluginTs.configs.recommended.rules,
"@typescript-eslint/no-unused-vars": ["warn", { argsIgnorePattern: "^_" }]
},
ignores: ["dist/**", "node_modules/**"]
},
prettier
];
Create Prettier config
📄 .prettierrc
{
"semi": true,
"singleQuote": false,
"tabWidth": 2,
"printWidth": 80,
"trailingComma": "es5"
}
Update package.json
scripts
"scripts": {
"lint": "eslint 'src/**/*.ts'",
"format": "prettier --write 'src/**/*.ts'"
}
Verification
- Run ESLint
npm run lint
- Run Prettier
npm run format
- Optional: enable auto-formatting in VS Code
📄
.vscode/settings.json
{
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll": true,
"source.fixAll.eslint": true
},
"eslint.validate": ["typescript"]
}
✅ ESLint and Prettier are now integrated and ready to keep your code clean and consistent.
Next step:
chore: setup Express and add /health route