From d707ed8b583e894447c9cea82bb20e8959aa893d Mon Sep 17 00:00:00 2001 From: adilallo <39313955+adilallo@users.noreply.github.com> Date: Mon, 26 Jan 2026 08:19:49 -0700 Subject: [PATCH] Update ESLint configuration --- eslint.config.mjs | 105 +++++++++++++++++++++++++++++++++++++++------- package-lock.json | 37 +++++++++++----- package.json | 6 ++- tsconfig.json | 10 +---- 4 files changed, 121 insertions(+), 37 deletions(-) diff --git a/eslint.config.mjs b/eslint.config.mjs index 92a78fc..654c98f 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -1,24 +1,97 @@ +// ESLint flat config for Next.js 16 +// Note: Using a workaround for FlatCompat circular reference issue // For more info, see https://github.com/storybookjs/eslint-plugin-storybook#configuration-flat-config-format import storybook from "eslint-plugin-storybook"; - -import { dirname } from "path"; -import { fileURLToPath } from "url"; -import { FlatCompat } from "@eslint/eslintrc"; - -const __filename = fileURLToPath(import.meta.url); -const __dirname = dirname(__filename); - -const compat = new FlatCompat({ - baseDirectory: __dirname, -}); +import js from "@eslint/js"; +import tseslint from "@typescript-eslint/eslint-plugin"; +import tsparser from "@typescript-eslint/parser"; +import nextPlugin from "@next/eslint-plugin-next"; +import globals from "globals"; const eslintConfig = [ - ...compat.extends("next/core-web-vitals"), - { - files: ["**/*.js", "**/*.jsx", "**/*.mjs"], - ignores: ["**/*.ts", "**/*.tsx"], - }, + // Base JavaScript recommended rules + js.configs.recommended, + // Storybook config ...storybook.configs["flat/recommended"], + // Global ignores + { + ignores: [ + ".next/**", + "node_modules/**", + "dist/**", + "build/**", + "coverage/**", + "storybook-static/**", + "playwright-report/**", + "test-results/**", + "lhci-results/**", + "docs/**", + ], + }, + // JavaScript files configuration + { + files: ["**/*.{js,jsx}"], + languageOptions: { + ecmaVersion: "latest", + sourceType: "module", + globals: { + ...globals.node, + ...globals.browser, + ...globals.es2021, + }, + parserOptions: { + ecmaFeatures: { + jsx: true, + }, + }, + }, + }, + // TypeScript files configuration + { + files: ["**/*.{ts,tsx}"], + languageOptions: { + parser: tsparser, + globals: { + ...globals.node, + ...globals.browser, + ...globals.es2021, + }, + parserOptions: { + ecmaVersion: "latest", + sourceType: "module", + ecmaFeatures: { + jsx: true, + }, + project: "./tsconfig.json", + }, + }, + plugins: { + "@typescript-eslint": tseslint, + "@next/next": nextPlugin, + }, + rules: { + "@typescript-eslint/no-unused-vars": [ + "error", + { + argsIgnorePattern: "^_", + varsIgnorePattern: "^_", + }, + ], + "@typescript-eslint/no-explicit-any": "warn", + // Next.js rules + "@next/next/no-html-link-for-pages": "off", + "@next/next/no-img-element": "warn", + }, + }, + // All files - basic rules + { + files: ["**/*.{ts,tsx,js,jsx}"], + rules: { + // Basic rules + "react/no-unescaped-entities": "off", + "no-console": "warn", + }, + }, ]; export default eslintConfig; diff --git a/package-lock.json b/package-lock.json index 45b0599..2f26019 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,7 +21,7 @@ }, "devDependencies": { "@axe-core/playwright": "^4.10.2", - "@eslint/eslintrc": "^3", + "@eslint/eslintrc": "^3.3.3", "@lhci/cli": "^0.15.1", "@playwright/test": "^1.55.0", "@storybook/addon-a11y": "^8.3.0", @@ -47,6 +47,7 @@ "eslint": "^9", "eslint-config-next": "^16.0.0", "eslint-plugin-storybook": "^9.0.7", + "globals": "^17.1.0", "jest-axe": "^10.0.0", "jsdom": "^26.1.0", "msw": "^2.10.5", @@ -57,6 +58,7 @@ "storybook": "^8.3.0", "tailwindcss": "^4.0.0", "typescript": "^5.9.2", + "typescript-eslint": "^8.53.1", "vitest": "^3.2.4", "wait-on": "^8.0.4", "web-vitals": "^4.2.4", @@ -2805,9 +2807,9 @@ } }, "node_modules/@eslint/eslintrc": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-3.3.1.tgz", - "integrity": "sha512-gtF186CXhIl1p4pJNGZw8Yc6RlshoePRvE0X91oPGb3vZ8pM3qOS9W9NGPat9LziaBV7XrJWGylNQXkGcnM3IQ==", + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-3.3.3.tgz", + "integrity": "sha512-Kr+LPIUVKz2qkx1HAMH8q1q6azbqBAsXJUxBl/ODDuVPX45Z9DfwB8tPjTi6nNZ8BuM3nbJxC5zCAg5elnBUTQ==", "dev": true, "license": "MIT", "dependencies": { @@ -2817,7 +2819,7 @@ "globals": "^14.0.0", "ignore": "^5.2.0", "import-fresh": "^3.2.1", - "js-yaml": "^4.1.0", + "js-yaml": "^4.1.1", "minimatch": "^3.1.2", "strip-json-comments": "^3.1.1" }, @@ -2845,6 +2847,19 @@ "url": "https://github.com/sponsors/epoberezkin" } }, + "node_modules/@eslint/eslintrc/node_modules/globals": { + "version": "14.0.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-14.0.0.tgz", + "integrity": "sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/@eslint/eslintrc/node_modules/json-schema-traverse": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", @@ -15850,9 +15865,9 @@ } }, "node_modules/globals": { - "version": "14.0.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-14.0.0.tgz", - "integrity": "sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==", + "version": "17.1.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-17.1.0.tgz", + "integrity": "sha512-8HoIcWI5fCvG5NADj4bDav+er9B9JMj2vyL2pI8D0eismKyUvPLTSs+Ln3wqhwcp306i73iyVnEKx3F6T47TGw==", "dev": true, "license": "MIT", "engines": { @@ -19207,9 +19222,9 @@ "license": "MIT" }, "node_modules/js-yaml": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", - "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.1.tgz", + "integrity": "sha512-qQKT4zQxXl8lLwBtHMWwaTcGfFOZviOJet3Oy/xmGk2gZH677CJM9EvtfdSkgWcATZhj/55JZ0rmy3myCT5lsA==", "dev": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index 4834df9..9209b9f 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "dev": "next dev --turbopack", "build": "next build", "start": "next start", - "lint": "next lint", + "lint": "eslint . --ext .js,.jsx,.ts,.tsx", "postinstall": "npm rebuild lightningcss", "storybook": "storybook dev -p 6006", "storybook:local": "storybook dev -p 6006", @@ -56,7 +56,7 @@ }, "devDependencies": { "@axe-core/playwright": "^4.10.2", - "@eslint/eslintrc": "^3", + "@eslint/eslintrc": "^3.3.3", "@lhci/cli": "^0.15.1", "@playwright/test": "^1.55.0", "@storybook/addon-a11y": "^8.3.0", @@ -82,6 +82,7 @@ "eslint": "^9", "eslint-config-next": "^16.0.0", "eslint-plugin-storybook": "^9.0.7", + "globals": "^17.1.0", "jest-axe": "^10.0.0", "jsdom": "^26.1.0", "msw": "^2.10.5", @@ -92,6 +93,7 @@ "storybook": "^8.3.0", "tailwindcss": "^4.0.0", "typescript": "^5.9.2", + "typescript-eslint": "^8.53.1", "vitest": "^3.2.4", "wait-on": "^8.0.4", "web-vitals": "^4.2.4", diff --git a/tsconfig.json b/tsconfig.json index 4436cd4..575fac1 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,11 +1,7 @@ { "compilerOptions": { "target": "ES2017", - "lib": [ - "dom", - "dom.iterable", - "esnext" - ], + "lib": ["dom", "dom.iterable", "esnext"], "allowJs": true, "skipLibCheck": true, "strict": false, @@ -36,7 +32,5 @@ "**/*.jsx", ".next/dev/types/**/*.ts" ], - "exclude": [ - "node_modules" - ] + "exclude": ["node_modules"] }