Content-Length: 405571 | pFad | http://github.com/typescript-eslint/typescript-eslint/issues/11123

73 Bug: "Unexpected non-object config" after upgrading from 8.29.0 to 8.31.1 · Issue #11123 · typescript-eslint/typescript-eslint · GitHub
Skip to content

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

Closed as not planned
@ARiyou2000

Description

@ARiyou2000

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    awaiting responseIssues waiting for a reply from the OP or another partybugSomething isn't workingpackage: eslint-pluginIssues related to @typescript-eslint/eslint-pluginunable to reproissues that a maintainer was not able to reproduce

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions









      ApplySandwichStrip

      pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


      --- a PPN by Garber Painting Akron. With Image Size Reduction included!

      Fetched URL: http://github.com/typescript-eslint/typescript-eslint/issues/11123

      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy