Skip to content

Commit 4960650

Browse files
committed
ESLint Rule Set Changes: Use warnings instead of errors to indicate code style issues, expansion of linting rules (with the required changes to the codebase).
1 parent 2458636 commit 4960650

20 files changed

+132
-81
lines changed

.eslintrc.json

Lines changed: 85 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,94 +2,136 @@
22
"root": true,
33
"parser": "@typescript-eslint/parser",
44
"parserOptions": {
5-
"ecmaVersion": 6,
6-
"sourceType": "module"
5+
"project": [
6+
"./src/tsconfig.json",
7+
"./tests/tsconfig.json",
8+
"./web/tsconfig.json"
9+
]
710
},
811
"plugins": [
912
"@typescript-eslint"
1013
],
1114
"rules": {
15+
"arrow-spacing": [
16+
"warn",
17+
{
18+
"before": true,
19+
"after": true
20+
}
21+
],
1222
"brace-style": [
13-
"error",
23+
"warn",
1424
"1tbs",
1525
{
1626
"allowSingleLine": true
1727
}
1828
],
19-
"comma-dangle": "error",
20-
"comma-spacing": "error",
21-
"comma-style": "error",
29+
"comma-dangle": "warn",
30+
"comma-spacing": "warn",
31+
"comma-style": "warn",
2232
"dot-location": [
23-
"error",
33+
"warn",
2434
"property"
2535
],
26-
"eol-last": "error",
27-
"eqeqeq": "error",
28-
"func-call-spacing": "error",
36+
"eol-last": "warn",
37+
"eqeqeq": "warn",
38+
"func-call-spacing": "warn",
2939
"indent": [
30-
"error",
40+
"warn",
3141
"tab",
3242
{
3343
"SwitchCase": 1
3444
}
3545
],
36-
"key-spacing": "error",
46+
"key-spacing": "warn",
3747
"linebreak-style": [
38-
"error",
48+
"warn",
3949
"windows"
4050
],
41-
"new-cap": "error",
42-
"new-parens": "error",
43-
"no-console": "warn",
51+
"new-cap": "warn",
52+
"new-parens": "warn",
53+
"no-alert": "error",
54+
"no-console": "error",
4455
"no-eval": "error",
56+
"no-extra-boolean-cast": "warn",
57+
"no-implied-eval": "error",
58+
"no-irregular-whitespace": "warn",
4559
"no-labels": "error",
46-
"no-multi-spaces": "error",
60+
"no-multi-spaces": "warn",
61+
"no-proto": "error",
62+
"no-prototype-builtins": "error",
4763
"no-redeclare": "error",
64+
"no-global-assign": "error",
65+
"no-return-await": "warn",
4866
"no-shadow-restricted-names": "error",
49-
"no-throw-literal": "error",
50-
"no-unused-expressions": "error",
51-
"no-whitespace-before-property": "error",
67+
"no-script-url": "error",
68+
"no-sparse-arrays": "warn",
69+
"no-throw-literal": "warn",
70+
"no-trailing-spaces": "warn",
71+
"no-unneeded-ternary": "warn",
72+
"no-unsafe-negation": "warn",
73+
"no-unused-expressions": "warn",
74+
"no-var": "warn",
75+
"no-whitespace-before-property": "warn",
76+
"no-with": "error",
77+
"padded-blocks": [
78+
"warn",
79+
{
80+
"classes": "never",
81+
"switches": "never"
82+
}
83+
],
5284
"quotes": [
53-
"error",
85+
"warn",
5486
"single"
5587
],
56-
"rest-spread-spacing": "error",
57-
"semi": "error",
88+
"rest-spread-spacing": "warn",
89+
"semi": "warn",
5890
"sort-imports": [
59-
"error",
91+
"warn",
6092
{
6193
"allowSeparatedGroups": true,
6294
"ignoreDeclarationSort": true
6395
}
6496
],
6597
"space-before-function-paren": [
66-
"error",
98+
"warn",
6799
{
68100
"anonymous": "always",
69101
"named": "never",
70102
"asyncArrow": "always"
71103
}
72104
],
73-
"space-before-blocks": "error",
74-
"space-infix-ops": "error",
75-
"spaced-comment": "error",
76-
"template-curly-spacing": "error",
105+
"space-before-blocks": "warn",
106+
"space-infix-ops": "warn",
107+
"spaced-comment": "warn",
108+
"template-curly-spacing": "warn",
77109
"wrap-iife": [
78-
"error",
110+
"warn",
79111
"inside"
80112
],
81-
"yoda": "error",
113+
"yoda": "warn",
114+
"@typescript-eslint/await-thenable": "warn",
115+
"@typescript-eslint/ban-ts-comment": "error",
116+
"@typescript-eslint/class-literal-property-style": [
117+
"warn",
118+
"fields"
119+
],
82120
"@typescript-eslint/explicit-member-accessibility": [
83-
"error",
121+
"warn",
84122
{
85123
"overrides": {
86124
"accessors": "off",
87125
"constructors": "off"
88126
}
89127
}
90128
],
129+
"@typescript-eslint/method-signature-style": [
130+
"warn",
131+
"property"
132+
],
91133
"@typescript-eslint/naming-convention": [
92-
"error",
134+
"warn",
93135
{
94136
"selector": "class",
95137
"format": [
@@ -102,7 +144,10 @@
102144
"camelCase"
103145
]
104146
}
105-
]
147+
],
148+
"@typescript-eslint/no-misused-new": "warn",
149+
"@typescript-eslint/no-this-alias": "warn",
150+
"@typescript-eslint/no-unnecessary-boolean-literal-compare": "warn"
106151
},
107152
"overrides": [
108153
{
@@ -111,6 +156,12 @@
111156
"no-console": "off",
112157
"spaced-comment": "off"
113158
}
159+
},
160+
{
161+
"files": "./tests/mocks/*.ts",
162+
"rules": {
163+
"no-global-assign": "off"
164+
}
114165
}
115166
]
116167
}

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1466,8 +1466,8 @@
14661466
"compile-src": "tsc -p ./src && node ./.vscode/package-src.js",
14671467
"compile-web": "tsc -p ./web && node ./.vscode/package-web.js",
14681468
"compile-web-debug": "tsc -p ./web && node ./.vscode/package-web.js debug",
1469-
"lint": "eslint -c .eslintrc.json --ext .ts ./src ./tests ./web",
1470-
"package": "npm run clean && vsce package",
1469+
"lint": "eslint -c .eslintrc.json --max-warnings 0 --ext .ts ./src ./tests ./web",
1470+
"package": "vsce package",
14711471
"package-and-install": "npm run package && node ./.vscode/install-package.js",
14721472
"test": "jest --verbose",
14731473
"test-and-report-coverage": "jest --verbose --coverage"

src/avatarManager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ class AvatarRequestQueue {
530530
* @param item The avatar request item.
531531
*/
532532
private insertItem(item: AvatarRequestItem) {
533-
var l = 0, r = this.queue.length - 1, c, prevLength = this.queue.length;
533+
let l = 0, r = this.queue.length - 1, c, prevLength = this.queue.length;
534534
while (l <= r) {
535535
c = l + r >> 1;
536536
if (this.queue[c].checkAfter <= item.checkAfter) {

src/commands.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ export class CommandManager extends Disposable {
317317
/**
318318
* Opens a file in Visual Studio Code, based on a Git Graph URI (from the Diff View).
319319
* The method run when the `git-graph.openFile` command is invoked.
320-
* @param arg The Git Graph URI.
320+
* @param arg The Git Graph URI.
321321
*/
322322
private openFile(arg?: vscode.Uri) {
323323
const uri = arg || vscode.window.activeTextEditor?.document.uri;

src/dataSource.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -624,8 +624,8 @@ export class DataSource extends Disposable {
624624
/**
625625
* Edit an existing remote of a repository.
626626
* @param repo The path of the repository.
627-
* @param nameOld The old name of the remote.
628-
* @param nameNew The new name of the remote.
627+
* @param nameOld The old name of the remote.
628+
* @param nameNew The new name of the remote.
629629
* @param urlOld The old URL of the remote.
630630
* @param urlNew The new URL of the remote.
631631
* @param pushUrlOld The old Push URL of the remote.
@@ -1703,7 +1703,7 @@ export class DataSource extends Disposable {
17031703

17041704
/**
17051705
* Spawn Git, with the return value resolved from `stdout` as a string.
1706-
* @param args The arguments to pass to Git.
1706+
* @param args The arguments to pass to Git.
17071707
* @param repo The repository to run the command in.
17081708
* @param resolveValue A callback invoked to resolve the data from `stdout`.
17091709
*/
@@ -1713,7 +1713,7 @@ export class DataSource extends Disposable {
17131713

17141714
/**
17151715
* Spawn Git, with the return value resolved from `stdout` as a buffer.
1716-
* @param args The arguments to pass to Git.
1716+
* @param args The arguments to pass to Git.
17171717
* @param repo The repository to run the command in.
17181718
* @param resolveValue A callback invoked to resolve the data from `stdout`.
17191719
*/

src/gitGraphView.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export class GitGraphView extends Disposable {
5454
GitGraphView.currentPanel.respondLoadRepos(repoManager.getRepos(), loadViewTo);
5555
}
5656
} else {
57-
// If the Git Graph panel is not visible
57+
// If the Git Graph panel is not visible
5858
GitGraphView.currentPanel.loadViewTo = loadViewTo;
5959
}
6060
GitGraphView.currentPanel.panel.reveal(column);
@@ -150,7 +150,7 @@ export class GitGraphView extends Disposable {
150150
this.panel
151151
);
152152

153-
// Instantiate a RepoFileWatcher that watches for file changes in the repository currently open in the Git Graph View
153+
// Instantiate a RepoFileWatcher that watches for file changes in the repository currently open in the Git Graph View
154154
this.repoFileWatcher = new RepoFileWatcher(logger, () => {
155155
if (this.panel.visible) {
156156
this.sendMessage({ command: 'refresh' });

src/life-cycle/startup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* Git Graph generates an event when it is installed, updated, or uninstalled, that is anonymous, non-personal, and cannot be correlated.
33
* - Each event only contains the Git Graph and Visual Studio Code version numbers, and a 256 bit cryptographically strong pseudo-random nonce.
4-
* - The two version numbers recorded in these events only allow aggregate compatibility information to be generated (e.g. 50% of users are
4+
* - The two version numbers recorded in these events only allow aggregate compatibility information to be generated (e.g. 50% of users are
55
* using Visual Studio Code >= 1.41.0). These insights enable Git Graph to utilise the latest features of Visual Studio Code as soon as
66
* the majority of users are using a compatible version. The data cannot, and will not, be used for any other purpose.
77
* - Full details are available at: https://api.mhutchie.com/vscode-git-graph/about

src/life-cycle/uninstall.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* Git Graph generates an event when it is installed, updated, or uninstalled, that is anonymous, non-personal, and cannot be correlated.
33
* - Each event only contains the Git Graph and Visual Studio Code version numbers, and a 256 bit cryptographically strong pseudo-random nonce.
4-
* - The two version numbers recorded in these events only allow aggregate compatibility information to be generated (e.g. 50% of users are
4+
* - The two version numbers recorded in these events only allow aggregate compatibility information to be generated (e.g. 50% of users are
55
* using Visual Studio Code >= 1.41.0). These insights enable Git Graph to utilise the latest features of Visual Studio Code as soon as
66
* the majority of users are using a compatible version. The data cannot, and will not, be used for any other purpose.
77
* - Full details are available at: https://api.mhutchie.com/vscode-git-graph/about

src/life-cycle/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* Git Graph generates an event when it is installed, updated, or uninstalled, that is anonymous, non-personal, and cannot be correlated.
33
* - Each event only contains the Git Graph and Visual Studio Code version numbers, and a 256 bit cryptographically strong pseudo-random nonce.
4-
* - The two version numbers recorded in these events only allow aggregate compatibility information to be generated (e.g. 50% of users are
4+
* - The two version numbers recorded in these events only allow aggregate compatibility information to be generated (e.g. 50% of users are
55
* using Visual Studio Code >= 1.41.0). These insights enable Git Graph to utilise the latest features of Visual Studio Code as soon as
66
* the majority of users are using a compatible version. The data cannot, and will not, be used for any other purpose.
77
* - Full details are available at: https://api.mhutchie.com/vscode-git-graph/about

src/logger.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export class Logger extends Disposable {
4848
}
4949
}
5050

51-
/**
51+
/**
5252
* Pad a number with a leading zero if it is less than two digits long.
5353
* @param n The number to be padded.
5454
* @returns The padded number.
@@ -57,7 +57,7 @@ function pad2(n: number) {
5757
return (n > 9 ? '' : '0') + n;
5858
}
5959

60-
/**
60+
/**
6161
* Pad a number with leading zeros if it is less than three digits long.
6262
* @param n The number to be padded.
6363
* @returns The padded number.

0 commit comments

Comments
 (0)