Skip to content

Bug: (flat config) ESLint crashes when merging a null value in a config #17820

Closed
@bradzacher

Description

Environment

Node version: v18.16.1
npm version: v9.5.0
Local ESLint version: v8.55.0 (Currently used)
Global ESLint version: Not found
Operating System: darwin 23.1.0

What parser are you using?

Default (Espree)

What did you do?

module.exports = [
  {
    languageOptions: {
      parserOptions: {
        foo: {},
      }
    },
  },
  {
    languageOptions: {
      parserOptions: {
        foo: null,
      }
    },
  },
]

What did you expect to happen?

The second parserOptions.foo should override the first - which is the way it used to work with .eslintrc configs.

What actually happened?

Oops! Something went wrong! :(

ESLint: 8.55.0

TypeError: Cannot convert undefined or null to object
    at Function.keys (<anonymous>)
    at deepMerge (<root>/node_modules/eslint/lib/config/flat-config-schema.js:91:30)
    at deepMerge (<root>/node_modules/eslint/lib/config/flat-config-schema.js:105:27)
    at ObjectSchema.merge (<root>/node_modules/eslint/lib/config/flat-config-schema.js:271:16)
    at <root>/node_modules/@humanwhocodes/object-schema/src/object-schema.js:244:54
    at Array.reduce (<anonymous>)
    at ObjectSchema.merge (<root>/node_modules/@humanwhocodes/object-schema/src/object-schema.js:237:24)
    at ObjectSchema.merge (<root>/node_modules/@humanwhocodes/object-schema/src/object-schema.js:176:39)
    at <root>/node_modules/@humanwhocodes/object-schema/src/object-schema.js:244:54
    at Array.reduce (<anonymous>)

Link to Minimal Reproducible Example

https://github.com/bradzacher/eslint-flat-config-bugs/tree/main/null-merge-crash

Participation

  • I am willing to submit a pull request for this issue.

Additional comments

In typescript-eslint we have a convenience config which can be used to disable type-aware linting on files i.e. someone can use { files: ["*.js"], extends: ['plugin:@typescript-eslint/disable-type-checked'] } to override their base config and disable type-aware linting.

In eslintrc files this works as expected. In flat configs this crashes.

Metadata

Assignees

Labels

acceptedThere is consensus among the team that this change meets the criteria for inclusionbugESLint is working incorrectlyrepro:yesIssues with a reproducible example

Type

No type

Projects

  • Status

    Complete
  • Status

    Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions