Skip to content

Enhancement: tseslint.config() should prohibit nested extends #11360

Open
@kirkwaiblinger

Description

@kirkwaiblinger

Before You File a Proposal Please Confirm You Have Done The Following...

Relevant Package

typescript-eslint

My proposal is suitable for this project

  • I believe my proposal would be useful to the broader TypeScript community (meaning it is not a niche proposal).

Description

The following is neither a type nor runtime error:

tseslint.config({
  extends: [
    {
      extends: [
        {
          rules: {
            rule1: "error",
          },
        },
      ],
    },
  ],
})

and it results in

[
  {
    extends: [
      {
        rules: {
          rule1: "error",
        },
      },
    ],
  },
]

This means that

tseslint.config(
  tseslint.config({
    extends: [
      {
        extends: [
          {
            rules: {
              rule1: "error",
            },
          },
        ],
      },
    ],
  }),
)

results in

[
  {
    rules: {
      rule1: "error",
    },
  },
]

and, therefore tseslint.config() is not idempotent. I think we want to avoid this behavior, especially since it means that defineConfig(tseslint.config()), which is now being promoted against our recommendation, will be similarly problematic.

Additional Info

Note that eslint core defineConfig() does explicitly error on this case: https://github.com/eslint/rewrite/blob/0496201974aad87fdcf3aa2a63ec74e91b54825e/packages/config-helpers/src/define-config.js#L452-L454

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issueenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions