File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -70,6 +70,25 @@ export default function createConfig({
7070 } )
7171 }
7272
73+ // More meaningful error message for the user, in case they didn't know the correct config name.
74+ for ( const name of configNamesToExtend ) {
75+ if ( ! tseslint . configs [ name ] ) {
76+ const nameInCamelCase = name . replace ( / - ( [ a - z ] ) / g, ( _ , letter ) =>
77+ letter . toUpperCase ( ) ,
78+ )
79+
80+ // @ts -expect-error
81+ if ( tseslint . configs [ nameInCamelCase ] ) {
82+ throw new Error (
83+ `The config name "${ name } " is not supported in "extends". ` +
84+ `Please use "${ nameInCamelCase } " instead.` ,
85+ )
86+ }
87+
88+ throw new Error ( `Unknown config name in "extends": ${ name } .` )
89+ }
90+ }
91+
7392 const mayHaveJsxInSfc = supportedScriptLangs . jsx || supportedScriptLangs . tsx
7493 const needsTypeAwareLinting = configNamesToExtend . some (
7594 name =>
Original file line number Diff line number Diff line change @@ -191,3 +191,14 @@ test('#87: should not error if the project root has an older version of espree i
191191 const { stdout } = await runLintAgainst ( 'with-older-espree' , FROM_FIXTURES )
192192 expect ( stdout ) . toMatch ( WHITESPACE_ONLY )
193193} )
194+
195+ test ( 'should guide user to use camelCase names in "extends"' , async ( ) => {
196+ const eslintConfigPath = path . join ( __dirname , '../examples/type-checked/eslint.config.js' )
197+ const { modify, restore } = setupFileMutations ( eslintConfigPath )
198+ modify ( ( oldContents ) => oldContents . replace ( 'recommendedTypeChecked' , 'recommended-type-checked' ) )
199+ const { failed, stderr } = await runLintAgainst ( 'type-checked' )
200+ restore ( )
201+
202+ expect ( failed ) . toBe ( true )
203+ expect ( stderr ) . contain ( 'Please use "recommendedTypeChecked"' )
204+ } )
You can’t perform that action at this time.
0 commit comments