From b0b172b97604971fa947a6ed9fa47a4fc0c56a27 Mon Sep 17 00:00:00 2001 From: Oleksandr Fediashov Date: Thu, 11 Nov 2021 11:58:50 +0100 Subject: [PATCH 1/4] fix --- packages/react-conformance/src/defaultErrorMessages.tsx | 7 +++---- packages/react-conformance/src/defaultTests.tsx | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/react-conformance/src/defaultErrorMessages.tsx b/packages/react-conformance/src/defaultErrorMessages.tsx index b2d403cf6fd1b..4c30487150105 100644 --- a/packages/react-conformance/src/defaultErrorMessages.tsx +++ b/packages/react-conformance/src/defaultErrorMessages.tsx @@ -4,6 +4,7 @@ import { EOL } from 'os'; import * as path from 'path'; import { errorMessageColors, formatArray, getErrorMessage, formatErrors } from './utils/errorMessages'; +import { getPackagePath } from './defaultTests'; /* eslint-disable @typescript-eslint/naming-convention */ @@ -362,8 +363,7 @@ export const defaultErrorMessages = { 'exported-top-level': (testInfo: IsConformantOptions, error: Error) => { const { displayName, componentPath } = testInfo; const { testErrorPath, resolveInfo } = errorMessageColors; - const rootPath = componentPath.replace(/[\\/]src[\\/].*/, ''); - const indexFile = path.join(rootPath, 'src', 'index'); + const indexFile = path.join(getPackagePath(componentPath), 'src', 'index'); const exportInfo = testInfo.useDefaultExport ? `export { default as ${displayName} } from './${displayName};` @@ -391,8 +391,7 @@ export const defaultErrorMessages = { 'has-top-level-file': (testInfo: IsConformantOptions, error: Error) => { const { displayName, componentPath } = testInfo; const { testErrorPath, resolveInfo } = errorMessageColors; - const rootPath = componentPath.replace(/[\\/]src[\\/].*/, ''); - const topLevelFile = path.join(rootPath, 'src', displayName); + const topLevelFile = path.join(getPackagePath(componentPath), 'src', displayName); // Message Description: Handles scenario where the displayName doesn't match the component's filename. // diff --git a/packages/react-conformance/src/defaultTests.tsx b/packages/react-conformance/src/defaultTests.tsx index ac8338506f312..fe2078000eef0 100644 --- a/packages/react-conformance/src/defaultTests.tsx +++ b/packages/react-conformance/src/defaultTests.tsx @@ -520,7 +520,7 @@ export const defaultTests: TestObject = { }, }; -function getPackagePath(componentPath: string) { +export function getPackagePath(componentPath: string) { // Use lastIndexOf in case anyone has all their repos under a folder called "src" (it happens) const srcIndex = componentPath.replace(/\\/g, '/').lastIndexOf('/src/'); return componentPath.slice(0, srcIndex); From c1f48151db3f10b270452012d12b1df72157d0cf Mon Sep 17 00:00:00 2001 From: Oleksandr Fediashov Date: Thu, 11 Nov 2021 12:01:55 +0100 Subject: [PATCH 2/4] fix paths --- packages/react-conformance/src/defaultErrorMessages.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/react-conformance/src/defaultErrorMessages.tsx b/packages/react-conformance/src/defaultErrorMessages.tsx index a8e484e20b481..115016b0c3940 100644 --- a/packages/react-conformance/src/defaultErrorMessages.tsx +++ b/packages/react-conformance/src/defaultErrorMessages.tsx @@ -613,9 +613,7 @@ export const defaultErrorMessages = { ) => { const { componentPath, displayName } = testInfo; const { testErrorInfo, resolveInfo, testErrorPath } = errorMessageColors; - - const rootPath = componentPath.replace(/[\\/]src[\\/].*/, ''); - const indexFile = path.join(rootPath, 'src', 'index.ts'); + const indexFile = path.join(getPackagePath(componentPath), 'src', 'index.ts'); const constantValue = `export const ${exportName} = "${componentClassName}";`; From 8c47bf26c893401e0a1544ef34e3a751cb0039c3 Mon Sep 17 00:00:00 2001 From: Oleksandr Fediashov Date: Thu, 11 Nov 2021 12:02:58 +0100 Subject: [PATCH 3/4] Change files --- ...t-conformance-90ba2958-fc3c-4b00-9180-740ecb0fb58e.json | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 change/@fluentui-react-conformance-90ba2958-fc3c-4b00-9180-740ecb0fb58e.json diff --git a/change/@fluentui-react-conformance-90ba2958-fc3c-4b00-9180-740ecb0fb58e.json b/change/@fluentui-react-conformance-90ba2958-fc3c-4b00-9180-740ecb0fb58e.json new file mode 100644 index 0000000000000..66145c8594020 --- /dev/null +++ b/change/@fluentui-react-conformance-90ba2958-fc3c-4b00-9180-740ecb0fb58e.json @@ -0,0 +1,7 @@ +{ + "type": "minor", + "comment": "fix paths generated in defaultErrorMessages", + "packageName": "@fluentui/react-conformance", + "email": "olfedias@microsoft.com", + "dependentChangeType": "patch" +} From 8b36c45c7b7c73db912ad962d20dab3e83280b20 Mon Sep 17 00:00:00 2001 From: Oleksandr Fediashov Date: Fri, 12 Nov 2021 10:32:38 +0100 Subject: [PATCH 4/4] Update change/@fluentui-react-conformance-90ba2958-fc3c-4b00-9180-740ecb0fb58e.json Co-authored-by: Elizabeth Craig --- ...-react-conformance-90ba2958-fc3c-4b00-9180-740ecb0fb58e.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/change/@fluentui-react-conformance-90ba2958-fc3c-4b00-9180-740ecb0fb58e.json b/change/@fluentui-react-conformance-90ba2958-fc3c-4b00-9180-740ecb0fb58e.json index 66145c8594020..e699599b11d6e 100644 --- a/change/@fluentui-react-conformance-90ba2958-fc3c-4b00-9180-740ecb0fb58e.json +++ b/change/@fluentui-react-conformance-90ba2958-fc3c-4b00-9180-740ecb0fb58e.json @@ -1,5 +1,5 @@ { - "type": "minor", + "type": "patch", "comment": "fix paths generated in defaultErrorMessages", "packageName": "@fluentui/react-conformance", "email": "olfedias@microsoft.com",