Thanks to visit codestin.com
Credit goes to github.com

Skip to content

v4 #322

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 116 commits into from
Apr 11, 2021
Merged

v4 #322

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
116 commits
Select commit Hold shift + click to select a range
58d72d5
feat: recommend prefer-screen-queries (#169)
nickserv Jun 17, 2020
d8a2ac6
feat: recommend no-wait-for-empty-callback (#168)
nickserv Jun 17, 2020
094f53c
feat(no-container): setup new rule on index
Jun 18, 2020
da88a9d
refactor(no-container): set rules
Jun 18, 2020
ee369e5
test(no-container): define scenarios
Jun 18, 2020
5d02426
refactor(no-debug): extract auxiliary functions
Jun 19, 2020
0205374
refactor(no-container): add conditional
Jun 19, 2020
d8e555e
docs(no-container): add new and update README
Jun 19, 2020
497a5b6
refactor(no-container): allow custom render
Jun 19, 2020
4ab2305
test(no-container): add custom render function
Jun 19, 2020
c11fcd6
docs(no-container): update further reading topics
Jun 19, 2020
ac2d7ac
Merge remote-tracking branch 'origin/master' into v4
Belco90 Jun 19, 2020
1d8077c
Merge branch 'v4' of https://github.com/thebinaryfelix/eslint-plugin-…
Jun 19, 2020
d624bfe
Merge branch 'v4' into no-container
thebinaryfelix Jun 19, 2020
1c59122
docs(no-container): update
Jun 19, 2020
52f5995
test(no-container): add scenarios
Jun 19, 2020
4eb5381
refactor(no-container): adjust to new scenarios
Jun 19, 2020
3943f45
docs(no-container): add incorrect use cases
Jun 19, 2020
8e2cdcc
refactor(no-container): remove wrong use case
thebinaryfelix Jun 20, 2020
78fdfe7
refactor(no-container): add scenario
thebinaryfelix Jun 20, 2020
9812cf4
refactor(no-container): rename function
thebinaryfelix Jun 20, 2020
e63968f
refactor(no-container): remove condition
thebinaryfelix Jun 20, 2020
5aa3a80
refactor(no-container): update error message
thebinaryfelix Jun 20, 2020
63f2db4
Merge remote-tracking branch 'origin/master' into v4
Belco90 Jun 21, 2020
a4cc8d8
feat(no-promise-in-fire-event): add new no-promise-in-fire-event rule…
timdeschryver Jun 21, 2020
9d44911
Merge branch 'v4' into no-container
thebinaryfelix Jun 21, 2020
86f9c84
feat: add no-container rule #177
gndelia Jun 21, 2020
9db40ee
refactor: rename recommended config to dom (#184)
Belco90 Jun 22, 2020
11d67b2
feat: add rule no-multiple-assertions-wait-for (#189)
renatoagds Jun 30, 2020
b2ef721
Merge remote-tracking branch 'origin/master' into v4
Belco90 Jun 30, 2020
9d4c1e4
feat: add no-node-access rule (#190)
thebinaryfelix Jul 15, 2020
9aa6730
feat: add prefer-user-event rule (#192)
gndelia Jul 20, 2020
17e3cfe
Merge remote-tracking branch 'origin/master' into v4
Belco90 Jul 20, 2020
3b9d5b5
feat: add render-result-naming-convention rule (#200)
Belco90 Jul 27, 2020
8ad0184
Merge remote-tracking branch 'origin/master' into v4
Belco90 Jul 27, 2020
91200b7
feat: add no-side-effects-wait-for rule (#196)
renatoagds Jul 28, 2020
2ac6b81
Merge v4 with develop
Belco90 Aug 15, 2020
44de9fc
chore: lint and format on pre-commit and ci (#216)
gndelia Aug 17, 2020
4b7300e
chore: merge master into v4 (#233)
MichaelDeBoey Sep 20, 2020
9c2072d
chore: update dependencies + run prettier on codebase (#234)
MichaelDeBoey Sep 21, 2020
3a0d125
Merge remote-tracking branch 'origin/master' into v4
Belco90 Oct 18, 2020
1dbb513
style: apply prettier after merge
Belco90 Oct 18, 2020
ce4770f
refactor(no-node-access): use new testing library rule maker (#237)
Belco90 Oct 20, 2020
63c9d7b
refactor: improve logic to detect if testing librar imported (#239)
Belco90 Oct 25, 2020
6abb4ee
feat: new setting for reported filename pattern (#244)
Belco90 Nov 1, 2020
d1f0388
Merge remote-tracking branch 'origin/master' into v4
Belco90 Nov 1, 2020
5a6644f
refactor(no-dom-import): use createTestingLibraryRule (#247)
Belco90 Nov 1, 2020
eb17456
docs(consistent-data-testid): add clarification about rule creation (…
Belco90 Nov 3, 2020
287ca77
refactor(no-manual-cleanup): use custom rule creator (#249)
Belco90 Nov 4, 2020
c880f2f
refactor(prefer-user-event): use new custom rule creator (#251)
gndelia Nov 9, 2020
b48b286
refactor(prefer-presence-queries): use custom rule creator (#252)
Belco90 Nov 10, 2020
6018dd1
refactor: detection helpers tweaks (#254)
Belco90 Nov 10, 2020
ae3eac7
refactor(ast-utils): migrate custom node-utils to ASTUtils (#256)
Nov 17, 2020
8b66b52
chore: decrease node-utils coverage threshold
Belco90 Nov 17, 2020
727a966
refactor(prefer-wait-for): use new custom rule creator (#255)
gndelia Nov 19, 2020
5ce0ba0
Merge remote-tracking branch 'origin/master' into v4
Belco90 Nov 23, 2020
dcc0693
refactor: use custom rule creator for promise-queries rules (#260)
Belco90 Nov 28, 2020
9062040
refactor(await-async-utils): use custom rule creator (#263)
Belco90 Dec 6, 2020
668a1bf
refactor(await-fire-event): use custom rule creator (#265)
Belco90 Dec 7, 2020
6f506ee
refactor(no-promise-in-fire-event): use custom rule creator (#266)
Belco90 Dec 7, 2020
d0c76d4
refactor(no-wait-for-snapshot) migrate to v4 (#271)
gndelia Dec 13, 2020
bd60704
refactor(prefer-find-by) migrate to v4 (#270)
gndelia Dec 13, 2020
af32b0c
refactor(prefer-explicit-assert): use new utils and remove custom que…
Dec 29, 2020
ca2910b
Merge remote-tracking branch 'origin/main' into v4
Belco90 Jan 24, 2021
ed09979
fix(no-await-sync-query): avoid reporting queries if not within calle…
Belco90 Jan 30, 2021
b1355ad
refactor: remove duplicated param type
Belco90 Jan 30, 2021
5a5881e
refactor: rename helpers for determining query variants
Belco90 Jan 30, 2021
4e9e585
refactor(render-result-naming-convention): migrate to v4 (#280)
Belco90 Mar 3, 2021
192a37e
refactor: second round of tweaks (#281)
Belco90 Mar 8, 2021
50727e6
refactor(render-result-naming-convention): refine checks to decide if…
Belco90 Mar 14, 2021
f740836
ci: update pipeline with v4 changes (#289)
Belco90 Mar 16, 2021
b0b8c48
Merge remote-tracking branch 'origin/main' into v4
Belco90 Mar 16, 2021
6d90153
refactor(prefer-screen-queries): migrate to v4 (#285)
Belco90 Mar 16, 2021
dd30d02
chore: update dependencies (#290)
MichaelDeBoey Mar 16, 2021
ea62638
refactor(no-wait-for-empty-callback): migrate to v4 (#284)
Belco90 Mar 16, 2021
9bcf595
refactor(refactor no-debug): migrate to v4 (#293)
Belco90 Mar 20, 2021
65028a5
refactor(no-container): migrate to v4 (#295)
Belco90 Mar 20, 2021
2588602
Merge remote-tracking branch 'origin/main' into v4
Belco90 Mar 21, 2021
461809f
Merge remote-tracking branch 'origin/v4' into v4
Belco90 Mar 21, 2021
69d5bbe
refactor: remove mechanism to match files to be reported (#297)
Belco90 Mar 23, 2021
b1b8b25
refactor(no-render-in-setup): migrate to v4 (#299)
Belco90 Mar 25, 2021
3b785c2
Merge remote-tracking branch 'origin/main' into v4
Belco90 Mar 25, 2021
15fd7c4
refacto(no-wait-for-side-effects): migrate to v4 (#300)
Belco90 Mar 27, 2021
9386773
refactor(no-wait-for-multiple-assertions): migrate to v4 (#301)
Belco90 Mar 27, 2021
a6eea4d
refactor(no-await-sync-events): migrate to v4 (#302)
Belco90 Mar 28, 2021
82ace49
refactor: cleanup after migrating all rules to v4 (#303)
Belco90 Mar 28, 2021
a8c1fe4
fix(await-async-utils): reference correct node name
Belco90 Mar 30, 2021
82124af
fix(prefer-find-by): simplify error message
Belco90 Mar 30, 2021
cac6670
fix(no-await-sync-query): avoid false positive from parent func
Belco90 Mar 31, 2021
06b437c
test(no-await-sync-query): increase code coverage up to 100%
Belco90 Apr 1, 2021
98448bb
feat(no-wait-for-multiple-assertions): report assertions
Belco90 Apr 1, 2021
592c128
test(no-wait-for-multiple-assertions): increase code coverage up to 100%
Belco90 Apr 1, 2021
93b81f5
fix(no-wait-for-side-effects): report on each side effect node
Belco90 Apr 2, 2021
c801b1d
test(no-await-sync-query): include extra case for disappearance
Belco90 Apr 2, 2021
c176c2a
fix: guard against null deepest identifier node
Belco90 Apr 2, 2021
83f27d8
fix: guard against null property identifier node
Belco90 Apr 2, 2021
91abe97
ci: decrease coverage threshold
Belco90 Apr 2, 2021
7e9d5c5
fix: first round of bugfixes for v4
Belco90 Apr 3, 2021
abfe5e8
fix: enable TS strict mode
Belco90 Apr 3, 2021
751889b
fix: remove closing comment leftover
Belco90 Apr 3, 2021
8ceb80f
refactor: declare test cases typings as expected
Belco90 Apr 3, 2021
c20dbb9
fix: remove wrong boolean check for detection
Belco90 Apr 3, 2021
cc040a5
Merge "main" branch into "306_null-identifiers"
Belco90 Apr 3, 2021
eaca948
Merge pull request #309 from testing-library/306_null-identifiers
Belco90 Apr 3, 2021
fd81fc5
fix(prefer-user-event): format list of userEvent methods correctly (…
Belco90 Apr 4, 2021
66df731
fix: second round of bugfixes for v4 (#314)
Belco90 Apr 5, 2021
f4b5958
docs: add guide for migrating to v4 (#312)
Belco90 Apr 5, 2021
9365bf1
docs: update README for v4 (#317)
Belco90 Apr 8, 2021
ce38144
chore: update dependencies (#319)
MichaelDeBoey Apr 10, 2021
20027f4
fix: third round of bug fixes (#320)
Belco90 Apr 10, 2021
025f23d
docs: update contributing guidelines to v4 (#321)
Belco90 Apr 11, 2021
b150663
ci: remove unnecessary quote marks for node versions
Belco90 Apr 11, 2021
b5b93a4
Revert "ci: remove unnecessary quote marks for node versions"
Belco90 Apr 11, 2021
8f2e0a5
chore: revert node 10.22.1 as minimum version
Belco90 Apr 11, 2021
511986c
ci: include 12.0 in node versions matrix
Belco90 Apr 11, 2021
22387d5
ci: wrap matrix values within quotes
Belco90 Apr 11, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
coverage/
dist/
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"extends": [
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"prettier/@typescript-eslint",
"prettier",
"plugin:jest/recommended",
"plugin:jest-formatting/recommended"
],
Expand Down
12 changes: 8 additions & 4 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
version: 2
updates:
# Set update schedule for GitHub Actions
- package-ecosystem: 'github-actions'
directory: '/'
- package-ecosystem: github-actions
directory: /
schedule:
interval: 'daily'
interval: daily

- package-ecosystem: npm
directory: /
schedule:
interval: daily
11 changes: 7 additions & 4 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
uses: styfle/[email protected]
with:
access_token: ${{ secrets.GITHUB_TOKEN }}

- name: Checkout
uses: actions/checkout@v2

Expand All @@ -37,12 +38,14 @@ jobs:
with:
useLockFile: false

- name: Check Types
run: npm run type-check

- name: Lint code
run: npm run lint

# TODO: reenable on v4 + run tsc
# - name: Check format
# run: npm run format:check
- name: Check format
run: npm run format:check

tests:
name: Tests (Node v${{ matrix.node }} - ESLint v${{ matrix.eslint }})
Expand All @@ -51,7 +54,7 @@ jobs:
strategy:
matrix:
node: [ '10.12', '10', '12.0', '12', '14' ]
eslint: [ '5', '6', '7' ]
eslint: [ '7.5', '7' ]

steps:
- name: Cancel Previous Runs
Expand Down
2 changes: 1 addition & 1 deletion .huskyrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"hooks": {
"pre-commit": "npm run test && lint-staged",
"pre-commit": "lint-staged",
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
}
8 changes: 6 additions & 2 deletions .lintstagedrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{
"*.js": ["eslint --fix", "git add"],
"*.md": ["prettier --write", "git add"]
"*.{js,ts}": [
"eslint --max-warnings 0 --fix",
"prettier --write",
"jest --findRelatedTests"
],
"*.md": ["prettier --write"]
}
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
3 changes: 3 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
singleQuote: true,
};
4 changes: 0 additions & 4 deletions .prettierrc.json

This file was deleted.

17 changes: 17 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"pkgRoot": "dist",
"branches": [
"+([0-9])?(.{+([0-9]),x}).x",
"main",
"next",
"next-major",
{
"name": "beta",
"prerelease": true
},
{
"name": "alpha",
"prerelease": true
}
]
}
26 changes: 13 additions & 13 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@ appearance, race, religion, or sexual identity and orientation.
Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
- The use of sexualized language or imagery and unwelcome sexual attention or
advances
- Trolling, insulting/derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or electronic
address, without explicit permission
- Other conduct which could reasonably be considered inappropriate in a
professional setting

## Our Responsibilities

Expand Down
62 changes: 61 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,41 @@ Additionally, you need to do a couple of extra things:
- Include your rule in the "Supported Rules" table within the [README.md](./README.md).
Don't forget to include the proper badges if needed and to sort alphabetically the rules for readability.

## Modifying rules
### Custom rule creator

In v4 we introduced several improvements for both the final users as for contributors. Now there is a custom Rule Creator available called `createTestingLibraryRule` which should be the default Rule Creator used in this plugin. This Testing Library Rule Creator extends TSESLint Rule Creator to enhance rules automatically, so it prevents rules to be reported if nothing related to Testing Library found, and injects a 3rd parameter within `create` function: `helpers`.

This new `helpers` available in the `create` of the rule gives you access to a bunch of utils to detect things related to Testing Library. You can find all of them in `detect-testing-library-utils.ts` file, but these are some helpers available:

- `isTestingLibraryImported`
- `isGetQueryVariant`
- `isQueryQueryVariant`
- `isFindQueryVariant`
- `isSyncQuery`
- `isAsyncQuery`
- `isQuery`
- `isCustomQuery`
- `isAsyncUtil`
- `isFireEventUtil`
- `isUserEventUtil`
- `isFireEventMethod`
- `isUserEventMethod`
- `isRenderUtil`
- `isRenderVariableDeclarator`
- `isDebugUtil`
- `isPresenceAssert`
- `isAbsenceAssert`
- `isNodeComingFromTestingLibrary`

Our custom Rule Creator will also take care of common checks like making sure Testing Library is imported, or verify Shared Settings. You don't need to implement anything to check if there is some import related to Testing Library or anything similar in your rule anymore, just stick to the `helpers` received as a 3rd parameter in your `create` function.

If you need some check related to Testing Library which is not available in any existing helper, feel free to implement a new one. You need to make sure to:

- add corresponding type
- pass it through `helpers`
- write some generic test within `fake-rule.ts`, which is a dumb rule to be able to test all enhanced behavior from our custom Rule Creator.

## Updating existing rules

A couple of things you need to remember when editing already existing rules:

Expand All @@ -80,6 +114,32 @@ A couple of things you need to remember when editing already existing rules:
- Try to add tests to cover the changes introduced, no matter if that's
a bug fix or a new feature.

## Writing Tests

When writing tests for a new or existing rule, please make sure to follow these guidelines:

### Write real-ish scenarios

Since the plugin will report differently depending on which Testing Library package is imported and what Shared Settings are enabled, writing more realistic scenarios is pretty important. Ideally, you should:

- wrap the code for your rule with a real test file structure, something like

```javascript
import { render } from '@testing-library/react';

test('should report invalid render usage', () => {
// the following line is the actual code you needed to test your rule,
// but everything else helps finding edge cases and makes it more robust.
const wrapper = render(<Component />);
});
```

- add some extra valid and invalid cases for checking what's the result when some Shared Settings are enabled (so things may or may not be reported depending on the settings), or something named in the same way as a Testing Library util is found, but it's not coming from any Testing Library package (so it shouldn't be reported).

### Check as much as you can from error reported on invalid test cases

Please make sure you check `line`, `column`, `messageId` and `data` (if some) in your invalid test cases to check errors are reported as expected.

## Help needed

Please check the [the open issues](https://github.com/testing-library/eslint-plugin-testing-library/issues)
Expand Down
Loading