Skip to content

Commit

Permalink
Migrated to use ESLint instead of TSLint. Minor code style changes to…
Browse files Browse the repository at this point in the history
… conform to the new ESLint rules.
  • Loading branch information
mhutchie committed Aug 2, 2020
1 parent 9731921 commit f2e9c5f
Show file tree
Hide file tree
Showing 16 changed files with 98 additions and 50 deletions.
74 changes: 74 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module"
},
"plugins": [
"@typescript-eslint"
],
"rules": {
"eqeqeq": "error",
"indent": [
"error",
"tab",
{
"SwitchCase": 1
}
],
"linebreak-style": [
"error",
"windows"
],
"no-console": "warn",
"no-redeclare": "error",
"no-shadow-restricted-names": "error",
"no-throw-literal": "error",
"no-unused-expressions": "error",
"quotes": [
"error",
"single"
],
"semi": "error",
"sort-imports": [
"error",
{
"allowSeparatedGroups": true,
"ignoreDeclarationSort": true
}
],
"@typescript-eslint/explicit-member-accessibility": [
"error",
{
"overrides": {
"accessors": "off",
"constructors": "off"
}
}
],
"@typescript-eslint/naming-convention": [
"error",
{
"selector": "class",
"format": [
"StrictPascalCase"
]
},
{
"selector": "function",
"format": [
"camelCase"
]
}
]
},
"overrides": [
{
"files": "./src/askpass/askpassMain.ts",
"rules": {
"no-console": "off"
}
}
]
}
2 changes: 1 addition & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"ms-vscode.vscode-typescript-tslint-plugin"
"dbaeumer.vscode-eslint"
]
}
4 changes: 2 additions & 2 deletions .vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ resources/demo.gif
src/
tests/
web/
.eslintrc.json
.gitignore
jest.config.js
tslint.json
jest.config.js
17 changes: 10 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -881,10 +881,11 @@
"vscode:prepublish": "npm run compile",
"vscode:uninstall": "node ./out/life-cycle/uninstall.js",
"clean": "node ./.vscode/clean.js",
"compile": "npm run clean && npm run compile-src && npm run compile-web",
"compile": "npm run lint && npm run clean && npm run compile-src && npm run compile-web",
"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",
"package-and-install": "npm run package && node ./.vscode/install-package.js",
"test": "jest --verbose",
Expand All @@ -894,13 +895,15 @@
"iconv-lite": "0.5.0"
},
"devDependencies": {
"@types/jest": "^25.2.1",
"@types/node": "^8.10.25",
"@types/jest": "25.2.3",
"@types/node": "8.10.62",
"@types/vscode": "1.38.0",
"jest": "^25.4.0",
"ts-jest": "^25.4.0",
"tslint": "^5.12.1",
"@typescript-eslint/eslint-plugin": "3.7.1",
"@typescript-eslint/parser": "3.7.1",
"eslint": "7.6.0",
"jest": "25.5.4",
"ts-jest": "25.5.1",
"typescript": "3.7.2",
"uglify-js": "^3.4.9"
"uglify-js": "3.10.0"
}
}
2 changes: 1 addition & 1 deletion src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { CodeReviewData, CodeReviews, ExtensionState } from './extensionState';
import { GitGraphView } from './gitGraphView';
import { Logger } from './logger';
import { RepoManager } from './repoManager';
import { abbrevCommit, abbrevText, getPathFromUri, getRelativeTimeDiff, getRepoName, GitExecutable, isPathInWorkspace, resolveToSymbolicPath, showErrorMessage, showInformationMessage, UNABLE_TO_FIND_GIT_MSG } from './utils';
import { GitExecutable, UNABLE_TO_FIND_GIT_MSG, abbrevCommit, abbrevText, getPathFromUri, getRelativeTimeDiff, getRepoName, isPathInWorkspace, resolveToSymbolicPath, showErrorMessage, showInformationMessage } from './utils';

/**
* Manages the registration and execution of Git Graph Commands.
Expand Down
2 changes: 1 addition & 1 deletion src/dataSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { getConfig } from './config';
import { Event } from './event';
import { Logger } from './logger';
import { CommitOrdering, DateType, ErrorInfo, GitCommit, GitCommitDetails, GitCommitStash, GitConfigLocation, GitFileChange, GitFileStatus, GitPushBranchMode, GitRepoSettings, GitResetMode, GitSignatureStatus, GitStash, MergeActionOn, RebaseActionOn, SquashMessageFormat } from './types';
import { abbrevCommit, constructIncompatibleGitVersionMessage, getPathFromStr, getPathFromUri, GitExecutable, isGitAtLeastVersion, openGitTerminal, realpath, resolveSpawnOutput, UNABLE_TO_FIND_GIT_MSG, UNCOMMITTED } from './utils';
import { GitExecutable, UNABLE_TO_FIND_GIT_MSG, UNCOMMITTED, abbrevCommit, constructIncompatibleGitVersionMessage, getPathFromStr, getPathFromUri, isGitAtLeastVersion, openGitTerminal, realpath, resolveSpawnOutput } from './utils';

const EOL_REGEX = /\r\n|\r|\n/g;
const INVALID_BRANCH_REGEX = /^\(.* .*\)$/;
Expand Down
2 changes: 1 addition & 1 deletion src/diffDocProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as path from 'path';
import * as vscode from 'vscode';
import { DataSource } from './dataSource';
import { GitFileStatus } from './types';
import { getPathFromStr, showErrorMessage, UNCOMMITTED } from './utils';
import { UNCOMMITTED, getPathFromStr, showErrorMessage } from './utils';

export const enum DiffSide {
Old,
Expand Down
2 changes: 1 addition & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { onStartUp } from './life-cycle/startup';
import { Logger } from './logger';
import { RepoManager } from './repoManager';
import { StatusBarItem } from './statusBarItem';
import { findGit, getGitExecutable, GitExecutable, showErrorMessage, showInformationMessage, UNABLE_TO_FIND_GIT_MSG } from './utils';
import { GitExecutable, UNABLE_TO_FIND_GIT_MSG, findGit, getGitExecutable, showErrorMessage, showInformationMessage } from './utils';

/**
* Activate Git Graph.
Expand Down
2 changes: 1 addition & 1 deletion src/extensionState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as vscode from 'vscode';
import { Avatar, AvatarCache } from './avatarManager';
import { Event } from './event';
import { CodeReview, ErrorInfo, FileViewType, GitGraphViewGlobalState, GitRepoSet, GitRepoState, IncludeCommitsMentionedByReflogs, OnlyFollowFirstParent, RepoCommitOrdering, ShowTags } from './types';
import { getPathFromStr, GitExecutable } from './utils';
import { GitExecutable, getPathFromStr } from './utils';

const AVATAR_STORAGE_FOLDER = '/avatars';
const AVATAR_CACHE = 'avatarCache';
Expand Down
2 changes: 1 addition & 1 deletion src/gitGraphView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Logger } from './logger';
import { RepoFileWatcher } from './repoFileWatcher';
import { RepoManager } from './repoManager';
import { ErrorInfo, GitConfigLocation, GitGraphViewInitialState, GitPushBranchMode, GitRepoSet, LoadGitGraphViewTo, RefLabelAlignment, RequestMessage, ResponseMessage, TabIconColourTheme } from './types';
import { archive, copyFilePathToClipboard, copyToClipboard, createPullRequest, getNonce, getRepoName, openExtensionSettings, openFile, showErrorMessage, UNABLE_TO_FIND_GIT_MSG, UNCOMMITTED, viewDiff, viewFileAtRevision, viewScm } from './utils';
import { UNABLE_TO_FIND_GIT_MSG, UNCOMMITTED, archive, copyFilePathToClipboard, copyToClipboard, createPullRequest, getNonce, getRepoName, openExtensionSettings, openFile, showErrorMessage, viewDiff, viewFileAtRevision, viewScm } from './utils';

/**
* Manages the Git Graph View.
Expand Down
2 changes: 1 addition & 1 deletion src/life-cycle/startup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import * as fs from 'fs';
import * as path from 'path';
import * as vscode from 'vscode';
import { generateNonce, getDataDirectory, getLifeCycleStateInDirectory, LifeCycleStage, LifeCycleState, saveLifeCycleStateInDirectory, sendQueue } from './utils';
import { LifeCycleStage, LifeCycleState, generateNonce, getDataDirectory, getLifeCycleStateInDirectory, saveLifeCycleStateInDirectory, sendQueue } from './utils';

/**
* Run on startup to detect if Git Graph has been installed or updated, and if so generate an event.
Expand Down
2 changes: 1 addition & 1 deletion src/life-cycle/uninstall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* - Full details are available at: https://api.mhutchie.com/vscode-git-graph/about
*/

import { generateNonce, getDataDirectory, getLifeCycleStateInDirectory, LifeCycleStage, sendQueue } from './utils';
import { LifeCycleStage, generateNonce, getDataDirectory, getLifeCycleStateInDirectory, sendQueue } from './utils';

(async function () {
try {
Expand Down
2 changes: 1 addition & 1 deletion tests/diffDocProvider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jest.mock('../src/logger');
import * as path from 'path';
import { ConfigurationChangeEvent } from 'vscode';
import { DataSource } from '../src/dataSource';
import { decodeDiffDocUri, DiffDocProvider, DiffSide, encodeDiffDocUri } from '../src/diffDocProvider';
import { DiffDocProvider, DiffSide, decodeDiffDocUri, encodeDiffDocUri } from '../src/diffDocProvider';
import { EventEmitter } from '../src/event';
import { Logger } from '../src/logger';
import { GitFileStatus } from '../src/types';
Expand Down
2 changes: 1 addition & 1 deletion tests/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { EventEmitter } from '../src/event';
import { ExtensionState } from '../src/extensionState';
import { Logger } from '../src/logger';
import { GitFileStatus, PullRequestProvider } from '../src/types';
import { abbrevCommit, abbrevText, archive, constructIncompatibleGitVersionMessage, copyFilePathToClipboard, copyToClipboard, createPullRequest, evalPromises, findGit, getGitExecutable, getNonce, getPathFromStr, getPathFromUri, getRelativeTimeDiff, getRepoName, GitExecutable, isGitAtLeastVersion, isPathInWorkspace, openExtensionSettings, openFile, openGitTerminal, pathWithTrailingSlash, realpath, resolveSpawnOutput, resolveToSymbolicPath, showErrorMessage, showInformationMessage, UNCOMMITTED, viewDiff, viewFileAtRevision, viewScm } from '../src/utils';
import { GitExecutable, UNCOMMITTED, abbrevCommit, abbrevText, archive, constructIncompatibleGitVersionMessage, copyFilePathToClipboard, copyToClipboard, createPullRequest, evalPromises, findGit, getGitExecutable, getNonce, getPathFromStr, getPathFromUri, getRelativeTimeDiff, getRepoName, isGitAtLeastVersion, isPathInWorkspace, openExtensionSettings, openFile, openGitTerminal, pathWithTrailingSlash, realpath, resolveSpawnOutput, resolveToSymbolicPath, showErrorMessage, showInformationMessage, viewDiff, viewFileAtRevision, viewScm } from '../src/utils';

let extensionContext = vscode.mocks.extensionContext;
let terminal = vscode.mocks.terminal;
Expand Down
29 changes: 0 additions & 29 deletions tslint.json

This file was deleted.

2 changes: 1 addition & 1 deletion web/global.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as GG from "../out/types"; // Import types from back-end (requires `npm run compile-src`)
import * as GG from '../out/types'; // Import types from back-end (requires `npm run compile-src`)

declare global {

Expand Down

2 comments on commit f2e9c5f

@TomasJuocepis
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, I noticed that CONTRIBUTING.md hasn't been updated from a TSLint reference to a ESLint reference.

@mhutchie
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @TomasJuocepis for spotting this!

I had updated the recommended extensions in .vsocde/extensions.json, but forgot about this reference. I've corrected this in f867fcc.

Please sign in to comment.