Skip to content

Commit

Permalink
chore(linting): enable eslint-plugin-vitest (#11160)
Browse files Browse the repository at this point in the history
**Related Issue:** N/A

## Summary

This will replace `eslint-plugin-jest` rules that are no longer
applicable after #10310.
  • Loading branch information
jcfranco authored Dec 28, 2024
1 parent 43a9b30 commit 4a1ed6e
Show file tree
Hide file tree
Showing 8 changed files with 194 additions and 13 deletions.
185 changes: 185 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
"eslint-plugin-prettier": "5.2.1",
"eslint-plugin-react": "7.37.3",
"eslint-plugin-unicorn": "56.0.1",
"eslint-plugin-vitest": "0.5.4",
"globals": "15.13.0",
"globby": "14.0.2",
"happy-dom": "15.11.7",
Expand Down
7 changes: 4 additions & 3 deletions packages/calcite-components/eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import jsdocPlugin from "eslint-plugin-jsdoc";
import prettierPlugin from "eslint-plugin-prettier";
import reactPlugin from "eslint-plugin-react";
import unicornPlugin from "eslint-plugin-unicorn";
import vitestPlugin from "eslint-plugin-vitest";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
Expand All @@ -29,6 +30,7 @@ export default [

...compat.extends("eslint:recommended", "plugin:@typescript-eslint/recommended", "prettier"),

vitestPlugin.configs.recommended,
cspellPluginRecommended,
jestPlugin.configs["flat/recommended"],
jsdocPlugin.configs["flat/recommended"],
Expand All @@ -44,6 +46,7 @@ export default [
jest: jestPlugin,
prettier: prettierPlugin,
unicorn: unicornPlugin,
vitest: vitestPlugin,
},

languageOptions: {
Expand Down Expand Up @@ -133,9 +136,6 @@ export default [
},
],

"jest/expect-expect": "off",
"jest/no-export": "warn",

curly: "error",
"one-var": ["error", "never"],
"no-eval": "error",
Expand Down Expand Up @@ -232,6 +232,7 @@ export default [
checkFilenames: false,
},
],
"vitest/expect-expect": "off",
},
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ describe("calcite-dialog", () => {
]);
});

describe("accessible", async () => {
describe("accessible", () => {
accessible(async () => {
const page = await newE2EPage();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -953,18 +953,18 @@ describe("calcite-input-time-picker", () => {
await page.waitForChanges();

expect(await popoverPositionContainer.isVisible()).toBe(true);
expect(await isElementFocused(page, "calcite-input-text", { shadowed: true }));
expect(await isElementFocused(page, "calcite-input-text", { shadowed: true })).toBe(true);

await inputTimePicker.click();
await page.waitForChanges();

expect(await popoverPositionContainer.isVisible()).toBe(false);
expect(await isElementFocused(page, "calcite-input-text", { shadowed: true }));
expect(await isElementFocused(page, "calcite-input-text", { shadowed: true })).toBe(true);

await input.click();
await page.waitForChanges();

expect(await isElementFocused(page, "calcite-input-text", { shadowed: true }));
expect(await isElementFocused(page, "calcite-input-text", { shadowed: true })).toBe(true);
});

it("toggles the time picker when using arrow down/escape key", async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable jest/no-conditional-expect -- Using conditional logic in a confined test helper to handle specific scenarios, reducing duplication, balancing test readability and maintainability. **/
import { describe, expect, it } from "vitest";
import { minMaxLengthTypes, minMaxStepTypes, patternTypes, syncHiddenFormInput } from "./input";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable jest/no-conditional-expect -- Using conditional logic in a confined test helper to handle specific scenarios, reducing duplication, balancing test readability and maintainability. **/
import { LuminaJsx } from "@arcgis/lumina";
import { E2EElement, newE2EPage } from "@arcgis/lumina-compiler/puppeteerTesting";
import { expect, it } from "vitest";
Expand Down
4 changes: 0 additions & 4 deletions packages/calcite-components/src/utils/dom.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,12 +332,8 @@ describe("dom", () => {
const element = document.createElement("div");
document.body.append(element);
expect(hasVisibleContent(element)).toBe(false);
});

it("should return false if element has no visible content", () => {
const element = document.createElement("div");
element.innerHTML = "\n<!-- some comment -->\n";
document.body.append(element);
expect(hasVisibleContent(element)).toBe(false);
});
});
Expand Down

0 comments on commit 4a1ed6e

Please sign in to comment.