@@ -11,6 +11,7 @@ import * as recast from "recast";
11
11
import { Legacy } from "@eslint/eslintrc" ;
12
12
import camelCase from "camelcase" ;
13
13
import pluginsNeedingCompat from "./compat-plugins.js" ;
14
+ import configsNeedingCompat from "./compat-configs.js" ;
14
15
import { convertIgnorePatternToMinimatch } from "@eslint/compat" ;
15
16
16
17
//-----------------------------------------------------------------------------
@@ -147,6 +148,23 @@ function pluginNeedsCompat(pluginName) {
147
148
) ;
148
149
}
149
150
151
+ /**
152
+ * Determines if a shareable config needs the compat utility.
153
+ * @param {string } configName The name of the config.
154
+ * @returns {boolean } `true` if the config needs the compat utility.
155
+ */
156
+ function configNeedsCompat ( configName ) {
157
+ const configNameToTest = configName . includes ( "/" )
158
+ ? configName . slice ( 0 , configName . indexOf ( "/" ) )
159
+ : configName ;
160
+
161
+ const fullConfigName = naming . normalizePackageName (
162
+ configNameToTest ,
163
+ "eslint-config" ,
164
+ ) ;
165
+ return configsNeedingCompat . includes ( fullConfigName ) ;
166
+ }
167
+
150
168
/**
151
169
* Gets the name of the variable to use for the plugin. If the plugin name
152
170
* contains slashes or an @ symbol, it will be normalized to a camelcase name.
@@ -165,6 +183,9 @@ function getPluginVariableName(pluginName) {
165
183
name = name . slice ( 1 ) ;
166
184
}
167
185
186
+ // replace slash with uppercase of following letter
187
+ name = name . replace ( / \/ ( .) / gu, ( _ , letter ) => letter . toUpperCase ( ) ) ;
188
+
168
189
return camelCase ( name ) ;
169
190
}
170
191
@@ -682,11 +703,19 @@ function migrateConfigObject(migration, config) {
682
703
683
704
// Check if any of the extends are plugins that need the compat utility
684
705
const needsCompat = extendsArray . some ( extend => {
685
- if ( ! extend . startsWith ( "plugin:" ) ) {
706
+ if (
707
+ extend . startsWith ( "eslint:" ) ||
708
+ extend . startsWith ( "." ) ||
709
+ extend . startsWith ( "/" )
710
+ ) {
686
711
return false ;
687
712
}
688
713
689
- return pluginNeedsCompat ( extend . slice ( 7 ) ) ;
714
+ if ( extend . startsWith ( "plugin:" ) ) {
715
+ return pluginNeedsCompat ( extend . slice ( 7 ) ) ;
716
+ }
717
+
718
+ return configNeedsCompat ( extend ) ;
690
719
} ) ;
691
720
692
721
if ( needsCompat ) {
0 commit comments