{"id":19801,"library":"eslint-plugin-jasmine","title":"eslint-plugin-jasmine","description":"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).","status":"active","version":"4.2.2","language":"javascript","source_language":"en","source_url":"https://github.com/tlvince/eslint-plugin-jasmine","tags":["javascript","eslint","eslint-plugin","eslintplugin","jasmine"],"install":[{"cmd":"npm install eslint-plugin-jasmine","lang":"bash","label":"npm"},{"cmd":"yarn add eslint-plugin-jasmine","lang":"bash","label":"yarn"},{"cmd":"pnpm add eslint-plugin-jasmine","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency, plugin requires ESLint to function","package":"eslint","optional":false}],"imports":[{"note":"Plugin is exported as CommonJS default. In ESLint flat config (v9+), you must import and spread plugin.configs.recommended or plugin.rules.","wrong":"using require('eslint-plugin-jasmine') without default import in ESM projects","symbol":"plugin","correct":"import plugin from 'eslint-plugin-jasmine'; or use as 'jasmine' in .eslintrc plugins array"},{"note":"The recommended config sets rules as shown in the README. For flat config: import plugin from 'eslint-plugin-jasmine'; export default [...plugin.configs.recommended];","wrong":"using 'jasmine/recommended' without 'plugin:' prefix in older ESLint versions","symbol":"recommended config","correct":"extends: 'plugin:jasmine/recommended' in .eslintrc or import { recommended } from 'eslint-plugin-jasmine' in flat config"},{"note":"ESLint provides a separate Jasmine environment for globals like describe/it/expect. This plugin alone does not add those globals. Must be set explicitly.","wrong":"assuming plugin automatically sets the Jasmine globals without env","symbol":"env","correct":"env: { jasmine: true } in .eslintrc or environments: { jasmine: true } in flat config"}],"quickstart":{"code":"// .eslintrc.js\nmodule.exports = {\n  plugins: ['jasmine'],\n  env: { jasmine: true },\n  extends: ['plugin:jasmine/recommended'],\n  rules: {\n    'jasmine/no-focused-tests': 'error',\n    'jasmine/no-disabled-tests': 'warn',\n  },\n};\n\n// For ESLint flat config (eslint.config.js)\nimport plugin from 'eslint-plugin-jasmine';\nexport default [\n  {\n    plugins: { jasmine: plugin },\n    languageOptions: { globals: { ...plugin.environments.jasmine.globals } },\n    rules: {\n      ...plugin.configs.recommended.rules,\n      'jasmine/no-focused-tests': 'error',\n    },\n  },\n];","lang":"javascript","description":"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."},"warnings":[{"fix":"Follow flat config example in README. Use stable v4.1.x if not ready for betas.","message":"ESLint 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.","severity":"breaking","affected_versions":">=4.2.0"},{"fix":"Remove rule from config; use built-in ESLint valid-expect or other rules.","message":"Rule 'jasmine/valid-expect' is deprecated and will be removed in future versions.","severity":"deprecated","affected_versions":">=4.1.0"},{"fix":"Add env: { jasmine: true } in your ESLint config.","message":"The plugin does not automatically enable the Jasmine environment. You must set env: { jasmine: true } in .eslintrc or configure globals manually in flat config.","severity":"gotcha","affected_versions":">=4.0.0"},{"fix":"Upgrade to v4.2.2 or configure rule to allow no arguments.","message":"Rule '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.","severity":"gotcha","affected_versions":">=4.2.0 <4.2.2"},{"fix":"Update custom rules to follow ESLint rule format: module.exports = { meta: {...}, create(context) { return {...} } }.","message":"In v4.2.0, rules were refactored to export an object with a 'create' method. Custom rule implementations relying on old format may break.","severity":"gotcha","affected_versions":">=4.2.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Update to eslint-plugin-jasmine@4.1.2+ and ensure rule name is correct: 'prefer-toBeUndefined' (with two 'e's).","cause":"Rule was added in v4.1.0 but some configurations might have a typo or old version.","error":"Definition for rule 'jasmine/prefer-toBeUndefined' was not found"},{"fix":"Run npm install --save-dev eslint-plugin-jasmine. Ensure you're in the correct project directory.","cause":"Plugin not installed or not in node_modules.","error":"ESLint: Failed to load plugin 'jasmine' declared in '.eslintrc': Cannot find module 'eslint-plugin-jasmine'"},{"fix":"Set rule severity to 0, 1, or 2. E.g., 'jasmine/no-focused-tests': 'error' works as well.","cause":"Rule severity set to incorrect value (e.g., string or boolean).","error":"Configuration for rule 'jasmine/no-focused-tests' is invalid: Severity should be one of the following: 0 = off, 1 = warn, 2 = error"},{"fix":"Use plugin.languageOptions?.globals or manually set globals. Upgrade to latest version.","cause":"Flat config requires importing from the plugin directly; environments might not be exported in older versions.","error":"Cannot read property 'globals' of undefined when using plugin.environments.jasmine in flat config"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}