Registry / testing / eslint-plugin-no-only-tests

eslint-plugin-no-only-tests

JSON →
library3.3.0jsnpmunverified

ESLint rule that prevents committing focused tests (`.only`) commonly used in Mocha, Jest, Jasmine, and other JS test frameworks. Version 3.3.0 is the current stable release, maintained actively with regular updates. Unlike general lint rules, it supports multiple test block names and custom focus methods, with opt-in autofixing. It catches `describe.only`, `it.only`, `test.only`, and many other patterns by default, and can be configured for any test framework that uses `.only` or similar focus patterns.

npm install eslint-plugin-no-only-tests
INSTALL
IMPORT
SIG · ESLINT-PLUGIN-NO-O
E
eslint-plugin-no-only-tests
testingjavascriptv3.3.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

plugin
import eslintPluginNoOnlyTests from 'eslint-plugin-no-only-tests'
const plugin = require('eslint-plugin-no-only-tests')
Default import for use in eslint.config.js (flat config). For CommonJS require, use the correct path: const plugin = require('eslint-plugin-no-only-tests');
rules
import { rules } from 'eslint-plugin-no-only-tests'
const rules = require('eslint-plugin-no-only-tests').rules
Accessing the rules object directly is useful for custom configs or programmatic use.
rule
// In .eslintrc: "no-only-tests/no-only-tests": "error"
"no-only-tests": "error"
The rule is namespaced under 'no-only-tests', so you must use 'no-only-tests/no-only-tests' as the key.

Shows how to configure the plugin and rule to flag any `.only` calls in test files, preventing accidental commits.

// .eslintrc.json { "plugins": ["no-only-tests"], "rules": { "no-only-tests/no-only-tests": "error" } } // Example test file that will cause an error: describe.only('my suite', () => { it('test', () => { // ... }); });
Debug
Known issues
gotchaThe rule does not automatically fix `.only` by default; the `fix` option must be explicitly set to `true` to enable autofixing.
fix
Set the option `{"fix": true}` in the rule config.
affects: >=3.0.0
gotchaThe `block` option supports prefix matching with a trailing asterisk (e.g., `test*`), but this may cause unexpected matches if not used carefully.
fix
Review your block patterns and ensure they only match intended test function names.
affects: >=3.0.0
breakingIn v3.0.0, the rule was moved to a new `no-only-tests/no-only-tests` namespace; previously it was just `no-only-tests`.
fix
Update your ESLint config: use `"no-only-tests/no-only-tests"` instead of `"no-only-tests"`.
affects: >=3.0.0
deprecatedThe `fix` option as a boolean is deprecated in favor of an object with `fix: true`.
fix
Use `{"fix": true}` instead of just `"fix": true`.
affects: >=3.0.0
Errors
Common errors & fixes
ESLint: 'no-only-tests' is not a valid rule.
The rule name is 'no-only-tests/no-only-tests' because it is namespaced under the plugin.
fix
Use 'no-only-tests/no-only-tests' as the rule key.
Error: Cannot find module 'eslint-plugin-no-only-tests'
The package is not installed or ESLint cannot resolve it.
fix
Run `npm install --save-dev eslint-plugin-no-only-tests`.
Definition for rule 'no-only-tests/no-only-tests' was not found.
The plugin is not listed in the 'plugins' array in your ESLint config.
fix
Add '"plugins": ["no-only-tests"]' to your ESLint configuration.
Upgrade
Version history
3.3.0latest on npm
Audit
Dependencies
eslintrequiredPeer dependency – requires ESLint as the linting framework
Agent activity
45 hits · last 30 days
node
42
OpenAI (training)
2
Bingbot
1
Resources
eslint-plugin-no-only-tests — npm install eslint-plugin-no-only-tests · libregistry