Skip to content

Commit 763b699

Browse files
authored
Merge pull request #615 from fcollonval/auto-backport-of-pr-581-on-0.10.x
Backport PR #581 on branch 0.10.x
2 parents ecf94e3 + fb64d82 commit 763b699

24 files changed

+885
-477
lines changed

.eslintignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules
2+
dist
3+
coverage
4+
**/*.d.ts
5+
tests

.eslintrc.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
module.exports = {
2+
extends: [
3+
'eslint:recommended',
4+
'plugin:@typescript-eslint/eslint-recommended',
5+
'plugin:@typescript-eslint/recommended',
6+
'plugin:prettier/recommended',
7+
'plugin:react/recommended'
8+
],
9+
parser: '@typescript-eslint/parser',
10+
parserOptions: {
11+
project: 'tsconfig.json',
12+
sourceType: 'module'
13+
},
14+
plugins: ['@typescript-eslint'],
15+
rules: {
16+
'@typescript-eslint/camelcase': 'off',
17+
'@typescript-eslint/explicit-function-return-type': 'off',
18+
'@typescript-eslint/interface-name-prefix': [
19+
'error',
20+
{ prefixWithI: 'always' }
21+
],
22+
'@typescript-eslint/no-unused-vars': ['warn', { args: 'none' }],
23+
'@typescript-eslint/no-explicit-any': 'off',
24+
'@typescript-eslint/no-namespace': 'off',
25+
'@typescript-eslint/no-this-alias': [
26+
'error',
27+
{
28+
allowedNames: ['self'], // Allow `const self = this`
29+
},
30+
],
31+
'@typescript-eslint/no-use-before-define': 'off',
32+
'@typescript-eslint/quotes': [
33+
'error',
34+
'single',
35+
{ avoidEscape: true, allowTemplateLiterals: false }
36+
],
37+
curly: ['error', 'all'],
38+
eqeqeq: 'error',
39+
'prefer-arrow-callback': 'error'
40+
},
41+
settings: {
42+
react: {
43+
version: 'detect'
44+
}
45+
}
46+
};

.prettierignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules
2+
**/node_modules
3+
**/lib
4+
**/package.json

.prettierrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"singleQuote": true
3+
}

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@ install: pip install --upgrade --upgrade-strategy=eager pytest pytest-asyncio "j
1111
script:
1212
# Build the sdist (identical to what will be uploaded to eg pypi on release)
1313
- python setup.py sdist
14+
# Linter checks
15+
- jlpm run eslint-check
16+
1417
# Install the extension from the sdist ensuring the cache is unused
1518
- pip install jupyterlab_git[test] --pre --no-index --find-links=dist --no-deps --no-cache-dir -v
1619
# Install the extension dependencies based on the current setup.py
1720
- pip install jupyterlab_git[test]
1821
# Log the current state of jupyterlab's extensions
1922
- jupyter labextension list
2023

21-
# Do a tslint check
22-
- jlpm run lint
23-
2424
# Rebuild jupyterlab to include our extension
2525
- jupyter lab build
2626

package.json

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
"clean:labextension": "rimraf jupyterlab_git/labextension",
2121
"clean:slate": "jlpm clean:more && jlpm clean:labextension && rimraf node_modules",
2222
"contributors:generate": "jlpm run all-contributors generate",
23-
"lint": "tslint --project .",
23+
"lint": "eslint . --ext .ts,.tsx --fix",
2424
"test": "jest",
25-
"tslint-check": "tslint-config-prettier-check ./tslint.json",
25+
"eslint-check": "eslint . --ext .ts,.tsx",
2626
"watch": "tsc -w"
2727
},
2828
"files": [
@@ -80,9 +80,15 @@
8080
"@types/react": "~16.8.13",
8181
"@types/react-dom": "~16.0.5",
8282
"@types/react-textarea-autosize": "^4.3.5",
83+
"@typescript-eslint/eslint-plugin": "^2.25.0",
84+
"@typescript-eslint/parser": "^2.25.0",
8385
"all-contributors-cli": "6.14.0",
8486
"enzyme": "3.7.0",
8587
"enzyme-adapter-react-16": "1.7.0",
88+
"eslint": "^6.8.0",
89+
"eslint-config-prettier": "^6.10.1",
90+
"eslint-plugin-prettier": "^3.1.2",
91+
"eslint-plugin-react": "^7.19.0",
8692
"husky": "1.3.1",
8793
"identity-obj-proxy": "^3.0.0",
8894
"jest": "^24",
@@ -93,11 +99,7 @@
9399
"puppeteer": "^1.10.0",
94100
"rimraf": "^2.6.1",
95101
"ts-jest": "^24",
96-
"tslint": "^5.11.0",
97-
"tslint-config-prettier": "1.18.0",
98-
"tslint-plugin-prettier": "^2.0.0",
99-
"typescript": "~3.5.1",
100-
"typescript-tslint-plugin": "^0.5.4"
102+
"typescript": "~3.5.1"
101103
},
102104
"peerDependencies": {
103105
"codemirror": "^5.0.0"
@@ -112,7 +114,7 @@
112114
},
113115
"lint-staged": {
114116
"*.{ts,tsx}": [
115-
"tslint --fix",
117+
"eslint . --ext .ts,.tsx --fix",
116118
"git add"
117119
]
118120
},

src/components/FileList.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,8 @@ export class FileList extends React.Component<IFileListProps, IFileListState> {
198198
discardAllUnstagedFiles = async () => {
199199
const result = await showDialog({
200200
title: 'Discard all changes',
201-
body: `Are you sure you want to permanently discard changes to all files? This action cannot be undone.`,
201+
body:
202+
'Are you sure you want to permanently discard changes to all files? This action cannot be undone.',
202203
buttons: [Dialog.cancelButton(), Dialog.warnButton({ label: 'Discard' })]
203204
});
204205
if (result.button.accept) {
@@ -214,7 +215,8 @@ export class FileList extends React.Component<IFileListProps, IFileListState> {
214215
discardAllChanges = async () => {
215216
const result = await showDialog({
216217
title: 'Discard all changes',
217-
body: `Are you sure you want to permanently discard changes to all files? This action cannot be undone.`,
218+
body:
219+
'Are you sure you want to permanently discard changes to all files? This action cannot be undone.',
218220
buttons: [Dialog.cancelButton(), Dialog.warnButton({ label: 'Discard' })]
219221
});
220222
if (result.button.accept) {

src/components/GitPanel.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export class GitPanel extends React.Component<
9393
refreshHistory = async () => {
9494
if (this.props.model.pathRepository !== null) {
9595
// Get git log for current branch
96-
let logData = await this.props.model.log(this.props.settings.composite[
96+
const logData = await this.props.model.log(this.props.settings.composite[
9797
'historyCount'
9898
] as number);
9999
let pastCommits = new Array<Git.ISingleCommitInfo>();
@@ -402,7 +402,7 @@ export class GitPanel extends React.Component<
402402
* List of sorted modified files.
403403
*/
404404
private get _sortedFiles(): Git.IStatusFile[] {
405-
let { files } = this.state;
405+
const { files } = this.state;
406406

407407
files.sort((a, b) => a.to.localeCompare(b.to));
408408
return files;

src/components/diff/DiffWidget.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export async function openDiffView(
2626
) {
2727
if (isDiffSupported(filePath) || isText) {
2828
const id = `nbdiff-${filePath}-${getRefValue(diffContext.currentRef)}`;
29-
let mainAreaItems = model.shell.widgets('main');
29+
const mainAreaItems = model.shell.widgets('main');
3030
let mainAreaItem = mainAreaItems.next();
3131
while (mainAreaItem) {
3232
if (mainAreaItem.id === id) {

src/components/diff/NbDiff.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,9 @@ export class NBDiff extends React.Component<IDiffProps, INBDiffState> {
195195
});
196196
} else {
197197
// Handle response
198-
let base = data.base;
199-
let diff = data.diff;
200-
let nbdModel = new NotebookDiffModel(base, diff);
198+
const base = data.base;
199+
const diff = data.diff;
200+
const nbdModel = new NotebookDiffModel(base, diff);
201201
this.setState({
202202
nbdModel: nbdModel
203203
});

0 commit comments

Comments
 (0)