Skip to content

fix(typescript-eslint): error on nested extends in tseslint.config() #11361

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
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
7 changes: 7 additions & 0 deletions packages/typescript-eslint/src/config-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,13 @@ function configImpl(...configs: unknown[]): ConfigArray {
` 'basePath' in 'extends' is not allowed.`,
);
}

if ('extends' in extension) {
throw new TypeError(
`tseslint.config(): Config at index ${configIndex}${nameErrorPhrase} has an 'extends' array that contains a config with an 'extends' property at index ${extensionIndex}.` +
` Nested 'extends' is not allowed.`,
);
}
}
if (nonObjectExtensions.length > 0) {
const extensionIndices = nonObjectExtensions.join(', ');
Expand Down
15 changes: 15 additions & 0 deletions packages/typescript-eslint/tests/config-helper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -416,4 +416,19 @@ describe('config helper', () => {
"tseslint.config(): Config at index 0 (anonymous) has an 'extends' array that contains a config with a 'basePath' property at index 0. 'basePath' in 'extends' is not allowed.",
);
});

it('should error when trying to use nested extends', () => {
expect(() => {
tseslint.config({
extends: [
{
extends: [
{ rules: { rule1: 'error' } },
{ rules: { rule2: 'error' } },
],
},
],
});
}).toThrow();
});
});
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy