From 12aa58213530d2bd2da913ea97bf9886575867ff Mon Sep 17 00:00:00 2001 From: Katerina Skroumpelou Date: Thu, 13 Jul 2023 13:19:24 +0300 Subject: [PATCH] fix(storybook): change storybook tsconfig path in eslint file too (#18101) (cherry picked from commit e545db7da96fb0c1174f0e736e5439a831bb07a5) --- .../configuration/lib/util-functions.ts | 34 +++++++++++++------ 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/packages/storybook/src/generators/configuration/lib/util-functions.ts b/packages/storybook/src/generators/configuration/lib/util-functions.ts index 5aa9d786bf7a8..07b7896d91314 100644 --- a/packages/storybook/src/generators/configuration/lib/util-functions.ts +++ b/packages/storybook/src/generators/configuration/lib/util-functions.ts @@ -719,17 +719,29 @@ export function renameAndMoveOldTsConfig( const projectTsConfig = joinPathFragments(projectRoot, 'tsconfig.json'); - if (!tree.exists(projectTsConfig)) { - return; + if (tree.exists(projectTsConfig)) { + updateJson(tree, projectTsConfig, (json) => { + for (let i = 0; i < json.references?.length; i++) { + if (json.references[i].path === './.storybook/tsconfig.json') { + json.references[i].path = './tsconfig.storybook.json'; + break; + } + } + return json; + }); } - updateJson(tree, projectTsConfig, (json) => { - for (let i = 0; i < json.references?.length; i++) { - if (json.references[i].path === './.storybook/tsconfig.json') { - json.references[i].path = './tsconfig.storybook.json'; - break; - } - } - return json; - }); + const projectEsLintFile = joinPathFragments(projectRoot, '.eslintrc.json'); + + if (tree.exists(projectEsLintFile)) { + updateJson(tree, projectEsLintFile, (json) => { + const jsonString = JSON.stringify(json); + const newJsonString = jsonString.replace( + /\.storybook\/tsconfig\.json/g, + 'tsconfig.storybook.json' + ); + json = JSON.parse(newJsonString); + return json; + }); + } }