From 9c1eda35b3664c11960afe6190467a2e255701c1 Mon Sep 17 00:00:00 2001 From: Martin Hochel Date: Tue, 31 Jan 2023 18:40:08 +0100 Subject: [PATCH 1/4] fix(tools): make sure export maps always use posix paths --- tools/generators/migrate-converged-pkg/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/generators/migrate-converged-pkg/index.ts b/tools/generators/migrate-converged-pkg/index.ts index c189ec5079359..427de28bd3441 100644 --- a/tools/generators/migrate-converged-pkg/index.ts +++ b/tools/generators/migrate-converged-pkg/index.ts @@ -669,7 +669,7 @@ function updatePackageJson(tree: Tree, options: NormalizedSchemaWithTsConfigs) { return json; function normalizePackageEntryPointPaths(entryPath: string) { - return './' + path.normalize(entryPath); + return './' + path.posix.normalize(entryPath); } } } From dddaa62c4b645903a6bf82aea2c39cf75e3d39ff Mon Sep 17 00:00:00 2001 From: Martin Hochel Date: Tue, 31 Jan 2023 19:00:06 +0100 Subject: [PATCH 2/4] fix(scripts-generators): remove empty export {} and run lint fix when create-component is invoked --- scripts/generators/create-component/index.ts | 37 +++++++++++++++----- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/scripts/generators/create-component/index.ts b/scripts/generators/create-component/index.ts index 2ca117bef71d0..aecadc770d852 100644 --- a/scripts/generators/create-component/index.ts +++ b/scripts/generators/create-component/index.ts @@ -1,15 +1,15 @@ // Plop script for templating out a converged React component //#region Imports -import { NodePlopAPI, AddManyActionConfig } from 'plop'; -import { Actions } from 'node-plop'; -import * as fs from 'fs-extra'; +import { execSync } from 'child_process'; import * as os from 'os'; import * as path from 'path'; -import { execSync } from 'child_process'; -import chalk from 'chalk'; -import { names, WorkspaceJsonConfiguration } from '@nrwl/devkit'; import { findGitRoot, getAllPackageInfo, isConvergedPackage } from '@fluentui/scripts-monorepo'; +import { WorkspaceJsonConfiguration, names } from '@nrwl/devkit'; +import chalk from 'chalk'; +import * as fs from 'fs-extra'; +import { Actions } from 'node-plop'; +import { AddManyActionConfig, NodePlopAPI } from 'plop'; //#endregion @@ -117,6 +117,11 @@ module.exports = (plop: NodePlopAPI) => { stdio: 'inherit', }); + execSync(`yarn workspace ${data.packageNpmName} lint --fix`, { + cwd: root, + stdio: 'inherit', + }); + return 'Component ready!'; }, ]; @@ -139,18 +144,32 @@ const checkIfComponentAlreadyExists = (data: Data): string => { const appendToPackageIndex = (data: Data): string => { const { componentName, packageName, packagePath } = data; - // get the package index file path const indexPath = path.join(packagePath, 'src/index.ts'); + const indexContent = cleanCreatePackageTemplate(indexPath); + const appendLine = `export * from './${componentName}';`; + // read contents and see if line is exists - const contents = fs.readFileSync(indexPath, { encoding: 'utf8' }); - if (!contents.includes(appendLine)) { + if (!indexContent.includes(appendLine)) { // doesn't exist so append fs.writeFileSync(indexPath, `${appendLine}${os.EOL}`, { flag: 'a' }); return `Updated package ${packageName} index.ts to include ${componentName}`; } + return `Package ${packageName} index.ts already contains reference to ${componentName}`; + + function cleanCreatePackageTemplate(filePath: string) { + const content = fs.readFileSync(filePath, { encoding: 'utf8' }); + const templateContent = 'export {}'; + + if (content.indexOf(templateContent) !== -1) { + fs.writeFileSync(filePath, ''); + return ''; + } + return content; + } }; + //#endregion function getProjectMetadata(options: { root: string; name: string }) { From 5a7497e41a44c22195c2c3c9859c54f09af784fc Mon Sep 17 00:00:00 2001 From: Martin Hochel Date: Wed, 1 Feb 2023 09:49:53 +0100 Subject: [PATCH 3/4] feat(eslint-plugin): turn off fluentui/max-lenght rule for v9 --- packages/eslint-plugin/src/configs/base.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/eslint-plugin/src/configs/base.js b/packages/eslint-plugin/src/configs/base.js index d5de005e17200..5956169dcabe7 100644 --- a/packages/eslint-plugin/src/configs/base.js +++ b/packages/eslint-plugin/src/configs/base.js @@ -13,6 +13,7 @@ module.exports = { * @see https://github.com/typescript-eslint/typescript-eslint/tree/main/packages/eslint-plugin */ ...getNamingConventionRule(), + '@fluentui/max-len': 'off', }, overrides: [ { From 2e302d335bde0f09e248c1f066a76f65b342fe53 Mon Sep 17 00:00:00 2001 From: Martin Hochel Date: Wed, 1 Feb 2023 09:50:41 +0100 Subject: [PATCH 4/4] generate change file --- ...eslint-plugin-9c309582-f6de-425d-bc96-c927db2786da.json | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 change/@fluentui-eslint-plugin-9c309582-f6de-425d-bc96-c927db2786da.json diff --git a/change/@fluentui-eslint-plugin-9c309582-f6de-425d-bc96-c927db2786da.json b/change/@fluentui-eslint-plugin-9c309582-f6de-425d-bc96-c927db2786da.json new file mode 100644 index 0000000000000..34c0a3ff31846 --- /dev/null +++ b/change/@fluentui-eslint-plugin-9c309582-f6de-425d-bc96-c927db2786da.json @@ -0,0 +1,7 @@ +{ + "type": "minor", + "comment": "feat(eslint-plugin): turn off fluentui/max-lenght rule for v9", + "packageName": "@fluentui/eslint-plugin", + "email": "martinhochel@microsoft.com", + "dependentChangeType": "patch" +}