Skip to content

Commit

Permalink
ESLint Rule Set Changes: Use warnings instead of errors to indicate c…
Browse files Browse the repository at this point in the history
…ode style issues, expansion of linting rules (with the required changes to the codebase).
  • Loading branch information
mhutchie committed Mar 17, 2021
1 parent 2458636 commit 4960650
Show file tree
Hide file tree
Showing 20 changed files with 132 additions and 81 deletions.
119 changes: 85 additions & 34 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,94 +2,136 @@
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module"
"project": [
"./src/tsconfig.json",
"./tests/tsconfig.json",
"./web/tsconfig.json"
]
},
"plugins": [
"@typescript-eslint"
],
"rules": {
"arrow-spacing": [
"warn",
{
"before": true,
"after": true
}
],
"brace-style": [
"error",
"warn",
"1tbs",
{
"allowSingleLine": true
}
],
"comma-dangle": "error",
"comma-spacing": "error",
"comma-style": "error",
"comma-dangle": "warn",
"comma-spacing": "warn",
"comma-style": "warn",
"dot-location": [
"error",
"warn",
"property"
],
"eol-last": "error",
"eqeqeq": "error",
"func-call-spacing": "error",
"eol-last": "warn",
"eqeqeq": "warn",
"func-call-spacing": "warn",
"indent": [
"error",
"warn",
"tab",
{
"SwitchCase": 1
}
],
"key-spacing": "error",
"key-spacing": "warn",
"linebreak-style": [
"error",
"warn",
"windows"
],
"new-cap": "error",
"new-parens": "error",
"no-console": "warn",
"new-cap": "warn",
"new-parens": "warn",
"no-alert": "error",
"no-console": "error",
"no-eval": "error",
"no-extra-boolean-cast": "warn",
"no-implied-eval": "error",
"no-irregular-whitespace": "warn",
"no-labels": "error",
"no-multi-spaces": "error",
"no-multi-spaces": "warn",
"no-proto": "error",
"no-prototype-builtins": "error",
"no-redeclare": "error",
"no-global-assign": "error",
"no-return-await": "warn",
"no-shadow-restricted-names": "error",
"no-throw-literal": "error",
"no-unused-expressions": "error",
"no-whitespace-before-property": "error",
"no-script-url": "error",
"no-sparse-arrays": "warn",
"no-throw-literal": "warn",
"no-trailing-spaces": "warn",
"no-unneeded-ternary": "warn",
"no-unsafe-negation": "warn",
"no-unused-expressions": "warn",
"no-var": "warn",
"no-whitespace-before-property": "warn",
"no-with": "error",
"padded-blocks": [
"warn",
{
"classes": "never",
"switches": "never"
}
],
"quotes": [
"error",
"warn",
"single"
],
"rest-spread-spacing": "error",
"semi": "error",
"rest-spread-spacing": "warn",
"semi": "warn",
"sort-imports": [
"error",
"warn",
{
"allowSeparatedGroups": true,
"ignoreDeclarationSort": true
}
],
"space-before-function-paren": [
"error",
"warn",
{
"anonymous": "always",
"named": "never",
"asyncArrow": "always"
}
],
"space-before-blocks": "error",
"space-infix-ops": "error",
"spaced-comment": "error",
"template-curly-spacing": "error",
"space-before-blocks": "warn",
"space-infix-ops": "warn",
"spaced-comment": "warn",
"template-curly-spacing": "warn",
"wrap-iife": [
"error",
"warn",
"inside"
],
"yoda": "error",
"yoda": "warn",
"@typescript-eslint/await-thenable": "warn",
"@typescript-eslint/ban-ts-comment": "error",
"@typescript-eslint/class-literal-property-style": [
"warn",
"fields"
],
"@typescript-eslint/explicit-member-accessibility": [
"error",
"warn",
{
"overrides": {
"accessors": "off",
"constructors": "off"
}
}
],
"@typescript-eslint/method-signature-style": [
"warn",
"property"
],
"@typescript-eslint/naming-convention": [
"error",
"warn",
{
"selector": "class",
"format": [
Expand All @@ -102,7 +144,10 @@
"camelCase"
]
}
]
],
"@typescript-eslint/no-misused-new": "warn",
"@typescript-eslint/no-this-alias": "warn",
"@typescript-eslint/no-unnecessary-boolean-literal-compare": "warn"
},
"overrides": [
{
Expand All @@ -111,6 +156,12 @@
"no-console": "off",
"spaced-comment": "off"
}
},
{
"files": "./tests/mocks/*.ts",
"rules": {
"no-global-assign": "off"
}
}
]
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1466,8 +1466,8 @@
"compile-src": "tsc -p ./src && node ./.vscode/package-src.js",
"compile-web": "tsc -p ./web && node ./.vscode/package-web.js",
"compile-web-debug": "tsc -p ./web && node ./.vscode/package-web.js debug",
"lint": "eslint -c .eslintrc.json --ext .ts ./src ./tests ./web",
"package": "npm run clean && vsce package",
"lint": "eslint -c .eslintrc.json --max-warnings 0 --ext .ts ./src ./tests ./web",
"package": "vsce package",
"package-and-install": "npm run package && node ./.vscode/install-package.js",
"test": "jest --verbose",
"test-and-report-coverage": "jest --verbose --coverage"
Expand Down
2 changes: 1 addition & 1 deletion src/avatarManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ class AvatarRequestQueue {
* @param item The avatar request item.
*/
private insertItem(item: AvatarRequestItem) {
var l = 0, r = this.queue.length - 1, c, prevLength = this.queue.length;
let l = 0, r = this.queue.length - 1, c, prevLength = this.queue.length;
while (l <= r) {
c = l + r >> 1;
if (this.queue[c].checkAfter <= item.checkAfter) {
Expand Down
2 changes: 1 addition & 1 deletion src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ export class CommandManager extends Disposable {
/**
* Opens a file in Visual Studio Code, based on a Git Graph URI (from the Diff View).
* The method run when the `git-graph.openFile` command is invoked.
* @param arg The Git Graph URI.
* @param arg The Git Graph URI.
*/
private openFile(arg?: vscode.Uri) {
const uri = arg || vscode.window.activeTextEditor?.document.uri;
Expand Down
8 changes: 4 additions & 4 deletions src/dataSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -624,8 +624,8 @@ export class DataSource extends Disposable {
/**
* Edit an existing remote of a repository.
* @param repo The path of the repository.
* @param nameOld The old name of the remote.
* @param nameNew The new name of the remote.
* @param nameOld The old name of the remote.
* @param nameNew The new name of the remote.
* @param urlOld The old URL of the remote.
* @param urlNew The new URL of the remote.
* @param pushUrlOld The old Push URL of the remote.
Expand Down Expand Up @@ -1703,7 +1703,7 @@ export class DataSource extends Disposable {

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

/**
* Spawn Git, with the return value resolved from `stdout` as a buffer.
* @param args The arguments to pass to Git.
* @param args The arguments to pass to Git.
* @param repo The repository to run the command in.
* @param resolveValue A callback invoked to resolve the data from `stdout`.
*/
Expand Down
4 changes: 2 additions & 2 deletions src/gitGraphView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class GitGraphView extends Disposable {
GitGraphView.currentPanel.respondLoadRepos(repoManager.getRepos(), loadViewTo);
}
} else {
// If the Git Graph panel is not visible
// If the Git Graph panel is not visible
GitGraphView.currentPanel.loadViewTo = loadViewTo;
}
GitGraphView.currentPanel.panel.reveal(column);
Expand Down Expand Up @@ -150,7 +150,7 @@ export class GitGraphView extends Disposable {
this.panel
);

// Instantiate a RepoFileWatcher that watches for file changes in the repository currently open in the Git Graph View
// Instantiate a RepoFileWatcher that watches for file changes in the repository currently open in the Git Graph View
this.repoFileWatcher = new RepoFileWatcher(logger, () => {
if (this.panel.visible) {
this.sendMessage({ command: 'refresh' });
Expand Down
2 changes: 1 addition & 1 deletion src/life-cycle/startup.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Git Graph generates an event when it is installed, updated, or uninstalled, that is anonymous, non-personal, and cannot be correlated.
* - Each event only contains the Git Graph and Visual Studio Code version numbers, and a 256 bit cryptographically strong pseudo-random nonce.
* - The two version numbers recorded in these events only allow aggregate compatibility information to be generated (e.g. 50% of users are
* - The two version numbers recorded in these events only allow aggregate compatibility information to be generated (e.g. 50% of users are
* using Visual Studio Code >= 1.41.0). These insights enable Git Graph to utilise the latest features of Visual Studio Code as soon as
* the majority of users are using a compatible version. The data cannot, and will not, be used for any other purpose.
* - Full details are available at: https://api.mhutchie.com/vscode-git-graph/about
Expand Down
2 changes: 1 addition & 1 deletion src/life-cycle/uninstall.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Git Graph generates an event when it is installed, updated, or uninstalled, that is anonymous, non-personal, and cannot be correlated.
* - Each event only contains the Git Graph and Visual Studio Code version numbers, and a 256 bit cryptographically strong pseudo-random nonce.
* - The two version numbers recorded in these events only allow aggregate compatibility information to be generated (e.g. 50% of users are
* - The two version numbers recorded in these events only allow aggregate compatibility information to be generated (e.g. 50% of users are
* using Visual Studio Code >= 1.41.0). These insights enable Git Graph to utilise the latest features of Visual Studio Code as soon as
* the majority of users are using a compatible version. The data cannot, and will not, be used for any other purpose.
* - Full details are available at: https://api.mhutchie.com/vscode-git-graph/about
Expand Down
2 changes: 1 addition & 1 deletion src/life-cycle/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Git Graph generates an event when it is installed, updated, or uninstalled, that is anonymous, non-personal, and cannot be correlated.
* - Each event only contains the Git Graph and Visual Studio Code version numbers, and a 256 bit cryptographically strong pseudo-random nonce.
* - The two version numbers recorded in these events only allow aggregate compatibility information to be generated (e.g. 50% of users are
* - The two version numbers recorded in these events only allow aggregate compatibility information to be generated (e.g. 50% of users are
* using Visual Studio Code >= 1.41.0). These insights enable Git Graph to utilise the latest features of Visual Studio Code as soon as
* the majority of users are using a compatible version. The data cannot, and will not, be used for any other purpose.
* - Full details are available at: https://api.mhutchie.com/vscode-git-graph/about
Expand Down
4 changes: 2 additions & 2 deletions src/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class Logger extends Disposable {
}
}

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

/**
/**
* Pad a number with leading zeros if it is less than three digits long.
* @param n The number to be padded.
* @returns The padded number.
Expand Down
4 changes: 2 additions & 2 deletions src/repoManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,7 @@ function readExternalConfigFile(repo: string) {
/**
* Writes the External Configuration File of a repository to the File System.
* @param repo The path of the repository.
* @param file The file contents.
* @param file The file contents.
* @returns A promise that resolves to a success message, or rejects to an error message.
*/
function writeExternalConfigFile(repo: string, file: ExternalRepoConfig.File) {
Expand Down Expand Up @@ -910,7 +910,7 @@ function generateExternalConfigFile(state: GitRepoState): Readonly<ExternalRepoC
/**
* Validate an external configuration file.
* @param file The external configuration file.
* @returns NULL => Value, String => The first field that is invalid.
* @returns NULL => Value, String => The first field that is invalid.
*/
function validateExternalConfigFile(file: Readonly<ExternalRepoConfig.File>) {
if (typeof file.commitOrdering !== 'undefined' && file.commitOrdering !== RepoCommitOrdering.Date && file.commitOrdering !== RepoCommitOrdering.AuthorDate && file.commitOrdering !== RepoCommitOrdering.Topological) {
Expand Down
4 changes: 2 additions & 2 deletions src/statusBarItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class StatusBarItem extends Disposable {
this.setNumRepos(initialNumRepos);
}

/**
/**
* Sets the number of repositories known to Git Graph, before refreshing the Status Bar Item.
* @param numRepos The number of repositories known to Git Graph.
*/
Expand All @@ -53,7 +53,7 @@ export class StatusBarItem extends Disposable {
this.refresh();
}

/**
/**
* Show or hide the Status Bar Item according to the configured value of `git-graph.showStatusBarItem`, and the number of repositories known to Git Graph.
*/
private refresh() {
Expand Down
2 changes: 1 addition & 1 deletion tests/repoFileWatcher.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ describe('RepoFileWatcher', () => {
const onDidCreate = (<jest.Mock<any, any>>repoFileWatcher['fsWatcher']!.onDidCreate).mock.calls[0][0];
const onDidChange = (<jest.Mock<any, any>>repoFileWatcher['fsWatcher']!.onDidChange).mock.calls[0][0];

// Run
// Run
repoFileWatcher.mute();
repoFileWatcher.unmute();
onDidCreate(vscode.Uri.file('/path/to/repo/file'));
Expand Down
2 changes: 1 addition & 1 deletion web/contextMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class ContextMenu {
}
return;
} else {
// ContextMenu is dependent on the commit and ref
// ContextMenu is dependent on the commit and ref
const elems = <NodeListOf<HTMLElement>>commitElem.querySelectorAll('[data-fullref]');
for (let i = 0; i < elems.length; i++) {
if (elems[i].dataset.fullref! === this.target.ref) {
Expand Down
4 changes: 2 additions & 2 deletions web/dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ class Dialog {
* @param target The target that the dialog was triggered on.
* @param secondaryActionName An optional name for the secondary action.
* @param secondaryActioned An optional callback to be invoked when the secondary action is selected by the user.
* @param includeLineBreak Should a line break be added between the message and form inputs.
* @param includeLineBreak Should a line break be added between the message and form inputs.
*/
public showForm(message: string, inputs: ReadonlyArray<DialogInput>, actionName: string, actioned: (values: DialogInputValue[]) => void, target: DialogTarget | null, secondaryActionName: string = 'Cancel', secondaryActioned: ((values: DialogInputValue[]) => void) | null = null, includeLineBreak: boolean = true) {
const multiElement = inputs.length > 1;
Expand Down Expand Up @@ -419,7 +419,7 @@ class Dialog {
}
return;
} else {
// Dialog is dependent on the commit and ref
// Dialog is dependent on the commit and ref
const elems = <NodeListOf<HTMLElement>>commitElem.querySelectorAll('[data-fullref]');
for (let i = 0; i < elems.length; i++) {
if (elems[i].dataset.fullref! === this.target.ref) {
Expand Down
Loading

0 comments on commit 4960650

Please sign in to comment.