Skip to content

Commit

Permalink
eslint: address more exceptions (#1291)
Browse files Browse the repository at this point in the history
Related: #1225
  • Loading branch information
ssbarnea committed May 2, 2024
1 parent 23f0dd1 commit b587e75
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 20 deletions.
7 changes: 3 additions & 4 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ export default tseslint.config(
"@typescript-eslint/no-namespace": "error",
"@typescript-eslint/no-non-null-assertion": "error",
"@typescript-eslint/no-unused-vars": "error",
"no-case-declarations": "error",
"no-constant-condition": "error",
"no-control-regex": "error",
"no-empty-function": "error",
"no-prototype-builtins": "error",
"tsdoc/syntax": "error",
// Needed for tseslint.configs.strictTypeChecked
Expand All @@ -62,10 +65,6 @@ export default tseslint.config(
// "@typescript-eslint/restrict-template-expressions": "error",
// "@typescript-eslint/no-unsafe-argument": "error",
// "@typescript-eslint/no-unsafe-return": "error",
// Fix temporary off/warn made during eslint v9 upgrade:
"no-empty-function": "warn",
"no-case-declarations": "off",
"no-constant-condition": "off",
},
},
);
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ export class ExecutionEnvironment {

private isPluginDocCacheValid(hostCacheBasePath: string) {
const markerFilePath = path.join(hostCacheBasePath, this.successFileMarker);
return true ? fs.existsSync(markerFilePath) : false;
return fs.existsSync(markerFilePath);
}

public get getBasicContainerAndImageDetails() {
Expand Down
9 changes: 6 additions & 3 deletions packages/ansible-language-server/src/utils/docsFinder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export async function findDocumentation(
collection = "builtin";
break;
case "collection":
case "collection_doc_fragment":
case "collection_doc_fragment": {
const pathArray = file.split(path.sep);
const pluginsDirIndex = pathArray.indexOf("plugins");
namespace = pathArray[pluginsDirIndex - 2];
Expand All @@ -70,6 +70,7 @@ export async function findDocumentation(
collection = `${collection}.${subCollectionArray.join(".")}`;
}
break;
}
}

return new LazyModuleDocumentation(
Expand Down Expand Up @@ -104,15 +105,17 @@ export async function findPluginRouting(
for (const file of files) {
let collection;
switch (kind) {
case "builtin":
case "builtin": {
collection = "ansible.builtin";
break;
case "collection":
}
case "collection": {
const pathArray = file.split(path.sep);
collection = `${pathArray[pathArray.length - 4]}.${
pathArray[pathArray.length - 3]
}`;
break;
}
}
const runtimeContent = await fs.promises.readFile(file, {
encoding: "utf8",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,13 +234,29 @@ describe("getAnsibleMetaData()", () => {

describe("Verify ansible-lint details", () => {
it("should contain all the keys for ansible-lint information", function () {
expect(actualAnsibleMetaData["ansible-lint information"]);
if (actualAnsibleMetaData["ansible-lint information"]) {
expect(Object.keys(ansibleLintInfoForTest).length).equals(
Object.keys(actualAnsibleMetaData["ansible-lint information"])
.length,
const expectedKeys = Object.keys(ansibleLintInfoForTest);
const actualKeys = Object.keys(
actualAnsibleMetaData["ansible-lint information"],
);

const missingKeys = expectedKeys.filter(
(key) => !actualKeys.includes(key),
);

const extraKeys = actualKeys.filter(
(key) => !expectedKeys.includes(key),
);

expect(missingKeys).to.deep.equal(
[],
`Missing keys: ${missingKeys.join(", ")}`,
);
expect(extraKeys).to.deep.equal(
[],
`Extra keys: ${extraKeys.join(", ")}`,
);
} else {
expect(false);
}
});
it("should have information about ansible-lint version used", function () {
Expand Down
3 changes: 2 additions & 1 deletion src/features/contentCreator/createAnsibleCollectionPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ export class CreateAnsibleCollection {
let payload;

switch (command) {
case "open-explorer":
case "open-explorer": {
payload = message.payload;
const selectedUri = await this.openExplorerDialog(
payload.selectOption,
Expand All @@ -252,6 +252,7 @@ export class CreateAnsibleCollection {
arguments: { selectedUri: selectedUri },
} as PostMessageEvent);
return;
}

case "check-ade-presence":
await this.isADEPresent(webview);
Expand Down
4 changes: 2 additions & 2 deletions src/features/contentCreator/createAnsibleProjectPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ export class CreateAnsibleProject {
let payload;

switch (command) {
case "open-explorer":
case "open-explorer": {
payload = message.payload;
const selectedUri = await this.openExplorerDialog(
payload.selectOption,
Expand All @@ -241,7 +241,7 @@ export class CreateAnsibleProject {
arguments: { selectedUri: selectedUri },
} as PostMessageEvent);
return;

}
case "init-create":
payload = message.payload as AnsibleProjectFormInterface;
await this.runInitCommand(payload, webview);
Expand Down
6 changes: 4 additions & 2 deletions src/features/lightspeed/playbookGeneration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export async function showPlaybookGenerationPage(
panel.webview.onDidReceiveMessage(async (message) => {
const command = message.command;
switch (command) {
case "generatePlaybook":
case "generatePlaybook": {
const playbook = await generatePlaybook(
// TODO
message.content,
Expand All @@ -114,7 +114,8 @@ export async function showPlaybookGenerationPage(
panel?.dispose();
await openNewPlaybookEditor(playbook);
break;
case "summarizeInput":
}
case "summarizeInput": {
const summary = await summarizeInput(
// TODO
message.content,
Expand All @@ -125,6 +126,7 @@ export async function showPlaybookGenerationPage(
);
panel.webview.postMessage({ command: "summary", summary });
break;
}
case "thumbsUp":
case "thumbsDown":
vscode.commands.executeCommand("ansible.lightspeed.thumbsUpDown");
Expand Down
4 changes: 2 additions & 2 deletions src/webview/apps/contentCreator/welcomePageApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function updateAnsibleCreatorAvailabilityStatus() {
const message = event.data; // The JSON data our extension sent

switch (message.command) {
case "systemDetails":
case "systemDetails": {
const systemDetails = message.arguments;
const ansibleVersion = systemDetails["ansible version"];
const ansibleLocation = systemDetails["ansible location"];
Expand Down Expand Up @@ -114,7 +114,7 @@ function updateAnsibleCreatorAvailabilityStatus() {
ansibleDevEnvironmentStatusText.innerHTML = `<p class='not-found-optional'>[optional] ansible-dev-environment version: Not found</p>`;
}
installStatusDiv?.appendChild(ansibleDevEnvironmentStatusText);

}
// <p>&#x2717; python version: ${pythonVersion}</p>
// <p>&#x2717; python location: ${pythonLocation}</p>
// <p>&#x2717; ansible-creator version: ${ansibleCreatorVersion}</p>
Expand Down

0 comments on commit b587e75

Please sign in to comment.