{"id":14978216,"url":"https://github.com/maks-rafalko/eslint-plugin-proper-tests","last_synced_at":"2025-10-28T08:32:00.077Z","repository":{"id":246733179,"uuid":"822306794","full_name":"maks-rafalko/eslint-plugin-proper-tests","owner":"maks-rafalko","description":"ESLint rules for writing more proper tests.","archived":false,"fork":false,"pushed_at":"2024-10-10T22:29:43.000Z","size":39,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-10T22:44:58.603Z","etag":null,"topics":["eslint","eslint-plugin","eslintplugin","jest","rules"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/eslint-plugin-proper-tests","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/maks-rafalko.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-30T21:44:22.000Z","updated_at":"2024-10-10T22:29:46.000Z","dependencies_parsed_at":"2024-07-10T15:56:49.618Z","dependency_job_id":null,"html_url":"https://github.com/maks-rafalko/eslint-plugin-proper-tests","commit_stats":null,"previous_names":["maks-rafalko/eslint-plugin-proper-tests"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maks-rafalko%2Feslint-plugin-proper-tests","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maks-rafalko%2Feslint-plugin-proper-tests/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maks-rafalko%2Feslint-plugin-proper-tests/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maks-rafalko%2Feslint-plugin-proper-tests/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maks-rafalko","download_url":"https://codeload.github.com/maks-rafalko/eslint-plugin-proper-tests/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219859904,"owners_count":16556031,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["eslint","eslint-plugin","eslintplugin","jest","rules"],"created_at":"2024-09-24T13:57:05.099Z","updated_at":"2025-10-28T08:32:00.068Z","avatar_url":"https://github.com/maks-rafalko.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://eslint.org/\"\u003e\n    \u003cimg alt=\"eslint\" height=\"150\" src=\"https://eslint.org/assets/images/logo/eslint-logo-color.svg\"\u003e\n  \u003c/a\u003e\n  \u003ch1\u003eeslint-plugin-proper-tests\u003c/h1\u003e\n  \u003cp\u003eESLint plugin for writing proper tests\u003c/p\u003e\n\u003c/div\u003e\n\n## Installation\n\n```bash\nnpm install -D eslint-plugin-proper-tests\n```\n\n\u003e [!NOTE]  \n\u003e For `@typescript-eslint` v7 use version ^1.0.0 of this plugin.\n\u003e For `@typescript-eslint` v8 use version ^2.0.0 of this plugin.\n\u003e For ESLint 9 and flat config use version ^2.1.0 of this plugin.\n\n## Usage\n\nFlat configuration format:\n\nWith flat configuration, use the `flat/recommended` shared config in your `eslint.config.mjs` configuration file:\n\n```js\nimport pluginProperTests from 'eslint-plugin-proper-tests';\n\nexport default [\n    {\n        ...pluginProperTests.configs['flat/recommended']\n    },\n]\n```\n\nRun ESLint and enjoy the results.\n\nOr, alternatively, add `proper-tests` to the plugins section of your `eslint.config.mjs` configuration file and configure the rules one by one:\n\n```js\nimport pluginProperTests from 'eslint-plugin-proper-tests';\n\nexport default [\n    {\n        plugins: {\n            'proper-tests': pluginProperTests,\n        },\n        rules: {\n            \"proper-tests/no-useless-matcher-to-be-defined\": \"error\"\n            // other rules...\n        }\n    },\n]\n```\n\nOld configuration format:\n\nWith old configuration, use the `recommended` shared config in your `.eslintrc` configuration file:\n\n```js\nmodule.exports = {\n  \"extends\": [\"plugin:proper-tests/recommended\"]\n}\n```\n\nand you are good to go. Run ESLint and enjoy the results.\n\nOr, alternatively, add `proper-tests` to the plugins section of your `.eslintrc` configuration file:\n\n```js\nmodule.exports = {\n  \"plugins\": [\"proper-tests\"],\n  // ...  \n}\n```\n\nand configure the rules one by one:\n\n```js\nmodule.exports = {\n  \"plugins\": [\"proper-tests\"],\n  \"rules\": {\n    \"proper-tests/no-useless-matcher-to-be-defined\": \"error\"\n  }\n}\n```\n\n## Power of Types\n\nThis plugin uses TypeScript to provide more accurate results. To enable this, you need to [configure ESLint to work with TypeScript](https://typescript-eslint.io/getting-started/typed-linting):\n\nFlat configuration format:\n\n```js\nimport pluginProperTests from 'eslint-plugin-proper-tests';\n\nexport default [\n    {\n        languageOptions: {\n            parserOptions: { project: true },\n        },\n    },\n    // ...\n]\n```\n\nOld configuration format:\n\n```js\nmodule.exports = {\n  \"parser\": \"@typescript-eslint/parser\",\n  \"parserOptions\": {\n    \"project\": true,\n    \"tsconfigRootDir\": __dirname,\n  }\n}\n```\n\nIf `parserOptions` is not configured, you will get an error:\n\n```shell\nError while loading rule 'proper-tests/no-useless-matcher-to-be-defined': You have used a rule which requires type information, \nbut don't have parserOptions set to generate type information for this file\n```\n\n## Running rules only on test-related files\n\nThe rules provided by this plugin assume that the files they are checking are\ntest-related. This means it's generally not suitable to include them in your\ntop-level configuration as that applies to all files being linted which can\ninclude source files.\n\nFlat configuration format:\n\nFor `eslint.config.mjs` configs you can use the following syntax:\n\n```js\nimport pluginProperTests from 'eslint-plugin-proper-tests';\n\nexport default [\n    {\n        files: ['**/*.test.ts'], // limit rules to test files only\n        ...pluginProperTests.configs['flat/recommended']\n    },\n]\n```\n\nOld configuration format:\n\nFor `.eslintrc` configs you can use\n[overrides](https://eslint.org/docs/user-guide/configuring/configuration-files#how-do-overrides-work)\nto have ESLint apply additional rules to specific files:\n\n```js\nmodule.exports = {\n  \"extends\": [\"eslint:recommended\"],\n  \"overrides\": [\n    {\n      \"files\": [\"test/**\"],\n      \"plugins\": [\"proper-tests\"],\n      \"extends\": [\"plugin:proper-tests/recommended\"],\n      \"rules\": { \"proper-tests/no-useless-matcher-to-be-defined\": \"off\" }\n    }\n  ],\n  \"rules\": {\n    \"indent\": [\"error\", 2]\n  }\n}\n```\n\n## Shareable configurations\n\n### Recommended\n\nThis plugin exports a recommended configuration that enforces good testing\npractices.\n\nFlat configuration format:\n\nTo enable this configuration with `eslint.config.mjs`, use the `flat/recommended` shared config:\n\n```js\nimport pluginProperTests from 'eslint-plugin-proper-tests';\n\nexport default [\n    {\n        ...pluginProperTests.configs['flat/recommended']\n    },\n]\n```\n\nOld configuration format:\n\nTo enable this configuration with `.eslintrc`, use the `extends` property:\n\n```json\n{\n  \"extends\": [\"plugin:proper-tests/recommended\"]\n}\n```\n\nand you are done, no other configuration is needed.\n\n## Rules\n\n\u003c!-- begin auto-generated rules list --\u003e\n\n💼 Configurations enabled in.\\\n☑️ Set in the `flat/recommended` configuration.\\\n✅ Set in the `recommended` configuration.\n\n| Name                                                                               | Description                                                                                                     | 💼   |\n| :--------------------------------------------------------------------------------- | :-------------------------------------------------------------------------------------------------------------- | :--- |\n| [no-long-arrays-in-test-each](docs/rules/no-long-arrays-in-test-each.md)           | Disallow using long arrays with objects inside `test.each()` or `it.each()`. Force moving them out of the file. | ☑️ ✅ |\n| [no-mixed-expectation-groups](docs/rules/no-mixed-expectation-groups.md)           | Disallow mixing expectations for different variables between each other.                                        | ☑️ ✅ |\n| [no-useless-matcher-to-be-defined](docs/rules/no-useless-matcher-to-be-defined.md) | Disallow using `.toBeDefined()` matcher when it is known that variable is always defined.                       | ☑️ ✅ |\n| [no-useless-matcher-to-be-null](docs/rules/no-useless-matcher-to-be-null.md)       | Disallow using `.toBeNull()` when TypeScript types conflict with it.                                            | ☑️ ✅ |\n\n\u003c!-- end auto-generated rules list --\u003e\n\nIn order to use the rules powered by TypeScript type-checking, you must be using\n`@typescript-eslint/parser` \u0026 adjust your eslint config as outlined\n[here](https://typescript-eslint.io/getting-started/typed-linting/).\n\n## Related Projects\n\n### eslint-plugin-jest\n\nThe main plugin to be installed when Jest is used.\n\n\u003chttps://github.com/jest-community/eslint-plugin-jest\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaks-rafalko%2Feslint-plugin-proper-tests","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaks-rafalko%2Feslint-plugin-proper-tests","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaks-rafalko%2Feslint-plugin-proper-tests/lists"}