Skip to content

Bug: "Unexpected non-object config" after upgrading from 8.29.0 to 8.31.1 #11123

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
4 tasks done
ARiyou2000 opened this issue May 1, 2025 · 2 comments
Open
4 tasks done
Labels
awaiting response Issues waiting for a reply from the OP or another party bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin unable to repro issues that a maintainer was not able to reproduce

Comments

@ARiyou2000
Copy link

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have searched for related issues and found none that matched my issue.
  • I have read the FAQ and my problem is not listed.

Playground Link

.

Repro Code

The code didn't matter, and it wouldn't work with anything.

ESLint Config

import nx from "@nx/eslint-plugin";
import eslintConfigPrettier from "eslint-config-prettier/flat";
import importPlugin from "eslint-plugin-import";
import jsdoc from "eslint-plugin-jsdoc";
import jsxA11y from "eslint-plugin-jsx-a11y";
import pluginLingui from "eslint-plugin-lingui";
import playwright from "eslint-plugin-playwright";
import react from "eslint-plugin-react";
import reactCompiler from "eslint-plugin-react-compiler";
import reactHooks from "eslint-plugin-react-hooks";
import reactRefresh from "eslint-plugin-react-refresh";
import globals from "globals";
import tseslint from "typescript-eslint";

function createEsLintConfig(reactBase = false) {
  return tseslint.config(
    nx.configs["flat/base"],
    nx.configs["flat/javascript"], // Already extends // js.configs.recommended,
    nx.configs["flat/typescript"], // Almost same rules as ["flat/javascript"] but for ts files
    jsdoc.configs["flat/recommended"],
    tseslint.configs.strictTypeChecked,
    tseslint.configs.stylisticTypeChecked,
    // nx.configs["flat/react"],
    reactBase && react.configs.flat.all,
    reactBase && react.configs.flat["jsx-runtime"], // Add this if you are using React 17+
    reactBase && reactHooks.configs["recommended-latest"],
    reactBase && reactRefresh.configs.recommended,
    reactBase && jsxA11y.flatConfigs.recommended,
    reactBase && pluginLingui.configs["flat/recommended"],
    reactBase && reactCompiler.configs.recommended,
    // Todo: check if ignores is in the right place
    {
      ignores: [
        "**/dist",
        "**/vite.config.*.timestamp*",
        "**/vitest.config.*.timestamp*",
      ],
    },
    // NX targeted config
    {
      files: ["**/*.ts", "**/*.tsx", "**/*.js", "**/*.jsx"],
      rules: {
        "@nx/enforce-module-boundaries": [
          "error",
          {
            allowCircularSelfDependency: true,
            enforceBuildableLibDependency: true,
            allow: [
              "^.*/eslint(\\.base)?\\.config\\.[cm]?js$",
              "^.*/vite(\\.base)?\\.config*",
            ],
            depConstraints: [
              {
                sourceTag: "*",
                onlyDependOnLibsWithTags: ["*"],
              },
            ],
          },
        ],
      },
    },
    // Playwright
    {
      ...playwright.configs["flat/recommended"],
      files: ["tests/**"],
      rules: {
        ...playwright.configs["flat/recommended"].rules,
        // Customize Playwright rules
        // ...
      },
    },

    // Additional config
    {
      files: [
        "**/*.ts",
        "**/*.tsx",
        "**/*.cts",
        "**/*.mts",
        "**/*.js",
        "**/*.jsx",
        "**/*.cjs",
        "**/*.mjs",
      ],

      // Override or add rules here
      languageOptions: {
        ecmaVersion: 2020,
        globals: {
          ...globals.serviceworker,
          ...globals.browser,
        },
        parserOptions: {
          ecmaVersion: "latest",
          ecmaFeatures: { jsx: true },
          sourceType: "module",
          // Linting with Type Information: Start
          projectService: {
            parser: tseslint.parser,
            allowDefaultProject: [
              "eslint.base.config.mjs",
              "eslint.config.mjs",
              "prettier.config.mjs",
            ],
          },
          tsconfigRootDir: import.meta.dirname,
          // Linting with Type Information: End
        },
      },
      // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
      plugins: {
        // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
        ...importPlugin.flatConfigs.recommended.plugins,
      },
      rules: (function () {
        const baseRules = {
          "@typescript-eslint/array-type": "off",
          "@typescript-eslint/consistent-type-definitions": "off",
          "@typescript-eslint/consistent-type-imports": [
            "warn",
            {
              prefer: "type-imports",
              fixStyle: "inline-type-imports",
            },
          ],
          "no-unused-vars": "off",
          "@typescript-eslint/no-unused-vars": [
            "error",
            { varsIgnorePattern: "^[A-Z_]" },
          ],
          "no-redeclare": "off",
          "@typescript-eslint/no-redeclare": "error",
          "@typescript-eslint/require-await": "off",
          "@typescript-eslint/no-misused-promises": [
            "error",
            {
              checksVoidReturn: {
                attributes: false,
              },
            },
          ],

          "jsdoc/require-jsdoc": "off",
          "jsdoc/tag-lines": ["error", "any", { startLines: 1 }],
        };
        if (reactBase) {
          const reactRules = {
            // Safely merge React-specific rule configs
            ...Object.fromEntries(
              nx.configs["flat/react"]
                .map((config) => Object.entries(config.rules ?? {}))
                .flat(),
            ),
            ...reactRefresh.configs.recommended.rules,
            ...reactCompiler.configs.recommended.rules,
            ...baseRules,
            "react-refresh/only-export-components": [
              "warn",
              { allowConstantExport: true },
            ],
            "react/jsx-filename-extension": [1, { extensions: [".tsx"] }],
            "react/jsx-no-bind": "off",
            "react/jsx-max-depth": [2, { max: 4 }],
            // TODO: check this and
            "react/forbid-component-props": "off",
            "react/jsx-no-literals": [
              "warn",
              {
                noStrings: false,
                ignoreProps: true,
                allowedStrings: [],
                noAttributeStrings: false,
                elementOverrides: {
                  Trans: {
                    allowElement: true,
                    // applyToNestedElements: true
                  },
                },
              },
            ],
          };
          return reactRules;
        }
        return baseRules;
      })(),
    },

    // Prettier must come last
    eslintConfigPrettier,
  );
}

export default createEsLintConfig(false);

tsconfig

{
  "compileOnSave": false,
  "compilerOptions": {
    "target": "ES2022",
    "jsx": "react-jsx",
    "module": "ESNext",
    "lib": ["ES2022", "DOM", "DOM.Iterable"],
    "types": ["vite/client", "vitest"],

    /* Bundler mode */
    // "moduleResolution": "bundler",
    // "allowImportingTsExtensions": true,
    // "verbatimModuleSyntax": true,
    // "isolatedModules": true,
    // "moduleDetection": "force",
    // "noEmit": true,

    /* Linting */
    "skipLibCheck": true,
    "strict": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "noFallthroughCasesInSwitch": true,
    "noUncheckedSideEffectImports": true,
    "baseUrl": ".",
    "paths": {
      // "~/*": ["./*"],
      "~/classes/*": ["libs/classes/src/*"],
      "~/components/*": ["libs/components/src/*"],
      "~/contexts/*": ["libs/contexts/src/*"],
      "~/hooks/*": ["libs/hooks/src/*"],
      "~/models/*": ["libs/models/src/*"],
      "~/services/*": ["libs/services/src/*"],
      "~/types/*": ["libs/types/src/*"],
      "~/ui/*": ["libs/ui/src/*"],
      "~/utils/*": ["libs/utils/src/*"],
      "~/validations/*": ["libs/validations/src/*"]
    },

    /* Other base config */
    "rootDir": ".",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "importHelpers": true,
    "skipDefaultLibCheck": true
  },
  "exclude": ["node_modules", "tmp"]
}

Expected Result

It happened after upgrading, and I fixed it by downgrading to ^8.29.0 with the same config, and it worked.

Actual Result

- eslint.config.mjs: Config (unnamed): Unexpected non-object config at user-defined index 24.

Additional Info

No response

@ARiyou2000 ARiyou2000 added bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look labels May 1, 2025
@bradzacher
Copy link
Member

Please create an isolated reproduction repo.
A github repo with the minimum required fields and code to reproduce your issue.

@bradzacher bradzacher added awaiting response Issues waiting for a reply from the OP or another party unable to repro issues that a maintainer was not able to reproduce and removed triage Waiting for team members to take a look labels May 1, 2025
@kirkwaiblinger
Copy link
Member

kirkwaiblinger commented May 1, 2025

@ARiyou2000 It's quite plausible that new validation errors are occurring, since changes were recently made in #11070. I'd echo Brad's request for an isolated/minimal reproduction so that we can determine whether the validation is being overzealous or it's right to complain! Thanks!

@kirkwaiblinger kirkwaiblinger changed the title Bug: [Unexpected non-object config] <after upgrading from 8.29.0 to 8.31.1> Bug: "Unexpected non-object config" after upgrading from 8.29.0 to 8.31.1 May 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting response Issues waiting for a reply from the OP or another party bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin unable to repro issues that a maintainer was not able to reproduce
Projects
None yet
Development

No branches or pull requests

3 participants