Skip to content

Commit a7dc6bc

Browse files
committed
Switch to eslint
1 parent 295640e commit a7dc6bc

21 files changed

+726
-337
lines changed

.eslintignore

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

.eslintrc.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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/interface-name-prefix': [
18+
'error',
19+
{ prefixWithI: 'always' }
20+
],
21+
'@typescript-eslint/no-unused-vars': ['warn', { args: 'none' }],
22+
'@typescript-eslint/no-explicit-any': 'off',
23+
'@typescript-eslint/no-namespace': 'off',
24+
'@typescript-eslint/no-this-alias': [
25+
'error',
26+
{
27+
allowedNames: ['self'], // Allow `const self = this`; `[]` by default
28+
},
29+
],
30+
'@typescript-eslint/no-use-before-define': 'off',
31+
'@typescript-eslint/quotes': [
32+
'error',
33+
'single',
34+
{ avoidEscape: true, allowTemplateLiterals: false }
35+
],
36+
curly: ['error', 'all'],
37+
'prefer-arrow-callback': 'error'
38+
},
39+
settings: {
40+
react: {
41+
version: 'detect'
42+
}
43+
}
44+
};

.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+
}

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": [
@@ -83,9 +83,15 @@
8383
"@types/react": "~16.8.13",
8484
"@types/react-dom": "~16.0.5",
8585
"@types/react-textarea-autosize": "^4.3.5",
86+
"@typescript-eslint/eslint-plugin": "^2.25.0",
87+
"@typescript-eslint/parser": "^2.25.0",
8688
"all-contributors-cli": "6.14.0",
8789
"enzyme": "3.7.0",
8890
"enzyme-adapter-react-16": "1.7.0",
91+
"eslint": "^6.8.0",
92+
"eslint-config-prettier": "^6.10.1",
93+
"eslint-plugin-prettier": "^3.1.2",
94+
"eslint-plugin-react": "^7.19.0",
8995
"husky": "1.3.1",
9096
"identity-obj-proxy": "^3.0.0",
9197
"jest": "^24",
@@ -96,11 +102,7 @@
96102
"puppeteer": "^1.10.0",
97103
"rimraf": "^2.6.1",
98104
"ts-jest": "^24",
99-
"tslint": "^5.11.0",
100-
"tslint-config-prettier": "1.18.0",
101-
"tslint-plugin-prettier": "^2.0.0",
102-
"typescript": "~3.7.1",
103-
"typescript-tslint-plugin": "^0.5.4"
105+
"typescript": "~3.7.1"
104106
},
105107
"peerDependencies": {
106108
"codemirror": "^5.0.0"
@@ -115,7 +117,7 @@
115117
},
116118
"lint-staged": {
117119
"*.{ts,tsx}": [
118-
"tslint --fix",
120+
"eslint . --ext .ts,.tsx --fix",
119121
"git add"
120122
]
121123
},

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
@@ -196,9 +196,9 @@ export class NBDiff extends React.Component<IDiffProps, INBDiffState> {
196196
});
197197
} else {
198198
// Handle response
199-
let base = data.base;
200-
let diff = data.diff;
201-
let nbdModel = new NotebookDiffModel(base, diff);
199+
const base = data.base;
200+
const diff = data.diff;
201+
const nbdModel = new NotebookDiffModel(base, diff);
202202
this.setState({
203203
nbdModel: nbdModel
204204
});

src/components/diff/PlainTextDiff.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,17 @@ export interface IPlainTextDiffState {
1717
errorMessage: string;
1818
}
1919

20-
export interface IPlainTextDiffProps extends IDiffProps {}
21-
2220
/**
2321
* A React component to render the diff of a plain text file
2422
*
2523
* 1. It calls the `/git/diffcontent` API on the server to get the previous and current content
2624
* 2. Renders the content using CodeMirror merge addon
2725
*/
2826
export class PlainTextDiff extends React.Component<
29-
IPlainTextDiffProps,
27+
IDiffProps,
3028
IPlainTextDiffState
3129
> {
32-
constructor(props: IPlainTextDiffProps) {
30+
constructor(props: IDiffProps) {
3331
super(props);
3432
this.state = { errorMessage: null };
3533
this._mergeViewRef = React.createRef<HTMLDivElement>();

0 commit comments

Comments
 (0)