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

test: more eslint plugins #12

Merged
merged 3 commits into from
Jun 3, 2024
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
28 changes: 23 additions & 5 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,34 @@

import pluginJs from "@eslint/js";
// @ts-expect-error no types for this plugin
import configPrettier from "eslint-config-prettier";
// @ts-expect-error no types for this plugin
import pluginBetterMutation from "eslint-plugin-better-mutation";
// @ts-expect-error no types for this plugin
import pluginJest from "eslint-plugin-jest";
// @ts-expect-error no types for this plugin
import pluginJestDom from "eslint-plugin-jest-dom";
// @ts-expect-error no types for this plugin
import pluginJsxA11y from "eslint-plugin-jsx-a11y";
// @ts-expect-error no types for this plugin
import pluginReactHooks from "eslint-plugin-react-hooks";
// @ts-expect-error no types for this plugin
import pluginReactConfig from "eslint-plugin-react/configs/jsx-runtime.js";
import pluginReactJsx from "eslint-plugin-react/configs/jsx-runtime.js";
// @ts-expect-error no types for this plugin
import pluginReactRecommended from "eslint-plugin-react/configs/recommended.js";
// @ts-expect-error no types for this plugin
import pluginTestingLibrary from "eslint-plugin-testing-library";
import globals from "globals";
import tseslint from "typescript-eslint";

export default tseslint.config(
pluginJs.configs.recommended,
...tseslint.configs.strictTypeChecked,
...tseslint.configs.stylisticTypeChecked,
pluginReactConfig,
// jsx-runtime only disables rules, so need both recommended and jsx.
pluginReactRecommended,
pluginReactJsx,
configPrettier,
{
ignores: ["*", "!js/", "!*.ts", "!*.mjs"],
},
Expand Down Expand Up @@ -70,16 +81,23 @@ export default tseslint.config(
},
{
files: ["js/test/", "js/**/*.test.*"],
// we use both jest's recommended and style rules, but only need to set the plugin once here,
// and it doesn't matter which config we get the plugin from.
...pluginJest.configs["flat/recommended"],
plugins: {
jest: pluginJest,
"jest-dom": pluginJestDom,
"testing-library": pluginTestingLibrary,
},
rules: {
...pluginJest.configs["flat/style"].rules,
...pluginJest.configs["flat/recommended"].rules,
...pluginJestDom.configs["flat/recommended"].rules,
...pluginTestingLibrary.configs.react.rules,
// empty functions are fine
"@typescript-eslint/no-empty-function": "off",
// expect.any is untyped and triggers this all the time.
"@typescript-eslint/no-unsafe-assignment": "off",
/* we do `view = render(); view.getBy()` which also doesn't require destructuring
and has less global mutable state than `screen`. */
"testing-library/prefer-screen-queries": "off",
},
},
{
Expand Down
213 changes: 213 additions & 0 deletions package-lock.json

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

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,14 @@
"@types/phoenix": "^1.6.4",
"@types/phoenix_live_view": "^0.18.5",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-better-mutation": "^1.4.1",
"eslint-plugin-jest": "^28.5.0",
"eslint-plugin-jest-dom": "^5.4.0",
"eslint-plugin-jsx-a11y": "^6.8.0",
"eslint-plugin-react": "^7.34.2",
"eslint-plugin-react-hooks": "^4.6.2",
"eslint-plugin-testing-library": "^6.2.2",
"globals": "^15.3.0",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
Expand Down
Loading