style: lint and format

This commit is contained in:
Sérgio Ramos 2017-11-02 13:33:43 +00:00
parent 8bb9c18b9c
commit 28918fb464
18 changed files with 62 additions and 66 deletions

View File

@ -6,7 +6,8 @@
"main": "src/schema/index.js", "main": "src/schema/index.js",
"scripts": { "scripts": {
"lint": "eslint . --fix --ext .js --ext .graphql", "lint": "eslint . --fix --ext .js --ext .graphql",
"fmt": "prettier --write --single-quote src/**/*.js src/*.js src/**/*.graphql", "fmt":
"prettier --write --single-quote src/**/*.js src/*.js src/**/*.graphql",
"test": "echo 0", "test": "echo 0",
"test-ci": "echo 0", "test-ci": "echo 0",
"start": "PORT=4000 node src/server.js", "start": "PORT=4000 node src/server.js",
@ -50,8 +51,6 @@
"prettier": "^1.7.4" "prettier": "^1.7.4"
}, },
"nodemonConfig": { "nodemonConfig": {
"ignore": [ "ignore": ["doc/*"]
"doc/*"
]
} }
} }

View File

@ -60,15 +60,17 @@ const resolvers = {
package: (root, { id, name }) => api.packages.get({ id, name }), package: (root, { id, name }) => api.packages.get({ id, name }),
machines: (root, { id, brand, state, tags, ...rest }, _, ctx) => machines: (root, { id, brand, state, tags, ...rest }, _, ctx) =>
id ? api.machines.get({ id }).then(machine => [machine]) id
: api.machines.list( ? api.machines.get({ id }).then(machine => [machine])
Object.assign(rest, { : api.machines
brand: brand ? brand.toLowerCase() : brand, .list(
state: state ? state.toLowerCase() : state, Object.assign(rest, {
tags: fromKeyValue(tags) brand: brand ? brand.toLowerCase() : brand,
}) state: state ? state.toLowerCase() : state,
) tags: fromKeyValue(tags)
.then(machines => { })
)
.then(machines => {
const field = forceArray(ctx.fieldNodes) const field = forceArray(ctx.fieldNodes)
.filter(({ name }) => name.value === 'machines') .filter(({ name }) => name.value === 'machines')
.shift(); .shift();

View File

@ -1,15 +1,17 @@
import React from 'react'; import React from 'react';
import forceArray from 'force-array';
import { import { TableTr, TableTd } from 'joyent-ui-toolkit';
TableTr,
TableTd
} from 'joyent-ui-toolkit';
export default ({ rule = '', global = false, enabled = false }) => ( export default ({ rule = '', global = false, enabled = false }) => (
<TableTr> <TableTr>
<TableTd><code>{rule}</code></TableTd> <TableTd>
<TableTd center middle><code>{JSON.stringify(global)}</code></TableTd> <code>{rule}</code>
<TableTd center middle><code>{JSON.stringify(enabled)}</code></TableTd> </TableTd>
<TableTd center middle>
<code>{JSON.stringify(global)}</code>
</TableTd>
<TableTd center middle>
<code>{JSON.stringify(enabled)}</code>
</TableTd>
</TableTr> </TableTr>
); );

View File

@ -2,7 +2,6 @@ import React from 'react';
import { Row, Col } from 'react-styled-flexboxgrid'; import { Row, Col } from 'react-styled-flexboxgrid';
import forceArray from 'force-array'; import forceArray from 'force-array';
import find from 'lodash.find'; import find from 'lodash.find';
import remcalc from 'remcalc';
import titleCase from 'title-case'; import titleCase from 'title-case';
import { import {
@ -35,7 +34,7 @@ import {
Anchor Anchor
} from 'joyent-ui-toolkit'; } from 'joyent-ui-toolkit';
const { SmallOnly, Small, Medium } = QueryBreakpoints; const { SmallOnly, Medium } = QueryBreakpoints;
const stateColor = { const stateColor = {
PROVISIONING: 'primary', PROVISIONING: 'primary',
@ -156,7 +155,7 @@ export default ({
const items = forceArray(instances).map(instance => { const items = forceArray(instances).map(instance => {
// eslint-disable-next-line camelcase // eslint-disable-next-line camelcase
const { id, name, state, firewall_enabled, snapshots, brand } = instance; const { id, state, firewall_enabled, snapshots, brand } = instance;
const isSelected = Boolean(find(selected, ['id', id])); const isSelected = Boolean(find(selected, ['id', id]));
const isSubmitting = isSelected && submitting; const isSubmitting = isSelected && submitting;
@ -221,7 +220,9 @@ export default ({
<TableTh xs="48" /> <TableTh xs="48" />
</TableTr> </TableTr>
</TableThead> </TableThead>
<TableTbody>{items.map(instance => <Item key={instance.id} {...instance} />)}</TableTbody> <TableTbody>
{items.map(instance => <Item key={instance.id} {...instance} />)}
</TableTbody>
</Table> </Table>
); );

View File

@ -1,10 +1,7 @@
import React from 'react'; import React from 'react';
import forceArray from 'force-array'; import forceArray from 'force-array';
import { import { TableTr, TableTd } from 'joyent-ui-toolkit';
TableTr,
TableTd
} from 'joyent-ui-toolkit';
export default ({ name, gateway, subnet, resolvers = [] }) => ( export default ({ name, gateway, subnet, resolvers = [] }) => (
<TableTr> <TableTr>

View File

@ -109,7 +109,9 @@ export default ({
</TableTh> </TableTh>
</TableTr> </TableTr>
</TableThead> </TableThead>
<TableTbody>{items.map(snapshot => <Item key={snapshot.name} {...snapshot} />)}</TableTbody> <TableTbody>
{items.map(snapshot => <Item key={snapshot.name} {...snapshot} />)}
</TableTbody>
</Table> </Table>
); );

View File

@ -1,6 +1,6 @@
query instance($name: String) { query instance($name: String) {
machines(name: $name) { machines(name: $name) {
id, id
dns_names dns_names
} }
} }

View File

@ -1,7 +1,7 @@
query instance($name: String!) { query instance($name: String!) {
machines(name: $name) { machines(name: $name) {
id, id
name, name
dns_names dns_names
} }
} }

View File

@ -22,10 +22,7 @@ const { default: Card, Header, HeaderBox, HeaderMeta } = require('.');
const { Row, Col } = require('react-styled-flexboxgrid'); const { Row, Col } = require('react-styled-flexboxgrid');
const { H4, P } = require('../text'); const { H4, P } = require('../text');
const { const { InstancesIconLight, IconActionsLight } = require('../icons');
InstancesIconLight,
IconActionsLight
} = require('../icons');
<Card shadow collapsed> <Card shadow collapsed>
<Header> <Header>
@ -108,10 +105,7 @@ const { default: Card, Header, HeaderBox, HeaderMeta, Outlet } = require('.');
const { Row, Col } = require('react-styled-flexboxgrid'); const { Row, Col } = require('react-styled-flexboxgrid');
const { H4, P, Small } = require('../text'); const { H4, P, Small } = require('../text');
const { const { InstancesIconLight, IconActionsLight } = require('../icons');
InstancesIconLight,
IconActionsLight
} = require('../icons');
<Card shadow> <Card shadow>
<Header> <Header>

View File

@ -1,7 +1,6 @@
import React from 'react'; import React from 'react';
import styled from 'styled-components'; import styled from 'styled-components';
import remcalc from 'remcalc'; import remcalc from 'remcalc';
import is from 'styled-is';
const Header = styled.div` const Header = styled.div`
display: flex; display: flex;

View File

@ -3,7 +3,6 @@ import styled from 'styled-components';
import remcalc from 'remcalc'; import remcalc from 'remcalc';
import P from '../text/p'; import P from '../text/p';
import typography from '../typography';
const Text = P.extend` const Text = P.extend`
text-align: center; text-align: center;

View File

@ -1,11 +1,7 @@
import React from 'react'; import React from 'react';
import styled from 'styled-components'; import styled from 'styled-components';
import is from 'styled-components';
import remcalc from 'remcalc'; import remcalc from 'remcalc';
import P from '../text/p';
import typography from '../typography';
const UL = styled.ul` const UL = styled.ul`
padding: 0; padding: 0;
margin: 0; margin: 0;

View File

@ -4,15 +4,15 @@ const { default: HeaderBrand } = require('./brand.js');
const { default: HeaderItem } = require('./item.js'); const { default: HeaderItem } = require('./item.js');
<Header> <Header>
<HeaderWrapper> <HeaderWrapper>
<HeaderBrand beta><TritonBetaIcon/></HeaderBrand> <HeaderBrand beta><TritonBetaIcon/></HeaderBrand>
<HeaderNav> <HeaderNav>
<li><a href="#">Compute</a></li> <li><a href="#">Compute</a></li>
<li><a href="#" class="active">Network</a></li> <li><a href="#" class="active">Network</a></li>
</HeaderNav> </HeaderNav>
<HeaderItem>Return to existing portal</HeaderItem> <HeaderItem>Return to existing portal</HeaderItem>
<HeaderItem><DataCenterIconLight/>eu-east-1</HeaderItem> <HeaderItem><DataCenterIconLight/>eu-east-1</HeaderItem>
<HeaderItem><UserIconLight/>Nicola</HeaderItem> <HeaderItem><UserIconLight/>Nicola</HeaderItem>
</HeaderWrapper> </HeaderWrapper>
</Header> </Header>
``` ```

View File

@ -18,7 +18,7 @@ export { default as DataCenterIconLight } from './data-center-light';
export { default as DotIcon } from './dot'; export { default as DotIcon } from './dot';
export { default as ChevronIcon } from './chevron'; export { default as ChevronIcon } from './chevron';
export { default as TritonIcon } from './triton'; export { default as TritonIcon } from './triton';
export { default as TritonBetaIcon } from './triton-beta' export { default as TritonBetaIcon } from './triton-beta';
export { default as CompletedIcon } from './completed'; export { default as CompletedIcon } from './completed';
export { default as PartCompletedIcon } from './part-complete'; export { default as PartCompletedIcon } from './part-complete';
export { default as IncompleteIcon } from './incomplete'; export { default as IncompleteIcon } from './incomplete';

View File

@ -1,5 +1,3 @@
import React from 'react';
import TritonBetaIcon from './svg/triton_beta.svg'; import TritonBetaIcon from './svg/triton_beta.svg';
export default TritonBetaIcon; export default TritonBetaIcon;

View File

@ -11,7 +11,7 @@ const { Message, MessageTitle, MessageDescription } = require('.');
sure that you choose the data center that suits your requirements. Learn sure that you choose the data center that suits your requirements. Learn
more more
</MessageDescription> </MessageDescription>
</Message> </Message>;
``` ```
#### Error #### Error
@ -23,7 +23,7 @@ const { Message, MessageTitle, MessageDescription } = require('.');
<Message error> <Message error>
<MessageTitle>Choosing deployment data center</MessageTitle> <MessageTitle>Choosing deployment data center</MessageTitle>
<MessageDescription>Oh no</MessageDescription> <MessageDescription>Oh no</MessageDescription>
</Message> </Message>;
``` ```
#### Warning #### Warning
@ -35,5 +35,5 @@ const { Message, MessageTitle, MessageDescription } = require('.');
<Message warning> <Message warning>
<MessageTitle>Choosing deployment data center</MessageTitle> <MessageTitle>Choosing deployment data center</MessageTitle>
<MessageDescription>There were some issues</MessageDescription> <MessageDescription>There were some issues</MessageDescription>
</Message> </Message>;
``` ```

View File

@ -1,7 +1,7 @@
```jsx ```jsx
const React = require('react'); const React = require('react');
const { default: Table, Thead, Tr, Th, Tbody, Td } = require('./'); const { default: Table, Thead, Tr, Th, Tbody, Td } = require('./');
const { H4, P } = require('../text'); const { H4 } = require('../text');
<Table> <Table>
<Thead> <Thead>
@ -15,8 +15,12 @@ const { H4, P } = require('../text');
</Thead> </Thead>
<Tbody> <Tbody>
<Tr actionable> <Tr actionable>
<Td border="right" middle center>HB</Td> <Td border="right" middle center>
<Td><H4>percona_high-ram-32_1</H4></Td> HB
</Td>
<Td>
<H4>percona_high-ram-32_1</H4>
</Td>
<Td>Provisioning</Td> <Td>Provisioning</Td>
<Td>2252839a</Td> <Td>2252839a</Td>
<Td>HB</Td> <Td>HB</Td>
@ -36,5 +40,5 @@ const { H4, P } = require('../text');
<Td>HB</Td> <Td>HB</Td>
</Tr> </Tr>
</Tbody> </Tbody>
</Table> </Table>;
``` ```

View File

@ -1,4 +1,5 @@
```jsx ```jsx
const React = require('react');
const { default: Tooltip, Container, Target } = require('./'); const { default: Tooltip, Container, Target } = require('./');
const { Row, Col } = require('react-styled-flexboxgrid'); const { Row, Col } = require('react-styled-flexboxgrid');
@ -41,6 +42,7 @@ const { Row, Col } = require('react-styled-flexboxgrid');
#### Tooltip > hover #### Tooltip > hover
```jsx ```jsx
const React = require('react');
const { default: Tooltip, Container, Target } = require('./'); const { default: Tooltip, Container, Target } = require('./');
const { Row, Col } = require('react-styled-flexboxgrid'); const { Row, Col } = require('react-styled-flexboxgrid');
@ -59,6 +61,7 @@ const { Row, Col } = require('react-styled-flexboxgrid');
#### Tooltip > click #### Tooltip > click
```jsx ```jsx
const React = require('react');
const { default: Tooltip, Container, Target } = require('./'); const { default: Tooltip, Container, Target } = require('./');
const { Row, Col } = require('react-styled-flexboxgrid'); const { Row, Col } = require('react-styled-flexboxgrid');