Skip to content

Commit 0a46eef

Browse files
Run prettier on all files
1 parent 4869802 commit 0a46eef

File tree

5 files changed

+57
-32
lines changed

5 files changed

+57
-32
lines changed

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
},
3333
"scripts": {
3434
"test": "run-p test:js test:types:*",
35-
"prettier": "prettier {{__tests__,src,type-definitions}/**.{js,flow},README.md}",
36-
"format": "prettier --write",
35+
"prettier": "prettier {{__tests__,src,type-definitions}/**/*.{js,flow,ts},README.md}",
36+
"format": "yarn prettier --write",
3737
"test:js": "jest",
3838
"test:types:ts": "yarn build && tsc ./type-definitions/ReComponent.d.ts --lib es2015 && dtslint type-definitions/ts-tests",
3939
"test:types:flow": "flow check .",

type-definitions/ReComponent.d.ts

+22-14
Original file line numberDiff line numberDiff line change
@@ -4,55 +4,63 @@ export enum UpdateType {
44
NO_UPDATE = 0,
55
UPDATE = 1,
66
SIDE_EFFECTS = 2,
7-
UPDATE_WITH_SIDE_EFFECTS = 3,
7+
UPDATE_WITH_SIDE_EFFECTS = 3
88
}
99

1010
export type SideEffect<T> = (this: T) => any;
1111

1212
export type NoUpdateAction = {
1313
type: UpdateType.NO_UPDATE;
14-
}
14+
};
1515

1616
export type UpdateAction<T> = {
1717
type: UpdateType.UPDATE;
1818
state: T;
19-
}
19+
};
2020

2121
export type SideEffectsAction<T> = {
2222
type: UpdateType.SIDE_EFFECTS;
2323
sideEffects: SideEffect<T>;
24-
}
24+
};
2525

2626
export type UpdateWithSideEffectsAction<S, SE> = {
2727
type: UpdateType.UPDATE_WITH_SIDE_EFFECTS;
2828
state: S;
2929
sideEffects: SideEffect<SE>;
30-
}
30+
};
3131

3232
export type ReducerAction<S, SE> =
33-
NoUpdateAction |
34-
UpdateAction<S> |
35-
SideEffectsAction<SE> |
36-
UpdateWithSideEffectsAction<S, SE>;
33+
| NoUpdateAction
34+
| UpdateAction<S>
35+
| SideEffectsAction<SE>
36+
| UpdateWithSideEffectsAction<S, SE>;
3737

3838
export function NoUpdate(): NoUpdateAction;
3939

4040
export function Update<T>(state: T): UpdateAction<T>;
4141

4242
export function SideEffects<T>(sideEffect: SideEffect<T>): SideEffectsAction<T>;
4343

44-
export function UpdateWithSideEffects<S, SE>(state: S, sideEffects: SideEffect<SE>): UpdateWithSideEffectsAction<S, SE>;
44+
export function UpdateWithSideEffects<S, SE>(
45+
state: S,
46+
sideEffects: SideEffect<SE>
47+
): UpdateWithSideEffectsAction<S, SE>;
4548

4649
export type Action = {
4750
type: string;
48-
}
51+
};
4952

5053
export class ReComponent<P = {}, S = {}> extends Component<P, S> {
51-
static reducer<TState, TAction extends Action, TSideEffect = any>(action: Action, state: TState): ReducerAction<TState, TSideEffect>;
54+
static reducer<TState, TAction extends Action, TSideEffect = any>(
55+
action: Action,
56+
state: TState
57+
): ReducerAction<TState, TSideEffect>;
5258

5359
send<TAction extends Action>(action: TAction): void;
5460

55-
createSender<TAction extends string>(type: TAction): (<TPayload>(payload: TPayload) => { type: TAction, payload: TPayload });
61+
createSender<TAction extends string>(
62+
type: TAction
63+
): (<TPayload>(payload: TPayload) => { type: TAction; payload: TPayload });
5664
}
5765

58-
export class RePureComponent<P = {}, S = {}> extends ReComponent<P, S> { }
66+
export class RePureComponent<P = {}, S = {}> extends ReComponent<P, S> {}

type-definitions/__tests__/ReComponent.js

+18-13
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,17 @@ import * as React from "react";
44

55
import {
66
ReComponent,
7-
87
Update,
98
NoUpdate,
109
SideEffects,
1110
UpdateWithSideEffects
1211
} from "../../";
1312

14-
type Action = {| type: "A" |} | {| type: "B" |} | {| type: "C" |} | {| type: "D" |}
13+
type Action =
14+
| {| type: "A" |}
15+
| {| type: "B" |}
16+
| {| type: "C" |}
17+
| {| type: "D" |};
1518

1619
class StateMismatch extends ReComponent<{}, { count: number }, Action> {
1720
// $ExpectError
@@ -54,7 +57,6 @@ class UpdateTypes extends ReComponent<{}, { count: number }, Action> {
5457
instance.someClassProperty = 1;
5558
// $ExpectError - `instance.someClassProperty` has to be number
5659
instance.someClassProperty = "1";
57-
5860
});
5961
}
6062
}
@@ -63,9 +65,9 @@ class UpdateTypes extends ReComponent<{}, { count: number }, Action> {
6365
class TypedActionTypes extends ReComponent<
6466
{},
6567
{ count: number },
66-
{| type: 'CLICK' |}
68+
{| type: "CLICK" |}
6769
> {
68-
handleClick = () => this.send({ type: 'CLICK' });
70+
handleClick = () => this.send({ type: "CLICK" });
6971

7072
static reducer(action, state) {
7173
switch (action.type) {
@@ -105,7 +107,7 @@ const absurd = <T>(x: empty): T => {
105107
class ExhaustivelyTypedFailingActionTypes extends ReComponent<
106108
{},
107109
{ count: number },
108-
{| type: 'CLICK' |} | {| type: 'CLACK' |}
110+
{| type: "CLICK" |} | {| type: "CLACK" |}
109111
> {
110112
static reducer(action, state) {
111113
switch (action.type) {
@@ -139,16 +141,17 @@ class ExhaustivelyTypedPassingActionTypes extends ReComponent<
139141
}
140142
}
141143

142-
143144
class FailingPayloadType extends ReComponent<
144145
{},
145146
{ count: number, awesome: boolean },
146147
{ type: "CLICK", payload: number } | { type: "CLACK", payload: boolean }
147148
> {
148149
// $ExpectError - `clicks` should be `number`
149-
handleClick = (clicks: boolean) => this.send({ type: 'CLICK', payload: clicks });
150+
handleClick = (clicks: boolean) =>
151+
this.send({ type: "CLICK", payload: clicks });
150152
// $ExpectError - `awesome` should be `boolean`
151-
handleClack = (awesome: number) => this.send({ type: 'CLACK', payload: awesome });
153+
handleClack = (awesome: number) =>
154+
this.send({ type: "CLACK", payload: awesome });
152155

153156
static reducer(action, state) {
154157
switch (action.type) {
@@ -170,9 +173,11 @@ class PassingPayloadType extends ReComponent<
170173
{},
171174
{ count: number, awesome: boolean },
172175
{ type: "CLICK", payload: number } | { type: "CLACK", payload: boolean }
173-
> {
174-
handleClick = (clicks: number) => this.send({ type: 'CLICK', payload: clicks });
175-
handleClack = (awesome: boolean) => this.send({ type: 'CLACK', payload: awesome });
176+
> {
177+
handleClick = (clicks: number) =>
178+
this.send({ type: "CLICK", payload: clicks });
179+
handleClack = (awesome: boolean) =>
180+
this.send({ type: "CLACK", payload: awesome });
176181

177182
static reducer(action, state) {
178183
switch (action.type) {
@@ -191,7 +196,7 @@ class PassingPayloadType extends ReComponent<
191196
class CreateSenderTest extends ReComponent<
192197
{},
193198
{ count: number },
194-
{| type: 'CLICK' |} | {| type: 'CLACK', payload: number |}
199+
{| type: "CLICK" |} | {| type: "CLACK", payload: number |}
195200
> {
196201
handleClick = this.createSender("CLICK");
197202
handleClack = this.createSender("CLACK");

type-definitions/ts-tests/exports.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1-
import * as recomponent from 'react-recomponent';
2-
import { NoUpdate, Update, SideEffects, UpdateWithSideEffects, ReComponent, RePureComponent } from 'react-recomponent';
1+
import * as recomponent from "react-recomponent";
2+
import {
3+
NoUpdate,
4+
Update,
5+
SideEffects,
6+
UpdateWithSideEffects,
7+
ReComponent,
8+
RePureComponent
9+
} from "react-recomponent";
310

411
NoUpdate; // $ExpectType () => NoUpdateAction
512
Update; // $ExpectType <T>(state: T) => UpdateAction<T>

type-definitions/ts-tests/updateTypes.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
import { NoUpdate, Update, SideEffects, UpdateWithSideEffects } from 'react-recomponent';
1+
import {
2+
NoUpdate,
3+
Update,
4+
SideEffects,
5+
UpdateWithSideEffects
6+
} from "react-recomponent";
27

38
// $ExpectType NoUpdateAction
49
NoUpdate();

0 commit comments

Comments
 (0)