From e3923bc63e6af1f5b1f77dc4f1bafbd7d7383bf7 Mon Sep 17 00:00:00 2001 From: Mathieu Dutour Date: Sat, 8 Jul 2017 13:52:43 +0200 Subject: [PATCH] run prettier --- app/src/ui/app.tsx | 9 +- app/src/ui/changes/no-changes.tsx | 12 +-- app/src/ui/changes/sketch-file.tsx | 1 - app/src/ui/premium-upsell/coupon-input.tsx | 27 ++++-- app/src/ui/premium-upsell/premium-upsell.tsx | 91 +++++++++++++------ .../repository-settings.tsx | 4 +- app/src/ui/repository.tsx | 9 +- .../terms-and-conditions.tsx | 41 +++++---- .../ui/updates/sketch-version-outdated.tsx | 10 +- app/test/unit/accounts-store-test.ts | 13 ++- app/test/unit/git/commit-test.ts | 48 +++++++--- app/test/unit/git/diff-test.ts | 17 +++- app/test/unit/repository-matching-test.ts | 90 ++++++++++++++++-- 13 files changed, 273 insertions(+), 99 deletions(-) diff --git a/app/src/ui/app.tsx b/app/src/ui/app.tsx index aad07b9d8..67bda72b4 100644 --- a/app/src/ui/app.tsx +++ b/app/src/ui/app.tsx @@ -1303,9 +1303,7 @@ export class App extends React.Component { } if (sketchVersion === null) { - return ( - - ) + return } if (semver.satisfies(sketchVersion, '>=43.0.0')) { @@ -1313,7 +1311,10 @@ export class App extends React.Component { } return ( - + ) } diff --git a/app/src/ui/changes/no-changes.tsx b/app/src/ui/changes/no-changes.tsx index 190000765..0302365f9 100644 --- a/app/src/ui/changes/no-changes.tsx +++ b/app/src/ui/changes/no-changes.tsx @@ -25,19 +25,17 @@ export class NoChanges extends React.Component {
Create a new Sketch File
-
-
Open this repository in {opener}
-
diff --git a/app/src/ui/changes/sketch-file.tsx b/app/src/ui/changes/sketch-file.tsx index 03272f774..39386d5f7 100644 --- a/app/src/ui/changes/sketch-file.tsx +++ b/app/src/ui/changes/sketch-file.tsx @@ -19,7 +19,6 @@ export class SketchFile extends React.Component< ISketchFileProps, Readonly<{}> > { - public render() { const listItemPadding = 10 * 2 const checkboxWidth = 20 diff --git a/app/src/ui/premium-upsell/coupon-input.tsx b/app/src/ui/premium-upsell/coupon-input.tsx index e8a459047..7f0ccad62 100644 --- a/app/src/ui/premium-upsell/coupon-input.tsx +++ b/app/src/ui/premium-upsell/coupon-input.tsx @@ -14,27 +14,36 @@ export class CouponInput extends React.Component< ICouponInputProps, Readonly<{}> > { - public render() { const { couponState, coupon, onValueChanged } = this.props const couponLabel = ( Coupon - {couponState && ( + {couponState && {' - '} {couponState === 'loading' ? - : couponState.error - ? {couponState.error} - : {couponState.discount} - } - - )} + : couponState.error + ? + {' '} + {couponState.error} + + : + {' '} + {couponState.discount} + } + } ) - return + return ( + + ) } } diff --git a/app/src/ui/premium-upsell/premium-upsell.tsx b/app/src/ui/premium-upsell/premium-upsell.tsx index 033561ce3..576908f2f 100644 --- a/app/src/ui/premium-upsell/premium-upsell.tsx +++ b/app/src/ui/premium-upsell/premium-upsell.tsx @@ -33,7 +33,6 @@ export class PremiumUpsell extends React.Component< IPremiumUpsellProps, IPremiumUpsellState > { - private scheduler = new ThrottledScheduler(200) private requestId = 0 @@ -45,7 +44,7 @@ export class PremiumUpsell extends React.Component< loadingCheckout: false, coupon: '', plan: 'kactus-1-month', - couponState: null + couponState: null, } } @@ -79,7 +78,7 @@ export class PremiumUpsell extends React.Component< this.props.dispatcher.unlockKactus(this.props.user, token.id, { email: token.email, enterprise: this.props.enterprise, - coupon: this.state.coupon !== '' ? this.state.coupon : undefined + coupon: this.state.coupon !== '' ? this.state.coupon : undefined, }) } @@ -88,21 +87,23 @@ export class PremiumUpsell extends React.Component< this.scheduler.clear() return this.setState({ coupon, - couponState: null + couponState: null, }) } this.setState({ coupon, - couponState: 'loading' + couponState: 'loading', }) this.scheduler.queue(async () => { this.requestId += 1 const couponState = await fetchCoupon(coupon, this.requestId) - if (couponState.requestId !== this.requestId) { return } + if (couponState.requestId !== this.requestId) { + return + } this.setState({ - couponState + couponState, }) }) } @@ -141,31 +142,59 @@ export class PremiumUpsell extends React.Component< } const copy = this.props.enterprise - ? ( -
-

Hey! This feature is only available in the enterprise version of Kactus.

+ ?
+

+ Hey! This feature is only available in the enterprise version of + Kactus. +

  • Unlimited public repositories
  • -
  • No locked-in commitment: you can always generate the sketch files to switch back
  • -
  • Unlimited private repositories
  • -
  • Support single sign-on and on-premises deployment
  • +
  • + No locked-in commitment: you can always generate the sketch files + to switch back +
  • +
  • + Unlimited private repositories +
  • +
  • + Support single sign-on and on-premises deployment +
-

More information available here.

- +

+ More information available{' '} + here. +

+
- ) - : ( -
-

Hey! This feature is only available in the full access version of Kactus.

+ :
+

+ Hey! This feature is only available in the full access version of + Kactus. +

  • Unlimited public repositories
  • -
  • No locked-in commitment: you can always generate the sketch files to switch back
  • -
  • Unlimited private repositories
  • +
  • + No locked-in commitment: you can always generate the sketch files + to switch back +
  • +
  • + Unlimited private repositories +
-

More information available here.

- +

+ More information available{' '} + here. +

+
- ) return (
@@ -185,11 +214,21 @@ export class PremiumUpsell extends React.Component< onDismissed={this.props.onDismissed} loading={loadingCheckout} > - {copy} + + {copy} + - + diff --git a/app/src/ui/repository-settings/repository-settings.tsx b/app/src/ui/repository-settings/repository-settings.tsx index 939556f7c..543d5f595 100644 --- a/app/src/ui/repository-settings/repository-settings.tsx +++ b/app/src/ui/repository-settings/repository-settings.tsx @@ -186,7 +186,9 @@ export class RepositorySettings extends React.Component< } private onShowKactusDoc = () => { - this.props.dispatcher.openInBrowser('http://kactus.io/help/#kactus-dot-json') + this.props.dispatcher.openInBrowser( + 'http://kactus.io/help/#kactus-dot-json' + ) } private onSubmit = async () => { diff --git a/app/src/ui/repository.tsx b/app/src/ui/repository.tsx index b5b469779..55a8ed05f 100644 --- a/app/src/ui/repository.tsx +++ b/app/src/ui/repository.tsx @@ -10,7 +10,7 @@ import { TabBar } from './tab-bar' import { IRepositoryState as IRepositoryModelState, RepositorySection, - PopupType + PopupType, } from '../lib/app-state' import { Dispatcher, IssuesStore, GitHubUserStore } from '../lib/dispatcher' import { assertNever } from '../lib/fatal-error' @@ -168,7 +168,12 @@ export class RepositoryView extends React.Component { !selectedSketchFile && (!changesState.workingDirectory.files.length || !selectedFile || !diff) ) { - return + return ( + + ) } else { return (

- These Kactus Terms and Conditions ("Application Terms") are a - legal agreement between you (either as an individual or on behalf - of an entity) and GitHub, Inc. regarding your use of - Kactus and associated documentation ("Software"). - These Application Terms apply to the executable code - version of the Software. Source code for the Software is - available separately and free of charge under open + These Kactus Terms and Conditions ("Application Terms") are a legal + agreement between you (either as an individual or on behalf of an + entity) and GitHub, Inc. regarding your use of Kactus and associated + documentation ("Software"). These Application Terms apply to the + executable code version of the Software. Source code for the + Software is available separately and free of charge under open source software license agreements. If you do not agree to all of the terms in these Application Terms, do not download, install, use, or copy the Software. @@ -95,8 +93,8 @@ export class TermsAndConditions extends React.Component< To the extent the terms of the licenses applicable to open source components require Kactus to make an offer to provide source code in connection with the Software, such offer is hereby made, and you may - exercise it by contacting Kactus: - http://kactus.io/contact. + exercise it by contacting Kactus:{' '} + {contact}.

@@ -121,9 +119,9 @@ export class TermsAndConditions extends React.Component<

- The names Kactus, Kactus.io, and related Kactus logos and/or stylized - names are trademarks of Kactus. You agree not to display or use - these trademarks in any manner without Kactus's prior, written + The names Kactus, Kactus.io, and related Kactus logos and/or + stylized names are trademarks of Kactus. You agree not to display or + use these trademarks in any manner without Kactus's prior, written permission, except as allowed by Kactus's Logos and Usage Policy: logos.

@@ -135,7 +133,9 @@ export class TermsAndConditions extends React.Component< information the Software collects in the settings panel. If the Software does collect personal information on Kactus's behalf, Kactus will process that information in accordance with the - Kactus Privacy Statement. + + Kactus Privacy Statement + .

Additional Services

@@ -237,8 +237,11 @@ export class TermsAndConditions extends React.Component<
  • License to Kactus Policies. These Application Terms are licensed - under the Creative Commons Attribution license. - You may use it freely under the terms of the Creative Commons license. + under the{' '} + + Creative Commons Attribution license + . You may use it freely under the terms of the + Creative Commons license.
  • diff --git a/app/src/ui/updates/sketch-version-outdated.tsx b/app/src/ui/updates/sketch-version-outdated.tsx index 67f7adfb6..b8694311d 100644 --- a/app/src/ui/updates/sketch-version-outdated.tsx +++ b/app/src/ui/updates/sketch-version-outdated.tsx @@ -17,13 +17,19 @@ export class SketchVersionOutdated extends React.Component< {} > { public render() { - const copy = this.props.found ? `Kactus is only compatible with Sketch >= 43. We found ${this.props.found}.` : 'Kactus needs Sketch to function properly and we couldn\'t find it.' + const copy = this.props.found + ? `Kactus is only compatible with Sketch >= 43. We found ${this.props + .found}.` + : "Kactus needs Sketch to function properly and we couldn't find it." return (
    - {copy} Download Sketch now + {copy}{' '} + + Download Sketch now +
    ) diff --git a/app/test/unit/accounts-store-test.ts b/app/test/unit/accounts-store-test.ts index 05b0bde8d..b5dd25e1d 100644 --- a/app/test/unit/accounts-store-test.ts +++ b/app/test/unit/accounts-store-test.ts @@ -19,7 +19,18 @@ describe('AccountsStore', () => { describe('adding a new user', () => { it('contains the added user', async () => { const newAccountLogin = 'tonald-drump' - await accountsStore!.addAccount(new Account(newAccountLogin, '', '', new Array(), '', 1, '', false)) + await accountsStore!.addAccount( + new Account( + newAccountLogin, + '', + '', + new Array(), + '', + 1, + '', + false + ) + ) const users = await accountsStore!.getAll() expect(users[0].login).to.equal(newAccountLogin) diff --git a/app/test/unit/git/commit-test.ts b/app/test/unit/git/commit-test.ts index 9c156f186..8028e788a 100644 --- a/app/test/unit/git/commit-test.ts +++ b/app/test/unit/git/commit-test.ts @@ -36,7 +36,11 @@ import { import * as fs from 'fs-extra' const temp = require('temp').track() -async function getTextDiff(repo: Repository, kactusFiles: Array, file: WorkingDirectoryFileChange): Promise { +async function getTextDiff( + repo: Repository, + kactusFiles: Array, + file: WorkingDirectoryFileChange +): Promise { const diff = await getWorkingDirectoryDiff(repo, kactusFiles, file) expect(diff.kind === DiffType.Text) return diff as ITextDiff @@ -63,7 +67,12 @@ describe('git/commit', () => { let files = status.workingDirectory.files expect(files.length).to.equal(1) - await createCommit(repository!, kactusState.files, 'Special commit', files) + await createCommit( + repository!, + kactusState.files, + 'Special commit', + files + ) status = await getStatus(repository!) files = status.workingDirectory.files @@ -111,7 +120,12 @@ describe('git/commit', () => { files[1].withIncludeAll(true), ] - await createCommit(repo, kactusState.files, 'added two files\n\nthis is a description', allChanges) + await createCommit( + repo, + kactusState.files, + 'added two files\n\nthis is a description', + allChanges + ) const statusAfter = await getStatus(repo) @@ -139,7 +153,9 @@ describe('git/commit', () => { expect(files.length).to.equal(1) - await createCommit(repo, kactusState.files, 'renamed a file', [ files[0].withIncludeAll(true) ]) + await createCommit(repo, kactusState.files, 'renamed a file', [ + files[0].withIncludeAll(true), + ]) const statusAfter = await getStatus(repo) @@ -170,7 +186,7 @@ describe('git/commit', () => { ) // commit just this change, ignore everything else - await createCommit(repository!, [], 'title', [ file ]) + await createCommit(repository!, [], 'title', [file]) // verify that the HEAD of the repository has moved const newTip = (await getCommits(repository!, 'HEAD', 1))[0] @@ -221,7 +237,7 @@ describe('git/commit', () => { const updatedFile = file.withSelection(selection) // commit just this change, ignore everything else - await createCommit(repository!, [], 'title', [ updatedFile ]) + await createCommit(repository!, [], 'title', [updatedFile]) // verify that the HEAD of the repository has moved const newTip = (await getCommits(repository!, 'HEAD', 1))[0] @@ -274,7 +290,7 @@ describe('git/commit', () => { ) // commit just this change, ignore everything else - await createCommit(repository!, [], 'title', [ file ]) + await createCommit(repository!, [], 'title', [file]) // verify that the HEAD of the repository has moved const newTip = (await getCommits(repository!, 'HEAD', 1))[0] @@ -318,7 +334,7 @@ describe('git/commit', () => { ) // commit just this change, ignore everything else - await createCommit(repository!, [], 'title', [ updatedFile ]) + await createCommit(repository!, [], 'title', [updatedFile]) // verify that the HEAD of the repository has moved const newTip = (await getCommits(repository!, 'HEAD', 1))[0] @@ -358,7 +374,7 @@ describe('git/commit', () => { ) // commit just this change, ignore everything else - await createCommit(repository!, [], 'title', [ file ]) + await createCommit(repository!, [], 'title', [file]) // verify that the HEAD of the repository has moved const newTip = (await getCommits(repository!, 'HEAD', 1))[0] @@ -398,7 +414,9 @@ describe('git/commit', () => { expect(files.length).to.equal(1) - await createCommit(repo, [], 'renamed a file', [ files[0].withIncludeAll(true) ]) + await createCommit(repo, [], 'renamed a file', [ + files[0].withIncludeAll(true), + ]) const statusAfter = await getStatus(repo) @@ -432,13 +450,17 @@ describe('git/commit', () => { const partiallySelectedFile = files[0].withSelection(selection) - await createCommit(repo, [], 'renamed a file', [ partiallySelectedFile ]) + await createCommit(repo, [], 'renamed a file', [partiallySelectedFile]) const statusAfter = await getStatus(repo) expect(statusAfter.workingDirectory.files.length).to.equal(1) - const diff = await getTextDiff(repo, [], statusAfter.workingDirectory.files[0]) + const diff = await getTextDiff( + repo, + [], + statusAfter.workingDirectory.files[0] + ) expect(diff.hunks.length).to.equal(1) expect(diff.hunks[0].lines.length).to.equal(4) @@ -465,7 +487,7 @@ describe('git/commit', () => { const selection = files[0].selection.withSelectAll() const selectedFile = files[0].withSelection(selection) - await createCommit(repo, [], 'Merge commit!', [ selectedFile ]) + await createCommit(repo, [], 'Merge commit!', [selectedFile]) const commits = await getCommits(repo, 'HEAD', 5) expect(commits[0].parentSHAs.length).to.equal(2) diff --git a/app/test/unit/git/diff-test.ts b/app/test/unit/git/diff-test.ts index 65f3caa5e..33516a0ef 100644 --- a/app/test/unit/git/diff-test.ts +++ b/app/test/unit/git/diff-test.ts @@ -32,8 +32,11 @@ import { import { GitProcess } from 'dugite' -async function getTextDiff(repo: Repository, file: WorkingDirectoryFileChange): Promise { - const diff = await getWorkingDirectoryDiff(repo, [], file) +async function getTextDiff( + repo: Repository, + file: WorkingDirectoryFileChange +): Promise { + const diff = await getWorkingDirectoryDiff(repo, [], file) expect(diff.kind === DiffType.Text) return diff as ITextDiff } @@ -115,8 +118,14 @@ describe('git/diff', () => { describe('imageDiff', () => { it('changes for images are set', async () => { - const diffSelection = DiffSelection.fromInitialSelection(DiffSelectionType.All) - const file = new WorkingDirectoryFileChange('modified-image.jpg', AppFileStatus.Modified, diffSelection) + const diffSelection = DiffSelection.fromInitialSelection( + DiffSelectionType.All + ) + const file = new WorkingDirectoryFileChange( + 'modified-image.jpg', + AppFileStatus.Modified, + diffSelection + ) const diff = await getWorkingDirectoryDiff(repository!, [], file) expect(diff.kind === DiffType.Image) diff --git a/app/test/unit/repository-matching-test.ts b/app/test/unit/repository-matching-test.ts index fcd69ce29..ae94e0b11 100644 --- a/app/test/unit/repository-matching-test.ts +++ b/app/test/unit/repository-matching-test.ts @@ -6,36 +6,106 @@ import { Account } from '../../src/models/account' describe('Repository matching', () => { it('matches HTTPS URLs', () => { - const accounts = [ new Account('alovelace', 'https://api.github.com', '', [ ], '', 1, '', false) ] - const repo = matchGitHubRepository(accounts, 'https://github.com/someuser/somerepo.git')! + const accounts = [ + new Account( + 'alovelace', + 'https://api.github.com', + '', + [], + '', + 1, + '', + false + ), + ] + const repo = matchGitHubRepository( + accounts, + 'https://github.com/someuser/somerepo.git' + )! expect(repo.name).to.equal('somerepo') expect(repo.owner.login).to.equal('someuser') }) it('matches HTTPS URLs without the git extension', () => { - const accounts = [ new Account('alovelace', 'https://api.github.com', '', [ ], '', 1, '', false) ] - const repo = matchGitHubRepository(accounts, 'https://github.com/someuser/somerepo')! + const accounts = [ + new Account( + 'alovelace', + 'https://api.github.com', + '', + [], + '', + 1, + '', + false + ), + ] + const repo = matchGitHubRepository( + accounts, + 'https://github.com/someuser/somerepo' + )! expect(repo.name).to.equal('somerepo') expect(repo.owner.login).to.equal('someuser') }) it('matches git URLs', () => { - const accounts = [ new Account('alovelace', 'https://api.github.com', '', [ ], '', 1, '', false) ] - const repo = matchGitHubRepository(accounts, 'git:github.com/someuser/somerepo.git')! + const accounts = [ + new Account( + 'alovelace', + 'https://api.github.com', + '', + [], + '', + 1, + '', + false + ), + ] + const repo = matchGitHubRepository( + accounts, + 'git:github.com/someuser/somerepo.git' + )! expect(repo.name).to.equal('somerepo') expect(repo.owner.login).to.equal('someuser') }) it('matches SSH URLs', () => { - const accounts = [ new Account('alovelace', 'https://api.github.com', '', [ ], '', 1, '', false) ] - const repo = matchGitHubRepository(accounts, 'git@github.com:someuser/somerepo.git')! + const accounts = [ + new Account( + 'alovelace', + 'https://api.github.com', + '', + [], + '', + 1, + '', + false + ), + ] + const repo = matchGitHubRepository( + accounts, + 'git@github.com:someuser/somerepo.git' + )! expect(repo.name).to.equal('somerepo') expect(repo.owner.login).to.equal('someuser') }) it(`doesn't match if there aren't any users with that endpoint`, () => { - const accounts = [ new Account('alovelace', 'https://github.babbageinc.com', '', [ ], '', 1, '', false) ] - const repo = matchGitHubRepository(accounts, 'https://github.com/someuser/somerepo.git') + const accounts = [ + new Account( + 'alovelace', + 'https://github.babbageinc.com', + '', + [], + '', + 1, + '', + false + ), + ] + const repo = matchGitHubRepository( + accounts, + 'https://github.com/someuser/somerepo.git' + ) expect(repo).to.equal(null) }) })