Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/avajs/eslint-plugin-ava
ESLint rules for AVA
https://github.com/avajs/eslint-plugin-ava
ava eslint eslint-config eslint-plugin eslint-rules hacktoberfest javascript linting-rules nodejs
Last synced: 1 day ago
JSON representation
ESLint rules for AVA
- Host: GitHub
- URL: https://github.com/avajs/eslint-plugin-ava
- Owner: avajs
- License: mit
- Created: 2016-01-15T14:09:39.000Z (almost 9 years ago)
- Default Branch: main
- Last Pushed: 2024-05-11T08:08:39.000Z (8 months ago)
- Last Synced: 2024-10-29T14:52:58.348Z (2 months ago)
- Topics: ava, eslint, eslint-config, eslint-plugin, eslint-rules, hacktoberfest, javascript, linting-rules, nodejs
- Language: JavaScript
- Homepage: https://avajs.dev
- Size: 646 KB
- Stars: 230
- Watchers: 12
- Forks: 49
- Open Issues: 47
-
Metadata Files:
- Readme: readme.md
- Contributing: .github/contributing.md
- License: license
Awesome Lists containing this project
- awesome-ava - eslint-plugin-ava - ESLint rules. (Packages)
- awesome-eslint - AVA - Linting rules for AVA. (Plugins / Testing Tools)
README
# eslint-plugin-ava [![Coverage Status](https://coveralls.io/repos/github/avajs/eslint-plugin-ava/badge.svg?branch=main)](https://coveralls.io/github/avajs/eslint-plugin-ava?branch=main)
> ESLint rules for [AVA](https://avajs.dev)
Translations: [Français](https://github.com/avajs/ava-docs/blob/main/fr_FR/related/eslint-plugin-ava/readme.md)
This plugin is bundled in [XO](https://github.com/xojs/xo). No need to do anything if you're using it.
[**Propose or contribute a new rule β‘**](.github/contributing.md)
## Install
```sh
npm install --save-dev eslint eslint-plugin-ava
```## Usage
Configure it in `package.json`.
```json
{
"name": "my-awesome-project",
"eslintConfig": {
"env": {
"es6": true
},
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"plugins": [
"ava"
],
"rules": {
"ava/assertion-arguments": "error",
"ava/...": "error"
}
}
}
```## Rules
The rules will only activate in test files.
πΌ [Configurations](https://github.com/avajs/eslint-plugin-ava#recommended-config) enabled in.\
β οΈ [Configurations](https://github.com/avajs/eslint-plugin-ava#recommended-config) set to warn in.\
π« [Configurations](https://github.com/avajs/eslint-plugin-ava#recommended-config) disabled in.\
β Set in the `recommended` [configuration](https://github.com/avajs/eslint-plugin-ava#recommended-config).\
π§ Automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/user-guide/command-line-interface#--fix).\
π‘ Manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions).| NameΒ Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β | Description | πΌ | β οΈ | π« | π§ | π‘ |
| :------------------------------------------------------------------- | :----------------------------------------------------------------------------------------------------------------------- | :- | :- | :- | :- | :- |
| [assertion-arguments](docs/rules/assertion-arguments.md) | Enforce passing correct arguments to assertions. | β | | | π§ | |
| [hooks-order](docs/rules/hooks-order.md) | Enforce test hook ordering. | β | | | π§ | |
| [max-asserts](docs/rules/max-asserts.md) | Enforce a limit on the number of assertions in a test. | | | β | | |
| [no-async-fn-without-await](docs/rules/no-async-fn-without-await.md) | Ensure that async tests use `await`. | β | | | | |
| [no-duplicate-modifiers](docs/rules/no-duplicate-modifiers.md) | Ensure tests do not have duplicate modifiers. | β | | | | |
| [no-identical-title](docs/rules/no-identical-title.md) | Ensure no tests have the same title. | β | | | | |
| [no-ignored-test-files](docs/rules/no-ignored-test-files.md) | Ensure no tests are written in ignored files. | β | | | | |
| [no-import-test-files](docs/rules/no-import-test-files.md) | Ensure no test files are imported anywhere. | β | | | | |
| [no-incorrect-deep-equal](docs/rules/no-incorrect-deep-equal.md) | Disallow using `deepEqual` with primitives. | β | | | π§ | |
| [no-inline-assertions](docs/rules/no-inline-assertions.md) | Ensure assertions are not called from inline arrow functions. | β | | | π§ | |
| [no-nested-tests](docs/rules/no-nested-tests.md) | Ensure no tests are nested. | β | | | | |
| [no-only-test](docs/rules/no-only-test.md) | Ensure no `test.only()` are present. | β | | | π§ | π‘ |
| [no-skip-assert](docs/rules/no-skip-assert.md) | Ensure no assertions are skipped. | β | | | | |
| [no-skip-test](docs/rules/no-skip-test.md) | Ensure no tests are skipped. | β | | | π§ | π‘ |
| [no-todo-implementation](docs/rules/no-todo-implementation.md) | Ensure `test.todo()` is not given an implementation function. | β | | | | |
| [no-todo-test](docs/rules/no-todo-test.md) | Ensure no `test.todo()` is used. | | β | | | |
| [no-unknown-modifiers](docs/rules/no-unknown-modifiers.md) | Disallow the use of unknown test modifiers. | β | | | | |
| [prefer-async-await](docs/rules/prefer-async-await.md) | Prefer using async/await instead of returning a Promise. | β | | | | |
| [prefer-power-assert](docs/rules/prefer-power-assert.md) | Enforce the use of the asserts that have no [power-assert](https://github.com/power-assert-js/power-assert) alternative. | | | β | | |
| [prefer-t-regex](docs/rules/prefer-t-regex.md) | Prefer using `t.regex()` to test regular expressions. | β | | | π§ | |
| [test-title](docs/rules/test-title.md) | Ensure tests have a title. | β | | | | |
| [test-title-format](docs/rules/test-title-format.md) | Ensure test titles have a certain format. | | | β | | |
| [use-t](docs/rules/use-t.md) | Ensure test functions use `t` as their parameter. | β | | | | |
| [use-t-throws-async-well](docs/rules/use-t-throws-async-well.md) | Ensure that `t.throwsAsync()` and `t.notThrowsAsync()` are awaited. | β | | | π§ | |
| [use-t-well](docs/rules/use-t-well.md) | Disallow the incorrect use of `t`. | β | | | π§ | |
| [use-test](docs/rules/use-test.md) | Ensure that AVA is imported with `test` as the variable name. | β | | | | |
| [use-true-false](docs/rules/use-true-false.md) | Ensure that `t.true()`/`t.false()` are used instead of `t.truthy()`/`t.falsy()`. | β | | | | |## Recommended config
This plugin exports a [`recommended` config](index.js) that enforces good practices.
Enable it in your `package.json` with the `extends` option:
```json
{
"name": "my-awesome-project",
"eslintConfig": {
"extends": "plugin:ava/recommended"
}
}
```See the [ESLint docs](https://eslint.org/docs/user-guide/configuring#extending-configuration-files) for more information about extending config files.
**Note**: This config will also enable the correct [parser options](https://eslint.org/docs/user-guide/configuring#specifying-parser-options) and [environment](https://eslint.org/docs/user-guide/configuring#specifying-environments).