Skip to content

Docs: Getting Started - invalid eslint.config.mjs example #10758

@hidarikani

Description

@hidarikani

Before You File a Documentation Request Please Confirm You Have Done The Following...

Suggested Changes

At the moment eslint.config.mjs example on Getting Started page is as follows:

import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';

export default [
  eslint.configs.recommended,
  tseslint.configs.recommended,
];

actually running eslint with this config results in following error:

% npm run lint

> your-app-name@1.0.0 lint
> eslint src


Oops! Something went wrong! :(

ESLint: 9.19.0

TypeError: Unexpected array.
    at flatTraverse (/Users/*****/Documents/GitHub/*****/node_modules/@eslint/config-array/dist/cjs/index.cjs:442:12)
    at flatTraverse.next (<anonymous>)
    at normalize (/Users/*****/Documents/GitHub/*****/node_modules/@eslint/config-array/dist/cjs/index.cjs:462:19)
    at async FlatConfigArray.normalize (/Users/*****/Documents/GitHub/*****/node_modules/@eslint/config-array/dist/cjs/index.cjs:928:30)
    at async ConfigLoader.calculateConfigArray (/Users/*****/Documents/GitHub/*****/node_modules/eslint/lib/config/config-loader.js:557:9)
    at async #calculateConfigArray (/Users/*****/Documents/GitHub/*****/node_modules/eslint/lib/config/config-loader.js:633:29)
    at async entryFilter (/Users/*****/Documents/GitHub/*****/node_modules/eslint/lib/eslint/eslint-helpers.js:281:33)
    at async NodeHfs.<anonymous> (file:///Users/*****/Documents/GitHub/*****/node_modules/@humanfs/core/src/hfs.js:574:24)
    at async NodeHfs.walk (file:///Users/*****/Documents/GitHub/*****/node_modules/@humanfs/core/src/hfs.js:614:3)
    at async globSearch (/Users/*****/Documents/GitHub/*****/node_modules/eslint/lib/eslint/eslint-helpers.js:323:26)

Package versions that I have installed:

"@eslint/js": "^9.19.0",
"eslint": "^9.19.0",
"typescript": "^5.7.2",
"typescript-eslint": "^8.22.0",

I was able to resolve the error by spreading typescript-eslint config:

import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';

export default [
  eslint.configs.recommended,
  ...tseslint.configs.recommended,
];

Affected URL(s)

https://typescript-eslint.io/getting-started/

Additional Info

By the way, on ESLint's Getting Started page. It's recommended to run setup wizard:

npm init @eslint/config@latest

The config created by the wizard also uses the spread: ...tseslint.configs.recommended.

Metadata

Metadata

Assignees

No one assigned

    Labels

    awaiting responseIssues waiting for a reply from the OP or another partylocked due to agePlease open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.unable 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