Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update eslint and minimal ruleset #896

Merged
merged 1 commit into from
Jan 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
node_modules
out
testFixture
**/*/__mocks__
**/*.d.ts
13 changes: 11 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
{
"env": { "browser": true, "es6": true, "node": true },
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module"
},
"plugins": ["@typescript-eslint", "prettier"],
"extends": [
"eslint:recommended",
Expand All @@ -11,6 +14,12 @@
"prettier"
],
"rules": {
"@typescript-eslint/no-explicit-any": ["warn", { "ignoreRestArgs": true }]
"@typescript-eslint/no-explicit-any": ["warn", { "ignoreRestArgs": true }],
"@typescript-eslint/naming-convention": "warn",
"@typescript-eslint/semi": "warn",
"curly": "warn",
"eqeqeq": "warn",
"no-throw-literal": "warn",
"semi": "off"
}
}
431 changes: 191 additions & 240 deletions package-lock.json

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -353,12 +353,12 @@
"@types/vscode": "^1.52.0",
"@types/which": "^2.0.1",
"@types/yauzl": "^2.9.1",
"@typescript-eslint/eslint-plugin": "^3.9.0",
"@typescript-eslint/parser": "^3.9.0",
"@typescript-eslint/eslint-plugin": "^5.9.0",
"@typescript-eslint/parser": "^5.9.0",
"chai": "^4.3.4",
"eslint": "^7.32.0",
"eslint": "^8.6.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^3.4.1",
"eslint-plugin-prettier": "^4.0.0",
"glob": "^7.1.6",
"jest": "^27.4.3",
"mocha": "^9.1.3",
Expand All @@ -369,4 +369,4 @@
"vsce": "^1.93.0",
"vscode-test": "^1.5.2"
}
}
}
14 changes: 7 additions & 7 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,13 +244,13 @@ function execWorkspaceCommand(client: LanguageClient, params: ExecuteCommandPara
return client.sendRequest(ExecuteCommandRequest.type, params);
}

interface moduleCaller {
interface ModuleCaller {
uri: string;
}

interface moduleCallersResponse {
interface ModuleCallersResponse {
version: number;
moduleCallers: moduleCaller[];
moduleCallers: ModuleCaller[];
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand All @@ -262,7 +262,7 @@ async function modulesCallersCommand(languageClient: TerraformLanguageClient, mo
return execWorkspaceCommand(languageClient.client, requestParams);
}

export async function moduleCallers(moduleUri: string): Promise<moduleCallersResponse> {
export async function moduleCallers(moduleUri: string): Promise<ModuleCallersResponse> {
const client = clientHandler.getClient();
if (client === undefined) {
return {
Expand All @@ -272,7 +272,7 @@ export async function moduleCallers(moduleUri: string): Promise<moduleCallersRes
}

const response = await modulesCallersCommand(client, moduleUri);
const moduleCallers: moduleCaller[] = response.callers;
const moduleCallers: ModuleCaller[] = response.callers;

return { version: response.v, moduleCallers };
}
Expand All @@ -296,7 +296,7 @@ async function terraformCommand(command: string, languageServerExec = true): Pro
}

selectedModule = selected;
} else if (response.moduleCallers.length == 1) {
} else if (response.moduleCallers.length === 1) {
selectedModule = response.moduleCallers[0].uri;
} else {
selectedModule = moduleUri.toString();
Expand All @@ -317,7 +317,7 @@ async function terraformCommand(command: string, languageServerExec = true): Pro
});
if (terraformCommand) {
const terminal =
vscode.window.terminals.find((t) => t.name == terminalName) ||
vscode.window.terminals.find((t) => t.name === terminalName) ||
vscode.window.createTerminal({ name: `Terraform ${selectedModule}`, cwd: moduleURI });
terminal.sendText(terraformCommand);
terminal.show();
Expand Down
8 changes: 6 additions & 2 deletions src/providers/moduleCalls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Utils } from 'vscode-uri';
import { ClientHandler } from '../clientHandler';
import { getActiveTextEditor, isTerraformFile } from '../vscodeUtils';

/* eslint-disable @typescript-eslint/naming-convention */
interface ModuleCall {
name: string;
source_addr: string;
Expand All @@ -13,11 +14,14 @@ interface ModuleCall {
docs_link?: string;
dependent_modules: ModuleCall[];
}
/* eslint-enable @typescript-eslint/naming-convention */

/* eslint-disable @typescript-eslint/naming-convention */
interface ModuleCallsResponse {
v: number;
module_calls: ModuleCall[];
}
/* eslint-enable @typescript-eslint/naming-convention */

class ModuleCallItem extends vscode.TreeItem {
constructor(
Expand Down Expand Up @@ -148,7 +152,7 @@ export class ModuleCallsDataProvider implements vscode.TreeDataProvider<ModuleCa
ExecuteCommandRequest.type,
params,
);
if (response == null) {
if (response === null) {
return Promise.resolve([]);
}

Expand All @@ -170,7 +174,7 @@ export class ModuleCallsDataProvider implements vscode.TreeDataProvider<ModuleCa
dependents: ModuleCall[],
): ModuleCallItem {
let deps: ModuleCallItem[] = [];
if (dependents.length != 0) {
if (dependents.length !== 0) {
deps = dependents.map((dp) =>
this.toModuleCall(
dp.name,
Expand Down
2 changes: 2 additions & 0 deletions src/providers/moduleProviders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { ExecuteCommandParams, ExecuteCommandRequest } from 'vscode-languageclie
import { ClientHandler } from '../clientHandler';
import { getActiveTextEditor, isTerraformFile } from '../vscodeUtils';

/* eslint-disable @typescript-eslint/naming-convention */
interface ModuleProvidersResponse {
v: number;
provider_requirements: {
Expand All @@ -18,6 +19,7 @@ interface ModuleProvidersResponse {
[provider: string]: string;
};
}
/* eslint-enable @typescript-eslint/naming-convention */

class ModuleProviderItem extends vscode.TreeItem {
constructor(
Expand Down
2 changes: 1 addition & 1 deletion src/telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type TelemetryEvent = {
export class TelemetryFeature implements StaticFeature {
constructor(private client: BaseLanguageClient, reporter: TelemetryReporter) {
this.client.onTelemetry((event: TelemetryEvent) => {
if (event.v != TELEMETRY_VERSION) {
if (event.v !== TELEMETRY_VERSION) {
console.log(`unsupported telemetry event: ${event}`);
return;
}
Expand Down
16 changes: 10 additions & 6 deletions src/test/unit/detector.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('terraform release detector', () => {
test('returns valid release', async () => {
const name = 'terraform-ls';
const shasums = 'terraform-ls_0.24.0_SHA256SUMS';
const shasums_signature = 'terraform-ls_0.24.0_SHA256SUMS.72D7468F.sig';
const shasumsSignature = 'terraform-ls_0.24.0_SHA256SUMS.72D7468F.sig';
const version = '0.24.0';
const buildInfo = {
arch: 'amd64',
Expand All @@ -28,7 +28,8 @@ describe('terraform release detector', () => {
builds: [buildInfo],
name: name,
shasums: shasums,
shasums_signature: shasums_signature,
// eslint-disable-next-line @typescript-eslint/naming-convention
shasums_signature: shasumsSignature,
version: version,
getBuild: jest.fn(),
download: jest.fn(),
Expand All @@ -43,7 +44,8 @@ describe('terraform release detector', () => {
builds: [buildInfo],
name: name,
shasums: shasums,
shasums_signature: shasums_signature,
// eslint-disable-next-line @typescript-eslint/naming-convention
shasums_signature: shasumsSignature,
version: version,
};

Expand All @@ -55,7 +57,7 @@ describe('terraform release detector', () => {
test('returns latest if invalid version', async () => {
const name = 'terraform-ls';
const shasums = 'terraform-ls_0.24.0_SHA256SUMS';
const shasums_signature = 'terraform-ls_0.24.0_SHA256SUMS.72D7468F.sig';
const shasumsSignature = 'terraform-ls_0.24.0_SHA256SUMS.72D7468F.sig';
const version = '0.24.0';
const buildInfo = {
arch: 'amd64',
Expand All @@ -75,7 +77,8 @@ describe('terraform release detector', () => {
builds: [buildInfo],
name: name,
shasums: shasums,
shasums_signature: shasums_signature,
// eslint-disable-next-line @typescript-eslint/naming-convention
shasums_signature: shasumsSignature,
version: version,
getBuild: jest.fn(),
download: jest.fn(),
Expand All @@ -90,7 +93,8 @@ describe('terraform release detector', () => {
builds: [buildInfo],
name: name,
shasums: shasums,
shasums_signature: shasums_signature,
// eslint-disable-next-line @typescript-eslint/naming-convention
shasums_signature: shasumsSignature,
version: version,
};

Expand Down
4 changes: 4 additions & 0 deletions src/test/unit/updater.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ describe('terraform-ls updater', () => {
return {
name: 'foo',
shasums: '',
// eslint-disable-next-line @typescript-eslint/naming-convention
shasums_signature: '',
version: '',
builds: [],
Expand Down Expand Up @@ -88,6 +89,7 @@ describe('terraform-ls updater', () => {
return {
name: 'terraform-ls',
version: '0.24.0',
// eslint-disable-next-line @typescript-eslint/naming-convention
shasums_signature: '',
builds: [],
getBuild: jest.fn(),
Expand Down Expand Up @@ -130,6 +132,7 @@ describe('terraform-ls updater', () => {
return {
name: 'terraform-ls',
version: '0.24.0',
// eslint-disable-next-line @typescript-eslint/naming-convention
shasums_signature: '',
builds: [],
getBuild: jest.fn(),
Expand Down Expand Up @@ -249,6 +252,7 @@ describe('terraform-ls updater', () => {
return {
name: 'terraform-ls',
version: '0.24.0',
// eslint-disable-next-line @typescript-eslint/naming-convention
shasums_signature: '',
builds: [],
getBuild: jest.fn(),
Expand Down