tlvince/eslint-plugin-jasmine

ESLint rules for Jasmine

101

stars

165

commits

JavaScript

primary language

Oct 14, 2024

updated

www.npmjs.com/package/eslint-plugin-jasmine
eslint
eslint-plugin-jasmine
jasmine

README

eslint-plugin-jasmine

Build Status npm version License

ESLint rules for Jasmine

Usage

With an ESLint version starting from v9

  1. Install eslint-plugin-jasmine as a dev-dependency:

    npm install --save-dev eslint-plugin-jasmine
    
  2. Enable the plugin, add its globals and the recommended rules to your ESLint configuration in eslint.config.js:

    import js from '@eslint/js';
    import jasmine from 'eslint-plugin-jasmine';
    import globals from 'globals';
    
    export default [
        js.configs.recommended,
        jasmine.configs.recommended,
        {
            languageOptions: {
                globals: {
                    ...globals.jasmine
                }
            },
            plugins: {
                jasmine
            }
        }
    ];
    

With an ESLint version lower than v9

  1. Install eslint-plugin-jasmine as a dev-dependency:

    npm install --save-dev eslint-plugin-jasmine
    
  2. Enable the plugin by adding it to your .eslintrc:

    plugins:
      - jasmine
    

ESLint itself provides a Jasmine environment for Jasmine's global variables. It's therefore recommended to also enable it in your .eslintrc:

plugins:
  - jasmine
env:
  jasmine: true

By default, no rules are enabled. See the next section for more.

Configuration

This plugin exports a recommended configuration that enforces good practices.

Using recommended configuration in ESLint version starting from v9:

Add jasmine.configs.recommended to the default export array in eslint.config.js:

export default [
  jasmine.configs.recommended,
  /* rest of your config */
];

Using recommended configuration in ESLint version lower than v9:

Use the extends property in your .eslintrc config file:

plugins:
  - jasmine
env:
  jasmine: true
extends: "plugin:jasmine/recommended"

See the ESLint config docs for more information about extending configuration files.

Rules

For example, using the recommended configuration, the no-focused-tests rule is enabled and will cause ESLint to throw an error (with an exit code of 1) when triggered.

Customizing rules in ESLint version starting from v9:

You may customise each rule by ading them under a rules property in eslint.config.js:

export default [
  {
    rules: {
      'jasmine/no-focused-tests': 0
    }
  },
  /* rest of your config */
];

Customizing rules in ESLint version lower than v9:

You may customise each rule by adding a value in your .eslintrc rules property:

plugins:
  - jasmine
env:
  jasmine: true
rules:
  jasmine/no-focused-tests: 0
  jasmine/no-suite-dupes:
    - 2
    - branch

See configuring rules for more information.

Author

© 2016 - 2017 Tom Vincent git@tlvince.com and contributors.

License

Released under the MIT license.

Contributors

(top 30 of 33)

tlvince

70 commits

emilos

8 commits

tlvince/eslint-plugin-jasmine

ESLint rules for Jasmine

101

stars

165

commits

JavaScript

primary language

Oct 14, 2024

updated

www.npmjs.com/package/eslint-plugin-jasmine
eslint
eslint-plugin-jasmine
jasmine

README

eslint-plugin-jasmine

Build Status npm version License

ESLint rules for Jasmine

Usage

With an ESLint version starting from v9

  1. Install eslint-plugin-jasmine as a dev-dependency:

    npm install --save-dev eslint-plugin-jasmine
    
  2. Enable the plugin, add its globals and the recommended rules to your ESLint configuration in eslint.config.js:

    import js from '@eslint/js';
    import jasmine from 'eslint-plugin-jasmine';
    import globals from 'globals';
    
    export default [
        js.configs.recommended,
        jasmine.configs.recommended,
        {
            languageOptions: {
                globals: {
                    ...globals.jasmine
                }
            },
            plugins: {
                jasmine
            }
        }
    ];
    

With an ESLint version lower than v9

  1. Install eslint-plugin-jasmine as a dev-dependency:

    npm install --save-dev eslint-plugin-jasmine
    
  2. Enable the plugin by adding it to your .eslintrc:

    plugins:
      - jasmine
    

ESLint itself provides a Jasmine environment for Jasmine's global variables. It's therefore recommended to also enable it in your .eslintrc:

plugins:
  - jasmine
env:
  jasmine: true

By default, no rules are enabled. See the next section for more.

Configuration

This plugin exports a recommended configuration that enforces good practices.

Using recommended configuration in ESLint version starting from v9:

Add jasmine.configs.recommended to the default export array in eslint.config.js:

export default [
  jasmine.configs.recommended,
  /* rest of your config */
];

Using recommended configuration in ESLint version lower than v9:

Use the extends property in your .eslintrc config file:

plugins:
  - jasmine
env:
  jasmine: true
extends: "plugin:jasmine/recommended"

See the ESLint config docs for more information about extending configuration files.

Rules

For example, using the recommended configuration, the no-focused-tests rule is enabled and will cause ESLint to throw an error (with an exit code of 1) when triggered.

Customizing rules in ESLint version starting from v9:

You may customise each rule by ading them under a rules property in eslint.config.js:

export default [
  {
    rules: {
      'jasmine/no-focused-tests': 0
    }
  },
  /* rest of your config */
];

Customizing rules in ESLint version lower than v9:

You may customise each rule by adding a value in your .eslintrc rules property:

plugins:
  - jasmine
env:
  jasmine: true
rules:
  jasmine/no-focused-tests: 0
  jasmine/no-suite-dupes:
    - 2
    - branch

See configuring rules for more information.

Author

© 2016 - 2017 Tom Vincent git@tlvince.com and contributors.

License

Released under the MIT license.

Contributors

(top 30 of 33)

tlvince

70 commits

emilos

8 commits

Languages

JavaScript

100.0%