Skip to content
This repository was archived by the owner on Oct 4, 2023. It is now read-only.

Commit 19a8516

Browse files
committed
Format with prettierrc
1 parent 2704b57 commit 19a8516

39 files changed

+422
-391
lines changed

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@
3838
"scripts": {
3939
"start": "react-scripts start",
4040
"build": "react-scripts build",
41-
"test:eslint": "eslint src",
41+
"test:eslint": "eslint src --fix",
4242
"test:jest": "react-scripts test",
43-
"test": "npm run test:eslint && npm run test:jest",
43+
"test": "CI=true npm run test:eslint && CI=true npm run test:jest",
4444
"eject": "react-scripts eject",
4545
"build:bundle": "microbundle",
4646
"build:types": "jsdoc -t node_modules/@otris/jsdoc-tsd -r ./src/rehook -d dist/rehook.d.ts",

src/App.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
// @TODO build a demo site.
22

3-
import React from "react";
3+
import React from 'react'
44

5-
import { withState, pipe, withHandlers } from "./rehook";
5+
import { withState, pipe, withHandlers } from './rehook'
66

77
const useCount = pipe(
8-
withState("count", "setCount", 0),
8+
withState('count', 'setCount', 0),
99
withHandlers({
1010
increment: ({ count, setCount }) => () => setCount(count + 1),
11-
decrement: ({ count, setCount }) => () => setCount(count - 1)
11+
decrement: ({ count, setCount }) => () => setCount(count - 1),
1212
})
13-
);
13+
)
1414

1515
function Something() {
16-
const { count, increment, decrement } = useCount();
16+
const { count, increment, decrement } = useCount()
1717

1818
return (
1919
<div>
2020
<button onClick={decrement}>-1</button>
2121
{count}
2222
<button onClick={increment}>+1</button>
2323
</div>
24-
);
24+
)
2525
}
2626

27-
export default Something;
27+
export default Something

src/index.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import React from "react";
2-
import ReactDOM from "react-dom";
3-
import App from "./app";
1+
import React from 'react'
2+
import ReactDOM from 'react-dom'
3+
import App from './app'
44

5-
ReactDOM.render(<App />, document.getElementById("root"));
5+
ReactDOM.render(<App />, document.getElementById('root'))

src/rehook/__tests__/branch-test.js

+17-15
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,40 @@
1-
import testUtil from "../test-util";
2-
import branch from "../branch";
3-
import withProps from "../with-props";
1+
/* eslint-env jest */
42

5-
test("branch left", () => {
3+
import testUtil from '../test-util'
4+
import branch from '../branch'
5+
import withProps from '../with-props'
6+
7+
test('branch left', () => {
68
const getProps = testUtil(
79
branch(
810
({ val }) => val,
911
withProps({ left: true }),
1012
withProps({ right: true })
1113
),
1214
{ val: true }
13-
);
15+
)
1416

15-
expect(getProps().left).toBe(true);
16-
});
17+
expect(getProps().left).toBe(true)
18+
})
1719

18-
test("branch right", () => {
20+
test('branch right', () => {
1921
const getProps = testUtil(
2022
branch(
2123
({ val }) => val,
2224
withProps({ left: true }),
2325
withProps({ right: true })
2426
),
2527
{ val: false }
26-
);
28+
)
2729

28-
expect(getProps().right).toBe(true);
29-
});
30+
expect(getProps().right).toBe(true)
31+
})
3032

31-
test("branch without right", () => {
33+
test('branch without right', () => {
3234
const getProps = testUtil(
3335
branch(({ val }) => val, withProps({ left: true })),
3436
{ val: false }
35-
);
37+
)
3638

37-
expect(getProps()).toEqual({ val: false });
38-
});
39+
expect(getProps()).toEqual({ val: false })
40+
})
+14-12
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
1-
import testUtil from "../test-util";
2-
import defaultProps from "../default-props";
1+
/* eslint-env jest */
32

4-
test("default props without prop", () => {
3+
import testUtil from '../test-util'
4+
import defaultProps from '../default-props'
5+
6+
test('default props without prop', () => {
57
const getProps = testUtil(
68
defaultProps({
7-
val: false
9+
val: false,
810
}),
911
{}
10-
);
12+
)
1113

12-
expect(getProps().val).toBe(false);
13-
});
14+
expect(getProps().val).toBe(false)
15+
})
1416

15-
test("default props with prop", () => {
17+
test('default props with prop', () => {
1618
const getProps = testUtil(
1719
defaultProps({
18-
val: false
20+
val: false,
1921
}),
2022
{ val: true }
21-
);
23+
)
2224

23-
expect(getProps().val).toBe(true);
24-
});
25+
expect(getProps().val).toBe(true)
26+
})
+9-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
import testUtil from "../test-util";
2-
import flattenProp from "../flatten-prop";
1+
/* eslint-env jest */
32

4-
test("flattens props", () => {
5-
const getProps = testUtil(flattenProp("obj"), { obj: { a: true, b: false } });
3+
import testUtil from '../test-util'
4+
import flattenProp from '../flatten-prop'
65

7-
expect(getProps().a).toBe(true);
8-
expect(getProps().b).toBe(false);
9-
});
6+
test('flattens props', () => {
7+
const getProps = testUtil(flattenProp('obj'), { obj: { a: true, b: false } })
8+
9+
expect(getProps().a).toBe(true)
10+
expect(getProps().b).toBe(false)
11+
})

src/rehook/__tests__/index-test.js

+23-21
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
1-
import * as exported from "../";
1+
/* eslint-env jest */
22

3-
test("exports expected", () => {
3+
import * as exported from '../'
4+
5+
test('exports expected', () => {
46
expect(Object.keys(exported)).toEqual([
5-
"branch",
6-
"catchRender",
7-
"defaultProps",
8-
"flattenProp",
9-
"lifecycle",
10-
"mapProps",
11-
"pipe",
12-
"renameProp",
13-
"renameProps",
14-
"renderComponent",
15-
"renderNothing",
16-
"withHandlers",
17-
"withPropsOnChange",
18-
"withProps",
19-
"withReducer",
20-
"withStateHandlers",
21-
"withState"
22-
]);
23-
});
7+
'branch',
8+
'catchRender',
9+
'defaultProps',
10+
'flattenProp',
11+
'lifecycle',
12+
'mapProps',
13+
'pipe',
14+
'renameProp',
15+
'renameProps',
16+
'renderComponent',
17+
'renderNothing',
18+
'withHandlers',
19+
'withPropsOnChange',
20+
'withProps',
21+
'withReducer',
22+
'withStateHandlers',
23+
'withState',
24+
])
25+
})
+10-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
import testUtil from "../test-util";
2-
import mapProps from "../map-props";
1+
/* eslint-env jest */
32

4-
test("maps props", () => {
3+
import testUtil from '../test-util'
4+
import mapProps from '../map-props'
5+
6+
test('maps props', () => {
57
const getProps = testUtil(mapProps(({ b }) => ({ b })), {
68
a: true,
7-
b: false
8-
});
9+
b: false,
10+
})
911

10-
expect(getProps().a).toBe(undefined); //
11-
expect(getProps().b).toBe(false);
12-
});
12+
expect(getProps().a).toBe(undefined) //
13+
expect(getProps().b).toBe(false)
14+
})

src/rehook/__tests__/pipe-test.js

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1-
import pipe from "../pipe";
1+
/* eslint-env jest */
22

3-
test("pipe", () => {
3+
import pipe from '../pipe'
4+
5+
test('pipe', () => {
46
expect(
57
pipe(
68
num => num + 1,
79
num => num + 1
810
)(0)
9-
).toBe(2);
11+
).toBe(2)
1012

1113
expect(
1214
pipe(
13-
x => ({ num: 0 }),
15+
() => ({ num: 0 }),
1416
x => ({ num: x.num + 1 })
1517
)()
16-
).toEqual({ num: 1 });
17-
});
18+
).toEqual({ num: 1 })
19+
})
+8-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
import testUtil from "../test-util";
2-
import renameProp from "../rename-prop";
1+
/* eslint-env jest */
32

4-
test("branch left", () => {
5-
const getProps = testUtil(renameProp("val", "renamed"), { val: true });
3+
import testUtil from '../test-util'
4+
import renameProp from '../rename-prop'
65

7-
expect(getProps().renamed).toBe(true);
8-
});
6+
test('branch left', () => {
7+
const getProps = testUtil(renameProp('val', 'renamed'), { val: true })
8+
9+
expect(getProps().renamed).toBe(true)
10+
})
+12-10
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
import testUtil from "../test-util";
2-
import renameProps from "../rename-props";
1+
/* eslint-env jest */
32

4-
test("branch left", () => {
5-
const getProps = testUtil(renameProps({ val: "renamed", val2: "renamed2" }), {
3+
import testUtil from '../test-util'
4+
import renameProps from '../rename-props'
5+
6+
test('branch left', () => {
7+
const getProps = testUtil(renameProps({ val: 'renamed', val2: 'renamed2' }), {
68
val: true,
79
val2: 0,
8-
other: false
9-
});
10+
other: false,
11+
})
1012

11-
expect(getProps().renamed).toBe(true);
12-
expect(getProps().renamed2).toBe(0);
13-
expect(getProps().other).toBe(false);
14-
});
13+
expect(getProps().renamed).toBe(true)
14+
expect(getProps().renamed2).toBe(0)
15+
expect(getProps().other).toBe(false)
16+
})
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
import renderComponent from "../render-component";
1+
/* eslint-env jest */
22

3-
test("render component", () => {
4-
let e = undefined;
3+
import renderComponent from '../render-component'
4+
5+
test('render component', () => {
6+
let e
57

68
try {
7-
renderComponent(() => "something")();
9+
renderComponent(() => 'something')()
810
} catch (thrown) {
9-
e = thrown;
11+
e = thrown
1012
}
1113

12-
expect(e).toBe("something");
13-
});
14+
expect(e).toBe('something')
15+
})
+8-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
import renderNothing from "../render-nothing";
1+
/* eslint-env jest */
2+
import renderNothing from '../render-nothing'
23

3-
test("render nothing", () => {
4-
let e = undefined;
4+
test('render nothing', () => {
5+
let e
56

67
try {
7-
renderNothing();
8+
renderNothing()
89
} catch (thrown) {
9-
e = thrown;
10+
e = thrown
1011
}
1112

12-
expect(e).toBe(null);
13-
});
13+
expect(e).toBe(null)
14+
})

0 commit comments

Comments
 (0)