Skip to content

Commit

Permalink
Add eslint rule: Disallow unused variables (#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcomura authored Feb 14, 2025
1 parent 14ef897 commit fabd795
Show file tree
Hide file tree
Showing 37 changed files with 55 additions and 39 deletions.
6 changes: 6 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ module.exports = {
],
},
],
"no-unused-vars": ["error", {
"vars": "all",
"args": "none",
"caughtErrors": "all",
"ignoreRestSiblings": false,
}],
'brace-style': 'off',
curly: 'error',
eqeqeq: ['error', 'always'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export class BitbucketResponseHandler extends ResponseHandler {
email = primary[0].email;
}
}
} catch (e) {
} catch {
//ignore
}

Expand Down
6 changes: 3 additions & 3 deletions src/bitbucket/bitbucket-cloud/pullRequests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ export class CloudPullRequestApi implements PullRequestApi {
}

return accumulatedTasks.map((task: any) => this.convertDataToTask(task, pr.site));
} catch (e) {
} catch {
return [];
}
}
Expand Down Expand Up @@ -624,7 +624,7 @@ export class CloudPullRequestApi implements PullRequestApi {
});

return (data.values || []).map((reviewer: any) => CloudPullRequestApi.toUserModel(reviewer.user));
} catch (e) {
} catch {
return [];
}
}
Expand All @@ -648,7 +648,7 @@ export class CloudPullRequestApi implements PullRequestApi {
}

return teamMembers.map((m: any) => CloudPullRequestApi.toUserModel(m.user));
} catch (e) {
} catch {
return [];
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/bitbucket/bitbucket-server/pullRequests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ export class ServerPullRequestApi implements PullRequestApi {
} else {
return 1;
}
} catch (e) {
} catch {
return a.ts!! ? 1 : -1;
}
}),
Expand Down
2 changes: 1 addition & 1 deletion src/bitbucket/bitbucket-server/repositories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class ServerRepositoriesApi implements RepositoriesApi {
const { data } = await this.client.get(`/rest/mirroring/1.0/mirrorServers?limit=100`);

return data.values.map((val: any) => new URL(val.baseUrl).hostname);
} catch (e) {
} catch {
// ignore
}
return [];
Expand Down
2 changes: 1 addition & 1 deletion src/commands/jira/showIssue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export async function showIssueForKey(issueKey?: string) {
if (issueKey) {
try {
issue = await issueForKey(issueKey);
} catch (e) {
} catch {
//not found
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/jira/projectManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class JiraProjectManager extends Disposable {
try {
const client = await Container.clientManager.jiraClient(site);
return await client.getProject(projectKey);
} catch (e) {
} catch {
//continue
}

Expand All @@ -45,7 +45,7 @@ export class JiraProjectManager extends Disposable {
if (projects.length > 0) {
return projects[0];
}
} catch (e) {
} catch {
//continue
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ export class StartWorkWebviewController implements WebviewController<StartWorkIs
imgData: imgData,
nonce: msg.nonce,
} as any);
} catch (e) {
} catch {
this.logger.error(new Error(`error fetching image: ${msg.url}`));
this.postMessage({
type: 'getImageDone',
Expand Down
2 changes: 1 addition & 1 deletion src/react/atlascode/common/form/useFormValidation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export function useFormValidation<FieldTypes>(watch?: Partial<FieldTypes>): Form
const watchDefaults = useRef<Partial<FieldTypes>>(watch ? watch : {});
const watches = useRef<Partial<FieldTypes>>(watch ? watch : {});
const errors = useRef<Partial<Errors<FieldTypes>>>({});
const [_toggle, reRender] = useState(false);
const [, reRender] = useState(false);

const handleChange = useConstant(() => async (e: Event) => {
const field = fields[(e.target as InputElement).name];
Expand Down
2 changes: 1 addition & 1 deletion src/react/atlascode/config/auth/dialog/AuthDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ function isCustomUrl(url: string): boolean {
try {
const urlObj = new URL(url);
return cloudHostnames.every((host) => !urlObj.hostname.endsWith(host));
} catch (e) {
} catch {
return false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/react/atlascode/startwork/StartWorkPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ const StartWorkPage: React.FunctionComponent = () => {
setSubmitState('submit-success');
setSubmitResponse(response);
setSuccessSnackbarOpen(true);
} catch (e) {
} catch {
setSubmitState('initial');
}
}, [
Expand Down
3 changes: 2 additions & 1 deletion src/react/index-dev.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { createVSCodeTheme } from './vscode/theme/vscodeTheme';
// @ts-ignore
// __webpack_public_path__ is used to set the public path for the js files - https://webpack.js.org/guides/public-path/
declare var __webpack_public_path__: string;
// eslint-disable-next-line no-unused-vars
__webpack_public_path__ = `${document.baseURI!}build/`;

const routes = {
Expand Down Expand Up @@ -73,7 +74,7 @@ class VsCodeApi {
try {
var json = JSON.parse(message.data);
window.postMessage(json.data, '*');
} catch (e) {
} catch {
console.error('Invalid JSON: ', message.data);
return;
}
Expand Down
1 change: 1 addition & 0 deletions src/react/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { createVSCodeTheme } from './vscode/theme/vscodeTheme';
// @ts-ignore
// __webpack_public_path__ is used to set the public path for the js files - https://webpack.js.org/guides/public-path/
declare var __webpack_public_path__: string;
// eslint-disable-next-line no-unused-vars
__webpack_public_path__ = `${document.baseURI!}build/`;

const routes = {
Expand Down
4 changes: 2 additions & 2 deletions src/util/keychain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ function getNodeModule<T>(moduleName: string): T | undefined {
const vscodeRequire = eval('require');
try {
return vscodeRequire(`${vscode.env.appRoot}/node_modules.asar/${moduleName}`);
} catch (err) {
} catch {
// Not in ASAR.
}
try {
return vscodeRequire(`${vscode.env.appRoot}/node_modules/${moduleName}`);
} catch (err) {
} catch {
// Not available.
}
return undefined;
Expand Down
2 changes: 1 addition & 1 deletion src/views/BitbucketActivityMonitor.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
interface BitbucketActivityMonitor {
export interface BitbucketActivityMonitor {
checkForNewActivity(): void;
}
1 change: 1 addition & 0 deletions src/views/BitbucketExplorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { CreatePullRequestNode } from './pullrequest/headerNode';
import { DescriptionNode, PullRequestTitlesNode } from './pullrequest/pullRequestNode';
import { PullRequestNodeDataProvider } from './pullRequestNodeDataProvider';
import { RefreshTimer } from './RefreshTimer';
import { BitbucketActivityMonitor } from './BitbucketActivityMonitor';

export abstract class BitbucketExplorer extends Explorer implements Disposable {
private _disposable: Disposable;
Expand Down
1 change: 1 addition & 0 deletions src/views/bbissues/bbIssuesExplorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { BitbucketIssuesDataProvider } from '../bitbucketIssuesDataProvider';
import { BaseTreeDataProvider } from '../Explorer';
import { BitbucketIssuesMonitor } from './bbIssuesMonitor';
import { BitbucketSite } from '../../bitbucket/model';
import { BitbucketActivityMonitor } from '../BitbucketActivityMonitor';

export class BitbucketIssuesExplorer extends BitbucketExplorer {
constructor(ctx: BitbucketContext) {
Expand Down
1 change: 1 addition & 0 deletions src/views/bbissues/bbIssuesMonitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as vscode from 'vscode';
import { clientForSite } from '../../bitbucket/bbUtils';
import { BitbucketIssue, WorkspaceRepo } from '../../bitbucket/model';
import { Commands } from '../../commands';
import { BitbucketActivityMonitor } from '../BitbucketActivityMonitor';

export class BitbucketIssuesMonitor implements BitbucketActivityMonitor {
private _lastCheckedTime = new Map<String, Date>();
Expand Down
4 changes: 2 additions & 2 deletions src/views/gitContentProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class GitContentProvider implements vscode.TextDocumentContentProvider {
const absolutePath = pathlib.join(scm.rootUri.fsPath, path);
try {
return await scm.show(commitHash, absolutePath);
} catch (err) {
} catch {
await scm.fetch(wsRepo!.mainSiteRemote.remote.name, branchName);
return await scm.show(commitHash, absolutePath);
}
Expand All @@ -52,7 +52,7 @@ export class GitContentProvider implements vscode.TextDocumentContentProvider {
return fileContent;
})(),
]);
} catch (err) {
} catch {
vscode.window.showErrorMessage(
`We couldn't find ${path} at commit ${commitHash}. You may want to sync the branch with remote. Sometimes commits can disappear after a force-push.`,
);
Expand Down
4 changes: 2 additions & 2 deletions src/views/jira/activeIssueStatusBar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export class JiraActiveIssueStatusBar implements Disposable {
try {
const issue = (await getCachedIssue(parsedIssueKeys[0])) || (await issueForKey(parsedIssueKeys[0]));
this.updateStatusBarItem(issue);
} catch (e) {
} catch {
// do nothing
}
}
Expand All @@ -122,7 +122,7 @@ export class JiraActiveIssueStatusBar implements Disposable {
try {
const uriPath = fs.realpathSync(editor.document.uri.fsPath);
return uriPath.startsWith(repo.rootUri.fsPath);
} catch (e) {
} catch {
return false;
}
});
Expand Down
2 changes: 1 addition & 1 deletion src/views/jira/issueHoverProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class IssueHoverProvider implements HoverProvider {
let issue = undefined;
try {
issue = await issueForKey(key);
} catch (e) {
} catch {
return Promise.reject(`issue not found ${key}`);
}

Expand Down
1 change: 1 addition & 0 deletions src/views/pipelines/PipelinesExplorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { PipelinesMonitor } from './PipelinesMonitor';
import { Commands } from '../../commands';
import { BitbucketExplorer } from '../BitbucketExplorer';
import { BaseTreeDataProvider } from '../Explorer';
import { BitbucketActivityMonitor } from '../BitbucketActivityMonitor';

export class PipelinesExplorer extends BitbucketExplorer {
constructor(ctx: BitbucketContext) {
Expand Down
1 change: 1 addition & 0 deletions src/views/pipelines/PipelinesMonitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Commands } from '../../commands';
import { Container } from '../../container';
import { Pipeline, PipelineTarget } from '../../pipelines/model';
import { descriptionForState, generatePipelineTitle, shouldDisplay } from './Helpers';
import { BitbucketActivityMonitor } from '../BitbucketActivityMonitor';

export class PipelinesMonitor implements BitbucketActivityMonitor {
private _previousResults: Map<string, Pipeline[]> = new Map();
Expand Down
1 change: 1 addition & 0 deletions src/views/pullrequest/pullRequestCreatedMonitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { BitbucketContext } from '../../bitbucket/bbContext';
import { clientForSite } from '../../bitbucket/bbUtils';
import { Commands } from '../../commands';
import { Logger } from '../../logger';
import { BitbucketActivityMonitor } from '../BitbucketActivityMonitor';

export class PullRequestCreatedMonitor implements BitbucketActivityMonitor {
private _lastCheckedTime = new Map<String, Date>();
Expand Down
1 change: 1 addition & 0 deletions src/views/pullrequest/pullRequestsExplorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { BitbucketExplorer } from '../BitbucketExplorer';
import { BaseTreeDataProvider } from '../Explorer';
import { PullRequestNodeDataProvider } from '../pullRequestNodeDataProvider';
import { PullRequestCreatedMonitor } from './pullRequestCreatedMonitor';
import { BitbucketActivityMonitor } from '../BitbucketActivityMonitor';

export class PullRequestsExplorer extends BitbucketExplorer {
constructor(ctx: BitbucketContext) {
Expand Down
4 changes: 2 additions & 2 deletions src/webview/pullrequest/vscCreatePullRequestActionImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export class VSCCreatePullRequestActionApi implements CreatePullRequestActionApi
if (jiraIssueKeys.length > 0) {
try {
return await issueForKey(jiraIssueKeys[0]);
} catch (e) {
} catch {
//not found
}
}
Expand All @@ -125,7 +125,7 @@ export class VSCCreatePullRequestActionApi implements CreatePullRequestActionApi
try {
const bbApi = await clientForSite(site);
commits = await bbApi.repositories.getCommitsForRefs(site, sourceBranchName, destinationBranchName);
} catch (e) {}
} catch {}

const shell = new Shell(Uri.parse(wsRepo.rootUri).fsPath);
const diff = await shell.output(
Expand Down
4 changes: 2 additions & 2 deletions src/webview/startwork/vscStartWorkActionApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ export class VSCStartWorkActionApi implements StartWorkActionApi {
await scm.getBranch(destinationBranch);
await scm.checkout(destinationBranch);
return;
} catch (_) {}
} catch {}

// checkout if there's a matching remote branch (checkout will track remote branch automatically)
try {
await scm.getBranch(`remotes/${remote}/${destinationBranch}`);
await scm.checkout(destinationBranch);
return;
} catch (_) {}
} catch {}

// no existing branches, create a new one
await scm.createBranch(
Expand Down
1 change: 0 additions & 1 deletion src/webviews/components/WebviewComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ interface VsCodeApi {

declare function acquireVsCodeApi(): VsCodeApi;

export interface WebviewComponent<A extends Action, R, P = {}, S = {}> extends React.Component<P, S> {}
// WebviewComponent is the base React component for creating a webview in vscode.
// This handles comms between vscode and react.
// Generic Types:
Expand Down
2 changes: 1 addition & 1 deletion src/webviews/components/fieldValidators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export function validateUrl(value: string, state?: any): string | undefined {
if (url.hostname === '') {
err = 'NOT_URL';
}
} catch (e) {
} catch {
err = 'NOT_URL';
}

Expand Down
3 changes: 2 additions & 1 deletion src/webviews/components/index-dev.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import './App.css';
// @ts-ignore
// __webpack_public_path__ is used to set the public path for the js files - https://webpack.js.org/guides/public-path/
declare var __webpack_public_path__: string;
// eslint-disable-next-line no-unused-vars
__webpack_public_path__ = `${document.baseURI!}build/`;

const routes = {
Expand Down Expand Up @@ -35,7 +36,7 @@ class VsCodeApi {
try {
var json = JSON.parse(message.data);
window.postMessage(json.data, '*');
} catch (e) {
} catch {
return;
}
};
Expand Down
1 change: 1 addition & 0 deletions src/webviews/components/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import './App.css';
// @ts-ignore
// __webpack_public_path__ is used to set the public path for the js files - https://webpack.js.org/guides/public-path/
declare var __webpack_public_path__: string;
// eslint-disable-next-line no-unused-vars
__webpack_public_path__ = `${document.baseURI!}build/`;

const routes = {
Expand Down
6 changes: 3 additions & 3 deletions src/webviews/components/issue/AbstractIssueEditorPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ export abstract class AbstractIssueEditorPage<
nonce,
);
resolve((listEvent as IssueSuggestionsList).issues);
} catch (e) {
} catch {
resolve([]);
}
})();
Expand Down Expand Up @@ -322,7 +322,7 @@ export abstract class AbstractIssueEditorPage<

this.setState({ isSomethingLoading: false });
resolve(listEvent.options);
} catch (e) {
} catch {
this.setState({ isSomethingLoading: false });
resolve([]);
}
Expand Down Expand Up @@ -364,7 +364,7 @@ export abstract class AbstractIssueEditorPage<
...createEvent.selectFieldOptions,
},
});
} catch (e) {
} catch {
this.setState({ isSomethingLoading: false });
}
})();
Expand Down
2 changes: 1 addition & 1 deletion src/webviews/components/issue/JiraIssuePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,7 @@ export default class JiraIssuePage extends AbstractIssueEditorPage<Emit, Accept,
try {
created = `Created ${formatDistanceToNow(parseISO(this.state.fieldValues['created']))} ago`;
updated = `Updated ${formatDistanceToNow(parseISO(this.state.fieldValues['updated']))} ago`;
} catch (e) {
} catch {
created = this.state.fieldValues['created.rendered'] || this.state.fieldValues['created'];
updated = this.state.fieldValues['updated.rendered'] || this.state.fieldValues['updated'];
}
Expand Down
2 changes: 1 addition & 1 deletion src/webviews/jiraIssueWebview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,7 @@ export class JiraIssueWebview
imgData: imgData,
nonce: msg.nonce,
});
} catch (e) {
} catch {
Logger.error(new Error(`error fetching image: ${msg.url}`));
this.postMessage({
type: 'getImageDone',
Expand Down
Loading

0 comments on commit fabd795

Please sign in to comment.