6.2.2 • Published 21 days ago

eslint-plugin-testing-library v6.2.2

Weekly downloads
1,275,630
License
MIT
Repository
github
Last release
21 days ago

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

RuleDescriptionConfigurationsFixable
await-async-queryEnforce async queries to have proper awaitrecommended-badge angular-badge react-badge vue-badge
await-async-utilsEnforce async utils to be awaited properlyrecommended-badge angular-badge react-badge vue-badge
await-fire-eventEnforce async fire event methods to be awaitedvue-badge
consistent-data-testidEnsure data-testid values match a provided regex.
no-await-sync-queryDisallow unnecessary await for sync queriesrecommended-badge angular-badge react-badge vue-badge
no-debugDisallow the use of debugangular-badge react-badge vue-badge
no-dom-importDisallow importing from DOM Testing Libraryangular-badge react-badge vue-badgefixable-badge
no-manual-cleanupDisallow the use of cleanup
no-wait-for-empty-callbackDisallow empty callbacks for waitFor and waitForElementToBeRemoved
prefer-explicit-assertSuggest using explicit assertions rather than just getBy* queries
prefer-presence-queriesEnforce specific queries when checking element is present or not
prefer-screen-queriesSuggest using screen while using queries
prefer-wait-forUse waitFor instead of deprecated wait methodsfixable-badge

Contributors ✨

Thanks goes to these wonderful people (emoji key):

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

eslint-config-react-app@corva/uibyteplayerkstick-react-scriptsluohe-react-scriptsluohe-react-tplreact-scripts-changedreact-scripts-ossreact-scripts-os2dadachartaboutbits-react-scriptscustom-cracra-anjandps-scriptsdps2cules-crabadabam-react-scripts-spectacleserver-selector1tt-flowchart-buildersamueltrahan-react-scriptsrn-shared-liaogjcircular-progressbar-reactkishorelabs-react-scriptsturbine-one-react-scripts@v-n-m/react-scriptsv-n-m-react-scriptsux-inboxgron-ui@deck-engineering/eslint-config@anatolzak/react-custom-scriptsreact-mxgraph-editoreslint-config-refined@martynastell/build-configs@martynastell/eslint-configcinstabsguming-shop-modalkd-ui-libskdui-libsimmo-statistic@swallowtail/eslint-config@jkyu/monet-clitest-widget-orderwp5-react-scripts@stackshirts/react-scriptsrete-two-editorform-test-reactform-test-shv@samarmohan/eslint-config-react-typescriptreact-scripts-jackreact-scripts-arteslint-config-remedy@webiocomponents/webio-componentsadalnamskra-islanduitq-richeditor-testtq.richeditor.module@evoclass/evoui@jean9696/eslint-config-custom@oneui/react-scripts@julienpapini/react-scriptsbankos-loan-formeslint-config-typicalluohe-r-tpl@rocklab/eslint-config-rocklabreact-scripts-oseslint-plugin-ultimate-typescript-configeslint-config-imprint@raull/eslint-config-react-app@samarmohan/eslint-configwindego-react-scripts@kiva/ssirius-standalone@memoryai/frontend-config@alfabank/eslint-config-sitereact-scripts-heisenbergeslint-config-martyncherrynickelodeon-ips-themesautoketing-test-scriptseslint-config-rboweripaiva-scripts@martyncherry/eslint-config-tseject-react-testingeslint-config-superchargeeslint-config-ultimate-typescriptoverwolf-react-scriptseparts-shared-uioh-custom-react-scripts@assemble-inc/eslint-config-assemble@infinitebrahmanuniverse/nolb-eslint-plugin-t@jarisinc/eslint-config-jaris@soyhuce/eslint-config-jest@whims/eslint-configeslint-config-sandboxfast-my-react-componentssklif-ui-kitsklif-api@everything-registry/sub-chunk-1614eslint-config-wishket@tribufu/electron-scripts@tribufu/react-scripts@indonesiafurs/style-guide@ventsislavnikolov/eslint-config
7.0.0-beta.1

21 days ago

6.2.2

23 days ago

6.2.1

26 days ago

6.1.2

6 months ago

6.1.1

6 months ago

6.2.0

6 months ago

6.1.0

7 months ago

6.0.2

8 months ago

6.0.1

9 months ago

6.0.0

9 months ago

5.11.1

9 months ago

6.0.0-alpha.15

9 months ago

5.11.0

12 months ago

5.10.3

1 year ago

5.10.2

1 year ago

5.10.1

1 year ago

5.10.0

1 year ago

6.0.0-alpha.9

2 years ago

5.8.0

2 years ago

5.9.1

2 years ago

5.9.0

2 years ago

6.0.0-alpha.10

2 years ago

6.0.0-alpha.11

2 years ago

6.0.0-alpha.12

2 years ago

6.0.0-alpha.13

2 years ago

6.0.0-alpha.14

1 year ago

5.7.3

2 years ago

6.0.0-alpha.3

2 years ago

6.0.0-alpha.4

2 years ago

6.0.0-alpha.5

2 years ago

6.0.0-alpha.6

2 years ago

6.0.0-alpha.7

2 years ago

6.0.0-alpha.8

2 years ago

6.0.0-alpha.1

2 years ago

6.0.0-alpha.2

2 years ago

5.6.4

2 years ago

5.6.3

2 years ago

5.6.2

2 years ago

5.6.1

2 years ago

5.7.2

2 years ago

5.7.1

2 years ago

5.7.0

2 years ago

5.5.1

2 years ago

5.6.0

2 years ago

5.4.0

2 years ago

5.5.0

2 years ago

5.3.1

2 years ago

5.3.0

2 years ago

5.2.1

2 years ago

5.2.0

2 years ago

5.0.6

2 years ago

5.1.0

2 years ago

5.0.5

2 years ago

5.0.4

2 years ago

5.0.3

2 years ago

5.0.2

2 years ago

5.0.1

2 years ago

5.0.0

3 years ago

5.0.0-alpha.7

3 years ago

5.0.0-alpha.6

3 years ago

5.0.0-alpha.5

3 years ago

5.0.0-alpha.4

3 years ago

5.0.0-alpha.9

3 years ago

5.0.0-alpha.8

3 years ago

5.0.0-alpha.3

3 years ago

5.0.0-alpha.10

3 years ago

4.12.4

3 years ago

4.12.3

3 years ago

4.12.2

3 years ago

5.0.0-alpha.2

3 years ago

5.0.0-alpha.1

3 years ago

4.12.1

3 years ago

4.12.0

3 years ago

4.11.0

3 years ago

4.9.3

3 years ago

4.9.2

3 years ago

4.10.1

3 years ago

4.10.0

3 years ago

4.9.1

3 years ago

4.9.0

3 years ago

4.8.0

3 years ago

4.7.0

3 years ago

4.4.0

3 years ago

4.6.0

3 years ago

4.2.1

3 years ago

4.2.0

3 years ago

4.5.0

3 years ago

4.5.1

3 years ago

4.3.0

3 years ago

4.1.2

3 years ago

4.1.1

3 years ago

4.1.0

3 years ago

4.0.2

3 years ago

4.0.1

3 years ago

4.0.0

3 years ago

4.0.0-beta.6

3 years ago

4.0.0-beta.5

3 years ago

4.0.0-beta.4

3 years ago

4.0.0-beta.3

3 years ago

4.0.0-beta.2

3 years ago

4.0.0-beta.1

3 years ago

4.0.0-alpha.2

3 years ago

3.10.2

3 years ago

4.0.0-alpha.1

3 years ago

4.0.0-alpha.0

3 years ago

3.10.1

3 years ago

3.10.0

4 years ago

3.9.2

4 years ago

3.9.1

4 years ago

3.9.0

4 years ago

3.8.0

4 years ago

3.7.0

4 years ago

3.6.0

4 years ago

3.5.0

4 years ago

3.4.1

4 years ago

3.4.0

4 years ago

3.3.2

4 years ago

3.3.1

4 years ago

3.3.0

4 years ago

3.2.3

4 years ago

3.2.2

4 years ago

3.2.1

4 years ago

3.2.0

4 years ago

3.1.4

4 years ago

3.1.3

4 years ago

3.1.2

4 years ago

3.1.1

4 years ago

3.1.0

4 years ago

3.1.0-beta.3

4 years ago

3.1.0-beta.1

4 years ago

3.1.0-beta.2

4 years ago

3.0.4

4 years ago

3.0.3

4 years ago

3.0.2

4 years ago

3.0.1

4 years ago

3.0.0

4 years ago

2.2.3

4 years ago

2.2.2

4 years ago

2.2.1

4 years ago

2.2.0

4 years ago

2.1.0

4 years ago

2.0.0

4 years ago

1.5.0

4 years ago

1.4.1

4 years ago

1.4.0

4 years ago

1.3.4

4 years ago

1.3.3

4 years ago

1.3.2

5 years ago

1.3.1

5 years ago

1.3.0

5 years ago

1.2.0

5 years ago

1.1.1

5 years ago

1.0.0

5 years ago