All Projects → jfmengels → eslint-ava-rule-tester

jfmengels / eslint-ava-rule-tester

Licence: MIT License
ESLint's RuleTester for AVA

Programming Languages

javascript
184084 projects - #8 most used programming language

eslint-ava-rule-tester Build Status

ESLint's RuleTester for AVA

Allows you to run ESLint's RuleTester with AVA while still getting the nice report it provides by default.

Install

$ npm install --save-dev eslint-ava-rule-tester

Usage

Apart from how it is instantiated, the API is the same as ESLint's RuleTester. For information on how to test your rule, please follow the official documentation.

import test from 'ava';
import avaRuleTester from 'eslint-ava-rule-tester';
import rule from '../rules/my-awesome-rule';

const ruleTester = new avaRuleTester(test, {
  env: {
    es6: true
  }
});

ruleTester.run('my-awesome-rule', rule, {
  valid: [
    '...'
  ],
  invalid: [
    {
      code: 'console.lgo',
      errors: [{ message: 'console.log was mistyped', column: 1, line: 1 }],
      output: 'console.log' // Optional, use this when your rule fixes the errors
    }
  ]
});

Run ava --verbose to get a better overview of which tests failed.

License

MIT © Jeroen Engels

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].