You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
constMIGRATION_ERROR_TEXT=`Migration to eslint version 9 failed. Check if there are error messages above. You can also delete the existing eslint \`devDependency\` and run \`create add eslint\` to create a eslint.config.mjs file with the flat config where you can transfer your old eslint config manually.\` For more information, see [https://eslint.org/docs/latest/use/migrate-to-9.0.0#flat-config](Migrate to v9.x).`;
35
57
36
58
/**
@@ -58,8 +80,8 @@ export async function convertEslintConfig(
58
80
thrownewError('The prerequisites are not met. For more information, see the log messages above.');
* Logs a warning when native extends entries were stripped from the legacy config,
174
+
* and additionally notes when a `files` scope cannot be automatically preserved.
175
+
*
176
+
* @param files - the `files` property from the legacy config, if any
177
+
* @param eslintRecommended - whether `eslint:recommended` was stripped
178
+
* @param tsStripped - whether any `plugin:@typescript-eslint/*` entries were stripped
179
+
* @param logger - logger to report info to the user
180
+
*/
181
+
functionwarnIfFileScopeDropped(
182
+
files: string|string[]|undefined,
183
+
eslintRecommended: boolean,
184
+
tsStripped: boolean,
185
+
logger?: ToolsLogger
186
+
): void{
187
+
if(!eslintRecommended&&!tsStripped){
188
+
return;
189
+
}
190
+
constremoved: string[]=[];
191
+
if(eslintRecommended){
192
+
removed.push("'eslint:recommended'");
193
+
}
194
+
if(tsStripped){
195
+
removed.push("'plugin:@typescript-eslint/*'");
196
+
}
197
+
constbaseMessage=`${removed.join(' and ')}${removed.length>1 ? 'were' : 'was'} removed from the legacy config and will not be re-injected. Its rules are already covered by '@sap-ux/eslint-plugin-fiori-tools', so no manual re-addition is needed.`;
198
+
constfileScopeMessage=files
199
+
? ` The legacy config had a 'files' scope (${JSON.stringify(files)}) that cannot be automatically preserved.`
200
+
: '';
201
+
logger?.warn(baseMessage+fileScopeMessage);
202
+
}
203
+
204
+
/**
205
+
* Removes all traces of the SAP Fiori tools plugin
206
+
* (e.g. `eslint:recommended`, `plugin:@typescript-eslint/recommended`) from the existing legacy
207
+
* eslint configuration, so that the migration tool does not wrap them in a FlatCompat compat shim
208
+
* that would conflict with the native rule registrations inside `@sap-ux/eslint-plugin-fiori-tools`.
209
+
*
210
+
* If the legacy config had a `files` property together with `eslint:recommended` or
211
+
* `plugin:@typescript-eslint/*` entries, a warning is logged because that file scope cannot be
212
+
* automatically preserved — the converted project uses `@sap-ux/eslint-plugin-fiori-tools` which
213
+
* already applies the equivalent rules scoped to the webapp directory.
214
+
*
215
+
* The modified config is returned as a serialized JSON string and is not written back to
216
+
* mem-fs, so the original legacy config file is never staged for a disk write.
112
217
*
113
218
* @param basePath - base path to be used for the conversion
114
219
* @param fs - file system reference
115
220
* @param logger - logger to report info to the user
221
+
* @returns the stripped config serialized as a JSON string, ready to be passed to the migration command
116
222
* @throws {Error} if the existing .eslintrc.json file is not a valid JSON object
0 commit comments