Skip to content

Commit 13ec93c

Browse files
authored
fix(js): ensure typescript-sync generator produces formatted references when no prettier is installed (#29368)
<!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> <!-- If this is a particularly complex change or feature addition, you can request a dedicated Nx release for this pull request branch. Mention someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they will confirm if the PR warrants its own release for testing purposes, and generate it for you if appropriate. --> ## Current Behavior <!-- This is the behavior we have today --> ## Expected Behavior <!-- This is the behavior we should expect with the changes in this PR --> ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #
1 parent 4cd640a commit 13ec93c

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

packages/js/src/generators/typescript-sync/typescript-sync.spec.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ let projectGraph: ProjectGraph;
1414
jest.mock('@nx/devkit', () => ({
1515
...jest.requireActual('@nx/devkit'),
1616
createProjectGraphAsync: jest.fn(() => Promise.resolve(projectGraph)),
17+
formatFiles: jest.fn(() => Promise.resolve()),
1718
}));
1819

1920
describe('syncGenerator()', () => {
@@ -562,11 +563,11 @@ describe('syncGenerator()', () => {
562563
"compilerOptions": {
563564
"composite": true,
564565
// This is a nested comment
565-
"target": "es5",
566+
"target": "es5"
566567
},
567568
"references": []
568569
}
569-
`
570+
`
570571
);
571572

572573
await syncGenerator(tree);

packages/js/src/generators/typescript-sync/typescript-sync.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ function patchTsconfigJsonReferences(
604604
stringifiedJsonContents,
605605
['references'],
606606
updatedReferences,
607-
{ formattingOptions: { keepLines: false } }
607+
{ formattingOptions: { keepLines: true, insertSpaces: true, tabSize: 2 } }
608608
);
609609
const updatedJsonContents = applyEdits(stringifiedJsonContents, edits);
610610
// The final contents will be formatted by formatFiles() later

0 commit comments

Comments
 (0)