Skip to content

Commit

Permalink
Add eslint vitest plugin.
Browse files Browse the repository at this point in the history
  • Loading branch information
shammowla committed Dec 6, 2024
1 parent 821a59b commit 017be13
Show file tree
Hide file tree
Showing 4 changed files with 214 additions and 4 deletions.
14 changes: 14 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import globals from "globals";
import babelParser from "@babel/eslint-parser";
import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended";
import unusedImports from "eslint-plugin-unused-imports";
import vitestPlugin from "eslint-plugin-vitest";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
Expand All @@ -34,6 +35,7 @@ export default [
files: ["**/*.{mjs,js,jsx}"],
plugins: {
"unused-imports": unusedImports,
vitest: vitestPlugin,
},
languageOptions: {
parser: babelParser,
Expand All @@ -48,6 +50,14 @@ export default [
...globals.node,
fixture: true,
test: true,
describe: true,
it: true,
expect: true,
beforeEach: true,
afterEach: true,
beforeAll: true,
afterAll: true,
vi: true,
},
},
rules: {
Expand Down Expand Up @@ -115,6 +125,10 @@ export default [

"import/no-named-as-default-member": "off",
"import/no-named-as-default": "off",
"vitest/expect-expect": "error",
"vitest/no-disabled-tests": "warn",
"vitest/no-focused-tests": "error",
"vitest/no-identical-title": "error",
},
},
{
Expand Down
194 changes: 193 additions & 1 deletion 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 @@ -111,6 +111,7 @@
"eslint-plugin-react": "^7.37.2",
"eslint-plugin-testcafe": "^0.2.1",
"eslint-plugin-unused-imports": "^3.2.0",
"eslint-plugin-vitest": "^0.5.4",
"fs-extra": "^11.2.0",
"glob": "^11.0.0",
"globals": "^15.11.0",
Expand Down
9 changes: 6 additions & 3 deletions test/unit/lib/utils/numberAwareCompareFunction.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,11 @@ describe("numberAwareCompareFunction", () => {
});

it("handles non-strings", () => {
[undefined, null, 0, 42, { a: "foo" }, "foo"].sort(
numberAwareCompareFunction,
);
const values = [undefined, null, 0, 42, { a: "foo" }, "foo"];
const result = values.sort(numberAwareCompareFunction);
expect(result).toBeDefined();
expect(result).toHaveLength(values.length);
// Verify the function doesn't throw errors for non-string values
expect(() => values.sort(numberAwareCompareFunction)).not.toThrow();
});
});

0 comments on commit 017be13

Please sign in to comment.