Skip to content

Commit

Permalink
Expanded ESLint Style Rule Set to enforce additional consistency on c…
Browse files Browse the repository at this point in the history
…ode formatting.
  • Loading branch information
mhutchie committed Dec 23, 2020
1 parent cb7f9ae commit a80945b
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 18 deletions.
46 changes: 44 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,51 @@
"@typescript-eslint"
],
"rules": {
"brace-style": [
"error",
"1tbs",
{
"allowSingleLine": true
}
],
"comma-dangle": "error",
"comma-spacing": "error",
"comma-style": "error",
"dot-location": [
"error",
"property"
],
"eol-last": "error",
"eqeqeq": "error",
"func-call-spacing": "error",
"indent": [
"error",
"tab",
{
"SwitchCase": 1
}
],
"key-spacing": "error",
"linebreak-style": [
"error",
"windows"
],
"new-cap": "error",
"new-parens": "error",
"no-console": "warn",
"no-eval": "error",
"no-labels": "error",
"no-multi-spaces": "error",
"no-redeclare": "error",
"no-shadow-restricted-names": "error",
"no-throw-literal": "error",
"no-unused-expressions": "error",
"no-whitespace-before-property": "error",
"quotes": [
"error",
"single"
],
"rest-spread-spacing": "error",
"semi": "error",
"sort-imports": [
"error",
Expand All @@ -38,6 +62,23 @@
"ignoreDeclarationSort": true
}
],
"space-before-function-paren": [
"error",
{
"anonymous": "always",
"named": "never",
"asyncArrow": "always"
}
],
"space-before-blocks": "error",
"space-infix-ops": "error",
"spaced-comment": "error",
"template-curly-spacing": "error",
"wrap-iife": [
"error",
"inside"
],
"yoda": "error",
"@typescript-eslint/explicit-member-accessibility": [
"error",
{
Expand Down Expand Up @@ -65,9 +106,10 @@
},
"overrides": [
{
"files": "./src/askpass/askpassMain.ts",
"files": "./src/askpass/*.ts",
"rules": {
"no-console": "off"
"no-console": "off",
"spaced-comment": "off"
}
}
]
Expand Down
2 changes: 1 addition & 1 deletion src/askpass/askpassManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,4 @@ function getIPCHandlePath(nonce: string): string {
} else {
return path.join(os.tmpdir(), 'git-graph-askpass-' + nonce + '.sock');
}
}
}
6 changes: 3 additions & 3 deletions src/avatarManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class AvatarManager extends Disposable {
}),

// Dispose the avatar event emitter
this.avatarEventEmitter,
this.avatarEventEmitter
);
}

Expand Down Expand Up @@ -298,7 +298,7 @@ export class AvatarManager extends Disposable {
https.get({
hostname: 'gitlab.com', path: '/api/v4/users?search=' + avatarRequest.email,
headers: { 'User-Agent': 'vscode-git-graph', 'Private-Token': 'w87U_3gAxWWaPtFgCcus' }, // Token only has read access
agent: false, timeout: 15000,
agent: false, timeout: 15000
}, (res) => {
let respBody = '';
res.on('data', (chunk: Buffer) => { respBody += chunk; });
Expand Down Expand Up @@ -589,4 +589,4 @@ interface GravatarRemoteSource {
readonly type: 'gravatar';
}

type RemoteSource = GitHubRemoteSource | GitLabRemoteSource | GravatarRemoteSource;
type RemoteSource = GitHubRemoteSource | GitLabRemoteSource | GravatarRemoteSource;
4 changes: 2 additions & 2 deletions src/dataSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,13 @@ export class DataSource extends Disposable {
].join(GIT_LOG_SEPARATOR);

this.gitFormatLog = [
'%H', '%P',// Hash & Parent Information
'%H', '%P', // Hash & Parent Information
useMailmap ? '%aN' : '%an', useMailmap ? '%aE' : '%ae', dateType, // Author / Commit Information
'%s' // Subject
].join(GIT_LOG_SEPARATOR);

this.gitFormatStash = [
'%H', '%P', '%gD',// Hash, Parent & Selector Information
'%H', '%P', '%gD', // Hash, Parent & Selector Information
useMailmap ? '%aN' : '%an', useMailmap ? '%aE' : '%ae', dateType, // Author / Commit Information
'%s' // Subject
].join(GIT_LOG_SEPARATOR);
Expand Down
8 changes: 4 additions & 4 deletions src/gitGraphView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ export class GitGraphView extends Disposable {
this.sendMessage({
command: 'compareCommits',
commitHash: msg.commitHash, compareWithHash: msg.compareWithHash,
... await this.dataSource.getCommitComparison(msg.repo, msg.fromHash, msg.toHash),
...await this.dataSource.getCommitComparison(msg.repo, msg.fromHash, msg.toHash),
codeReview: msg.toHash !== UNCOMMITTED ? this.extensionState.getCodeReview(msg.repo, msg.fromHash + '-' + msg.toHash) : null,
refresh: msg.refresh
});
Expand Down Expand Up @@ -404,7 +404,7 @@ export class GitGraphView extends Disposable {
command: 'loadCommits',
refreshId: msg.refreshId,
onlyFollowFirstParent: msg.onlyFollowFirstParent,
... await this.dataSource.getCommits(msg.repo, msg.branches, msg.maxCommits, msg.showTags, msg.showRemoteBranches, msg.includeCommitsMentionedByReflogs, msg.onlyFollowFirstParent, msg.commitOrdering, msg.remotes, msg.hideRemotes, msg.stashes)
...await this.dataSource.getCommits(msg.repo, msg.branches, msg.maxCommits, msg.showTags, msg.showRemoteBranches, msg.includeCommitsMentionedByReflogs, msg.onlyFollowFirstParent, msg.commitOrdering, msg.remotes, msg.hideRemotes, msg.stashes)
});
break;
case 'loadConfig':
Expand Down Expand Up @@ -565,15 +565,15 @@ export class GitGraphView extends Disposable {
command: 'startCodeReview',
commitHash: msg.commitHash,
compareWithHash: msg.compareWithHash,
... await this.extensionState.startCodeReview(msg.repo, msg.id, msg.files, msg.lastViewedFile)
...await this.extensionState.startCodeReview(msg.repo, msg.id, msg.files, msg.lastViewedFile)
});
break;
case 'tagDetails':
this.sendMessage({
command: 'tagDetails',
tagName: msg.tagName,
commitHash: msg.commitHash,
... await this.dataSource.getTagDetails(msg.repo, msg.tagName)
...await this.dataSource.getTagDetails(msg.repo, msg.tagName)
});
break;
case 'viewDiff':
Expand Down
2 changes: 1 addition & 1 deletion src/statusBarItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@ export class StatusBarItem extends Disposable {
this.isVisible = shouldBeVisible;
}
}
}
}
2 changes: 1 addition & 1 deletion src/utils/@types/node/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ declare module 'fs' {
namespace realpath {
function native(path: PathLike, callback: (err: NodeJS.ErrnoException | null, resolvedPath: string) => void): void;
}
}
}
2 changes: 1 addition & 1 deletion tests/avatarManager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1752,4 +1752,4 @@ function waitForEvents(avatarManager: AvatarManager, n: number, runPendingTimers
}
});
});
}
}
4 changes: 2 additions & 2 deletions tests/mocks/spawn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ export function mockSpyOnSpawn(spyOnSpawn: jest.SpyInstance, callback: (onCallba
return {
on: (event: string, callback: (...args: any[]) => void) => onCallbacks[event] = callback,
stderr: {
on: (event: string, callback: (...args: any[]) => void) => stderrOnCallbacks[event] = callback,
on: (event: string, callback: (...args: any[]) => void) => stderrOnCallbacks[event] = callback
},
stdout: {
on: (event: string, callback: (...args: any[]) => void) => stdoutOnCallbacks[event] = callback,
on: (event: string, callback: (...args: any[]) => void) => stdoutOnCallbacks[event] = callback
}
};
});
Expand Down
2 changes: 1 addition & 1 deletion web/settingsWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ class SettingsWidget {
{ type: DialogInputType.Text, name: 'Source Owner', default: config.sourceOwner, placeholder: null, info: 'The owner of the repository that is the source of the Pull Request.' },
{ type: DialogInputType.Text, name: 'Source Repo', default: config.sourceRepo, placeholder: null, info: 'The name of the repository that is the source of the Pull Request.' },
{ type: DialogInputType.Text, name: 'Destination Owner', default: config.destOwner, placeholder: null, info: 'The owner of the repository that is the destination / target of the Pull Request.' },
{ type: DialogInputType.Text, name: 'Destination Repo', default: config.destRepo, placeholder: null, info: 'The name of the repository that is the destination / target of the Pull Request.' },
{ type: DialogInputType.Text, name: 'Destination Repo', default: config.destRepo, placeholder: null, info: 'The name of the repository that is the destination / target of the Pull Request.' }
];
if (config.provider === GG.PullRequestProvider.GitLab) {
inputs.push({ type: DialogInputType.Text, name: 'Destination Project ID', default: config.destProjectId, placeholder: null, info: 'The GitLab Project ID of the destination / target of the Pull Request. Leave this field blank to use the default destination / target configured in GitLab.' });
Expand Down

0 comments on commit a80945b

Please sign in to comment.