From 06d381449e2cd0526efac45a67df1aab13dee43d Mon Sep 17 00:00:00 2001 From: Debasmita Date: Sun, 12 Jul 2026 20:26:08 +0530 Subject: [PATCH] chore: add ESLint config, lint:fix script, and code quality docs (Closes #417) --- .eslintignore | 6 ++++++ CONTRIBUTING.md | 25 +++++++++++++++++++++++++ eslint.config.mjs | 13 +++++++++++-- package.json | 1 + 4 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 .eslintignore diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 000000000..67d23fd60 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,6 @@ +.next/ +node_modules/ +public/ +.next/ +*.js.map +*.d.ts diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c5a87a3cf..adbf1ad9a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -287,6 +287,31 @@ Examples: `feat/contribution-heatmap`, `fix/github-api-rate-limit`, `docs/supaba --- +### Lint & Code Quality + +This project uses **ESLint** (flat config v9+) with `eslint-config-next` to enforce code quality. + +Run linting before submitting a PR: + +```bash +npm run lint # Check for issues +npm run lint:fix # Auto-fix where possible +``` + +The ESLint config is in `eslint.config.mjs` at the root. Key rules: +- `no-console`: Warn on `console.log` (allow `warn`/`error`) +- `prefer-const`: Error on `let` that is never reassigned +- `no-unused-vars`: Warn on unused variables (ignore `_`-prefixed) +- `no-duplicate-imports`: Error on duplicate imports + +TypeScript type-checking is also run in CI: + +```bash +npm run type-check # tsc --noEmit +``` + +--- + ## Commit Messages Follow [Conventional Commits](https://www.conventionalcommits.org/): diff --git a/eslint.config.mjs b/eslint.config.mjs index e737ff015..ea0c2f8ce 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -2,7 +2,16 @@ import { createRequire } from "module"; const require = createRequire(import.meta.url); -// eslint-config-next ships a native flat config array in v16+ const nextConfig = require("eslint-config-next"); -export default [...nextConfig]; +export default [ + ...nextConfig, + { + rules: { + "no-console": ["warn", { allow: ["warn", "error"] }], + "prefer-const": "error", + "no-unused-vars": ["warn", { argsIgnorePattern: "^_" }], + "no-duplicate-imports": "error", + }, + }, +]; diff --git a/package.json b/package.json index b628898ae..cf31404d9 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "preview:cf": "opennextjs-cloudflare build && opennextjs-cloudflare preview", "start": "next start", "lint": "eslint src/", + "lint:fix": "eslint src/ --fix", "type-check": "tsc --noEmit", "test:e2e": "playwright test", "test:e2e:ui": "playwright test --ui"