{"name":"eslint-plugin-no-only-tests","version":"3.4.0","description":"ESLint rule for .only blocks in mocha tests","keywords":["describe","eslint","eslint-plugin","eslintplugin","fixture","it","mocha","only","rule"],"homepage":"https://github.com/levibuzolic/eslint-plugin-no-only-tests#readme","bugs":{"url":"https://github.com/levibuzolic/eslint-plugin-no-only-tests/issues"},"license":"MIT","author":{"name":"Levi Buzolic"},"repository":{"type":"git","url":"git+https://github.com/levibuzolic/eslint-plugin-no-only-tests.git"},"main":"index.js","exports":{".":"./index.js"},"scripts":{"test":"node test/check-package.mjs && node test/unit.mjs && node test/e2e.mjs","test:e2e":"node test/e2e.mjs","test:unit":"node test/unit.mjs","check:package":"node test/check-package.mjs","typecheck":"tsc","lint":"oxlint .","format":"oxfmt .","format:check":"oxfmt --check ."},"dependencies":{},"devDependencies":{"@types/eslint":"^9.6.0","@types/eslint__js":"^9.14.0","@types/estree":"^1.0.8","@types/node":"^25.6.0","eslint":"^10.0.0","oxfmt":"^0.46.0","oxlint":"^1.61.0","typescript":"^6.0.3"},"engines":{"node":">=5.0.0"},"packageManager":"bun@1.3.13","gitHead":"2279c515fd4c8c90b93d2d1baf962b1056831349","_id":"eslint-plugin-no-only-tests@3.4.0","_nodeVersion":"24.14.1","_npmVersion":"11.11.0","dist":{"integrity":"sha512-4S3/9Nb7A2tiMcpzEQE9bQSlpeOz6WJkgryBuou/SA8W2x2c8Zf4j0NvTKBjv6qNhF9T79tmkecm/0CHqV0UGg==","shasum":"a457d2c559bda3301ce5a75147b8ba447186e88a","tarball":"http://registry-npm.ywwl.com/eslint-plugin-no-only-tests/download/eslint-plugin-no-only-tests-3.4.0.tgz","fileCount":5,"unpackedSize":18762,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/eslint-plugin-no-only-tests@3.4.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQD7XgHjtMey5iuSOdrdWU6Dg8EFdN0xbSMIP5Irv0vPhwIhAMPwD78RYg+3fK8+6BkgiDAqwcOKBPRhBnZX8AcLsjD6"}],"size":6107,"noattachment":false,"key":"/eslint-plugin-no-only-tests/-/eslint-plugin-no-only-tests-3.4.0.tgz"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:9931ede3-8b7b-45d5-9abf-4366784d3c84"}},"directories":{},"maintainers":[{"name":"levibuzolic","email":"levibuzolic@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/eslint-plugin-no-only-tests_3.4.0_1777467356853_0.47420053432618703"},"_hasShrinkwrap":false,"readme":"# eslint-plugin-no-only-tests\n\n[![Version](https://img.shields.io/npm/v/eslint-plugin-no-only-tests.svg)](https://www.npmjs.com/package/eslint-plugin-no-only-tests) [![Downloads](https://img.shields.io/npm/dm/eslint-plugin-no-only-tests.svg)](https://npmcharts.com/compare/eslint-plugin-no-only-tests?minimal=true) [![GitHub Tests](https://github.com/levibuzolic/eslint-plugin-no-only-tests/actions/workflows/tests.yml/badge.svg)](https://github.com/levibuzolic/eslint-plugin-no-only-tests/actions/workflows/tests.yml)\n\nESLint rule for `.only` tests in [Mocha](https://mochajs.org/), [Jest](https://jestjs.io/), [Jasmine](https://jasmine.github.io/), [Mocha Cakes 2](https://github.com/iensu/mocha-cakes-2) and other JS testing libraries.\n\nThe following test blocks are matched by default: `describe`, `it`, `context`, `tape`, `test`, `fixture`, `serial`, `Feature`, `Scenario`, `Given`, `And`, `When` and `Then`.\n\nDesigned to prevent you from committing focused (`.only`) tests to CI, which may prevent your entire test suite from running.\n\nIf the testing framework you use doesn't use `.only` to focus tests, you can override the matchers with [options](#options).\n\n## Installation\n\n[Install ESLint](https://eslint.org/docs/user-guide/getting-started) if you haven't done so already, then install `eslint-plugin-no-only-tests`:\n\n```bash\nbun add --dev eslint eslint-plugin-no-only-tests\n```\n\nThis package supports Node.js 5 or newer.\n\nThis repository uses Bun as its package manager.\n\nIf you're using Oxlint only, you do not need to install ESLint.\n\n## Usage\n\n### Flat Config (ESLint >= 9)\n\nIf you're using ESLint's [flat config format](https://eslint.org/docs/latest/use/configure/configuration-files), add the plugin to your `eslint.config.js`:\n\n```javascript\nimport noOnlyTests from \"eslint-plugin-no-only-tests\";\n\nexport default [\n  {\n    plugins: {\n      \"no-only-tests\": noOnlyTests,\n    },\n    rules: {\n      \"no-only-tests/no-only-tests\": \"error\",\n    },\n  },\n];\n```\n\n### Traditional Config (.eslintrc)\n\nAdd `no-only-tests` to the plugins section of your `.eslintrc` configuration file. You can omit the `eslint-plugin-` prefix:\n\n```json\n\"plugins\": [\n  \"no-only-tests\"\n]\n```\n\nThen add the rule to the rules section of your `.eslintrc`:\n\n```json\n\"rules\": {\n  \"no-only-tests/no-only-tests\": \"error\"\n}\n```\n\n### Oxlint\n\nAdd `eslint-plugin-no-only-tests` to the jsPlugins section of your `.oxlintrc.json`.\n\n```json\n\"jsPlugins\": [\"eslint-plugin-no-only-tests\"],\n```\n\nThen add the rule to the rules section of your `.oxlintrc.json`:\n\n```json\n\"rules\": {\n  \"no-only-tests/no-only-tests\": \"error\"\n}\n```\n\n> [!TIP]\n> This package already works with Oxlint via `jsPlugins`. In `v3.4.0`, the rule was updated to use Oxlint's performance-focused `createOnce` API internally while keeping the same external configuration and ESLint compatibility.\n\n## Native test runner support\n\nSome test runners can already fail focused tests at runtime:\n\n- [Mocha](https://mochajs.org/running/cli/#--forbid-only): `--forbid-only`\n- [Playwright Test](https://playwright.dev/docs/api/class-testconfig#test-config-forbid-only): `forbidOnly: !!process.env.CI`\n- [Vitest](https://vitest.dev/api/test#test-only): fails on `.only` in CI by default unless `allowOnly` is enabled\n\nThis plugin is still useful with those runners if you want editor feedback, ESLint-based CI, or opt-in autofixing.\n\n## Common framework setups\n\n### Jest\n\nThe default configuration works for [`describe.only`](https://jestjs.io/docs/api#describeonlyname-fn), `it.only` and `test.only`:\n\n```json\n\"rules\": {\n  \"no-only-tests/no-only-tests\": \"error\"\n}\n```\n\nJest note: use this plugin when you want `.only` enforcement during linting, in editors, or in ESLint-based CI.\n\nIf your codebase also uses Jest's `fit` or `fdescribe` aliases, add them with `functions`:\n\n```json\n\"rules\": {\n  \"no-only-tests/no-only-tests\": [\"error\", { \"functions\": [\"fit\", \"fdescribe\"] }]\n}\n```\n\n### Vitest\n\nThe default configuration works for [`describe.only`](https://vitest.dev/guide/filtering#selecting-suites-and-tests-to-run), `it.only`, `test.only`, and chained calls such as `test.concurrent.only`:\n\n```json\n\"rules\": {\n  \"no-only-tests/no-only-tests\": \"error\"\n}\n```\n\n> [!NOTE]\n> Vitest already fails the run in CI when it encounters `.only`. The official [`allowOnly`](https://vitest.dev/config/allowonly) setting defaults to `!process.env.CI`, so focused tests fail by default in CI unless you opt back in.\n\n### Bun\n\nIf you use [`bun:test`](https://bun.sh/docs/test/writing-tests#testonly), the default configuration works for `test.only` and `describe.only`:\n\n```json\n\"rules\": {\n  \"no-only-tests/no-only-tests\": \"error\"\n}\n```\n\n> [!NOTE]\n> Bun documents `bun test --only` as the switch that enables focused execution. Plain `bun test` still runs the full test suite, even when `.only` appears in the codebase.\n\n### Mocha\n\n[Mocha](https://mochajs.org/running/cli/#--forbid-only) uses `describe.only` and `it.only`, so the default configuration works:\n\n```json\n\"rules\": {\n  \"no-only-tests/no-only-tests\": \"error\"\n}\n```\n\n> [!NOTE]\n> Mocha has a native CI/runtime guard via [`--forbid-only`](https://mochajs.org/running/cli/#--forbid-only), which fails the run if exclusive tests are present.\n\n### Cypress\n\n[Cypress](https://docs.cypress.io/app/core-concepts/writing-and-organizing-tests#Excluding-and-Including-Tests) uses Mocha-style `describe.only` and `it.only`, so the default configuration works:\n\n```json\n\"rules\": {\n  \"no-only-tests/no-only-tests\": \"error\"\n}\n```\n\n### Playwright Test\n\nThe default configuration works for [`test.only`](https://playwright.dev/docs/api/class-testconfig#test-config-forbid-only), `test.describe.only`, and similar chained APIs:\n\n```json\n\"rules\": {\n  \"no-only-tests/no-only-tests\": \"error\"\n}\n```\n\n> [!NOTE]\n> Playwright has a native CI/runtime guard via [`forbidOnly`](https://playwright.dev/docs/api/class-testconfig#test-config-forbid-only).\n\n### Jasmine\n\nJasmine uses focused functions such as [`fit` and `fdescribe`](https://jasmine.github.io/archives/2.8/focused_specs.html), so add them with `functions`:\n\n```json\n\"rules\": {\n  \"no-only-tests/no-only-tests\": [\"error\", { \"functions\": [\"fit\", \"fdescribe\"] }]\n}\n```\n\n### AVA\n\nThe default configuration works for AVA when your imported test function is named `test`, including `test.only` and `test.serial.only`:\n\n```json\n\"rules\": {\n  \"no-only-tests/no-only-tests\": \"error\"\n}\n```\n\nIf you alias the import, add the local name to `block`:\n\n```json\n\"rules\": {\n  \"no-only-tests/no-only-tests\": [\"error\", { \"block\": [\"check\"] }]\n}\n```\n\n```javascript\nimport check from \"ava\";\n\ncheck.only(\"focused test\", (t) => {\n  t.pass();\n});\n```\n\n### node:test\n\n[`node:test`](https://nodejs.org/api/test.html#only-tests) supports both `.only` helpers such as `describe.only(...)` and an options-based `{ only: true }` API.\n\nThis rule can catch the `.only` call style with the default configuration:\n\n```json\n\"rules\": {\n  \"no-only-tests/no-only-tests\": \"error\"\n}\n```\n\n`node:test` note: [`--test-only`](https://nodejs.org/api/test.html#only-tests) enables focused execution. It is not a fail-the-build guard like Mocha's `--forbid-only` or Playwright's `forbidOnly`.\n\nWithout `--test-only`, Node currently prints an informational message that `only` requires the `--test-only` flag and still exits successfully after running the tests.\n\nThis rule also does not flag object options such as `{ only: true }`, so that `node:test` API shape is not fully covered by either the default runtime behavior or this plugin.\n\n## Overrides\n\nIf you use a testing framework that uses a test block name that isn't present in the [defaults](#options), or a different way of focusing test (something other than `.only`) you can specify an array of blocks and focus methods to match in the options.\n\n```json\n\"rules\": {\n  \"no-only-tests/no-only-tests\": [\n    \"error\", {\n      \"block\": [\"test\", \"it\", \"assert\"],\n      \"focus\": [\"only\", \"focus\"]\n    }\n  ]\n}\n```\n\nThe above example will catch any uses of `test.only`, `test.focus`, `it.only`, `it.focus`, `assert.only` and `assert.focus`.\n\nThis rule supports opt-in autofixing when the `fix` option is set to `true` to avoid changing runtime code unintentionally when configured in an editor.\n\n```json\n\"rules\": {\n  \"no-only-tests/no-only-tests\": [\"error\", {\"fix\": true}]\n}\n```\n\n## Options\n\n| Option      | Type       | Description                                                                                                                                                                                                                                                                                                   |\n| ----------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `block`     | `string[]` | Specify the block names that your testing framework uses. Add a `*` to the end of any string to enable prefix matching (ie. `test*` will match `testExample.only`)<br>Defaults to `[\"describe\", \"it\", \"context\", \"test\", \"tape\", \"fixture\", \"serial\", \"Feature\", \"Scenario\", \"Given\", \"And\", \"When\", \"Then\"]` |\n| `focus`     | `string[]` | Specify the focus scope that your testing framework uses.<br>Defaults to `[\"only\"]`                                                                                                                                                                                                                           |\n| `functions` | `string[]` | Specify not permitted functions. Good examples are `fit` or `xit`.<br>Defaults to `[]` (disabled)                                                                                                                                                                                                             |\n| `fix`       | `boolean`  | Enable this rule to auto-fix violations, useful for a pre-commit hook, not recommended for users with auto-fixing enabled in their editor.<br>Defaults to `false`                                                                                                                                             |\n","publish_time":1777467356993,"_cnpm_publish_time":1777467356993,"dist-tags":{"latest":"3.4.0"}}