Skip to content

Commit 123b5ea

Browse files
committed
Apply prettier to the actions file
1 parent 77686fc commit 123b5ea

File tree

3 files changed

+65
-49
lines changed

3 files changed

+65
-49
lines changed

ui/frontend/.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ module.exports = {
6767
'Header.tsx',
6868
'PopButton.tsx',
6969
'Stdin.tsx',
70+
'actions.ts',
7071
'api.ts',
7172
'compileActions.ts',
7273
'editor/AceEditor.tsx',

ui/frontend/.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ node_modules
1818
!Header.tsx
1919
!PopButton.tsx
2020
!Stdin.tsx
21+
!actions.ts
2122
!api.ts
2223
!compileActions.ts
2324
!editor/AceEditor.tsx

ui/frontend/actions.ts

Lines changed: 63 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,22 @@
1-
import { ThunkAction as ReduxThunkAction, AnyAction } from '@reduxjs/toolkit';
1+
import { AnyAction, ThunkAction as ReduxThunkAction } from '@reduxjs/toolkit';
22

3+
import { addCrateType, editCode } from './reducers/code';
34
import {
4-
getCrateType,
5-
runAsTest,
6-
wasmLikelyToWork,
7-
} from './selectors';
5+
changeBacktrace,
6+
changeChannel,
7+
changeEditionRaw,
8+
changeMode,
9+
changePrimaryAction,
10+
} from './reducers/configuration';
11+
import { performCompileToAssemblyOnly } from './reducers/output/assembly';
12+
import { performCommonExecute } from './reducers/output/execute';
13+
import { performGistLoad } from './reducers/output/gist';
14+
import { performCompileToHirOnly } from './reducers/output/hir';
15+
import { performCompileToLlvmIrOnly } from './reducers/output/llvmIr';
16+
import { performCompileToMirOnly } from './reducers/output/mir';
17+
import { performCompileToWasmOnly } from './reducers/output/wasm';
18+
import { navigateToHelp, navigateToIndex } from './reducers/page';
19+
import { getCrateType, runAsTest, wasmLikelyToWork } from './selectors';
820
import State from './state';
921
import {
1022
Backtrace,
@@ -19,33 +31,15 @@ import {
1931
parseMode,
2032
} from './types';
2133

22-
import { performCommonExecute } from './reducers/output/execute';
23-
import { performGistLoad } from './reducers/output/gist';
24-
import { performCompileToAssemblyOnly } from './reducers/output/assembly';
25-
import { performCompileToHirOnly } from './reducers/output/hir';
26-
import { performCompileToLlvmIrOnly } from './reducers/output/llvmIr';
27-
import { performCompileToMirOnly } from './reducers/output/mir';
28-
import { performCompileToWasmOnly } from './reducers/output/wasm';
29-
import { navigateToHelp, navigateToIndex } from './reducers/page';
30-
import { addCrateType, editCode } from './reducers/code';
31-
import {
32-
changeBacktrace,
33-
changeChannel,
34-
changeEditionRaw,
35-
changeMode,
36-
changePrimaryAction,
37-
} from './reducers/configuration';
38-
3934
export type ThunkAction<T = void> = ReduxThunkAction<T, State, {}, AnyAction>;
4035

41-
export const reExecuteWithBacktrace = (): ThunkAction => dispatch => {
36+
export const reExecuteWithBacktrace = (): ThunkAction => (dispatch) => {
4237
dispatch(changeBacktrace(Backtrace.Enabled));
4338
dispatch(performExecuteOnly());
4439
};
4540

46-
4741
function performAutoOnly(): ThunkAction {
48-
return function(dispatch, getState) {
42+
return function (dispatch, getState) {
4943
const state = getState();
5044
const crateType = getCrateType(state);
5145
const tests = runAsTest(state);
@@ -62,7 +56,7 @@ const performTestOnly = (): ThunkAction => (dispatch, getState) => {
6256
return dispatch(performCommonExecute(crateType, true));
6357
};
6458

65-
const performCompileToNightlyHirOnly = (): ThunkAction => dispatch => {
59+
const performCompileToNightlyHirOnly = (): ThunkAction => (dispatch) => {
6660
dispatch(changeChannel(Channel.Nightly));
6761
dispatch(performCompileToHirOnly());
6862
};
@@ -94,36 +88,56 @@ export const performPrimaryAction = (): ThunkAction => (dispatch, getState) => {
9488
dispatch(primaryAction());
9589
};
9690

97-
const performAndSwitchPrimaryAction = (inner: () => ThunkAction, id: PrimaryAction) => (): ThunkAction => dispatch => {
98-
dispatch(changePrimaryAction(id));
99-
dispatch(inner());
100-
};
91+
const performAndSwitchPrimaryAction =
92+
(inner: () => ThunkAction, id: PrimaryAction) => (): ThunkAction => (dispatch) => {
93+
dispatch(changePrimaryAction(id));
94+
dispatch(inner());
95+
};
10196

102-
export const performExecute =
103-
performAndSwitchPrimaryAction(performExecuteOnly, PrimaryActionCore.Execute);
104-
export const performCompile =
105-
performAndSwitchPrimaryAction(performCompileOnly, PrimaryActionCore.Compile);
106-
export const performTest =
107-
performAndSwitchPrimaryAction(performTestOnly, PrimaryActionCore.Test);
108-
export const performCompileToAssembly =
109-
performAndSwitchPrimaryAction(performCompileToAssemblyOnly, PrimaryActionCore.Asm);
110-
export const performCompileToLLVM =
111-
performAndSwitchPrimaryAction(performCompileToLlvmIrOnly, PrimaryActionCore.LlvmIr);
112-
export const performCompileToMir =
113-
performAndSwitchPrimaryAction(performCompileToMirOnly, PrimaryActionCore.Mir);
114-
export const performCompileToNightlyHir =
115-
performAndSwitchPrimaryAction(performCompileToNightlyHirOnly, PrimaryActionCore.Hir);
116-
export const performCompileToWasm =
117-
performAndSwitchPrimaryAction(performCompileToCdylibWasmOnly, PrimaryActionCore.Wasm);
97+
export const performExecute = performAndSwitchPrimaryAction(
98+
performExecuteOnly,
99+
PrimaryActionCore.Execute,
100+
);
101+
export const performCompile = performAndSwitchPrimaryAction(
102+
performCompileOnly,
103+
PrimaryActionCore.Compile,
104+
);
105+
export const performTest = performAndSwitchPrimaryAction(performTestOnly, PrimaryActionCore.Test);
106+
export const performCompileToAssembly = performAndSwitchPrimaryAction(
107+
performCompileToAssemblyOnly,
108+
PrimaryActionCore.Asm,
109+
);
110+
export const performCompileToLLVM = performAndSwitchPrimaryAction(
111+
performCompileToLlvmIrOnly,
112+
PrimaryActionCore.LlvmIr,
113+
);
114+
export const performCompileToMir = performAndSwitchPrimaryAction(
115+
performCompileToMirOnly,
116+
PrimaryActionCore.Mir,
117+
);
118+
export const performCompileToNightlyHir = performAndSwitchPrimaryAction(
119+
performCompileToNightlyHirOnly,
120+
PrimaryActionCore.Hir,
121+
);
122+
export const performCompileToWasm = performAndSwitchPrimaryAction(
123+
performCompileToCdylibWasmOnly,
124+
PrimaryActionCore.Wasm,
125+
);
118126

119127
export function indexPageLoad({
120128
code,
121129
gist,
122130
version,
123131
mode: modeString,
124132
edition: editionString,
125-
}: { code?: string, gist?: string, version?: string, mode?: string, edition?: string }): ThunkAction {
126-
return function(dispatch) {
133+
}: {
134+
code?: string;
135+
gist?: string;
136+
version?: string;
137+
mode?: string;
138+
edition?: string;
139+
}): ThunkAction {
140+
return function (dispatch) {
127141
const channel = parseChannel(version) || Channel.Stable;
128142
const mode = parseMode(modeString) || Mode.Debug;
129143
let maybeEdition = parseEdition(editionString);
@@ -156,7 +170,7 @@ export function indexPageLoad({
156170
export const helpPageLoad = navigateToHelp;
157171

158172
export function showExample(code: string): ThunkAction {
159-
return function(dispatch) {
173+
return function (dispatch) {
160174
dispatch(navigateToIndex());
161175
dispatch(editCode(code));
162176
};

0 commit comments

Comments
 (0)