From 45d18e57ddee5651068418d46e940e3b00a452d2 Mon Sep 17 00:00:00 2001 From: Elizabeth Craig Date: Thu, 22 Jul 2021 15:54:04 -0700 Subject: [PATCH] Update prettier (#560) --- .github/dependabot.yml | 7 +++--- .prettierignore | 12 +++++++++- .prettierrc | 3 ++- CONTRIBUTING.md | 3 +-- ...-20e181e7-8452-4431-8b81-3ae32cf7090c.json | 7 ++++++ package.json | 4 ++-- src/__e2e__/bump.test.ts | 23 +++++++++++++++---- src/__e2e__/config.test.ts | 2 +- src/__e2e__/packageManager.test.ts | 14 +++++++++-- .../bump/updateRelatedChangeType.test.ts | 4 ++-- .../changelog/mergeChangelogs.test.ts | 10 ++++++-- .../changelog/renderChangelog.test.ts | 14 +++++++++-- .../changelog/renderPackageChangelog.test.ts | 14 +++++++++-- .../performPublishConfigOverrides.test.ts | 7 +++++- src/__tests__/publish/tagPackages.test.ts | 8 +++---- .../publish/toposortPackages.test.ts | 18 +++++++-------- .../validatePackageDependencies.test.ts | 4 ++-- src/bump/updateRelatedChangeType.ts | 12 ++++++++-- src/changefile/promptForChange.ts | 5 +++- src/changefile/readChangeFiles.ts | 2 +- src/fixtures/gitDefaults.ts | 8 +++---- src/fixtures/verdaccio.js | 4 ++-- yarn.lock | 7 +++++- 23 files changed, 140 insertions(+), 52 deletions(-) create mode 100644 change/beachball-20e181e7-8452-4431-8b81-3ae32cf7090c.json diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 0d58debb..d02e6b98 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,4 +1,3 @@ - # To get started with Dependabot version updates, you'll need to specify which # package ecosystems to update and where the package manifests are located. # Please see the documentation for all configuration options: @@ -6,9 +5,9 @@ version: 2 updates: - - package-ecosystem: "npm" - directory: "/" + - package-ecosystem: 'npm' + directory: '/' schedule: - interval: "daily" + interval: 'daily' # Disable version updates for npm dependencies open-pull-requests-limit: 0 diff --git a/.prettierignore b/.prettierignore index dbbfcba6..d77746dd 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,2 +1,12 @@ -CHANGELOG.md *.snap +*.styl +*.svg +.*ignore +.nojekyll +docs/.vuepress/dist +change +CHANGELOG.* +lib +LICENSE +node_modules +yarn.lock \ No newline at end of file diff --git a/.prettierrc b/.prettierrc index dea2b7aa..35d2dd39 100644 --- a/.prettierrc +++ b/.prettierrc @@ -2,5 +2,6 @@ "trailingComma": "es5", "tabWidth": 2, "singleQuote": true, - "printWidth": 120 + "printWidth": 120, + "arrowParens": "avoid" } diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 72f1506a..212e9069 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,7 +1,6 @@ - # Contributing -This project welcomes contributions and suggestions. Most contributions require you to agree to a +This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com. diff --git a/change/beachball-20e181e7-8452-4431-8b81-3ae32cf7090c.json b/change/beachball-20e181e7-8452-4431-8b81-3ae32cf7090c.json new file mode 100644 index 00000000..9a7e482f --- /dev/null +++ b/change/beachball-20e181e7-8452-4431-8b81-3ae32cf7090c.json @@ -0,0 +1,7 @@ +{ + "type": "none", + "comment": "Update prettier", + "packageName": "beachball", + "email": "elcraig@microsoft.com", + "dependentChangeType": "none" +} diff --git a/package.json b/package.json index cc99a258..ffcdc356 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "checkchange": "node ./lib/cli.js check", "docs": "vuepress dev docs --host localhost", "docs:build": "vuepress build docs", - "prettier": "prettier --write --config ../../.prettierrc --ignore-path ../../.prettierignore 'src/**/*'", + "format": "prettier --write '**/*'", "pub": "node ./lib/cli.js publish", "release": "node ./lib/cli.js publish -y", "release:docs": "yarn docs:build && yarn gh-pages -d docs/.vuepress/dist --dotfiles", @@ -67,7 +67,7 @@ "gh-pages": "^3.1.0", "jest": "^24.8.0", "ncp": "^2.0.0", - "prettier": "^1.19.0", + "prettier": "~2.3.2", "rimraf": "^3.0.0", "tmp": "^0.1.0", "ts-jest": "^24.0.2", diff --git a/src/__e2e__/bump.test.ts b/src/__e2e__/bump.test.ts index 2b7dd1cb..09fe855a 100644 --- a/src/__e2e__/bump.test.ts +++ b/src/__e2e__/bump.test.ts @@ -184,7 +184,11 @@ describe('version bumping', () => { git(['push', 'origin', 'master'], { cwd: repo.rootPath }); - await bump({ path: repo.rootPath, bumpDeps: false, fromRef: revParseOutput.stdout } as BeachballOptions); + await bump({ + path: repo.rootPath, + bumpDeps: false, + fromRef: revParseOutput.stdout, + } as BeachballOptions); const packageInfos = getPackageInfos(repo.rootPath); @@ -335,7 +339,10 @@ describe('version bumping', () => { git(['push', 'origin', 'master'], { cwd: repo.rootPath }); - await bump({ path: repo.rootPath, groups: [{ include: 'packages/*', name: 'testgroup' }] } as BeachballOptions); + await bump({ + path: repo.rootPath, + groups: [{ include: 'packages/*', name: 'testgroup' }], + } as BeachballOptions); const packageInfos = getPackageInfos(repo.rootPath); @@ -461,7 +468,11 @@ describe('version bumping', () => { git(['push', 'origin', 'master'], { cwd: repo.rootPath }); - await bump({ path: repo.rootPath, bumpDeps: true, scope: ['!packages/foo'] } as BeachballOptions); + await bump({ + path: repo.rootPath, + bumpDeps: true, + scope: ['!packages/foo'], + } as BeachballOptions); const packageInfos = getPackageInfos(repo.rootPath); expect(packageInfos['foo'].version).toBe('1.0.0'); @@ -491,7 +502,11 @@ describe('version bumping', () => { git(['push', 'origin', 'master'], { cwd: repo.rootPath }); - await bump({ path: repo.rootPath, bumpDeps: true, scope: ['!packages/foo'] } as BeachballOptions); + await bump({ + path: repo.rootPath, + bumpDeps: true, + scope: ['!packages/foo'], + } as BeachballOptions); const packageInfos = getPackageInfos(repo.rootPath); expect(packageInfos['foo'].version).toBe('1.0.0'); diff --git a/src/__e2e__/config.test.ts b/src/__e2e__/config.test.ts index 516a6929..c04038b5 100644 --- a/src/__e2e__/config.test.ts +++ b/src/__e2e__/config.test.ts @@ -27,7 +27,7 @@ it('--config overrides configuration path', async () => { const repo = await repositoryFactory.cloneRepository(); const config = await inDirectory(repo.root!, async () => { await writeConfig('module.exports = { branch: "origin/main" };'); - await writeFileAsync('alternate.config.js', 'module.exports = { branch: "origin/foo" };') + await writeFileAsync('alternate.config.js', 'module.exports = { branch: "origin/foo" };'); return getOptions([...baseArgv, '--config', 'alternate.config.js']); }); expect(config.branch).toEqual('origin/foo'); diff --git a/src/__e2e__/packageManager.test.ts b/src/__e2e__/packageManager.test.ts index 43f9dfb7..872a434e 100644 --- a/src/__e2e__/packageManager.test.ts +++ b/src/__e2e__/packageManager.test.ts @@ -59,7 +59,12 @@ describe('packageManager', () => { it('publish package with defaultNpmTag publishes as defaultNpmTag', () => { const testPackageInfoWithDefaultNpmTag = { ...testPackageInfo, - combinedOptions: { gitTags: true, tag: null, defaultNpmTag: testTag, disallowedChangeTypes: null }, + combinedOptions: { + gitTags: true, + tag: null, + defaultNpmTag: testTag, + disallowedChangeTypes: null, + }, }; const publishResult = packagePublish(testPackageInfoWithDefaultNpmTag, registry.getUrl(), '', ''); expect(publishResult.success).toBeTruthy(); @@ -83,7 +88,12 @@ describe('packageManager', () => { it('publish with specified tag overrides defaultNpmTag', () => { const testPackageInfoWithDefaultNpmTag = { ...testPackageInfo, - combinedOptions: { gitTags: true, tag: testTag, defaultNpmTag: 'thisShouldNotBeUsed', disallowedChangeTypes: null }, + combinedOptions: { + gitTags: true, + tag: testTag, + defaultNpmTag: 'thisShouldNotBeUsed', + disallowedChangeTypes: null, + }, }; const publishResult = packagePublish(testPackageInfoWithDefaultNpmTag, registry.getUrl(), '', ''); expect(publishResult.success).toBeTruthy(); diff --git a/src/__tests__/bump/updateRelatedChangeType.test.ts b/src/__tests__/bump/updateRelatedChangeType.test.ts index 9354d14c..a6f3e377 100644 --- a/src/__tests__/bump/updateRelatedChangeType.test.ts +++ b/src/__tests__/bump/updateRelatedChangeType.test.ts @@ -4,7 +4,7 @@ import _ from 'lodash'; import { ChangeInfo } from '../../types/ChangeInfo'; describe('updateRelatedChangeType', () => { - const bumpInfoFixture: BumpInfo = ({ + const bumpInfoFixture: BumpInfo = { changeFileChangeInfos: new Map(), dependents: {}, calculatedChangeInfos: {}, @@ -30,7 +30,7 @@ describe('updateRelatedChangeType', () => { newPackages: new Set(), packageGroups: {}, groupOptions: {}, - } as unknown) as BumpInfo; + } as unknown as BumpInfo; const changeInfoFixture: ChangeInfo = { dependentChangeType: 'none', diff --git a/src/__tests__/changelog/mergeChangelogs.test.ts b/src/__tests__/changelog/mergeChangelogs.test.ts index 5c5e5c68..b6b3c88c 100644 --- a/src/__tests__/changelog/mergeChangelogs.test.ts +++ b/src/__tests__/changelog/mergeChangelogs.test.ts @@ -44,7 +44,10 @@ describe('mergeChangelogs', () => { }, ]; - const mergedChangelog = mergeChangelogs(changelogs, { name: 'master', version: '1.2.3' } as PackageInfo); + const mergedChangelog = mergeChangelogs(changelogs, { + name: 'master', + version: '1.2.3', + } as PackageInfo); expect(mergedChangelog).toBeDefined(); expect(mergedChangelog!.name).toBe('master'); expect(mergedChangelog!.version).toBe('1.2.3'); @@ -72,7 +75,10 @@ describe('mergeChangelogs', () => { }, ]; - const mergedChangelog = mergeChangelogs(changelogs, { name: 'master', version: '1.2.3' } as PackageInfo); + const mergedChangelog = mergeChangelogs(changelogs, { + name: 'master', + version: '1.2.3', + } as PackageInfo); expect(mergedChangelog).toBeDefined(); expect(mergedChangelog!.name).toBe('master'); expect(mergedChangelog!.version).toBe('1.2.3'); diff --git a/src/__tests__/changelog/renderChangelog.test.ts b/src/__tests__/changelog/renderChangelog.test.ts index a251a21b..c654190f 100644 --- a/src/__tests__/changelog/renderChangelog.test.ts +++ b/src/__tests__/changelog/renderChangelog.test.ts @@ -21,8 +21,18 @@ describe('renderChangelog', () => { comments: { major: [], minor: [ - { comment: 'Awesome change', author: 'user1@example.com', commit: 'sha1', package: 'foo' }, - { comment: 'Boring change', author: 'user2@example.com', commit: 'sha2', package: 'foo' }, + { + comment: 'Awesome change', + author: 'user1@example.com', + commit: 'sha1', + package: 'foo', + }, + { + comment: 'Boring change', + author: 'user2@example.com', + commit: 'sha2', + package: 'foo', + }, ], patch: [ { comment: 'Fix', author: 'user1@example.com', commit: 'sha3', package: 'foo' }, diff --git a/src/__tests__/changelog/renderPackageChangelog.test.ts b/src/__tests__/changelog/renderPackageChangelog.test.ts index 469368a4..ca25bf70 100644 --- a/src/__tests__/changelog/renderPackageChangelog.test.ts +++ b/src/__tests__/changelog/renderPackageChangelog.test.ts @@ -18,8 +18,18 @@ describe('changelog renderers -', () => { comments: { major: [], minor: [ - { comment: 'Awesome change', author: 'user1@example.com', commit: 'sha1', package: 'foo' }, - { comment: 'Boring change', author: 'user2@example.com', commit: 'sha2', package: 'foo' }, + { + comment: 'Awesome change', + author: 'user1@example.com', + commit: 'sha1', + package: 'foo', + }, + { + comment: 'Boring change', + author: 'user2@example.com', + commit: 'sha2', + package: 'foo', + }, ], patch: [ { comment: 'Fix', author: 'user1@example.com', commit: 'sha3', package: 'foo' }, diff --git a/src/__tests__/publish/performPublishConfigOverrides.test.ts b/src/__tests__/publish/performPublishConfigOverrides.test.ts index 44ca867b..2369ef10 100644 --- a/src/__tests__/publish/performPublishConfigOverrides.test.ts +++ b/src/__tests__/publish/performPublishConfigOverrides.test.ts @@ -19,7 +19,12 @@ describe('perform publishConfig overrides', () => { const packageInfos: PackageInfos = { foo: { - combinedOptions: { defaultNpmTag: 'latest', disallowedChangeTypes: [], gitTags: true, tag: 'latest' }, + combinedOptions: { + defaultNpmTag: 'latest', + disallowedChangeTypes: [], + gitTags: true, + tag: 'latest', + }, name: 'foo', packageJsonPath: path.join(tmpDir, 'package.json'), packageOptions: {}, diff --git a/src/__tests__/publish/tagPackages.test.ts b/src/__tests__/publish/tagPackages.test.ts index f497e8d2..e725a3c2 100644 --- a/src/__tests__/publish/tagPackages.test.ts +++ b/src/__tests__/publish/tagPackages.test.ts @@ -11,7 +11,7 @@ const createTagParameters = (tag: string, cwd: string) => { return [['tag', '-a', '-f', tag, '-m', tag], { cwd }]; }; -const noTagBumpInfo = ({ +const noTagBumpInfo = { calculatedChangeInfos: { foo: 'minor', bar: 'major', @@ -34,9 +34,9 @@ const noTagBumpInfo = ({ }, modifiedPackages: new Set(['foo', 'bar']), newPackages: new Set(), -} as unknown) as BumpInfo; +} as unknown as BumpInfo; -const oneTagBumpInfo = ({ +const oneTagBumpInfo = { calculatedChangeInfos: { foo: 'minor', bar: 'major', @@ -59,7 +59,7 @@ const oneTagBumpInfo = ({ }, modifiedPackages: new Set(['foo', 'bar']), newPackages: new Set(), -} as unknown) as BumpInfo; +} as unknown as BumpInfo; beforeEach(() => { (gitFailFast as jest.Mock).mockReset(); diff --git a/src/__tests__/publish/toposortPackages.test.ts b/src/__tests__/publish/toposortPackages.test.ts index a5a05a06..9806b4eb 100644 --- a/src/__tests__/publish/toposortPackages.test.ts +++ b/src/__tests__/publish/toposortPackages.test.ts @@ -12,7 +12,7 @@ describe('toposortPackages', () => { }); it('sort packages with dependencies', () => { - const packageInfos = ({ + const packageInfos = { foo: { dependencies: { foo3: '1.0.0', @@ -25,13 +25,13 @@ describe('toposortPackages', () => { }, }, foo2: {}, - } as any) as PackageInfos; + } as any as PackageInfos; expect(toposortPackages(['foo', 'foo2', 'foo3'], packageInfos)).toEqual(['foo2', 'foo3', 'foo']); }); it('sort packages with different kinds of dependencies', () => { - const packageInfos = ({ + const packageInfos = { foo: { dependencies: { foo3: '1.0.0', @@ -54,13 +54,13 @@ describe('toposortPackages', () => { foo2: '1.0.0', }, }, - } as any) as PackageInfos; + } as any as PackageInfos; expect(toposortPackages(['foo', 'foo2', 'foo3', 'foo4'], packageInfos)).toEqual(['foo2', 'foo3', 'foo4', 'foo']); }); it('do not sort packages if it is not included', () => { - const packageInfos = ({ + const packageInfos = { foo: { dependencies: { foo3: '1.0.0', @@ -73,13 +73,13 @@ describe('toposortPackages', () => { foo2: '1.0.0', }, }, - } as any) as PackageInfos; + } as any as PackageInfos; expect(toposortPackages(['foo', 'foo3'], packageInfos)).toEqual(['foo3', 'foo']); }); it('throws if contains circular dependencies', () => { - const packageInfos = ({ + const packageInfos = { foo: { dependencies: { bar: '1.0.0', @@ -91,7 +91,7 @@ describe('toposortPackages', () => { foo: '1.0.0', }, }, - } as any) as PackageInfos; + } as any as PackageInfos; expect(() => { toposortPackages(['foo', 'bar'], packageInfos); @@ -99,7 +99,7 @@ describe('toposortPackages', () => { }); it('throws if package info is missing', () => { - const packageInfos = ({} as any) as PackageInfos; + const packageInfos = {} as any as PackageInfos; expect(() => { toposortPackages(['foo'], packageInfos); diff --git a/src/__tests__/publish/validatePackageDependencies.test.ts b/src/__tests__/publish/validatePackageDependencies.test.ts index 7c2f543c..1c32dda0 100644 --- a/src/__tests__/publish/validatePackageDependencies.test.ts +++ b/src/__tests__/publish/validatePackageDependencies.test.ts @@ -3,7 +3,7 @@ import { BumpInfo } from '../../types/BumpInfo'; import _ from 'lodash'; describe('validatePackageDependencies', () => { - const bumpInfoFixture = ({ + const bumpInfoFixture = { changes: new Map(), dependents: {}, calculatedChangeInfos: {}, @@ -23,7 +23,7 @@ describe('validatePackageDependencies', () => { scopedPackages: new Set(['foo', 'bar']), packageGroups: {}, groupOptions: {}, - } as unknown) as BumpInfo; + } as unknown as BumpInfo; it('invalid when dependencies contains private package', () => { const bumpInfo = _.merge(_.cloneDeep(bumpInfoFixture), { diff --git a/src/bump/updateRelatedChangeType.ts b/src/bump/updateRelatedChangeType.ts index a4cdc11a..9b839bcc 100644 --- a/src/bump/updateRelatedChangeType.ts +++ b/src/bump/updateRelatedChangeType.ts @@ -87,7 +87,11 @@ export function updateRelatedChangeType( if (bumpDeps && dependentPackages && dependentPackages.length > 0) { for (const dependentPackage of dependentPackages) { - queue.push({ subjectPackage: dependentPackage, changeType: dependentChangeType, baseChangeInfo }); + queue.push({ + subjectPackage: dependentPackage, + changeType: dependentChangeType, + baseChangeInfo, + }); } } @@ -100,7 +104,11 @@ export function updateRelatedChangeType( !groupOptions[groupName] || !groupOptions[groupName]?.disallowedChangeTypes?.includes(dependentChangeType) ) { - queue.push({ subjectPackage: packageNameInGroup, changeType: baseChangeInfo.type, baseChangeInfo }); + queue.push({ + subjectPackage: packageNameInGroup, + changeType: baseChangeInfo.type, + baseChangeInfo, + }); } } } diff --git a/src/changefile/promptForChange.ts b/src/changefile/promptForChange.ts index 91025b7a..ee662c52 100644 --- a/src/changefile/promptForChange.ts +++ b/src/changefile/promptForChange.ts @@ -90,7 +90,10 @@ export async function promptForChange(options: BeachballOptions) { }; if (questions.length > 0) { - response = (await prompts(questions as prompts.PromptObject[])) as { comment: string; type: ChangeType }; + response = (await prompts(questions as prompts.PromptObject[])) as { + comment: string; + type: ChangeType; + }; if (Object.keys(response).length === 0) { console.log('Cancelled, no change files are written'); diff --git a/src/changefile/readChangeFiles.ts b/src/changefile/readChangeFiles.ts index 88123112..e73f1cd0 100644 --- a/src/changefile/readChangeFiles.ts +++ b/src/changefile/readChangeFiles.ts @@ -41,7 +41,7 @@ export function readChangeFiles(options: BeachballOptions): ChangeSet { try { // sort the change files by modified time. Most recent modified file comes first. - filteredChangeFiles.sort(function(f1, f2) { + filteredChangeFiles.sort(function (f1, f2) { return ( fs.statSync(path.join(changePath, f2)).mtime.getTime() - fs.statSync(path.join(changePath, f1)).mtime.getTime() ); diff --git a/src/fixtures/gitDefaults.ts b/src/fixtures/gitDefaults.ts index 1120492e..0e24f279 100644 --- a/src/fixtures/gitDefaults.ts +++ b/src/fixtures/gitDefaults.ts @@ -1,7 +1,7 @@ import { git } from 'workspace-tools'; -export const defaultBranchName = "master"; -export const defaultRemoteBranchName = "origin/" + defaultBranchName; +export const defaultBranchName = 'master'; +export const defaultRemoteBranchName = 'origin/' + defaultBranchName; export function gitInitWithDefaultBranchName(cwd: string) { git(['init', '--bare'], { cwd }); @@ -15,5 +15,5 @@ export function gitInitWithDefaultBranchName(cwd: string) { */ export function setDefaultBranchName(cwd: string) { git(['symbolic-ref', 'HEAD', 'refs/heads/' + defaultBranchName], { cwd }); - git(['config', 'init.defaultBranch', defaultBranchName], { cwd }) -} \ No newline at end of file + git(['config', 'init.defaultBranch', defaultBranchName], { cwd }); +} diff --git a/src/fixtures/verdaccio.js b/src/fixtures/verdaccio.js index 45ca6f79..024e5602 100644 --- a/src/fixtures/verdaccio.js +++ b/src/fixtures/verdaccio.js @@ -4,11 +4,11 @@ const startServer = require('verdaccio').default; const store = require('verdaccio-memory').default; -const arguments = { +const args = { port: process.argv[2], }; -const port = arguments.port; +const port = args.port; if (!port) { console.error('Please provide a port'); diff --git a/yarn.lock b/yarn.lock index c0b75c14..06c35349 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8823,11 +8823,16 @@ prepend-http@^2.0.0: resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-2.0.0.tgz#e92434bfa5ea8c19f41cdfd401d741a3c819d897" integrity sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc= -prettier@^1.18.2, prettier@^1.19.0: +prettier@^1.18.2: version "1.19.1" resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.19.1.tgz#f7d7f5ff8a9cd872a7be4ca142095956a60797cb" integrity sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew== +prettier@~2.3.2: + version "2.3.2" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.3.2.tgz#ef280a05ec253712e486233db5c6f23441e7342d" + integrity sha512-lnJzDfJ66zkMy58OL5/NY5zp70S7Nz6KqcKkXYzn2tMVrNxvbqaBpg7H3qHaLxCJ5lNMsGuM8+ohS7cZrthdLQ== + pretty-error@^2.0.2: version "2.1.1" resolved "https://registry.yarnpkg.com/pretty-error/-/pretty-error-2.1.1.tgz#5f4f87c8f91e5ae3f3ba87ab4cf5e03b1a17f1a3"