diff --git a/app/client/.eslintrc.base.json b/app/client/.eslintrc.base.json index b075c619bc..70975b0a86 100644 --- a/app/client/.eslintrc.base.json +++ b/app/client/.eslintrc.base.json @@ -16,12 +16,14 @@ "react-hooks", "sort-destructure-keys", "cypress", + "testing-library", "jest" ], "extends": [ "plugin:react/recommended", // Uses the recommended rules from @eslint-plugin-react "plugin:@typescript-eslint/recommended", "plugin:cypress/recommended", + "plugin:testing-library/react", // Note: Please keep this as the last config to make sure that this (and by extension our .prettierrc file) overrides all configuration above it // https://www.npmjs.com/package/eslint-plugin-prettier#recommended-configuration "plugin:prettier/recommended" @@ -35,6 +37,13 @@ "project": "./tsconfig.json" }, "rules": { + "testing-library/consistent-data-testid": [ + "warn", + { + "testIdPattern": "^t--[a-zA-Z0-9_.-]*$", + "testIdAttribute": ["data-testid"] + } + ], "@typescript-eslint/consistent-type-definitions": "error", "@typescript-eslint/prefer-nullish-coalescing": "error", "@typescript-eslint/promise-function-async": "error", diff --git a/app/client/.eslintrc.js b/app/client/.eslintrc.js index 82f4f8f653..30bd6ceda3 100644 --- a/app/client/.eslintrc.js +++ b/app/client/.eslintrc.js @@ -13,6 +13,12 @@ const baseNoRestrictedImports = const eslintConfig = { extends: ["./.eslintrc.base.json"], rules: { + "testing-library/no-container": "off", + "testing-library/no-node-access": "off", + "testing-library/no-debugging-utils": "off", + "testing-library/prefer-screen-queries": "off", + "testing-library/render-result-naming-convention": "off", + "testing-library/no-unnecessary-act": "off", "@typescript-eslint/prefer-nullish-coalescing": "off", "@typescript-eslint/strict-boolean-expressions": "off", "@typescript-eslint/no-explicit-any": "off", diff --git a/app/client/package.json b/app/client/package.json index e980462b11..9fc3c1faf7 100644 --- a/app/client/package.json +++ b/app/client/package.json @@ -329,6 +329,7 @@ "eslint-plugin-react-hooks": "^4.6.0", "eslint-plugin-sort-destructure-keys": "^1.5.0", "eslint-plugin-storybook": "^0.6.15", + "eslint-plugin-testing-library": "^6.2.0", "esm": "^3.2.25", "factory.ts": "^0.5.1", "husky": "^8.0.0", diff --git a/app/client/packages/design-system/widgets-old/src/Dropdown/index.tsx b/app/client/packages/design-system/widgets-old/src/Dropdown/index.tsx index b05c7c33f2..ee8cc53117 100644 --- a/app/client/packages/design-system/widgets-old/src/Dropdown/index.tsx +++ b/app/client/packages/design-system/widgets-old/src/Dropdown/index.tsx @@ -858,6 +858,7 @@ export function RenderDropdownOptions(props: DropdownOptionsProps) { { render(