Skip to content

Commit

Permalink
style: format code style
Browse files Browse the repository at this point in the history
  • Loading branch information
AruSeito committed Oct 4, 2022
1 parent 49146fa commit c07221e
Show file tree
Hide file tree
Showing 178 changed files with 604 additions and 560 deletions.
3 changes: 2 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
"semi": false,
"singleQuote": false,
"tabWidth": 2,
"trailingComma": "all"
"trailingComma": "all",
"arrowParens": "always"
}
8 changes: 4 additions & 4 deletions apps/builder/src/api/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const axios = Axios.create({
})

axios.interceptors.request.use(
config => {
(config) => {
addRequestPendingPool(config)
const token = getLocalStorage("token")
if (token) {
Expand All @@ -36,13 +36,13 @@ axios.interceptors.request.use(
}
return config
},
err => {
(err) => {
return Promise.reject(err)
},
)

axios.interceptors.response.use(
response => {
(response) => {
const { config } = response
removeRequestPendingPool(config)
return response
Expand Down Expand Up @@ -80,7 +80,7 @@ export class Api {
errorState?.(false)
axios
.request<RespData, AxiosResponse<RespData>, RequestBody>(config)
.then(response => {
.then((response) => {
loading?.(false)
errorState?.(false)
success?.(response)
Expand Down
2 changes: 1 addition & 1 deletion apps/builder/src/api/helpers/axiosPendingPool.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const generateUniqueKey = (config: AxiosRequestConfig) =>
].join("/")

export const clearRequestPendingPool = () => {
pendingPollMap.forEach(cancel => {
pendingPollMap.forEach((cancel) => {
cancel?.()
})
pendingPollMap.clear()
Expand Down
10 changes: 5 additions & 5 deletions apps/builder/src/api/ws/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function transformComponentReduxPayloadToWsPayload(
componentNodes: ComponentNode[] | ComponentNode,
): ILLAWebSocketComponentPayload[] {
if (Array.isArray(componentNodes)) {
return componentNodes.map(node => {
return componentNodes.map((node) => {
return {
before: {
displayName: node.displayName,
Expand Down Expand Up @@ -92,11 +92,11 @@ export class Connection {
}
Api.request<Room>(
config,
response => {
(response) => {
let ws = generateWs(response.data.wsURL)
this.roomMap.set(type + roomId, ws)
},
error => {},
(error) => {},
() => {},
loading,
errorState,
Expand Down Expand Up @@ -135,13 +135,13 @@ function onMessage(this: ILLAWebSocket, event: MessageEvent) {
let payload = broadcast.payload
switch (type) {
case `${ADD_DISPLAY_NAME}/remote`: {
;(payload as string[]).forEach(name => {
;(payload as string[]).forEach((name) => {
DisplayNameGenerator.displayNameList.add(name)
})
break
}
case `${REMOVE_DISPLAY_NAME}/remote`: {
;(payload as string[]).forEach(name => {
;(payload as string[]).forEach((name) => {
DisplayNameGenerator.displayNameList.delete(name)
})
break
Expand Down
4 changes: 2 additions & 2 deletions apps/builder/src/auth/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ interface CheckIsLoginWrapperProps {
children: ReactNode
}

export const CheckIsLogin: FC<CheckIsLoginWrapperProps> = props => {
export const CheckIsLogin: FC<CheckIsLoginWrapperProps> = (props) => {
const { children } = props
const navigate = useNavigate()
const token = getLocalStorage("token")
Expand All @@ -31,7 +31,7 @@ export const CheckIsLogin: FC<CheckIsLoginWrapperProps> = props => {
url: "/users",
method: "GET",
},
response => {
(response) => {
// TIPS: can check user role
dispatch(
currentUserActions.updateCurrentUserReducer({
Expand Down
2 changes: 1 addition & 1 deletion apps/builder/src/components/CodeEditor/CodePreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function copyToClipboard(content: any) {
Message.success("copied to clipboard")
}

export const CodePreview: FC<CodePreviewProps> = props => {
export const CodePreview: FC<CodePreviewProps> = (props) => {
const { className, preview, ...otherProps } = props

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const formatEvaluate = (data: any) => {
return format
}

const Evaluate: FC<{ type: string; data?: any }> = props => {
const Evaluate: FC<{ type: string; data?: any }> = (props) => {
const { type, data } = props

return (
Expand Down Expand Up @@ -83,7 +83,7 @@ const handleTernCompletions = (data: TypeQueryResult): TransQuery => {
return result
}

export const HintTooltip: FC<HintTooltipProps> = props => {
export const HintTooltip: FC<HintTooltipProps> = (props) => {
const { current: data } = useRef(handleTernCompletions(props.data))
const { globalData: executionResult = {} } = props

Expand Down
2 changes: 1 addition & 1 deletion apps/builder/src/components/CodeEditor/TernSever/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ const filterDataWithCallBack = (
callback?: (key: string) => boolean,
) => {
return JSON.parse(
JSON.stringify(data, function (key, value) {
JSON.stringify(data, function(key, value) {
if (callback && callback(key)) {
return undefined
} else {
Expand Down
8 changes: 4 additions & 4 deletions apps/builder/src/components/CodeEditor/hinter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { isString } from "@illa-design/system"
import { AutoCompleteItem } from "./AutoComplete"

let origJsHint = CodeMirror.hint.javascript
CodeMirror.hint.javascript = async function (cm, option) {
CodeMirror.hint.javascript = async function(cm, option) {
return (
(await origJsHint(cm, option)) || {
from: cm.getCursor(),
Expand Down Expand Up @@ -38,7 +38,7 @@ const transHinters = (inner: Hints) => {
}

let origSqlHint = CodeMirror.hint.sql
CodeMirror.hint.sql = async function (cm, option) {
CodeMirror.hint.sql = async function(cm, option) {
const editor = cm
// [TODO] override sql-hint.js
// @ts-ignore override doc.modeOption
Expand All @@ -53,7 +53,7 @@ CodeMirror.hint.sql = async function (cm, option) {
}

let origXmlHint = CodeMirror.hint.xml
CodeMirror.hint.xml = async function (cm, option) {
CodeMirror.hint.xml = async function(cm, option) {
let inner = (await origXmlHint(cm, option)) || {
from: cm.getCursor(),
to: cm.getCursor(),
Expand All @@ -63,7 +63,7 @@ CodeMirror.hint.xml = async function (cm, option) {
}

let origHtmlHint = CodeMirror.hint.html
CodeMirror.hint.html = async function (cm, option) {
CodeMirror.hint.html = async function(cm, option) {
let inner = (await origHtmlHint(cm, option)) || {
from: cm.getCursor(),
to: cm.getCursor(),
Expand Down
14 changes: 7 additions & 7 deletions apps/builder/src/components/CodeEditor/modes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import "codemirror/addon/hint/javascript-hint"

import { EditorModes } from "./interface"

defineMode(EditorModes.Postgre_SQL_JS, function (config) {
defineMode(EditorModes.Postgre_SQL_JS, function(config) {
return multiplexingMode(getMode(config, { name: "text/x-pgsql" }), {
open: "{{",
close: "}}",
Expand All @@ -24,7 +24,7 @@ defineMode(EditorModes.Postgre_SQL_JS, function (config) {
})
})

defineMode(EditorModes.TEXT_JS, function (config) {
defineMode(EditorModes.TEXT_JS, function(config) {
return multiplexingMode(getMode(config, EditorModes.TEXT), {
open: "{{",
close: "}}",
Expand All @@ -37,7 +37,7 @@ defineMode(EditorModes.TEXT_JS, function (config) {
})
})

defineMode(EditorModes.SQL_JS, function (config) {
defineMode(EditorModes.SQL_JS, function(config) {
return multiplexingMode(getMode(config, { name: "text/x-mysql" }), {
open: "{{",
close: "}}",
Expand All @@ -50,7 +50,7 @@ defineMode(EditorModes.SQL_JS, function (config) {
})
})

defineMode(EditorModes.XML_JS, function (config) {
defineMode(EditorModes.XML_JS, function(config) {
return multiplexingMode(getMode(config, { name: "application/xml" }), {
open: "{{",
close: "}}",
Expand All @@ -63,7 +63,7 @@ defineMode(EditorModes.XML_JS, function (config) {
})
})

defineMode(EditorModes.HTML_JS, function (config) {
defineMode(EditorModes.HTML_JS, function(config) {
return multiplexingMode(getMode(config, { name: "text/html" }), {
open: "{{",
close: "}}",
Expand All @@ -75,7 +75,7 @@ defineMode(EditorModes.HTML_JS, function (config) {
parseDelimiters: false,
})
})
defineMode(EditorModes.JAVASCRIPT, function (config) {
defineMode(EditorModes.JAVASCRIPT, function(config) {
return multiplexingMode(
getMode(config, {
name: "application/javascript",
Expand All @@ -93,7 +93,7 @@ defineMode(EditorModes.JAVASCRIPT, function (config) {
)
})

defineMode(EditorModes.JSON, function (config) {
defineMode(EditorModes.JSON, function(config) {
return multiplexingMode(
getMode(config, {
name: "application/json",
Expand Down
2 changes: 1 addition & 1 deletion apps/builder/src/components/EditableText/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { EditableTextWrapperStyle, textStyle } from "./style"
import { isValidDisplayName } from "@/utils/typeHelper"
import { DisplayNameGenerator } from "@/utils/generators/generateDisplayName"

export const EditableText: FC<EditableTextProps> = props => {
export const EditableText: FC<EditableTextProps> = (props) => {
const { displayName, updateDisplayNameByBlur } = props
const [inputValue, setInputValue] = useState(displayName)
const [isFocusInput, setIsFocusInput] = useState(false)
Expand Down
2 changes: 1 addition & 1 deletion apps/builder/src/components/JSONViewer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import ReactJson from "react-json-view"
import { JSONViewerProps } from "./interface"
import { jsonViewContainer } from "./style"

export const JSONViewer: FC<JSONViewerProps> = props => {
export const JSONViewer: FC<JSONViewerProps> = (props) => {
const { data = {}, collapsed } = props

const reactJsonConfig = {
Expand Down
8 changes: 4 additions & 4 deletions apps/builder/src/hooks/useInitApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const useInitBuilderApp = (model: IllaMode) => {
method: "GET",
signal: controller.signal,
},
response => {
(response) => {
dispatch(configActions.updateIllaMode(model))
dispatch(appInfoActions.updateAppInfoReducer(response.data.appInfo))
dispatch(
Expand Down Expand Up @@ -57,9 +57,9 @@ export const useInitBuilderApp = (model: IllaMode) => {
dispatch(configActions.changeSelectedAction(response.data.actions[0]))
}
},
e => {},
e => {},
loading => {
(e) => {},
(e) => {},
(loading) => {
setLoadingState(loading)
},
)
Expand Down
4 changes: 2 additions & 2 deletions apps/builder/src/middleware/redux/reduxAsync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
} from "@/redux/currentApp/editor/components/componentsState"
import { UpdateComponentsShapePayload } from "@/redux/currentApp/editor/components/componentsPayload"

export const reduxAsync: Redux.Middleware = store => next => action => {
export const reduxAsync: Redux.Middleware = (store) => (next) => (action) => {
const { type, payload } = action
const typeList = type.split("/")
const reduxType = typeList[0]
Expand Down Expand Up @@ -62,7 +62,7 @@ export const reduxAsync: Redux.Middleware = store => next => action => {
break
case "copyComponentReducer":
const copyComponentPayload = (payload as CopyComponentPayload[]).map(
copyShape => copyShape.newComponentNode,
(copyShape) => copyShape.newComponentNode,
)
Connection.getRoom("app", currentAppID)?.send(
getPayload(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,9 @@ export const ActionResourceSelector: FC<ActionResourceSelectorProps> = (
<Button
colorScheme="techPurple"
onClick={() => {
const displayName =
DisplayNameGenerator.generateDisplayName(actionType)
const displayName = DisplayNameGenerator.generateDisplayName(
actionType,
)
const initialContent = getInitialContent(actionType)
const data: Partial<ActionItem<ActionContent>> = {
actionType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ export const ActionTypeSelector: FC<ActionTypeSelectorProps> = (props) => {
key={prop.actionType}
onSelect={(item) => {
if (item === "transformer") {
const displayName =
DisplayNameGenerator.generateDisplayName(item)
const displayName = DisplayNameGenerator.generateDisplayName(
item,
)
const initialContent = getInitialContent(item)
const data: Partial<ActionItem<ActionContent>> = {
actionType: item,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
getResourceTypeFromActionType,
} from "@/utils/actionResourceTransformer"

export const ActionGenerator: FC<ActionGeneratorProps> = function (props) {
export const ActionGenerator: FC<ActionGeneratorProps> = function(props) {
const { visible, onClose } = props
const [currentStep, setCurrentStep] = useState<ActionCreatorPage>("select")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ import {
onDeleteActionItem,
} from "@/page/App/components/Actions/api"

export const ActionList: FC<HTMLAttributes<HTMLDivElement>> = props => {
export const ActionList: FC<HTMLAttributes<HTMLDivElement>> = (props) => {
const { className } = props

const [generatorVisible, setGeneratorVisible] = useState<boolean>()
const [searchActionValue, setSearchActionValue] = useState("")
const actionList = useSelector((state: RootState) => {
return state.currentApp.action.filter(value => {
return state.currentApp.action.filter((value) => {
return value.displayName
.toLowerCase()
.includes(searchActionValue.toLowerCase())
Expand All @@ -44,7 +44,7 @@ export const ActionList: FC<HTMLAttributes<HTMLDivElement>> = props => {
return (
<div className={className} css={searchHeaderContainerStyle}>
<SearchHeader
onSearch={value => {
onSearch={(value) => {
setSearchActionValue(value)
}}
/>
Expand All @@ -68,13 +68,13 @@ export const ActionList: FC<HTMLAttributes<HTMLDivElement>> = props => {
_css={listStyle}
bordered={false}
data={actionList}
render={data => {
render={(data) => {
return (
<ActionListItem
action={data}
onCopyItem={onCopyActionItem}
onDeleteItem={onDeleteActionItem}
onItemClick={action => {
onItemClick={(action) => {
const selectedAction = store.getState().config
.selectedAction
if (selectedAction === null) {
Expand All @@ -86,7 +86,7 @@ export const ActionList: FC<HTMLAttributes<HTMLDivElement>> = props => {
// find last action
const lastAction = store
.getState()
.currentApp.action.find(value => {
.currentApp.action.find((value) => {
return (
value.displayName === selectedAction?.displayName
)
Expand Down Expand Up @@ -114,7 +114,7 @@ export const ActionList: FC<HTMLAttributes<HTMLDivElement>> = props => {
)
}}
renderRaw
renderKey={data => {
renderKey={(data) => {
return data.displayName
}}
/>
Expand Down
Loading

0 comments on commit c07221e

Please sign in to comment.