Registry / testing / eslint-plugin-jasmine

eslint-plugin-jasmine

JSON →
library4.2.2jsnpmunverified

ESLint plugin providing linting rules for Jasmine test suites. Current stable version is 4.2.2 (September 2024). Release cadence is irregular with minor patches and occasional feature releases. Key differentiators: it is the most widely used ESLint plugin for Jasmine, with a comprehensive set of rules covering common anti-patterns like focused tests, disabled tests, missing expectations, and improper use of spies. Includes a recommended configuration. Note: v4.2.0+ supports ESLint v9 flat config with some caveats (beta). Requires Node >=8 and npm >=6. Alternative: eslint-plugin-jasmine-no-describe-variables (lighter scope).

npm install eslint-plugin-jasmine
INSTALL
IMPORT
SIG · ESLINT-PLUGIN-JASM
E
eslint-plugin-jasmine
testingjavascriptv4.2.2
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 plugin from 'eslint-plugin-jasmine'; or use as 'jasmine' in .eslintrc plugins array
using require('eslint-plugin-jasmine') without default import in ESM projects
Plugin is exported as CommonJS default. In ESLint flat config (v9+), you must import and spread plugin.configs.recommended or plugin.rules.
recommended config
extends: 'plugin:jasmine/recommended' in .eslintrc or import { recommended } from 'eslint-plugin-jasmine' in flat config
using 'jasmine/recommended' without 'plugin:' prefix in older ESLint versions
The recommended config sets rules as shown in the README. For flat config: import plugin from 'eslint-plugin-jasmine'; export default [...plugin.configs.recommended];
env
env: { jasmine: true } in .eslintrc or environments: { jasmine: true } in flat config
assuming plugin automatically sets the Jasmine globals without env
ESLint provides a separate Jasmine environment for globals like describe/it/expect. This plugin alone does not add those globals. Must be set explicitly.

Demonstrates how to set up eslint-plugin-jasmine using both legacy .eslintrc and flat config. Includes enabling the plugin, setting the Jasmine environment, extending the recommended config, and customizing rules.

// .eslintrc.js module.exports = { plugins: ['jasmine'], env: { jasmine: true }, extends: ['plugin:jasmine/recommended'], rules: { 'jasmine/no-focused-tests': 'error', 'jasmine/no-disabled-tests': 'warn', }, }; // For ESLint flat config (eslint.config.js) import plugin from 'eslint-plugin-jasmine'; export default [ { plugins: { jasmine: plugin }, languageOptions: { globals: { ...plugin.environments.jasmine.globals } }, rules: { ...plugin.configs.recommended.rules, 'jasmine/no-focused-tests': 'error', }, }, ];
Debug
Known issues
breakingESLint v9 flat config support is experimental (v4.2.0-beta). Flat config consumers must import the plugin and manually set globals or use plugin.configs.recommended with caution.
fix
Follow flat config example in README. Use stable v4.1.x if not ready for betas.
affects: >=4.2.0
deprecatedRule 'jasmine/valid-expect' is deprecated and will be removed in future versions.
fix
Remove rule from config; use built-in ESLint valid-expect or other rules.
affects: >=4.1.0
gotchaThe plugin does not automatically enable the Jasmine environment. You must set env: { jasmine: true } in .eslintrc or configure globals manually in flat config.
fix
Add env: { jasmine: true } in your ESLint config.
affects: >=4.0.0
gotchaRule 'jasmine/expect-single-argument' may report false positives when using no matcher (e.g., expect(something)). Fixed in v4.2.2 but still tricky when using nothing.
fix
Upgrade to v4.2.2 or configure rule to allow no arguments.
affects: >=4.2.0 <4.2.2
gotchaIn v4.2.0, rules were refactored to export an object with a 'create' method. Custom rule implementations relying on old format may break.
fix
Update custom rules to follow ESLint rule format: module.exports = { meta: {...}, create(context) { return {...} } }.
affects: >=4.2.0
Errors
Common errors & fixes
Definition for rule 'jasmine/prefer-toBeUndefined' was not found
Rule was added in v4.1.0 but some configurations might have a typo or old version.
fix
Update to eslint-plugin-jasmine@4.1.2+ and ensure rule name is correct: 'prefer-toBeUndefined' (with two 'e's).
ESLint: Failed to load plugin 'jasmine' declared in '.eslintrc': Cannot find module 'eslint-plugin-jasmine'
Plugin not installed or not in node_modules.
fix
Run npm install --save-dev eslint-plugin-jasmine. Ensure you're in the correct project directory.
Configuration for rule 'jasmine/no-focused-tests' is invalid: Severity should be one of the following: 0 = off, 1 = warn, 2 = error
Rule severity set to incorrect value (e.g., string or boolean).
fix
Set rule severity to 0, 1, or 2. E.g., 'jasmine/no-focused-tests': 'error' works as well.
Cannot read property 'globals' of undefined when using plugin.environments.jasmine in flat config
Flat config requires importing from the plugin directly; environments might not be exported in older versions.
fix
Use plugin.languageOptions?.globals or manually set globals. Upgrade to latest version.
Upgrade
Version history
4.2.2latest on npm
Audit
Dependencies
eslintrequiredpeer dependency, plugin requires ESLint to function
Agent activity
2 hits · last 30 days
node
2
Resources
eslint-plugin-jasmine — npm install eslint-plugin-jasmine · libregistry