eslint-plugin-vest

    0.1.3 • Public • Published

    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', () => {});
    });

    Install

    npm i eslint-plugin-vest

    DownloadsWeekly Downloads

    5

    Version

    0.1.3

    License

    MIT

    Unpacked Size

    12.5 kB

    Total Files

    13

    Last publish

    Collaborators

    • ealush