Skip to content

Commit e8ae35e

Browse files
🎨 Fixes lint errors (#191)
1 parent 12a5fe6 commit e8ae35e

File tree

10 files changed

+64
-70
lines changed

10 files changed

+64
-70
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"release": "yarn build && changeset publish",
1515
"postinstall": "preconstruct dev",
1616
"lint": "yarn eslint \"./**/*.js\"",
17+
"lint:fix": "prettier --write packages/**/*.js",
1718
"validate": "yarn lint && yarn test && yarn flow",
1819
"build": "preconstruct build",
1920
"clean": "yarn delete:modules && yarn delete:dist",

packages/kind2string/test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,8 @@ describe('kind 2 string tests', () => {
334334
let converted = convert(res);
335335
expect(converted).toBe('react.Component');
336336
});
337+
338+
// eslint-disable-next-line jest/no-disabled-tests
337339
it.skip('Resolves down to a string representation for namespaced external imports', () => {
338340
let file = `
339341
import { Component } from 'react';

packages/pretty-proptypes/src/HybridLayout/PropEntry.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// @flow
22
/** @jsx jsx */
33
import { jsx, css } from '@emotion/core';
4-
import { Fragment, Component, type ComponentType, type Node } from 'react';
4+
import { Fragment, Component, type ComponentType } from 'react';
55
import md from 'react-markings';
66
import PrettyPropType from '../PrettyConvert';
77
import { HeadingType, HeadingDefault, Heading, HeadingRequired } from '../Prop/Heading';

packages/pretty-proptypes/src/HybridLayout/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
/** @jsx jsx */
66
import { jsx, css } from '@emotion/core';
7-
import React, { Component, type ComponentType } from 'react';
7+
import { Component, type ComponentType } from 'react';
88

99
import type { Components } from '../components';
1010
import type { CommonProps } from '../types';

packages/pretty-proptypes/src/PrettyConvert/converters.js

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,15 @@ export const converters: { [string]: ?Function } = {
104104
if (type.members.length === 0) {
105105
return <components.Type>Object</components.Type>;
106106
}
107-
let simpleObj = type.members.filter(mem => {
108-
if (mem === null) {
109-
/** if the member is null, error out */
110-
console.warn(`null property in members of ${type.referenceIdName} of kind ${type.kind} `)
111-
return false;
112-
}
113-
return !SIMPLE_TYPES.includes(mem.kind)
114-
}).length === 0;
107+
let simpleObj =
108+
type.members.filter(mem => {
109+
if (mem === null) {
110+
/** if the member is null, error out */
111+
console.warn(`null property in members of ${type.referenceIdName} of kind ${type.kind} `);
112+
return false;
113+
}
114+
return !SIMPLE_TYPES.includes(mem.kind);
115+
}).length === 0;
115116

116117
if (simpleObj) {
117118
return <components.Type>{convert(type)}</components.Type>;
@@ -121,20 +122,22 @@ export const converters: { [string]: ?Function } = {
121122
<span>
122123
<AddBrackets BracketStyler={components.TypeMeta} openBracket="{" closeBracket="}">
123124
<components.Indent>
124-
{type.members.filter(p => p).map(prop => {
125-
if (prop.kind === 'spread') {
126-
const nestedObj = resolveFromGeneric(prop.value);
127-
// Spreads almost always resolve to an object, but they can
128-
// also resolve to an import. We just allow it to fall through
129-
// to prettyConvert if there are no members
130-
if (nestedObj.members) {
131-
return nestedObj.members.map(newProp =>
132-
prettyConvert(newProp, components, depth)
133-
);
125+
{type.members
126+
.filter(p => p)
127+
.map(prop => {
128+
if (prop.kind === 'spread') {
129+
const nestedObj = resolveFromGeneric(prop.value);
130+
// Spreads almost always resolve to an object, but they can
131+
// also resolve to an import. We just allow it to fall through
132+
// to prettyConvert if there are no members
133+
if (nestedObj.members) {
134+
return nestedObj.members.map(newProp =>
135+
prettyConvert(newProp, components, depth)
136+
);
137+
}
134138
}
135-
}
136-
return prettyConvert(prop, components, depth);
137-
})}
139+
return prettyConvert(prop, components, depth);
140+
})}
138141
</components.Indent>
139142
</AddBrackets>
140143
</span>
@@ -244,5 +247,4 @@ const prettyConvert = (type: K.AnyKind, components: Components, depth: number =
244247
return converter(type, components, depth);
245248
};
246249

247-
248250
export default prettyConvert;

packages/pretty-proptypes/src/PrettyConvert/converters.test.js

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -124,35 +124,37 @@ test('resolve generic of array', () => {
124124

125125
test('objects with null members do not throw', () => {
126126
const type = {
127-
kind: "object",
127+
kind: 'object',
128128
members: [
129129
{
130-
kind: "property",
130+
kind: 'property',
131131
optional: false,
132132
key: {
133-
kind: "id",
134-
name: "children"
133+
kind: 'id',
134+
name: 'children'
135135
},
136136
value: {
137-
kind: "generic",
137+
kind: 'generic',
138138
value: {
139-
kind: "id",
140-
name: "React.ReactNode"
139+
kind: 'id',
140+
name: 'React.ReactNode'
141141
}
142142
}
143143
},
144144
null
145145
],
146-
referenceIdName: "LabelTextProps"
147-
}
146+
referenceIdName: 'LabelTextProps'
147+
};
148148
expect(() => prettyConvert(type, components)).not.toThrow();
149-
})
149+
});
150150

151+
// eslint-disable-next-line jest/no-disabled-tests
151152
test.skip('object with spread object', () => {
152-
let values = getSingleDefault(`{ ...something, c: 'something' }`);
153153
let wrapper = shallow(prettyConvert(`{ ...something, c: 'something' }`, components));
154154
expect(wrapper).toBe('something');
155155
});
156+
157+
// eslint-disable-next-line jest/no-disabled-tests
156158
test.skip('resolve generic of array with complex type', () => {
157159
let values = getSingleProp(`Array<{ b: string, c: number }>`);
158160
let wrapper = shallow(prettyConvert(values, components));

packages/pretty-proptypes/src/Props/Wrapper.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export const H2 = ({ children, ...rest }: { children: Node }) => (
3232
const PropsWrapper = ({ children, heading }: { children: Node, heading?: string }) => (
3333
<Wrapper>
3434
{typeof heading === 'string' && heading.length === 0 ? null : <H2>{heading || 'Props'}</H2>}
35-
{children}
35+
{children}
3636
</Wrapper>
3737
);
3838

Lines changed: 20 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// @flow
22
/** @jsx jsx */
33
import { jsx } from '@emotion/core';
4-
import { Fragment, Component, type ComponentType, type Node } from 'react';
4+
import { Fragment, Component, type ComponentType } from 'react';
55
import md from 'react-markings';
66
import PrettyPropType from '../PrettyConvert';
77
import { HeadingName, HeadingType, HeadingDefault } from '../Prop/Heading';
@@ -24,48 +24,37 @@ export default class Prop extends Component<PropProps> {
2424
return (
2525
<Fragment>
2626
<tbody>
27-
<tr valign="top" css={{
28-
'& > td': {
29-
padding: '14px 0px',
30-
}
31-
}}>
27+
<tr
28+
valign="top"
29+
css={{
30+
'& > td': {
31+
padding: '14px 0px'
32+
}
33+
}}
34+
>
3235
<td>
33-
<HeadingName>
34-
{name}
35-
</HeadingName>
36+
<HeadingName>{name}</HeadingName>
3637
</td>
37-
<td css={{
38-
display: 'flex',
39-
flexDirection: 'column',
40-
}}>
38+
<td
39+
css={{
40+
display: 'flex',
41+
flexDirection: 'column'
42+
}}
43+
>
4144
<span>
42-
<HeadingType>
43-
{type}
44-
</HeadingType>
45+
<HeadingType>{type}</HeadingType>
4546
</span>
4647
<span>
47-
<ShapeComponent {...commonProps}/>
48+
<ShapeComponent {...commonProps} />
4849
</span>
4950
</td>
51+
<td>{defaultValue !== undefined && <HeadingDefault>{defaultValue}</HeadingDefault>}</td>
5052
<td>
51-
{defaultValue !== undefined && (
52-
<HeadingDefault>
53-
{defaultValue}
54-
</HeadingDefault>
55-
)}
56-
</td>
57-
<td>
58-
{description &&
59-
(<components.Description>
60-
{md([description])}
61-
</components.Description>)
62-
}
53+
{description && <components.Description>{md([description])}</components.Description>}
6354
</td>
6455
</tr>
6556
</tbody>
6657
</Fragment>
6758
);
6859
}
6960
}
70-
71-

packages/pretty-proptypes/src/PropsTable/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
/** @jsx jsx */
66
import { jsx } from '@emotion/core';
7-
import React, { Component, type ComponentType } from 'react';
7+
import { Component, type ComponentType } from 'react';
88

99
import type { Components } from '../components';
1010
import type { CommonProps } from '../types';

stories/layout/Hybrid.stories.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import { HybridLayout } from 'pretty-proptypes';
44
import { css, Global } from '@emotion/core';
55
import TypeScriptComponent from '../TypeScriptComponent';
66

7-
import { colors } from '../../packages/pretty-proptypes/src/components/constants';
8-
97
export default {
108
title: 'Example/Layouts/Hybrid',
119
component: HybridLayout

0 commit comments

Comments
 (0)