Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

Commit

Permalink
clean up formatting and force it everywhere (#1698)
Browse files Browse the repository at this point in the history
* clean up formatting and force it everywhere

* change to use graphql instead of execute
  • Loading branch information
James Baxley committed Feb 22, 2018
1 parent e7308da commit d57f252
Show file tree
Hide file tree
Showing 62 changed files with 514 additions and 1,278 deletions.
8 changes: 8 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
node_modules
lib
coverage
npm
package.json
dist
*.snap
package-lock.json
4 changes: 0 additions & 4 deletions .prettierrc

This file was deleted.

6 changes: 1 addition & 5 deletions ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,7 @@ A new way to interact with Apollo and React, the `Query` component will allow us
Like the `Query` component, the `Mutation` component will allow using Apollo without an HOC but still get all of the benefits of Apollo. The rough draft looks something like this:
```js
<Mutation
stateUpdater={this.setState}
options={MutationOptions}
render={result => Component}
/>
<Mutation stateUpdater={this.setState} options={MutationOptions} render={result => Component} />
```
The stateUpdater prop allows for setting local component state based on the state of the _latest_ mutation fired or potentially allow a Map of results and statues. This API is still early and may change.
Expand Down
17 changes: 4 additions & 13 deletions dangerfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ const trivialPR = bodyAndTitle.includes('trivial');
const acceptedNoTests = bodyAndTitle.includes('skip new tests');

const typescriptOnly = (file: string) => includes(file, '.ts');
const filesOnly = (file: string) =>
fs.existsSync(file) && fs.lstatSync(file).isFile();
const filesOnly = (file: string) => fs.existsSync(file) && fs.lstatSync(file).isFile();

// Custom subsets of known files
const modifiedAppFiles = modified
Expand Down Expand Up @@ -42,15 +41,10 @@ const toSentence = (array: Array<string>): string => {
};

// ("/href/thing", "name") to "<a href="/href/thing">name</a>"
const createLink = (href: string, text: string): string =>
`<a href='${href}'>${text}</a>`;
const createLink = (href: string, text: string): string => `<a href='${href}'>${text}</a>`;

// Raise about missing code inside files
const raiseIssueAboutPaths = (
type: Function,
paths: string[],
codeToInclude: string,
) => {
const raiseIssueAboutPaths = (type: Function, paths: string[], codeToInclude: string) => {
if (paths.length > 0) {
const files = linkableFiles(paths);
const strict = '<code>' + codeToInclude + '</code>';
Expand Down Expand Up @@ -81,10 +75,7 @@ if (!isBot) {

// Warn when there is a big PR
const bigPRThreshold = 500;
if (
danger.github.pr.additions + danger.github.pr.deletions >
bigPRThreshold
) {
if (danger.github.pr.additions + danger.github.pr.deletions > bigPRThreshold) {
warn(':exclamation: Big PR');
}

Expand Down
3 changes: 1 addition & 2 deletions examples/base/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ export const CharacterWithoutData = ({ loading, hero, error }) => {
friend =>
friend && (
<h6 key={friend.id}>
{friend.name}:{' '}
{friend.appearsIn.map(x => x && x.toLowerCase()).join(', ')}
{friend.name}: {friend.appearsIn.map(x => x && x.toLowerCase()).join(', ')}
</h6>
),
)}
Expand Down
32 changes: 7 additions & 25 deletions examples/base/src/__tests__/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,7 @@ import { MockedProvider } from 'react-apollo/lib/test-utils';

import { addTypenameToDocument } from 'apollo-client';

import {
HERO_QUERY,
withCharacter,
CharacterWithoutData,
App,
ShapedProps,
} from '../App';
import { HERO_QUERY, withCharacter, CharacterWithoutData, App, ShapedProps } from '../App';

const query = addTypenameToDocument(HERO_QUERY);

Expand All @@ -40,9 +34,7 @@ describe('withCharacter', () => {
}

const ContainerWithData = withCharacter(Container);
const mocks = [
{ request: { query, variables }, result: { data: { hero: empty } } },
];
const mocks = [{ request: { query, variables }, result: { data: { hero: empty } } }];
renderer.create(
<MockedProvider mocks={mocks}>
<ContainerWithData {...variables} />
Expand Down Expand Up @@ -107,9 +99,7 @@ describe('withCharacter', () => {
}
componentWillReceiveProps(next: ShapedProps) {
expect(next.loading).toBe(false);
expect(next.error.message).toMatch(
/these are not the droids you are looking for/,
);
expect(next.error.message).toMatch(/these are not the droids you are looking for/);
done();
}
render() {
Expand Down Expand Up @@ -182,21 +172,15 @@ describe('CharacterWithoutData', () => {
expect(output.toJSON()).toMatchSnapshot();
});
it('returns markup for a hero with no friends', () => {
const output = renderer.create(
<CharacterWithoutData hero={hero_no_friends} />,
);
const output = renderer.create(<CharacterWithoutData hero={hero_no_friends} />);
expect(output.toJSON()).toMatchSnapshot();
});
it('returns markup for empty array of friends', () => {
const output = renderer.create(
<CharacterWithoutData hero={empty_array_friends} />,
);
const output = renderer.create(<CharacterWithoutData hero={empty_array_friends} />);
expect(output.toJSON()).toMatchSnapshot();
});
it('returns markup for a friend without an appearsIn', () => {
const output = renderer.create(
<CharacterWithoutData hero={friend_without_appearsIn} />,
);
const output = renderer.create(<CharacterWithoutData hero={friend_without_appearsIn} />);
expect(output.toJSON()).toMatchSnapshot();
});
it('renders a full data result', () => {
Expand All @@ -207,9 +191,7 @@ describe('CharacterWithoutData', () => {

describe('App', () => {
it('renders the data from NEWHOPE', () => {
const mocks = [
{ request: { query, variables }, result: { data: { hero: empty } } },
];
const mocks = [{ request: { query, variables }, result: { data: { hero: empty } } }];
const output = renderer.create(
<MockedProvider mocks={mocks}>
<App />
Expand Down
4 changes: 1 addition & 3 deletions examples/base/src/__tests__/__snapshots__/App.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ exports[`CharacterWithoutData renders a full data result 1`] = `
</div>
`;

exports[
`CharacterWithoutData returns markup for a friend without an appearsIn 1`
] = `
exports[`CharacterWithoutData returns markup for a friend without an appearsIn 1`] = `
<div>
<div>
<h3>
Expand Down
5 changes: 1 addition & 4 deletions examples/components/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,7 @@ const Character = ({ episode }) => (
friend =>
friend && (
<h6 key={friend.id}>
{friend.name}:{' '}
{friend.appearsIn
.map(x => x && x.toLowerCase())
.join(', ')}
{friend.name}: {friend.appearsIn.map(x => x && x.toLowerCase()).join(', ')}
</h6>
),
)}
Expand Down
15 changes: 3 additions & 12 deletions examples/flow/src/App.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
// @flow

import React from 'react';
import {
graphql,
type OperationComponent,
type QueryProps,
} from 'react-apollo';
import { graphql, type OperationComponent, type QueryProps } from 'react-apollo';
import gql from 'graphql-tag';

import type {
GetCharacterQuery,
GetCharacterQueryVariables,
} from './schema.flow.js';
import type { GetCharacterQuery, GetCharacterQueryVariables } from './schema.flow.js';

export const HERO_QUERY = gql`
query GetCharacter($episode: Episode!) {
Expand Down Expand Up @@ -55,9 +48,7 @@ export const CharacterWithoutData = ({ loading, hero, error }: Props) => {
friend && (
<h6 key={friend.id}>
{friend.name}:{' '}
{friend.appearsIn
.map(epis => epis && epis.toLowerCase())
.join(', ')}
{friend.appearsIn.map(epis => epis && epis.toLowerCase()).join(', ')}
</h6>
),
)}
Expand Down
32 changes: 7 additions & 25 deletions examples/flow/src/__tests__/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,7 @@ import { MockedProvider } from 'react-apollo/lib/test-utils';

import { addTypenameToDocument } from 'apollo-client';

import {
HERO_QUERY,
withCharacter,
CharacterWithoutData,
App,
ShapedProps,
} from '../App';
import { HERO_QUERY, withCharacter, CharacterWithoutData, App, ShapedProps } from '../App';

const query = HERO_QUERY;

Expand All @@ -40,9 +34,7 @@ describe('withCharacter', () => {
}

const ContainerWithData = withCharacter(Container);
const mocks = [
{ request: { query, variables }, result: { data: { hero: empty } } },
];
const mocks = [{ request: { query, variables }, result: { data: { hero: empty } } }];
renderer.create(
<MockedProvider mocks={mocks}>
<ContainerWithData {...variables} />
Expand Down Expand Up @@ -107,9 +99,7 @@ describe('withCharacter', () => {
}
componentWillReceiveProps(next: ShapedProps) {
expect(next.loading).toBe(false);
expect(next.error.message).toMatch(
/these are not the droids you are looking for/,
);
expect(next.error.message).toMatch(/these are not the droids you are looking for/);
done();
}
render() {
Expand Down Expand Up @@ -182,21 +172,15 @@ describe('CharacterWithoutData', () => {
expect(output.toJSON()).toMatchSnapshot();
});
it('returns markup for a hero with no friends', () => {
const output = renderer.create(
<CharacterWithoutData hero={hero_no_friends} />,
);
const output = renderer.create(<CharacterWithoutData hero={hero_no_friends} />);
expect(output.toJSON()).toMatchSnapshot();
});
it('returns markup for empty array of friends', () => {
const output = renderer.create(
<CharacterWithoutData hero={empty_array_friends} />,
);
const output = renderer.create(<CharacterWithoutData hero={empty_array_friends} />);
expect(output.toJSON()).toMatchSnapshot();
});
it('returns markup for a friend without an appearsIn', () => {
const output = renderer.create(
<CharacterWithoutData hero={friend_without_appearsIn} />,
);
const output = renderer.create(<CharacterWithoutData hero={friend_without_appearsIn} />);
expect(output.toJSON()).toMatchSnapshot();
});
it('renders a full data result', () => {
Expand All @@ -207,9 +191,7 @@ describe('CharacterWithoutData', () => {

describe('App', () => {
it('renders the data from NEWHOPE', () => {
const mocks = [
{ request: { query, variables }, result: { data: { hero: empty } } },
];
const mocks = [{ request: { query, variables }, result: { data: { hero: empty } } }];
const output = renderer.create(
<MockedProvider mocks={mocks}>
<App />
Expand Down
4 changes: 1 addition & 3 deletions examples/flow/src/__tests__/__snapshots__/App.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ exports[`CharacterWithoutData renders a full data result 1`] = `
</div>
`;

exports[
`CharacterWithoutData returns markup for a friend without an appearsIn 1`
] = `
exports[`CharacterWithoutData returns markup for a friend without an appearsIn 1`] = `
<div>
<div>
<h3>
Expand Down
Loading

0 comments on commit d57f252

Please sign in to comment.