next.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import js from "@eslint/js";
  2. import { globalIgnores } from "eslint/config";
  3. import eslintConfigPrettier from "eslint-config-prettier";
  4. import tseslint from "typescript-eslint";
  5. import pluginReactHooks from "eslint-plugin-react-hooks";
  6. import pluginReact from "eslint-plugin-react";
  7. import globals from "globals";
  8. import pluginNext from "@next/eslint-plugin-next";
  9. import { config as baseConfig } from "./base.js";
  10. /**
  11. * A custom ESLint configuration for libraries that use Next.js.
  12. *
  13. * @type {import("eslint").Linter.Config[]}
  14. * */
  15. export const nextJsConfig = [
  16. ...baseConfig,
  17. js.configs.recommended,
  18. eslintConfigPrettier,
  19. ...tseslint.configs.recommended,
  20. globalIgnores([
  21. // Default ignores of eslint-config-next:
  22. ".next/**",
  23. "out/**",
  24. "build/**",
  25. "next-env.d.ts",
  26. ]),
  27. {
  28. ...pluginReact.configs.flat.recommended,
  29. languageOptions: {
  30. ...pluginReact.configs.flat.recommended.languageOptions,
  31. globals: {
  32. ...globals.serviceworker,
  33. },
  34. },
  35. },
  36. {
  37. plugins: {
  38. "@next/next": pluginNext,
  39. },
  40. rules: {
  41. ...pluginNext.configs.recommended.rules,
  42. ...pluginNext.configs["core-web-vitals"].rules,
  43. },
  44. },
  45. {
  46. plugins: {
  47. "react-hooks": pluginReactHooks,
  48. },
  49. settings: { react: { version: "detect" } },
  50. rules: {
  51. ...pluginReactHooks.configs.recommended.rules,
  52. // React scope no longer necessary with new JSX transform.
  53. "react/react-in-jsx-scope": "off",
  54. },
  55. },
  56. ];