Skip to content

ESLint v10 compatibility #3977

@ferothefox

Description

@ferothefox

Is there an existing issue for this?

  • I have searched the existing issues and my issue is unique
  • My issue appears in the command-line and not only in the text editor

Description Overview

With the release of ESLint v10, we are unable to use this plugin.

Unfortunately, this is a private monorepo, but I can provide the two configs we use to lint every file:

import js from "@eslint/js";
import eslintConfigPrettier from "eslint-config-prettier";
import onlyWarn from "eslint-plugin-only-warn";
import turboPlugin from "eslint-plugin-turbo";
import tseslint from "typescript-eslint";

/**
 * @type {import("eslint").Linter.Config[]}
 * */
const baseConfig = [
  js.configs.recommended,
  eslintConfigPrettier,
  ...tseslint.configs.recommended,
  {
    plugins: {
      turbo: turboPlugin,
    },
    rules: {
      "turbo/no-undeclared-env-vars": "warn",
      "@typescript-eslint/no-unused-vars": [
        "warn",
        {
          argsIgnorePattern: "^_",
          varsIgnorePattern: "^_",
          caughtErrorsIgnorePattern: "^_",
        },
      ],
    },
  },
  {
    plugins: {
      onlyWarn,
    },
  },
  {
    ignores: ["dist/**"],
  },
];

export const config = baseConfig;
export default baseConfig;
import js from "@eslint/js";
import pluginNext from "@next/eslint-plugin-next";
import eslintConfigPrettier from "eslint-config-prettier";
import pluginReact from "eslint-plugin-react";
import pluginReactHooks from "eslint-plugin-react-hooks";
import { globalIgnores } from "eslint/config";
import globals from "globals";
import tseslint from "typescript-eslint";
import { config as baseConfig } from "./base.js";

/**
 * @type {import("eslint").Linter.Config[]}
 * */
const nextConfig = [
  ...baseConfig,
  js.configs.recommended,
  eslintConfigPrettier,
  ...tseslint.configs.recommended,
  globalIgnores([".next/**", "out/**", "build/**", "next-env.d.ts"]),
  {
    ...pluginReact.configs.flat.recommended,
    languageOptions: {
      ...pluginReact.configs.flat.recommended.languageOptions,
      globals: {
        ...globals.serviceworker,
      },
    },
  },
  {
    plugins: {
      "@next/next": pluginNext,
    },
    rules: {
      ...pluginNext.configs.recommended.rules,
      ...pluginNext.configs["core-web-vitals"].rules,
    },
  },
  {
    plugins: {
      "react-hooks": pluginReactHooks,
    },
    settings: { react: { version: "detect" } },
    rules: {
      ...pluginReactHooks.configs.recommended.rules,
      "react/react-in-jsx-scope": "off",
      "react/prop-types": "off",
    },
  },
];

export default nextConfig;
[19:49:32.151] @there/there-landing:lint: Oops! Something went wrong! :(
[19:49:32.151] @there/there-landing:lint: 
[19:49:32.151] @there/there-landing:lint: ESLint: 10.0.0
[19:49:32.151] @there/there-landing:lint: 
[19:49:32.151] @there/there-landing:lint: TypeError: Error while loading rule 'react/display-name': contextOrFilename.getFilename is not a function. (In 'contextOrFilename.getFilename()', 'contextOrFilename.getFilename' is undefined)
[19:49:32.151] @there/there-landing:lint: Occurred while linting /Users/evan/Documents/Projects/everywhere/apps/there-landing/postcss.config.mjs
[19:49:32.151] @there/there-landing:lint:     at resolveBasedir (/Users/evan/Documents/Projects/everywhere/node_modules/.bun/eslint-plugin-react@7.37.5+f5df91c0fbd3f627/node_modules/eslint-plugin-react/lib/util/version.js:31:100)
[19:49:32.151] @there/there-landing:lint:     at detectReactVersion (/Users/evan/Documents/Projects/everywhere/node_modules/.bun/eslint-plugin-react@7.37.5+f5df91c0fbd3f627/node_modules/eslint-plugin-react/lib/util/version.js:85:19)
[19:49:32.151] @there/there-landing:lint:     at getReactVersionFromContext (/Users/evan/Documents/Projects/everywhere/node_modules/.bun/eslint-plugin-react@7.37.5+f5df91c0fbd3f627/node_modules/eslint-plugin-react/lib/util/version.js:116:25)
[19:49:32.151] @there/there-landing:lint:     at testReactVersion (/Users/evan/Documents/Projects/everywhere/node_modules/.bun/eslint-plugin-react@7.37.5+f5df91c0fbd3f627/node_modules/eslint-plugin-react/lib/util/version.js:181:28)
[19:49:32.151] @there/there-landing:lint:     at usedPropTypesInstructions (/Users/evan/Documents/Projects/everywhere/node_modules/.bun/eslint-plugin-react@7.37.5+f5df91c0fbd3f627/node_modules/eslint-plugin-react/lib/util/usedPropTypes.js:307:36)
[19:49:32.151] @there/there-landing:lint:     at componentRule (/Users/evan/Documents/Projects/everywhere/node_modules/.bun/eslint-plugin-react@7.37.5+f5df91c0fbd3f627/node_modules/eslint-plugin-react/lib/util/Components.js:940:37)
[19:49:32.151] @there/there-landing:lint:     at createRuleListeners (/Users/evan/Documents/Projects/everywhere/node_modules/.bun/eslint@10.0.0+f5df91c0fbd3f627/node_modules/eslint/lib/linter/linter.js:497:15)
[19:49:32.151] @there/there-landing:lint:     at <anonymous> (/Users/evan/Documents/Projects/everywhere/node_modules/.bun/eslint@10.0.0+f5df91c0fbd3f627/node_modules/eslint/lib/linter/linter.js:623:7)
[19:49:32.151] @there/there-landing:lint:     at forEach (native:1:11)
[19:49:32.151] @there/there-landing:lint:     at runRules (/Users/evan/Documents/Projects/everywhere/node_modules/.bun/eslint@10.0.0+f5df91c0fbd3f627/node_modules/eslint/lib/linter/linter.js:557:31)
[19:49:32.151] @there/there-landing:lint:     at #flatVerifyWithoutProcessors (/Users/evan/Documents/Projects/everywhere/node_modules/.bun/eslint@10.0.0+f5df91c0fbd3f627/node_modules/eslint/lib/linter/linter.js:1248:4)
[19:49:32.151] @there/there-landing:lint:     at verify (/Users/evan/Documents/Projects/everywhere/node_modules/.bun/eslint@10.0.0+f5df91c0fbd3f627/node_modules/eslint/lib/linter/linter.js:861:9)
[19:49:32.151] @there/there-landing:lint:     at <anonymous> (/Users/evan/Documents/Projects/everywhere/node_modules/.bun/eslint-plugin-only-warn@1.1.0/node_modules/eslint-plugin-only-warn/src/only-warn.js:14:55)
[19:49:32.151] @there/there-landing:lint:     at verifyAndFix (/Users/evan/Documents/Projects/everywhere/node_modules/.bun/eslint@10.0.0+f5df91c0fbd3f627/node_modules/eslint/lib/linter/linter.js:1518:20)
[19:49:32.151] @there/there-landing:lint:     at verifyText (/Users/evan/Documents/Projects/everywhere/node_modules/.bun/eslint@10.0.0+f5df91c0fbd3f627/node_modules/eslint/lib/eslint/eslint-helpers.js:1179:45)
[19:49:32.151] @there/there-landing:lint:     at processTicksAndRejections (native:7:39)
[19:49:32.156] @there/there-landing:lint: ERROR: command finished with error: command (/Users/evan/Documents/Projects/everywhere/apps/there-landing) /private/tmp/bun-node-b64edcb49/bun run lint exited (2)
@there/there-landing#lint: command (/Users/evan/Documents/Projects/everywhere/apps/there-landing) /private/tmp/bun-node-b64edcb49/bun run lint exited (2)

turbo run lint, which runs eslint in every package in our repo

Expected Behavior

The only expected behavior is that the plugin would work.

eslint-plugin-react version

v7.37.5

eslint version

v10.0.0

node version

Bun

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions