Skip to content

Commit

Permalink
fix(misc): extacting base eslint config should be resilient from unsu…
Browse files Browse the repository at this point in the history
…pported format
  • Loading branch information
jaysoo committed Sep 11, 2024
1 parent 86e4a5d commit 94af427
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/eslint/src/generators/utils/flat-config/ast-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,12 @@ export function addBlockToFlatConfigExport(
return node.expression.right.elements;
}
});

// The config is not in the format that we generate with, skip update.
// This could happen during `init-migration` when extracting config from the base, but
// base config was not generated by Nx.
if (!exportsArray) return content;

const insert = printer.printNode(ts.EmitHint.Expression, config, source);
if (options.insertAtTheEnd) {
const index =
Expand Down Expand Up @@ -566,7 +572,7 @@ export function removeCompatExtends(
ts.ScriptKind.JS
);
const changes: StringChange[] = [];
findAllBlocks(source).forEach((node) => {
findAllBlocks(source)?.forEach((node) => {
if (
ts.isSpreadElement(node) &&
ts.isCallExpression(node.expression) &&
Expand Down Expand Up @@ -629,7 +635,7 @@ export function removePredefinedConfigs(
);
const changes: StringChange[] = [];
let removeImport = true;
findAllBlocks(source).forEach((node) => {
findAllBlocks(source)?.forEach((node) => {
if (
ts.isSpreadElement(node) &&
ts.isElementAccessExpression(node.expression) &&
Expand Down

0 comments on commit 94af427

Please sign in to comment.