Skip to content

Commit

Permalink
Adds lint rules to avoid process global usage
Browse files Browse the repository at this point in the history
  • Loading branch information
eamodio committed Jul 13, 2022
1 parent c02da2d commit aae54fd
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .eslintrc.base.json
Expand Up @@ -51,6 +51,7 @@
"no-lonely-if": "error",
"no-loop-func": "error",
"no-multi-spaces": "error",
"no-restricted-globals": ["error", "process"],
"no-restricted-imports": [
"error",
{
Expand All @@ -75,6 +76,7 @@
"net",
"os",
"path",
"process",
"punycode",
"querystring",
"readline",
Expand Down
1 change: 1 addition & 0 deletions src/env/node/fetch.ts
@@ -1,3 +1,4 @@
import * as process from 'process';
import * as url from 'url';
import { HttpsProxyAgent } from 'https-proxy-agent';
import fetch, { RequestInfo, RequestInit, Response } from 'node-fetch';
Expand Down
1 change: 1 addition & 0 deletions src/env/node/git/git.ts
@@ -1,3 +1,4 @@
import * as process from 'process';
import { Uri, window, workspace } from 'vscode';
import { hrtime } from '@env/hrtime';
import { GlyphChars } from '../../../constants';
Expand Down
9 changes: 5 additions & 4 deletions src/env/node/git/localGitProvider.ts
@@ -1,6 +1,7 @@
import { readdir, realpath } from 'fs';
import { homedir, hostname, userInfo } from 'os';
import { resolve as resolvePath } from 'path';
import { env as process_env } from 'process';
import {
Disposable,
env,
Expand Down Expand Up @@ -1753,17 +1754,17 @@ export class LocalGitProvider implements GitProvider, Disposable {
} while (true);
} else {
user.name =
process.env.GIT_AUTHOR_NAME || process.env.GIT_COMMITTER_NAME || userInfo()?.username || undefined;
process_env.GIT_AUTHOR_NAME || process_env.GIT_COMMITTER_NAME || userInfo()?.username || undefined;
if (!user.name) {
// If we found no user data, mark it so we won't bother trying again
this._repoInfoCache.set(repoPath, { ...repo, user: null });
return undefined;
}

user.email =
process.env.GIT_AUTHOR_EMAIL ||
process.env.GIT_COMMITTER_EMAIL ||
process.env.EMAIL ||
process_env.GIT_AUTHOR_EMAIL ||
process_env.GIT_COMMITTER_EMAIL ||
process_env.EMAIL ||
`${user.name}@${hostname()}`;
}

Expand Down
1 change: 1 addition & 0 deletions src/env/node/git/locator.ts
@@ -1,4 +1,5 @@
import { join as joinPaths } from 'path';
import * as process from 'process';
import { GlyphChars } from '../../../constants';
import { LogLevel } from '../../../logger';
import { any } from '../../../system/promise';
Expand Down
1 change: 1 addition & 0 deletions src/env/node/git/shell.ts
@@ -1,6 +1,7 @@
import { ExecException, execFile } from 'child_process';
import { exists, existsSync, Stats, statSync } from 'fs';
import { join as joinPaths } from 'path';
import * as process from 'process';
import { decode } from 'iconv-lite';
import { Logger } from '../../../logger';

Expand Down
1 change: 1 addition & 0 deletions src/env/node/platform.ts
@@ -1,3 +1,4 @@
import * as process from 'process';
import { env, UIKind } from 'vscode';

export const isWeb = env.uiKind === UIKind.Web;
Expand Down
1 change: 1 addition & 0 deletions src/test/runTest.ts
@@ -1,4 +1,5 @@
import * as path from 'path';
import * as process from 'process';
import { runTests } from '@vscode/test-electron';

async function main() {
Expand Down

0 comments on commit aae54fd

Please sign in to comment.