Skip to content

Commit 3c6ffe4

Browse files
committed
feat: prettier validate format
prettier validate format
1 parent 2406e72 commit 3c6ffe4

File tree

10 files changed

+87
-70
lines changed

10 files changed

+87
-70
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,4 @@
9292
"path": "cz-conventional-changelog"
9393
}
9494
}
95-
}
95+
}

src/components/collapse/index.tsx

+8-6
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
prefixClaName,
88
classNames,
99
getBEMElement,
10-
getBEMModifier
10+
getBEMModifier,
1111
} from 'mo/common/className';
1212
import './style.scss';
1313

@@ -23,10 +23,10 @@ interface IState {
2323
activePanelKey: React.Key | React.Key[];
2424
}
2525
const defaultCollapseClassName = prefixClaName('collapse');
26-
export const contentPaddingClassName = getBEMModifier(getBEMElement(
27-
defaultCollapseClassName,
28-
'content'
29-
), 'padding');
26+
export const contentPaddingClassName = getBEMModifier(
27+
getBEMElement(defaultCollapseClassName, 'content'),
28+
'padding'
29+
);
3030

3131
const initState = {
3232
activePanelKey: '',
@@ -48,7 +48,9 @@ const Collapse: React.FunctionComponent<ICollapseProps> = (
4848
return render();
4949
} else {
5050
return (
51-
<span className={contentPaddingClassName}>Cannot provide...</span>
51+
<span className={contentPaddingClassName}>
52+
Cannot provide...
53+
</span>
5254
);
5355
}
5456
};

src/components/collapse/style.scss

-1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,5 @@
6565
display: none;
6666
}
6767
}
68-
6968
}
7069
}

src/components/tree/index.tsx

+31-24
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@ export interface ITreeNodeItem {
3434
export interface ITreeProps extends TreeProps {
3535
data: ITreeNodeItem[];
3636
onSelectFile?: (IMenuItem) => void;
37-
newFileItem?: (fileData: ITreeNodeItem, type: FileType, callback: Function) => void;
37+
newFileItem?: (
38+
fileData: ITreeNodeItem,
39+
type: FileType,
40+
callback: Function
41+
) => void;
3842
updateFile?(fileData: ITreeNodeItem, newName: string, index: number): void;
3943
reName?(fileData: ITreeNodeItem, callback: Function): void;
4044
deleteFile?(fileData: ITreeNodeItem): void;
@@ -62,24 +66,23 @@ const TreeView: React.FunctionComponent<ITreeProps> = (props: ITreeProps) => {
6266
if (inputRef.current) {
6367
inputRef.current.focus();
6468
}
65-
})
66-
}
69+
});
70+
};
6771
const handleDelte = (activeData: ITreeNodeItem) => {
6872
confirm({
6973
title: `Are you sure you want to delete '${activeData?.name}' ?`,
7074
content: 'This action is irreversible!',
7175
onOk() {
72-
deleteFile && deleteFile(activeData)
73-
},
74-
onCancel() {
76+
deleteFile && deleteFile(activeData);
7577
},
78+
onCancel() {},
7679
});
77-
}
80+
};
7881
const addExpandedKeys = (activeData: ITreeNodeItem) => {
79-
const keys: any = [...expandedKeys]
80-
keys.push(activeData?.id)
82+
const keys: any = [...expandedKeys];
83+
keys.push(activeData?.id);
8184
setExpandedKeys(keys);
82-
}
85+
};
8386
const getContextMenuList = (type?: FileType) => {
8487
let contextMenu: IMenuItem[] = [];
8588
const commContextMenu = [
@@ -94,41 +97,45 @@ const TreeView: React.FunctionComponent<ITreeProps> = (props: ITreeProps) => {
9497
id: 'delete',
9598
name: 'Delete',
9699
onClick: (e, active) => {
97-
handleDelte(activeData)
98-
}
99-
}
100-
]
100+
handleDelte(activeData);
101+
},
102+
},
103+
];
101104
if (type === FileTypes.FOLDER) {
102105
contextMenu = [
103106
{
104107
id: 'newFile',
105108
name: 'New File',
106109
onClick: (e, active) => {
107-
addExpandedKeys(activeData)
110+
addExpandedKeys(activeData);
108111
newFileItem &&
109-
newFileItem(activeData, FileTypes.FILE as FileType, onFocus);
112+
newFileItem(
113+
activeData,
114+
FileTypes.FILE as FileType,
115+
onFocus
116+
);
110117
},
111118
},
112119
{
113120
id: 'newFolder',
114121
name: 'New Folder',
115122
onClick: (e, active) => {
116-
addExpandedKeys(activeData)
123+
addExpandedKeys(activeData);
117124
newFileItem &&
118125
newFileItem(
119126
activeData,
120127
FileTypes.FOLDER as FileType,
121128
onFocus
122129
);
123130
},
124-
}
131+
},
125132
].concat(commContextMenu);
126133
} else if (type === FileTypes.FILE) {
127134
contextMenu = [
128135
{
129136
id: 'openToSide',
130137
name: 'Open to the side',
131-
}
138+
},
132139
].concat(commContextMenu);
133140
}
134141
return contextMenu;
@@ -236,11 +243,11 @@ const TreeView: React.FunctionComponent<ITreeProps> = (props: ITreeProps) => {
236243
updateFile &&
237244
updateFile(item, e.target.value, index);
238245
}}
239-
onChange={(e) => { }}
246+
onChange={(e) => {}}
240247
/>
241248
) : (
242-
name
243-
)
249+
name
250+
)
244251
}
245252
key={id}
246253
icon={modify ? '' : <Icon type={icon} />}
@@ -259,10 +266,10 @@ const TreeView: React.FunctionComponent<ITreeProps> = (props: ITreeProps) => {
259266
switcherIcon={<Icon type="chevron-right" />}
260267
onRightClick={({ event, node }: any) => {
261268
setActiveData(node.data);
262-
setActiveId(node.data.id)
269+
setActiveId(node.data.id);
263270
}}
264271
onExpand={(expandedKeys) => {
265-
setExpandedKeys(expandedKeys)
272+
setExpandedKeys(expandedKeys);
266273
}}
267274
expandedKeys={expandedKeys}
268275
onSelect={(selectedKeys, e: any) => {

src/components/tree/style.scss

+4-8
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ $switch: #{$rcTree}-switcher;
44

55
#{$tree} {
66
font-size: 13px;
7-
7+
88
#{$rcTree} {
99
border: 1px solid transparent;
1010
margin: 0;
@@ -43,7 +43,7 @@ $switch: #{$rcTree}-switcher;
4343
outline: none;
4444
vertical-align: middle;
4545
width: 16px;
46-
46+
4747
&-noop {
4848
cursor: auto;
4949
display: none;
@@ -56,16 +56,12 @@ $switch: #{$rcTree}-switcher;
5656
}
5757

5858
&-disabled {
59-
60-
>span:not(#{$switch}),
61-
>a
62-
>a span {
59+
> span:not(#{$switch}),
60+
> a > a span {
6361
color: #767676;
6462
cursor: not-allowed;
6563
}
6664
}
67-
68-
6965
}
7066

7167
&-node-content-wrapper {

src/extensions/explore/index.tsx

+20-20
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ function init(extensionCtx: ExtensionService) {
8888
id: 'new_file',
8989
title: 'New File',
9090
iconName: 'codicon-new-file',
91-
onClick: () => { },
91+
onClick: () => {},
9292
},
9393
{
9494
id: 'new_folder',
@@ -115,26 +115,26 @@ function init(extensionCtx: ExtensionService) {
115115
data={explorerState.treeData}
116116
/>
117117
) : (
118-
<span className={contentPaddingClassName}>
119-
you have not yet opened a folder
120-
<Button
121-
onClick={() => {
122-
// test service
123-
explorerService.newFileItem(
124-
{
125-
id: '1',
126-
name: '',
127-
type: 'folder',
128-
modify: true,
129-
},
130-
FileTypes.FOLDER as FileType
131-
);
132-
}}
133-
>
134-
New Folder
118+
<span className={contentPaddingClassName}>
119+
you have not yet opened a folder
120+
<Button
121+
onClick={() => {
122+
// test service
123+
explorerService.newFileItem(
124+
{
125+
id: '1',
126+
name: '',
127+
type: 'folder',
128+
modify: true,
129+
},
130+
FileTypes.FOLDER as FileType
131+
);
132+
}}
133+
>
134+
New Folder
135135
</Button>
136-
</span>
137-
)}
136+
</span>
137+
)}
138138
</>
139139
);
140140
},

src/extensions/explore/tree.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ const serviceProps = {
1212
};
1313
editorService.open(tabData, tabData.activeTab);
1414
},
15-
newFileItem: function (fileData: ITreeNodeItem, type: FileType, callback: Function) {
15+
newFileItem: function (
16+
fileData: ITreeNodeItem,
17+
type: FileType,
18+
callback: Function
19+
) {
1620
explorerService.newFileItem(fileData, type, callback);
1721
},
1822
updateFile: function (fileData, newName, index) {

src/model/workbench/explorer.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export const getFileIconByName = (name: string): string => {
102102
return icon;
103103
};
104104

105-
export enum ExplorerEvent { }
105+
export enum ExplorerEvent {}
106106
export interface IPanelItem<T = any> extends IActionBarItem {
107107
renderPanel?: (props) => React.ReactNode | JSX.Element;
108108
toolbar?: T;

src/services/workbench/explorerService.ts

+14-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ import {
1111
import { ITreeNodeItem, FileType, FileTypes } from 'mo/components/tree';
1212
export interface IExplorerService extends Component<IExpolorer> {
1313
push(data: IPanelItem): void;
14-
newFileItem(fileData: ITreeNodeItem, type: FileType, callback?: Function): void;
14+
newFileItem(
15+
fileData: ITreeNodeItem,
16+
type: FileType,
17+
callback?: Function
18+
): void;
1519
updateFile(fileData: ITreeNodeItem, newName: string, index: number): void;
1620
reName(fileData: ITreeNodeItem, callback: Function): void;
1721
deleteFile(fileData: ITreeNodeItem): void;
@@ -51,7 +55,11 @@ export class ExplorerService
5155
* @param fileData treeNode ite
5256
* @param type new type
5357
*/
54-
public newFileItem(fileData: ITreeNodeItem, type: FileType, callback: Function) {
58+
public newFileItem(
59+
fileData: ITreeNodeItem,
60+
type: FileType,
61+
callback: Function
62+
) {
5563
const original = this.state.treeData;
5664
const loop = (data: ITreeNodeItem[]) => {
5765
for (const item of data) {
@@ -79,7 +87,7 @@ export class ExplorerService
7987
original?.push(fileData);
8088
}
8189
}
82-
if (callback) callback()
90+
if (callback) callback();
8391
}
8492

8593
/**
@@ -162,7 +170,9 @@ export class ExplorerService
162170
original,
163171
fileData.id
164172
);
165-
const curIndex = (prevParentNode.children || []).findIndex(item => item.id === fileData.id);
173+
const curIndex = (prevParentNode.children || []).findIndex(
174+
(item) => item.id === fileData.id
175+
);
166176
const deleteItem = (tree, id) => {
167177
const rootNode = tree[0];
168178
if (rootNode.id === id) {

src/style/theme.scss

+3-4
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@
119119

120120
// =============== Tree =============== //
121121
#{$tree} {
122-
123122
#{$rcTree}-treenode {
124123
&:hover {
125124
background-color: #333;
@@ -128,14 +127,14 @@
128127
.draggable {
129128
color: #bbb;
130129
}
131-
130+
132131
&-active {
133132
background: rgba(0, 0, 0, 0.1);
134133
}
135134
}
136135

137136
.drag-over {
138-
>.draggable {
137+
> .draggable {
139138
@include border-color(#316ac5);
140139
background-color: #316ac5;
141140
color: #bbb;
@@ -144,7 +143,7 @@
144143

145144
.drag-over-gap-top,
146145
.drag-over-gap-bottom {
147-
>.draggable {
146+
> .draggable {
148147
border-top: 2px rgb(0, 122, 204) solid;
149148
}
150149
}

0 commit comments

Comments
 (0)