Skip to content

Commit 98e5ef2

Browse files
authored
Merge pull request #336 from jupyterlab/stricter-lint
Stricter lint
2 parents 6c48220 + 2373ba5 commit 98e5ef2

28 files changed

+1109
-405
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ script:
1414
- pip install .
1515
- jupyter labextension install .
1616
- python -m jupyterlab.browser_check
17+
- yarn run lint

package.json

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
"clean": "rimraf lib",
1616
"prepublish": "npm run build",
1717
"watch": "tsc -w",
18-
"test": "jest"
18+
"test": "jest",
19+
"lint": "tslint --project .",
20+
"tslint-check": "tslint-config-prettier-check ./tslint.json"
1921
},
2022
"files": [
2123
"lib/**/*.{d.ts,eot,gif,html,jpg,js,js.map,json,png,svg,woff2,ttf}",
@@ -60,18 +62,36 @@
6062
"@types/react-dom": "~16.0.5",
6163
"enzyme": "3.7.0",
6264
"enzyme-adapter-react-16": "1.7.0",
65+
"husky": "1.3.1",
6366
"jest": "^23.6.0",
6467
"jest-fetch-mock": "^1.6.6",
65-
"prettier": "^1.14.3",
68+
"lint-staged": "8.1.5",
69+
"prettier": "1.16.4",
6670
"rimraf": "^2.6.1",
6771
"ts-jest": "^23.10.4",
6872
"tslint": "^5.11.0",
73+
"tslint-config-prettier": "1.18.0",
6974
"tslint-plugin-prettier": "^2.0.0",
70-
"typescript": "~3.1.2"
75+
"typescript": "~3.1.2",
76+
"typescript-tslint-plugin": "0.3.1"
7177
},
7278
"directories": {
7379
"lib": "lib"
7480
},
81+
"husky": {
82+
"hooks": {
83+
"pre-commit": "lint-staged"
84+
}
85+
},
86+
"lint-staged": {
87+
"*.{ts,tsx}": [
88+
"tslint --fix",
89+
"git add"
90+
]
91+
},
92+
"prettier": {
93+
"singleQuote": true
94+
},
7595
"repository": {
7696
"type": "git",
7797
"url": "https://github.com/jupyterlab/jupyterlab-git.git"

src/components/BranchHeader.tsx

Lines changed: 58 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -162,42 +162,40 @@ export class BranchHeader extends React.Component<
162162

163163
getHistoryHeaderStyle() {
164164
if (this.props.sideBarExpanded) {
165-
return classes(
166-
openHistorySideBarButtonStyle,
167-
selectedHeaderStyle
168-
);
165+
return classes(openHistorySideBarButtonStyle, selectedHeaderStyle);
169166
}
170-
return classes(
171-
unSelectedHeaderStyle,
172-
openHistorySideBarButtonStyle
173-
)
167+
return classes(unSelectedHeaderStyle, openHistorySideBarButtonStyle);
174168
}
175169

176170
getBranchHeaderStyle() {
177171
if (this.props.sideBarExpanded) {
178-
return classes(
179-
branchHeaderCenterContent,
180-
unSelectedHeaderStyle
181-
);
172+
return classes(branchHeaderCenterContent, unSelectedHeaderStyle);
182173
}
183-
return classes(
184-
selectedHeaderStyle,
185-
branchHeaderCenterContent
186-
)
174+
return classes(selectedHeaderStyle, branchHeaderCenterContent);
187175
}
188176

189177
render() {
190178
return (
191179
<div className={this.getBranchStyle()}>
192-
<div style={{display: "flex"}}>
193-
<div className={this.getHistoryHeaderStyle()}
194-
onClick={this.props.sideBarExpanded ? null : () => this.props.toggleSidebar()}
180+
<div style={{ display: 'flex' }}>
181+
<div
182+
className={this.getHistoryHeaderStyle()}
183+
onClick={
184+
this.props.sideBarExpanded
185+
? null
186+
: () => this.props.toggleSidebar()
187+
}
195188
title={'Show commit history'}
196189
>
197190
<h3 className={historyLabelStyle}>History</h3>
198191
</div>
199-
<div className={this.getBranchHeaderStyle()}
200-
onClick={this.props.sideBarExpanded ? () => this.props.toggleSidebar() : null}
192+
<div
193+
className={this.getBranchHeaderStyle()}
194+
onClick={
195+
this.props.sideBarExpanded
196+
? () => this.props.toggleSidebar()
197+
: null
198+
}
201199
>
202200
<h3 className={branchLabelStyle}>{this.props.currentBranch}</h3>
203201
<div
@@ -216,48 +214,52 @@ export class BranchHeader extends React.Component<
216214
<div
217215
className={
218216
this.props.disabled
219-
? classes(
220-
newBranchButtonStyle,
221-
headerButtonDisabledStyle
222-
)
217+
? classes(newBranchButtonStyle, headerButtonDisabledStyle)
223218
: newBranchButtonStyle
224219
}
225220
title={'Create a new branch'}
226221
onClick={() => this.toggleNewBranchBox()}
227222
/>
228223
)}
229-
{this.state.showNewBranchBox &&
230-
this.props.showList && (
231-
<NewBranchBox
232-
createNewBranch={this.createNewBranch}
233-
toggleNewBranchBox={this.toggleNewBranchBox}
234-
/>
224+
{this.state.showNewBranchBox && this.props.showList && (
225+
<NewBranchBox
226+
createNewBranch={this.createNewBranch}
227+
toggleNewBranchBox={this.toggleNewBranchBox}
228+
/>
229+
)}
230+
{this.props.upstreamBranch != null &&
231+
this.props.upstreamBranch !== '' && (
232+
<div className={branchTrackingIconStyle} />
233+
)}
234+
{this.props.upstreamBranch != null &&
235+
this.props.upstreamBranch !== '' && (
236+
<h3 className={branchTrackingLabelStyle}>
237+
{this.props.upstreamBranch}
238+
</h3>
235239
)}
236-
{this.props.upstreamBranch != null && this.props.upstreamBranch != '' && (<div className={branchTrackingIconStyle}/>)}
237-
{this.props.upstreamBranch != null && this.props.upstreamBranch != '' && (<h3 className={branchTrackingLabelStyle}>{this.props.upstreamBranch}</h3>)}
238240
</div>
239241
</div>
240-
{!this.props.sideBarExpanded && (<>
241-
{this.state.dropdownOpen && (
242-
<div>
243-
{this.props.data.map((branch: any, branchIndex: number) => {
244-
return (
245-
<li
246-
className={branchListItemStyle}
247-
key={branchIndex}
248-
onClick={() => this.switchBranch(branch.name)}
249-
>
250-
{branch.name}
251-
</li>
252-
);
253-
})}
254-
</div>
255-
)}
256-
{this.state.showNewBranchBox && (
257-
<div>Branching from {this.props.currentBranch}</div>
258-
)}
259-
{this.state.showCommitBox &&
260-
this.props.showList && (
242+
{!this.props.sideBarExpanded && (
243+
<>
244+
{this.state.dropdownOpen && (
245+
<div>
246+
{this.props.data.map((branch: any, branchIndex: number) => {
247+
return (
248+
<li
249+
className={branchListItemStyle}
250+
key={branchIndex}
251+
onClick={() => this.switchBranch(branch.name)}
252+
>
253+
{branch.name}
254+
</li>
255+
);
256+
})}
257+
</div>
258+
)}
259+
{this.state.showNewBranchBox && (
260+
<div>Branching from {this.props.currentBranch}</div>
261+
)}
262+
{this.state.showCommitBox && this.props.showList && (
261263
<CommitBox
262264
checkReadyForSubmit={this.updateCommitBoxState}
263265
stagedFiles={this.props.stagedFiles}
@@ -266,7 +268,8 @@ export class BranchHeader extends React.Component<
266268
refresh={this.props.refresh}
267269
/>
268270
)}
269-
</>)}
271+
</>
272+
)}
270273
</div>
271274
);
272275
}

src/components/FileList.tsx

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Menu } from '@phosphor/widgets';
66

77
import { PathExt } from '@jupyterlab/coreutils';
88

9-
import { Git, GitShowPrefixResult } from '../git';
9+
import { Git, IGitShowPrefixResult } from '../git';
1010

1111
import {
1212
moveFileUpButtonStyle,
@@ -214,26 +214,6 @@ export class FileList extends React.Component<IFileListProps, IFileListState> {
214214
});
215215
}
216216

217-
/** Handle clicks on a staged file
218-
*
219-
*/
220-
handleClickStaged(event: any) {
221-
event.preventDefault();
222-
if (event.buttons === 2) {
223-
<select>
224-
<option className="jp-Git-switch-branch" value="" disabled>
225-
Open
226-
</option>
227-
<option className="jp-Git-create-branch-line" disabled>
228-
unstaged this file
229-
</option>
230-
<option className="jp-Git-create-branch" value="">
231-
CREATE NEW
232-
</option>
233-
</select>;
234-
}
235-
}
236-
237217
/** Handle right-click on a staged file */
238218
contextMenuStaged = (
239219
event: any,
@@ -349,7 +329,7 @@ export class FileList extends React.Component<IFileListProps, IFileListState> {
349329
}
350330
let gitApi = new Git();
351331
let prefixData = await gitApi.showPrefix((fileBrowser as any).model.path);
352-
let underRepoPath = (prefixData as GitShowPrefixResult).under_repo_path;
332+
let underRepoPath = (prefixData as IGitShowPrefixResult).under_repo_path;
353333
let fileBrowserPath = (fileBrowser as any).model.path + '/';
354334
let openFilePath = fileBrowserPath.substring(
355335
0,
@@ -596,7 +576,7 @@ export function parseFileExtension(path: string): string {
596576
if (path[path.length - 1] === '/') {
597577
return folderFileIconStyle;
598578
}
599-
var fileExtension = PathExt.extname(path).toLocaleLowerCase();
579+
let fileExtension = PathExt.extname(path).toLocaleLowerCase();
600580
switch (fileExtension) {
601581
case '.md':
602582
return markdownFileIconStyle;
@@ -638,7 +618,7 @@ export function parseSelectedFileExtension(path: string): string {
638618
if (path[path.length - 1] === '/') {
639619
return folderFileIconSelectedStyle;
640620
}
641-
var fileExtension = PathExt.extname(path).toLocaleLowerCase();
621+
let fileExtension = PathExt.extname(path).toLocaleLowerCase();
642622
switch (fileExtension) {
643623
case '.md':
644624
return markdownFileIconSelectedStyle;

0 commit comments

Comments
 (0)