Skip to content

Commit b587e75

Browse files
authored
eslint: address more exceptions (#1291)
Related: #1225
1 parent 23f0dd1 commit b587e75

File tree

8 files changed

+41
-20
lines changed

8 files changed

+41
-20
lines changed

eslint.config.mjs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@ export default tseslint.config(
5050
"@typescript-eslint/no-namespace": "error",
5151
"@typescript-eslint/no-non-null-assertion": "error",
5252
"@typescript-eslint/no-unused-vars": "error",
53+
"no-case-declarations": "error",
54+
"no-constant-condition": "error",
5355
"no-control-regex": "error",
56+
"no-empty-function": "error",
5457
"no-prototype-builtins": "error",
5558
"tsdoc/syntax": "error",
5659
// Needed for tseslint.configs.strictTypeChecked
@@ -62,10 +65,6 @@ export default tseslint.config(
6265
// "@typescript-eslint/restrict-template-expressions": "error",
6366
// "@typescript-eslint/no-unsafe-argument": "error",
6467
// "@typescript-eslint/no-unsafe-return": "error",
65-
// Fix temporary off/warn made during eslint v9 upgrade:
66-
"no-empty-function": "warn",
67-
"no-case-declarations": "off",
68-
"no-constant-condition": "off",
6968
},
7069
},
7170
);

packages/ansible-language-server/src/services/executionEnvironment.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ export class ExecutionEnvironment {
548548

549549
private isPluginDocCacheValid(hostCacheBasePath: string) {
550550
const markerFilePath = path.join(hostCacheBasePath, this.successFileMarker);
551-
return true ? fs.existsSync(markerFilePath) : false;
551+
return fs.existsSync(markerFilePath);
552552
}
553553

554554
public get getBasicContainerAndImageDetails() {

packages/ansible-language-server/src/utils/docsFinder.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export async function findDocumentation(
5757
collection = "builtin";
5858
break;
5959
case "collection":
60-
case "collection_doc_fragment":
60+
case "collection_doc_fragment": {
6161
const pathArray = file.split(path.sep);
6262
const pluginsDirIndex = pathArray.indexOf("plugins");
6363
namespace = pathArray[pluginsDirIndex - 2];
@@ -70,6 +70,7 @@ export async function findDocumentation(
7070
collection = `${collection}.${subCollectionArray.join(".")}`;
7171
}
7272
break;
73+
}
7374
}
7475

7576
return new LazyModuleDocumentation(
@@ -104,15 +105,17 @@ export async function findPluginRouting(
104105
for (const file of files) {
105106
let collection;
106107
switch (kind) {
107-
case "builtin":
108+
case "builtin": {
108109
collection = "ansible.builtin";
109110
break;
110-
case "collection":
111+
}
112+
case "collection": {
111113
const pathArray = file.split(path.sep);
112114
collection = `${pathArray[pathArray.length - 4]}.${
113115
pathArray[pathArray.length - 3]
114116
}`;
115117
break;
118+
}
116119
}
117120
const runtimeContent = await fs.promises.readFile(file, {
118121
encoding: "utf8",

packages/ansible-language-server/test/utils/getAnsibleMetaData.test.ts

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -234,13 +234,29 @@ describe("getAnsibleMetaData()", () => {
234234

235235
describe("Verify ansible-lint details", () => {
236236
it("should contain all the keys for ansible-lint information", function () {
237+
expect(actualAnsibleMetaData["ansible-lint information"]);
237238
if (actualAnsibleMetaData["ansible-lint information"]) {
238-
expect(Object.keys(ansibleLintInfoForTest).length).equals(
239-
Object.keys(actualAnsibleMetaData["ansible-lint information"])
240-
.length,
239+
const expectedKeys = Object.keys(ansibleLintInfoForTest);
240+
const actualKeys = Object.keys(
241+
actualAnsibleMetaData["ansible-lint information"],
242+
);
243+
244+
const missingKeys = expectedKeys.filter(
245+
(key) => !actualKeys.includes(key),
246+
);
247+
248+
const extraKeys = actualKeys.filter(
249+
(key) => !expectedKeys.includes(key),
250+
);
251+
252+
expect(missingKeys).to.deep.equal(
253+
[],
254+
`Missing keys: ${missingKeys.join(", ")}`,
255+
);
256+
expect(extraKeys).to.deep.equal(
257+
[],
258+
`Extra keys: ${extraKeys.join(", ")}`,
241259
);
242-
} else {
243-
expect(false);
244260
}
245261
});
246262
it("should have information about ansible-lint version used", function () {

src/features/contentCreator/createAnsibleCollectionPage.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ export class CreateAnsibleCollection {
242242
let payload;
243243

244244
switch (command) {
245-
case "open-explorer":
245+
case "open-explorer": {
246246
payload = message.payload;
247247
const selectedUri = await this.openExplorerDialog(
248248
payload.selectOption,
@@ -252,6 +252,7 @@ export class CreateAnsibleCollection {
252252
arguments: { selectedUri: selectedUri },
253253
} as PostMessageEvent);
254254
return;
255+
}
255256

256257
case "check-ade-presence":
257258
await this.isADEPresent(webview);

src/features/contentCreator/createAnsibleProjectPage.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ export class CreateAnsibleProject {
231231
let payload;
232232

233233
switch (command) {
234-
case "open-explorer":
234+
case "open-explorer": {
235235
payload = message.payload;
236236
const selectedUri = await this.openExplorerDialog(
237237
payload.selectOption,
@@ -241,7 +241,7 @@ export class CreateAnsibleProject {
241241
arguments: { selectedUri: selectedUri },
242242
} as PostMessageEvent);
243243
return;
244-
244+
}
245245
case "init-create":
246246
payload = message.payload as AnsibleProjectFormInterface;
247247
await this.runInitCommand(payload, webview);

src/features/lightspeed/playbookGeneration.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export async function showPlaybookGenerationPage(
102102
panel.webview.onDidReceiveMessage(async (message) => {
103103
const command = message.command;
104104
switch (command) {
105-
case "generatePlaybook":
105+
case "generatePlaybook": {
106106
const playbook = await generatePlaybook(
107107
// TODO
108108
message.content,
@@ -114,7 +114,8 @@ export async function showPlaybookGenerationPage(
114114
panel?.dispose();
115115
await openNewPlaybookEditor(playbook);
116116
break;
117-
case "summarizeInput":
117+
}
118+
case "summarizeInput": {
118119
const summary = await summarizeInput(
119120
// TODO
120121
message.content,
@@ -125,6 +126,7 @@ export async function showPlaybookGenerationPage(
125126
);
126127
panel.webview.postMessage({ command: "summary", summary });
127128
break;
129+
}
128130
case "thumbsUp":
129131
case "thumbsDown":
130132
vscode.commands.executeCommand("ansible.lightspeed.thumbsUpDown");

src/webview/apps/contentCreator/welcomePageApp.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ function updateAnsibleCreatorAvailabilityStatus() {
5454
const message = event.data; // The JSON data our extension sent
5555

5656
switch (message.command) {
57-
case "systemDetails":
57+
case "systemDetails": {
5858
const systemDetails = message.arguments;
5959
const ansibleVersion = systemDetails["ansible version"];
6060
const ansibleLocation = systemDetails["ansible location"];
@@ -114,7 +114,7 @@ function updateAnsibleCreatorAvailabilityStatus() {
114114
ansibleDevEnvironmentStatusText.innerHTML = `<p class='not-found-optional'>[optional] ansible-dev-environment version: Not found</p>`;
115115
}
116116
installStatusDiv?.appendChild(ansibleDevEnvironmentStatusText);
117-
117+
}
118118
// <p>&#x2717; python version: ${pythonVersion}</p>
119119
// <p>&#x2717; python location: ${pythonLocation}</p>
120120
// <p>&#x2717; ansible-creator version: ${ansibleCreatorVersion}</p>

0 commit comments

Comments
 (0)