Socket
Socket
Sign inDemoInstall

eslint-plugin-testing-library

Package Overview
Dependencies
Maintainers
3
Versions
155
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-testing-library - npm Package Compare versions

Comparing version 4.0.0-beta.5 to 4.0.0-beta.6

29

package.json
{
"name": "eslint-plugin-testing-library",
"version": "4.0.0-beta.5",
"version": "4.0.0-beta.6",
"description": "ESLint rules for Testing Library",

@@ -8,3 +8,6 @@ "keywords": [

"eslintplugin",
"eslint-plugin"
"eslint-plugin",
"lint",
"testing-library",
"testing"
],

@@ -40,20 +43,20 @@ "author": {

"dependencies": {
"@typescript-eslint/experimental-utils": "^4.18.0"
"@typescript-eslint/experimental-utils": "^4.21.0"
},
"devDependencies": {
"@commitlint/cli": "^12.0.1",
"@commitlint/config-conventional": "^12.0.1",
"@types/jest": "^26.0.20",
"@typescript-eslint/eslint-plugin": "^4.18.0",
"@typescript-eslint/parser": "^4.18.0",
"@commitlint/cli": "^12.1.1",
"@commitlint/config-conventional": "^12.1.1",
"@types/jest": "^26.0.22",
"@typescript-eslint/eslint-plugin": "^4.21.0",
"@typescript-eslint/parser": "^4.21.0",
"cpy-cli": "^3.1.1",
"eslint": "^7.22.0",
"eslint": "^7.24.0",
"eslint-config-prettier": "^8.1.0",
"eslint-config-standard": "^16.0.2",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jest": "^24.3.1",
"eslint-plugin-jest": "^24.3.4",
"eslint-plugin-jest-formatting": "^2.0.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^3.3.1",
"eslint-plugin-promise": "^4.3.1",
"eslint-plugin-promise": "^5.1.0",
"husky": "^4.3.8",

@@ -65,4 +68,4 @@ "jest": "^26.6.3",

"semantic-release": "^17.4.2",
"ts-jest": "^26.5.3",
"typescript": "^4.2.3"
"ts-jest": "^26.5.4",
"typescript": "^4.2.4"
},

@@ -69,0 +72,0 @@ "peerDependencies": {

@@ -35,14 +35,22 @@ <div align="center">

```shell
$ npm install --save-dev eslint
# or
$ yarn add --dev eslint
```
$ npm i eslint --save-dev
```
Next, install `eslint-plugin-testing-library`:
```shell
$ npm install --save-dev eslint-plugin-testing-library
# or
$ yarn add --dev 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.
## Migrating to v4
You can find [here a detailed guide for migrating `eslint-plugin-testing-library` to v4](docs/migrating-to-v4-guide.md).
## Usage

@@ -58,3 +66,3 @@

Then configure the rules you want to use under the rules section.
Then configure the rules you want to use within `rules` property of your `.eslintrc`:

@@ -66,3 +74,4 @@ ```json

"testing-library/no-await-sync-query": "error",
"testing-library/no-debug": "warn"
"testing-library/no-debug": "warn",
"testing-library/no-dom-import": "off"
}

@@ -75,4 +84,18 @@ }

This plugin exports several recommended configurations that enforce good practices for specific Testing Library packages.
You can find more info about enabled rules in the [Supported Rules section](#supported-rules) within the `Configurations` column.
You can find more info about enabled rules in the [Supported Rules section](#supported-rules), under the `Configurations` column.
Since each one of these configurations is aimed at a particular Testing Library package, they are not extendable between them, so you should use only one of them at once per `eslintrc` file. For example, if you want to enable recommended configuration for React, you don't need to combine it somehow with DOM one:
```json
// ❌ Don't do this
{
"extends": ["plugin:testing-library/dom", "plugin:testing-library/react"]
}
// ✅ Do just this instead
{
"extends": ["plugin:testing-library/react"]
}
```
### DOM Testing Library

@@ -179,2 +202,38 @@

## Shared Settings
There are some configuration options available that will be shared across all the plugin rules. This is achieved using [ESLint Shared Settings](https://eslint.org/docs/user-guide/configuring/configuration-files#adding-shared-settings). These Shared Settings are meant to be used if you need to restrict the Aggressive Reporting mechanism, which is an out of the box advanced feature to lint Testing Library usages in a simpler way for most of the users. **So please before configuring any of these settings**, read more about [the advantages of `eslint-plugin-testing-library` Aggressive Reporting mechanism](docs/migrating-to-v4-guide.md#aggressive-reporting), and [how it's affected by these settings](docs/migrating-to-v4-guide.md#shared-settings).
If you are sure about configuring the settings, these are the options available:
### `testing-library/utils-module`
The name of your custom utility file from where you re-export everything from Testing Library package.
```json
// .eslintrc
{
"settings": {
"testing-library/utils-module": "my-custom-test-utility-file"
}
}
```
[You can find more details here](docs/migrating-to-v4-guide.md#testing-libraryutils-module).
### `testing-library/custom-renders`
A list of function names that are valid as Testing Library custom renders. Relates to [Aggressive Reporting - Renders](docs/migrating-to-v4-guide.md#renders)
```json
// .eslintrc
{
"settings": {
"testing-library/custom-renders": ["display", "renderWithProviders"]
}
}
```
[You can find more details here](docs/migrating-to-v4-guide.md#testing-librarycustom-renders).
## Contributors ✨

@@ -181,0 +240,0 @@

@@ -24,3 +24,3 @@ "use strict";

docs: {
description: 'Suggest using screen while using queries',
description: 'Suggest using screen while querying',
category: 'Best Practices',

@@ -30,3 +30,3 @@ recommended: 'error',

messages: {
preferScreenQueries: 'Use screen to query DOM elements, `screen.{{ name }}`',
preferScreenQueries: 'Avoid destructuring queries from `render` result, use `screen.{{ name }}` instead',
},

@@ -33,0 +33,0 @@ schema: [],

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc