Coder Social home page Coder Social logo

dmitry-lobanov / eslint-plugin-testing-library Goto Github PK

View Code? Open in Web Editor NEW

This project forked from testing-library/eslint-plugin-testing-library

0.0 0.0 0.0 365 KB

ESLint plugin for Testing Library

Home Page: https://npm.im/eslint-plugin-testing-library

License: MIT License

JavaScript 0.30% TypeScript 99.70%

eslint-plugin-testing-library's Introduction

eslint-plugin-testing-library

ESLint plugin to follow best practices and anticipate common mistakes when writing tests with Testing Library


Build status Package version MIT License
semantic-release PRs Welcome
Watch on Github Star on Github Tweet

All Contributors

Installation

You'll first need to install ESLint:

$ npm i eslint --save-dev

Next, install eslint-plugin-testing-library:

$ npm install eslint-plugin-testing-library --save-dev

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

Usage

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

{
  "plugins": ["testing-library"]
}

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

{
  "rules": {
    "testing-library/await-async-query": "error",
    "testing-library/no-await-sync-query": "error",
    "testing-library/no-debug": "warn"
  }
}

Shareable configurations

Recommended

This plugin exports a recommended configuration that enforces good Testing Library practices (you can find more info about enabled rules in Supported Rules section within Recommended column).

To enable this configuration use the extends property in your .eslintrc config file:

{
  "extends": ["plugin:testing-library/recommended"]
}

Frameworks

Starting from the premise that DOM Testing Library is the base for the rest of Testing Library frameworks wrappers, this plugin also exports different configuration for those frameworks that enforces good practices for specific rules that only apply to them (you can find more info about enabled rules in Supported Rules section within Frameworks column).

Note that frameworks configurations enable their specific rules + recommended rules.

Available frameworks configurations are:

Angular

To enable this configuration use the extends property in your .eslintrc config file:

{
  "extends": ["plugin:testing-library/angular"]
}

React

To enable this configuration use the extends property in your .eslintrc config file:

{
  "extends": ["plugin:testing-library/react"]
}

Vue

To enable this configuration use the extends property in your .eslintrc config file:

{
  "extends": ["plugin:testing-library/vue"]
}

Supported Rules

Rule Description Configurations Fixable
await-async-query Enforce async queries to have proper await recommended-badge angular-badge react-badge vue-badge
await-async-utils Enforce async utils to be awaited properly recommended-badge angular-badge react-badge vue-badge
await-fire-event Enforce async fire event methods to be awaited vue-badge
consistent-data-testid Ensure data-testid values match a provided regex.
no-await-sync-query Disallow unnecessary await for sync queries recommended-badge angular-badge react-badge vue-badge
no-debug Disallow the use of debug angular-badge react-badge vue-badge
no-dom-import Disallow importing from DOM Testing Library angular-badge react-badge vue-badge fixable-badge
no-manual-cleanup Disallow the use of cleanup
no-wait-for-empty-callback Disallow empty callbacks for waitFor and waitForElementToBeRemoved
prefer-explicit-assert Suggest using explicit assertions rather than just getBy* queries
prefer-presence-queries Enforce specific queries when checking element is present or not
prefer-screen-queries Suggest using screen while using queries
prefer-wait-for Use waitFor instead of deprecated wait methods fixable-badge

Contributors ✨

Thanks goes to these wonderful people (emoji key):


Mario Beltrán Alarcón

💻 📖 👀 ⚠️ 🚇

Thomas Lombart

💻 📖 👀 ⚠️ 🚇

Ben Monro

💻 📖 ⚠️

Nicola Molinari

💻 ⚠️ 📖 👀

Aarón García Hervás

📖

Matej Šnuderl

🤔 📖

Adrià Fontcuberta

💻 ⚠️

Jon Aldinger

📖

Thomas Knickman

💻 📖 ⚠️

Kevin Sullivan

📖

Jakub Jastrzębski

💻 📖 ⚠️

Nikolay Stoynov

📖

marudor

💻 ⚠️

Tim Deschryver

💻 📖 🤔 👀 ⚠️ 🐛 🚇 📦

Tobias Deekens

🐛

Victor Cordova

💻 ⚠️ 🐛

This project follows the all-contributors specification. Contributions of any kind welcome!

eslint-plugin-testing-library's People

Contributors

aarongarciah avatar afontcu avatar allcontributors[bot] avatar arvigeus avatar belco90 avatar benmonro avatar dependabot[bot] avatar emmenko avatar kubajastrz avatar marudor avatar timdeschryver avatar tknickman avatar victorandcode avatar wolverineks avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.