0.1.3 • Published 5 years ago

eslint-plugin-vest v0.1.3

Weekly downloads
1
License
MIT
Repository
-
Last release
5 years ago

eslint-plugin-vest

Eslint plugin for vest validations.

Installation

You'll first need to install ESLint:

$ npm i eslint --save-dev

Next, install eslint-plugin-vest:

$ npm install eslint-plugin-vest --save-dev

Note: If you installed ESLint globally (using the -g flag) then you must also install eslint-plugin-vest globally.

Usage

Add vest to the plugins section of your .eslintrc configuration file. You can omit the eslint-plugin- prefix:

{
  "plugins": ["vest"]
}

Then configure the rules you want to use under the rules section.

{
  "rules": {
    "exclude-before-test": 2,
    "hook-scope": 2
  }
}

Supported rules

exclude-before-test

This rule prevents you from calling the vest.only() and vest.skip() hooks after your test runs, improving performance and preventing unexpected behavior in async tests.

  • Bad code example 🚨
validate('MyForm', () => {
  test('fieldName1', 'message', () => {
    // ...
  });

  test('fieldName2', 'message', () => {
    // ...
  });

  vest.only('fieldName2'); // 🚨Should be called before test()
});
  • Good code example ✅
validate('MyForm', () => {
  vest.only();

  test('fieldName', 'message', () => {
    // ...
  });
});

hook-scope

Makes sure you only call vest hooks from the scope they are allowed to run from.

  • Bad code examples 🚨
validate('MyForm', () => {
  vest.warn(); // 🚨Should be called inside test()

  test('fieldName1', 'message', () => {
    // ...
  });

  test('fieldName2', 'message', () => {
    vest.only('fieldName2'); // 🚨Should be called inside validate()
  });
});
  • Good code examples ✅
validate('MyForm', () => {
  vest.only('fieldName2');

  test('fieldName1', 'message', () => {
    vest.warn();
    // ...
  });

  test('fieldName2', 'message', () => {});
});
0.1.4-dev-1aaf06

5 years ago

0.1.4-dev-c4124c

5 years ago

0.1.4-dev-3e4fa1

5 years ago

0.1.4-dev-8e6e76

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.2-dev-ab55f4

5 years ago

0.1.2-dev-103d63

5 years ago

0.1.17-dev

5 years ago

0.1.16

5 years ago

0.1.14

5 years ago

0.1.15

5 years ago

0.1.1

5 years ago

0.0.5

5 years ago

0.0.3

5 years ago

0.0.4

5 years ago