|
| 1 | +import js from "@eslint/js" |
| 2 | +import eslintConfigPrettier from "eslint-config-prettier" |
| 3 | +import tseslint from "typescript-eslint" |
| 4 | +import pluginReactHooks from "eslint-plugin-react-hooks" |
| 5 | +import pluginReact from "eslint-plugin-react" |
| 6 | +import globals from "globals" |
| 7 | +import pluginNext from "@next/eslint-plugin-next" |
| 8 | +import { config as baseConfig } from "./base.js" |
| 9 | + |
| 10 | +/** |
| 11 | + * Eslint configuration for all next.js applications in the ecosystem |
| 12 | + * |
| 13 | + * @type {import("eslint").Linter.Config[]} |
| 14 | + */ |
| 15 | +export const nextJsConfig = [ |
| 16 | + // Inherit shared base configuration |
| 17 | + ...baseConfig, |
| 18 | + |
| 19 | + // Core JavaScript linting rules from ESLint |
| 20 | + js.configs.recommended, |
| 21 | + |
| 22 | + // Disables ESLint rules that conflict with Prettier formatting |
| 23 | + eslintConfigPrettier, |
| 24 | + |
| 25 | + // Recommended rules for TypeScript projects |
| 26 | + ...tseslint.configs.recommended, |
| 27 | + |
| 28 | + { |
| 29 | + // Recommended rules for React projects using the flat config API |
| 30 | + ...pluginReact.configs.flat.recommended, |
| 31 | + |
| 32 | + // Extend language options to include service worker globals |
| 33 | + languageOptions: { |
| 34 | + ...pluginReact.configs.flat.recommended.languageOptions, |
| 35 | + globals: { ...globals.serviceworker }, |
| 36 | + }, |
| 37 | + }, |
| 38 | + { |
| 39 | + // Next.js plugin configuration |
| 40 | + plugins : { |
| 41 | + "@next/next": pluginNext, |
| 42 | + }, |
| 43 | + rules : { |
| 44 | + // Include Next.js recommended rules |
| 45 | + ...pluginNext.configs.recommended.rules, |
| 46 | + |
| 47 | + // Include Core Web Vitals rules for performance and accessibility |
| 48 | + ...pluginNext.configs["core-web-vitals"].rules, |
| 49 | + }, |
| 50 | + }, |
| 51 | + { |
| 52 | + // React Hooks plugin configuration |
| 53 | + plugins : { "react-hooks": pluginReactHooks, }, |
| 54 | + settings : { |
| 55 | + // Automatically detect the installed React version |
| 56 | + react : { version: "detect" }, |
| 57 | + }, |
| 58 | + rules : { |
| 59 | + // Include recommended rules for React Hooks |
| 60 | + ...pluginReactHooks.configs.recommended.rules, |
| 61 | + |
| 62 | + // Disable rule requiring React to be in scope for JSX |
| 63 | + // Not needed with the new JSX transform (React 17+) |
| 64 | + "react/react-in-jsx-scope": "off", |
| 65 | + }, |
| 66 | + }, |
| 67 | +] |
0 commit comments