Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Support ESLint 7.x #139

Merged
merged 1 commit into from Sep 20, 2020
Merged

feat: Support ESLint 7.x #139

merged 1 commit into from Sep 20, 2020

Conversation

MichaelDeBoey
Copy link
Member

@MichaelDeBoey MichaelDeBoey commented May 17, 2020

@Belco90
Copy link
Member

Belco90 commented Jun 11, 2020

@MichaelDeBoey After rechecking this, I'm wondering if what you want to do is to force the plugin to work only for ESLint >= 7? If so, I would avoid this restriction and just make it compatible with ESLint 7 without losing compatibility with ESLint 6 at least. From your changes it looks it would be only compatible with ESLint 7.

@MichaelDeBoey
Copy link
Member Author

@Belco90 @typescript-eslint/experimental-utils needs ESLint 7.x

@Belco90
Copy link
Member

Belco90 commented Jun 11, 2020

Sorry, let me reword this. There are two different uses of ESLint here:

  • Plugin dev dependency itself. This is the version we install for developing the actual plugin. This one is fine to be upgraded to v7 as you did in package.json
  • Users dependency. This is the version of ESLint the users installing eslint-plugin-testing-library are using in their environments, and we don't have control over that. If we force the users to use ESLint v7 in order to make this plugin to work, all dependents projects using this plugin would be forced to migrate to ESLint v7 in order to keep using it. You bumped this one too in package.json

So upgrading ESLint to v7 in our dev dependencies is fine, but it's not for peer dependency. ESLint is never a direct dependency of the plugin, so we should leave it compatible for ESLint >= 5 in peer dependency. This is why in the original issue I mentioned the fact we would need to update the CI to run all the tests against ESLint v5, v6 and v7 to make sure we offer proper compatibility for users using that range of versions in their projects.

You can check this in eslint-plugin-react. They don't even force ESLint to v7 in their dev dependencies but have a matrix instead with all the ESLint versions they offer compatibility in both dev and peer dependencies.

I don't know if I'm missing something else here or from your changes.

@MichaelDeBoey
Copy link
Member Author

@Belco90 Like I said before: @typescript-eslint/experimental-utils (which is a dependency of this plugin) requires ESLint 7.x, so we need to force users of this plugin to use ESLint 7.x

Sorry if I wasn't clear enough that @typescript-eslint/experimental-utils is a dependency of this plugin 馃槙

@Belco90
Copy link
Member

Belco90 commented Jun 11, 2020

That's what I was missing. I though @typescript-eslint/experimental-utils was a dev dependency, but it's a regular dependency. We could add then ESLint v7 as direct dependency so it's bundled with the plugin and the user can use whatever ESLint version they want from 5 to 7.

But that will make the plugin really heavy, so it doesn't sound like a good option.

I don't know which other options we have (not upgrading @typescript-eslint/experimental-utils yet so we don't need ESLint v7 as dependency?) but definitely I do not want to force users to migrate to ESLint v7. We are not "adding support for ESLint 7.x" with the current PR as its title claims, but "migrating the whole plugin to ESLint 7.x" with its corresponding breaking change.

@Belco90
Copy link
Member

Belco90 commented Jun 11, 2020

Is @typescript-eslint/experimental-utils only compatible with ESLint v7 tho? I don't see that as breaking change, but just they added support for v7.

@Belco90
Copy link
Member

Belco90 commented Jun 11, 2020

They support ESLint v5, v6 and v7 so again unless I'm missing something, I don't think we need to restrict it to ESLint v7 here.

@MichaelDeBoey
Copy link
Member Author

I'm sorry, I thought only ESLint 7.x was supported anymore.

I think forcing users to use ESLint 7.x as a breaking change is a good thing tbh.
We'll make the community use newer versions of software, which is a good thing imo.
Since this is a breaking change and it's the only breaking thing, I think this can be done.
Because technically we already support ESLint 7.x if we look at the current peerDependencies.

@Belco90
Copy link
Member

Belco90 commented Jun 11, 2020

Indeed, current peerDependencies are wrongly set so we need to fix that so it would be like "eslint": "^5 || ^6 || ^7".

I don't think we should drop support for ESLint 5 and 6 right now. Packages just don't drop support for node v10 and v12 a month after node v14 is released. We should do the same with ESLint here, and it's what heavily used ESLint plugins are doing (like typescript-eslint or eslint-plugin-react). It's not that easy to update ESLint for projects using it, we can't just force people to move to ESLint v7 from one day to the other.

Having said that, the changes for supporting ESLint v5, v6 and v7 aren't that complicated. Apart from the amazing work you did in this PR, we would need to update peer deps as mentioned before and add the ESLint dependencies matrix to CI. I can do the latter during this weekend, I have some spare time and it's something should have been included while ago to test support for v5 and v6. Probably updating the contributing guidelines is a good idea too.

At the moment we are not doing specific things for v7, so in the future we may need some extra checks in the code to do only few things depending on user ESLint version, but we are safe in that side for now.

@Belco90 Belco90 added chore Changes that affect the build system, CI config or other changes that don't modify src/test files dependencies Pull requests that update a dependency file enhancement New feature or request labels Jun 13, 2020
@Belco90
Copy link
Member

Belco90 commented Jun 13, 2020

CI matrix added in #164. Could you take a look at it please?

@Belco90
Copy link
Member

Belco90 commented Jun 13, 2020

Merged. The ESLint matrix is available and ESLint versions have been fixed properly between v5 and v6. You need to update that here so it accepts ESLint versions between v5 and v7 and generate the matrix until v7. Let me know if I can help you with it.

@MichaelDeBoey
Copy link
Member Author

MichaelDeBoey commented Jun 14, 2020

@Belco90 I've rebased this branch onto upstream/upstream and deleted the breaking change notice, since you already updated that in your CI PR.

@Belco90
Copy link
Member

Belco90 commented Jun 14, 2020

Nice! The CI is passing: https://travis-ci.org/github/testing-library/eslint-plugin-testing-library/builds/698191193

Do we really need to wait for those dependencies from the description to be updated to v7 support?

@MichaelDeBoey
Copy link
Member Author

MichaelDeBoey commented Jun 14, 2020

@Belco90 Since they're not compatible with ESLint 7 yet, I would wait for them.

@Belco90
Copy link
Member

Belco90 commented Jun 15, 2020

I think we should leave peer dependencies with no ended range: https://twitter.com/SemanticRelease/status/1249795728253353986

nickmccurdy
nickmccurdy previously approved these changes Jul 6, 2020
@chrisbobbe
Copy link

I see this update in the GitHub UI 馃檪:

nickmccurdy approved these changes on Jul 5

What's next for this PR; can it be merged, or maybe un-marked as a draft?

@nickmccurdy
Copy link
Member

nickmccurdy commented Sep 18, 2020

It seems to be blocked by mysticatea/eslint-plugin-node#223 and eslint-community/eslint-plugin-promise#189.

@Belco90
Copy link
Member

Belco90 commented Sep 19, 2020

Yep, although I've thought couple of times it would be fine to merge it. I think our plugin should work fine, it could imply just a bigger bundle size.

Copy link
Member

@Belco90 Belco90 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some regression changes around ESLint version declaration. I'm checking the failing test meanwhile.

.travis.yml Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
@Belco90
Copy link
Member

Belco90 commented Sep 19, 2020

I can see several warnings after bumping TS to v4:

ts-jest[versions] (WARN) Version 4.0.3 of typescript installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=3.4.0 <4.0.0). Please do not report issues in ts-jest if you are using unsupported versions.

It doesn't solve the issues in the tests tho, but I'm not sure if we should bump TS then.

@MichaelDeBoey
Copy link
Member Author

MichaelDeBoey commented Sep 20, 2020

@Belco90 Since all tests are green for ESLint 7.x, I think we can merge this one without mysticatea/eslint-plugin-node#224 & eslint-community/eslint-plugin-promise#190 being merged 馃檪

@MichaelDeBoey MichaelDeBoey marked this pull request as ready for review September 20, 2020 13:30
Copy link
Member

@Belco90 Belco90 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy to merge this, but since it is a breaking change I'm gonna request to point this PR to v4 rather than master. Can you do that please? So we use that new major to introduce this breaking change. I think you shouldn't have any issue pointing to that branch. Let me know if you need help if you find any problem tho.

Also, can you please update Installation section from README to specify ESLint v7.5 is required now?

Thanks.

@MichaelDeBoey
Copy link
Member Author

@Belco90 I'll revert all @typescript-eslint/experimental-utils changes so we can merge this one and unblock CRA.
I'll create a new PR with the changes and point it to v4 branch once this one's merged 馃檪

@Belco90
Copy link
Member

Belco90 commented Sep 20, 2020

Brilliant. Thanks for your hard work @MichaelDeBoey

@MichaelDeBoey
Copy link
Member Author

@Belco90 All tests are green 馃檪

Copy link
Member

@Belco90 Belco90 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome. Just a small tweak to peerDependencies and should be ready to go!

package.json Outdated Show resolved Hide resolved
@Belco90 Belco90 merged commit be75630 into testing-library:master Sep 20, 2020
@MichaelDeBoey MichaelDeBoey deleted the eslint-7 branch September 20, 2020 15:43
@Belco90
Copy link
Member

Belco90 commented Sep 20, 2020

馃帀 This PR is included in version 3.9.0 馃帀

The release is available on:

Your semantic-release bot 馃摝馃殌

@Belco90
Copy link
Member

Belco90 commented Sep 20, 2020

@all-contributors please add @MichaelDeBoey for code and platform

@allcontributors
Copy link
Contributor

@Belco90

I've put up a pull request to add @MichaelDeBoey! 馃帀

Belco90 added a commit that referenced this pull request Sep 20, 2020
* feat(prefer-explicit-assert): add 'assertion' config option (#220)

Closes #218

* docs: add skovy as a contributor (#221)

* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>

* feat: new no-wait-for-snapshot rule (#223)

Closes: #214

* docs: add Gpx as a contributor [skip ci] (#224)

* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>

* docs(no-wait-for-snapshot): fix link to rule doc (#225)

* docs: add jdanil as a contributor [skip ci] (#226)

* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>

* Update .travis.yml

* feat: support ESLint 7.x (#139)

Closes #138

* docs: add MichaelDeBoey as a contributor [skip ci] (#231)

* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>

* chore: update dependencies + run prettier on codebase (#232)

* chore: update dependencies

* chore: run Prettier on full codebase

Co-authored-by: Spencer Miskoviak <5247455+skovy@users.noreply.github.com>
Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
Co-authored-by: Giorgio Polvara <polvara@gmail.com>
Co-authored-by: Josh David <joshua.david@uqconnect.edu.au>
Co-authored-by: Mario Beltr谩n Alarc贸n <belco90@gmail.com>
Belco90 added a commit that referenced this pull request Apr 11, 2021
* feat: recommend prefer-screen-queries (#169)

BREAKING CHANGE: `prefer-screen-queries` rule is automatically enabled if recommended, angular, react or vue config enabled. If you have any of those enabled, you could get new ESLint errors related to this rule after upgrading this plugin.

* feat: recommend no-wait-for-empty-callback (#168)

BREAKING CHANGE: `no-wait-for-empty-callback` rule is automatically enabled if recommended, angular, react or vue config enabled. If you have any of those enabled, you could get new ESLint errors related to this rule after upgrading this plugin.

* feat(no-container): setup new rule on index

* refactor(no-container): set rules

* test(no-container): define scenarios

* refactor(no-debug): extract auxiliary functions
to node-utils, to be used by no-container

* refactor(no-container): add conditional
for containerIndex
| clean up method declaration

* docs(no-container): add new and update README

* refactor(no-container): allow custom render
functions

* test(no-container): add custom render function

* docs(no-container): update further reading topics

* docs(no-container): update
| add description about testing library frameworks
| add link to container docs
| remove recommended badge

* test(no-container): add scenarios

* refactor(no-container): adjust to new scenarios
| update error message

* docs(no-container): add incorrect use cases

* refactor(no-container): remove wrong use case
scenario

* refactor(no-container): add scenario
| destructure method from container

* refactor(no-container): rename function
and change its scope

* refactor(no-container): remove condition

* refactor(no-container): update error message
and incorrect use case

* feat(no-promise-in-fire-event): add new no-promise-in-fire-event rule (#180)

* feat(no-promise-in-fire-event): add new no-promise-in-fire-event rule

* test: 100% code coverage

* docs: add rule to readme

* chore: review changes

* chore: add rule to recommended config

* refactor: rename recommended config to dom (#184)

BREAKING CHANGE: `recommended` config preset has been renamed to `dom`, so make sure to update it in your ESLint config file if you were using `recommended` preset.

* feat: add rule no-multiple-assertions-wait-for (#189)

* feat: add initial files for no-multiple-expect-wait-for rule

* fix: add expect fields in test

* feat: add no-multiple-assertion-wait-for logic

* feat: add findClosestCalleName in node-utils

* feat: add check for expect and rename file

* docs: add no-multiple-assertions-wait-for rule doc

* docs: add link for no-multiple-assertions-wait-for doc

* docs: insert function example in no-multiple-assertions-wait-for

* refactor: remove find closest call node from node-utils

* fix: check expect based in total

* docs: better english in no-multiple-assertions-wait-for rule details

Co-authored-by: Tim Deschryver <28659384+timdeschryver@users.noreply.github.com>

* fix: use correct rule name in no-multiple-assertions-wait-for

Co-authored-by: Tim Deschryver <28659384+timdeschryver@users.noreply.github.com>

* docs: improve docs for no-multiple-assertions-wait-for

* fix: typo in no-multiple-assertions-wait-for

* fix: better english in no-multiple-assertions-wait-for

Co-authored-by: Tim Deschryver <28659384+timdeschryver@users.noreply.github.com>

* feat: add no-node-access rule (#190)

* refactor(utils): add properties and methods
that returns another Node

* test(no-node-access): add first scenarios

* feat(no-node-access): add rule
with few test cases

* test(no-node-access): add scenarios

* refactor(no-node-access): simplify conditions

* refactor(no-node-access): add scenario
when no variable is declared

* refactor(no-node-access): remove conditional

* refactor(utils): add DOM properties

* refactor(no-node-access): add scenario
for accessing document directly

* docs(no-node-access): add readme

* refactor(utils): export const
containing all properties and methods that return a Node

* docs(no-node-access): fix file location

* docs(readme): add no-node-access

* refactor(no-node-access): change highlight location

* docs(no-node-access): fix typo

* refactor(utils): add missing property
that returns a Node

* refactor(no-node-access): simplify checks
triggering error for all methods with names matching the forbidden ones

* test(no-node-access): add more scenarios
with destructuring

* docs(no-node-access): update examples

* refactor(no-node-access): narrow error cases

* refactor(no-node-access): check imports
to validate whether is importing a testing-library package
| update examples and testing scenarios

* refactor(no-node-access): rename variable

* feat: add prefer-user-event rule (#192)

* feat: add render-result-naming-convention rule (#200)

* feat: rule skeleton

* test: first round

* feat: rule implementation round 1

* refactor: move hasTestingLibraryImportModule

* test: fix invalid lines

* feat: check imported module

* feat: check imported render renamed

* feat: check custom render

* test: add more valid tests for custom render functions

* test: update tests for render wrapper functions

* docs: add rule docs

* test: increase coverage up to 100%

* fix: add rule meta description

* docs: update rule details to mention screen object

* refactor: return as soon as conditions are not met

* feat: check wildcard imports

* refactor: rename default import

* docs: include render result link

* feat: add no-side-effects-wait-for rule (#196)

* test: add scenarios for no-side-effects-wait-for

* feat: add no-side-effects-wait-for rule

* feat: add no-side-effects-wait-for in index

* test: add more valid scenarios in no-side-effects-wait-for

* docs: include no-side-effects-wait-for

* fix: typo in no-side-effects-wait-for doc

Co-authored-by: Gonzalo D'Elia <gonzalo.n.delia@gmail.com>

* fix: remove extra code in examples

* refactor: use some instead filter in no-side-effects-wait-for

* feat: check if no-side-effects-wait-for is called inside tests

* refactor: use util for import check at no-side-effects-wait-for

* test: valid scenario for no TL wait for import at no-side-effects

* refactor: usage of correct user event methods

Co-authored-by: Gonzalo D'Elia <gonzalo.n.delia@gmail.com>

* chore: lint and format on pre-commit and ci (#216)

* chore: lint and format on pre-commit and ci

* chore: changing stage name in travis ci conf

* chore: merge master into v4 (#233)

* feat(prefer-explicit-assert): add 'assertion' config option (#220)

Closes #218

* docs: add skovy as a contributor (#221)

* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>

* feat: new no-wait-for-snapshot rule (#223)

Closes: #214

* docs: add Gpx as a contributor [skip ci] (#224)

* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>

* docs(no-wait-for-snapshot): fix link to rule doc (#225)

* docs: add jdanil as a contributor [skip ci] (#226)

* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>

* Update .travis.yml

* feat: support ESLint 7.x (#139)

Closes #138

* docs: add MichaelDeBoey as a contributor [skip ci] (#231)

* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>

* chore: update dependencies + run prettier on codebase (#232)

* chore: update dependencies

* chore: run Prettier on full codebase

Co-authored-by: Spencer Miskoviak <5247455+skovy@users.noreply.github.com>
Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
Co-authored-by: Giorgio Polvara <polvara@gmail.com>
Co-authored-by: Josh David <joshua.david@uqconnect.edu.au>
Co-authored-by: Mario Beltr谩n Alarc贸n <belco90@gmail.com>

* chore: update dependencies + run prettier on codebase (#234)

BREAKING CHANGE: Minimum node version required is v10.22.1
BREAKING CHANGE: Minimum ESLint version required is 7.5.0. Support for ESLint between v5 and v7.4 has been dropped

* style: apply prettier after merge

* refactor(no-node-access): use new testing library rule maker (#237)

* build: add npmrc file

Adding .npmrc file to indicate we don't want to generate package-lock
properly.

* refactor: first approach for testing library detection

* refactor: move testing library detection to high-order function

* refactor: include create-testing-library-rule

* refactor(no-node-access): use create-testing-library-rule

* test: decrease coverage threshold for utils detection

* test: decrease coverage threshold for utils detection branches

* style: add missing return type on function

* style: format with prettier properly

Apparently the regexp for formatting the files within npm command must
be passed with double quotes. More details here:
https://dev.to/gruckion/comment/b665

* docs: copied types clarification

* refactor: improve logic to detect if testing librar imported (#239)

* refactor: check testing library imports automatically

* feat: add new shared setting for testing library module

* test: increase coverage for create testing library rule

* refactor: extract common enhanced rule create types

* docs: add jsdoc to detection helpers

* docs: update old comments related to ImportDeclaration

* test: check rule listener are combined properly

* feat: new setting for reported filename pattern (#244)

* feat: new setting for customizing file name pattern to report

* test: add custom rule tester for testing library

* refactor: use common rule tester config

* refactor(no-dom-import): use createTestingLibraryRule (#247)

* feat: new setting for customizing file name pattern to report

* test: add custom rule tester for testing library

* refactor: use common rule tester config

* refactor(no-dom-import): use createTestingLibraryRule

* feat(detection-helpers): check imports with require

* test(no-dom-import): include test cases for custom module setting

* test(no-dom-import): include test cases for custom module setting

* chore: fix merge

* refactor(no-dom-import): extract detection helpers for import nodes

* test: increase coverage

* refactor: rename setting for filename pattern

* docs(consistent-data-testid): add clarification about rule creation (#248)

* feat: new setting for customizing file name pattern to report

* test: add custom rule tester for testing library

* refactor: use common rule tester config

* refactor(no-dom-import): use createTestingLibraryRule

* feat(detection-helpers): check imports with require

* test(no-dom-import): include test cases for custom module setting

* test(no-dom-import): include test cases for custom module setting

* chore: fix merge

* refactor(no-dom-import): extract detection helpers for import nodes

* test: increase coverage

* refactor: rename setting for filename pattern

* refactor: add new detection option to skip reporting checks

* refactor(consistent-data-testid): use createTestingLibraryRule

* revert: refactor consistent-data-testid

* revert: detection options

* docs(consistent-data-testid): add clarification about rule creation

* refactor(no-manual-cleanup): use custom rule creator (#249)

* refactor(no-manual-cleanup): use custom rule creator

* refactor: extract detection utils for import module name

* refactor(no-manual-cleanup): use detection helpers for imported modules

* refactor(no-manual-cleanup): small improvements

* test(no-manual-cleanup): include more variants

* feat(no-manual-cleanup): report custom module

* refactor: rename type for import module node

* refactor: use node utils to know node type

* refactor: remove unused imports

* refactor: remove outdated comment line

* refactor(prefer-user-event): use new custom rule creator (#251)

* feat: add new settings for prefer-user-event pt1

* feat: part2 of refactoring user event. improved docs

* test: improved coverage for prefer-user-event. applied feedback

* refactor(prefer-presence-queries): use custom rule creator (#252)

* test(prefer-presence-queries): improve existing invalid tests

* refactor(prefer-presence-queries): use custom rule creator

* feat(prefer-presence-queries): use aggressive query reporting

* refactor(prefer-presence-queries): rename message ids

* test: add fake rule tests for queries

* refactor(extract helpers for detecting presence/absence assets): add fake rule tests for queries

* refactor(prefer-presence-queries): use presence/absence helpers

* refactor: simplify negated matcher condition

* style: format files after rebase

* refactor: detection helpers tweaks (#254)

* refactor(extract helpers for detecting presence/absence assets): add fake rule tests for queries

* refactor(prefer-presence-queries): use presence/absence helpers

* refactor: rename boolean detection helpers

* refactor: create helpers as separated functions

* refactor(ast-utils): migrate custom node-utils to ASTUtils (#256)

Closes #253 

* refactor(ast-utils): remove isIdentifier

* refactor(ast-utils): migrate isAwaitExpression

* refactor(ast-utils): use optional chaining for consistency

* chore: decrease node-utils coverage threshold

* refactor(prefer-wait-for): use new custom rule creator (#255)

* refactor: prefer-wait-for with the new settings

* refactor: generalized util method

* refactor: applied feedback from pr

* test: improve coverage

* refactor: use custom rule creator for promise-queries rules (#260)

* refactor(no-await-sync-query): use custom rule creator

* refactor(no-await-sync-query): improve error message

* test(no-await-sync-query): check error location in invalid cases

* refactor(no-await-sync-query): catch sync queries with detection helper

* test(no-await-sync-query): use more realistic scenarios

* test(no-await-sync-query): add more cases for custom queries and settings

* refactor(await-async-query): use custom rule creator

* refactor(await-async-query): improve error message

* feat: new detection helpers for findBy queries

* refactor(await-async-query): detection helpers + aggressive reporting

* test(await-async-query): add cases for custom queries

* test(await-async-query): add more cases for custom queries

* test(await-async-query): check errors locations

* test(await-async-query): mix built-in and custom queries

* test(await-async-query): non-matching query case

* feat(await-async-query): report query wrappers

* refactor(await-async-query): extract ast utils for functions

* test(await-async-query): cases for arrow functions

* refactor(await-async-query): extract ast util for promise handled

* test(await-async-query): increase coverage

* refactor(await-async-query): rename isPromiseResolved to hasChainedThen

* docs(await-async-query): update rule description and examples

* docs(await-async-query): minor improvements

* refactor: minor type fix

* docs(await-async-query): more fixes

* docs(await-async-query): wrong return type

* refactor(await-async-query): check regex more efficiently

* refactor(await-async-utils): use custom rule creator (#263)

* refactor: extract utils for checking promise all methods

* test(await-async-query): add cases for promise all and allSettled

* docs(await-async-query): add cases for promise all and allSettled

* refactor(await-async-utils): create rule with custom creator

* refactor(await-async-utils): replace async utils regexp by method

* refactor(await-async-utils): replace manual import checks by helper

* refactor(await-async-utils): replace manual promise checks by util

* refactor(await-async-utils): merge identifier and member expression nodes checks

* test(await-async-query): check column on invalid cases

* test(await-async-query): promise.allSettled cases

* refactor(await-async-query): extract util to get innermost returning function name

* feat(await-async-utils): report unhandled functions wrapping async utils

* docs: minor improvements

* test(await-async-utils): increase coverage

* refactor: repurpose getInnermostReturningFunctionName to getInnermostReturningFunction

* refactor(await-fire-event): use custom rule creator (#265)

* refactor(await-async-utils): create rule with custom creator

* docs(await-fire-event): update description

* refactor(await-fire-event): create rule with custom creator

* refactor(await-fire-event): replace manual promise checks by util

* refactor: simplify isNodeComingFromTestingLibrary

* fix: call findClosestCallExpressionNode recursively keeping args

* refactor(prefer-user-event): extract fire event helpers

* refactor(await-async-utils): remove unnecessary as expression

* refactor(await-fire-event): reuse fire event detection helpers

* feat(await-fire-event): detect functions wrapping fire event methods

* fix(await-fire-event): detect more cases

* test(await-fire-event): increase coverage

* docs(await-fire-event): update rule details and examples

* test(await-async-utils): remove outdated comment

* docs(await-fire-event): update async note

* style(await-fire-event): format rule doc

* refactor(await-fire-event): remove unnecessary check

* refactor(no-promise-in-fire-event): use custom rule creator (#266)

* refactor(await-async-utils): create rule with custom creator

* test(await-async-utils): remove outdated comment

* docs(no-promise-in-fire-event): improve description and examples

* docs(no-promise-in-fire-event): improve invalid errors checks

* refactor(no-promise-in-fire-event): use custom rule creator and helpers

* feat(no-promise-in-fire-event): detect promise in variable references

* docs(no-promise-in-fire-event): update examples

* test(no-promise-in-fire-event): increase coverage up to 100%

* refactor(no-wait-for-snapshot) migrate to v4 (#271)

* refactor: migrate no-wait-for-snapshot to v4

* refactor: apply pr suggestions

* refactor(prefer-find-by) migrate to v4 (#270)

* refactor: migrate prefer-find-by to v4

* refactor: applied pr suggestions

* refactor(prefer-explicit-assert): use new utils and remove custom query option (#274)

* refactor(prefer-explicit-assert): use new utils and remove custom query option

* test: add custom query method

* fix(no-await-sync-query): avoid reporting queries if not within callee (#278)

Fixes #276

* refactor: remove duplicated param type

* refactor: rename helpers for determining query variants

* refactor(render-result-naming-convention): migrate to v4 (#280)

* docs: add comments to main parts to be modified

* refactor(render-result-naming-convention): first approach for new helper

First implementation of isRenderUtil helper, and use it within this rule.

* refactor(aggressive-render): update criteria to consider valid renders

Before, it was checking if the name of the method started by "render". Now, it checks if the name of the method contains render.

* feat(aggressive-render): keep aggressive module reporting in mind

Depending on aggressive module reporting, isRenderUtil needs to check if node comes from valid Testing Library module or not.

* test(render-result-naming-convention): move valid to invalid tests

* docs(aggressive-reporting): improve jsdocs

* test(create-testing-library-rule): cases for render

* refactor: second round of tweaks (#281)

* refactor(shared-settings): rename utils-module

Rename testing-library/module to testing-library/utils-module

* refactor(detection-helpers): improve fn type definitions

* test(filename-pattern): simplify settings patterns

* fix: check member expression properly within isRenderUtil helper

* test: improve create-testing-library-rule test cases

* refactor: check if coming from Testing Library within isAsyncUtil

* refactor: extract common method for determining if node is TL util

* refactor: improve TL util node detection from identifier

* refactor: rename getIdentifierNode to clarify its behavior

* fix: improve check for determining if node coming from TL

* test: add async util test cases to fake rule

* docs: format jsdoc

* refactor(render-result-naming-convention): refine checks to decide if coming from Testing Library (#282)

* feat(render-result-naming-convention): detect render calls from wrappers

* fix: check imported node properly when specifiers are renamed

ImportNamespaceSpecifier had to be checked properly in order to detect rename imports properly like:
import { a as b } from 'foo'

* refactor: split checks for import matching node name in different methods

* test(render-result-naming-convention): add extra invalid case for wrapped function

* fix(render-result-naming-convention): cover more renamed imports

* ci: update pipeline with v4 changes (#289)

* ci: migrate to GitHub Actions (#286)

* ci: schedule github actions updates

* ci: add github actions release workflow

* ci: remove config related to travis

* ci: split workflows

* ci: use action for installing dependencies

* ci: remove lint max warnings

* ci: improve scripts

* ci: remove format check

* ci: install dependencies with npm

* ci: revert - install dependencies with npm

* ci: install dependencies manually on test step

* ci: set ci env var on install step

* ci: install peer deps in legacy mode

* ci: revert manual deps install

* ci: remove node 15

* ci: update badge in README.md

Closes #275

* ci: github actions improvements (#288)

* chore: fix scripts related to testing

* ci: bump checkout action to v2

* ci: merge workflows files into single one

* ci: add a step for canceling previous runs

* ci: remove workflow run conditions

* ci: rename workflow

* ci: update github actions with v4 CI changes

* chore: bump dependencies to last minor

* chore: setting test environment to jest-environment-jsdom v25

I had to downgrade jsdom because of some errors jsdom v16 was causing when running
tests in node v10. Apparently, jsdom v16 is compatible with node v10,
so I'm not sure why is causing an issue.

This can be removed when dropping support for node v10.

* refactor(prefer-screen-queries): migrate to v4 (#285)

* refactor(prefer-screen-queries): use new rule creator

* refactor(prefer-screen-queries): detect render methods with helper

* refactor(prefer-screen-queries): detect queries with helper

* fix(prefer-screen-queries): detect queries coming from proper render

* chore: update dependencies (#290)

* refactor(no-wait-for-empty-callback): migrate to v4 (#284)

* refactor(no-wait-for-empty-callback): use new rule creator and helpers

* test(no-wait-for-empty-callback): improve invalid asserts

* test(no-wait-for-empty-callback): increase rule coverage

* refactor: improve valid names definition (PR suggestions)

* refactor(refactor no-debug): migrate to v4 (#293)

* refactor(no-debug): use new rule creator

* test(no-debug): improve current invalid error assertions

* docs(no-debug): fix typo

* refactor(no-debug): report debug call expressions with detection helpers

* refactor(no-debug): report debug from renders with detection helpers

* refactor(no-debug): remove unnecessary checks

* refactor(no-container): migrate to v4 (#295)

* docs(no-container): remove custom render reference

* test(no-container): improve errors asserts

* refactor(no-container): use new rule creator

* refactor(no-container): extract isRenderVariableDeclarator helper

* refactor(no-container): improve node reported location

* refactor(no-container): detect nodes coming from render wrapper

* refactor(no-debug): detect nodes coming from render wrapper

* refactor: remove mechanism to match files to be reported (#297)

* refactor(no-render-in-setup): migrate to v4 (#299)

* docs: update rule description

- remove references "renderFunctions" rule option
- improve examples

* test: improve errors location asserts

* refactor: use new rule creator

* docs: update error message and description

* refactor(no-debug): remove option schema leftover

* refactor: remove custom render option in favor of helper

* refactor: improve error reported location

* feat: detect wrapper functions around render

* refactor: improve utils types

* refactor: remove unused node util

* test: improve test cases

* refacto(no-wait-for-side-effects): migrate to v4 (#300)

* test: improve errors location asserts

* refactor: use new rule creator

* refactor: improve error reported location

* refactor: use new helpers for detection

* test: add more cases

* feat: detect properly if fireEvent and userEvent should be reported

* test: add cases for increasing coverage up to 100%

* refactor: rename rule for consistency

* docs: remove duplicated no-wait-for-snapshot row

* fix: get identifier node simpler

* refactor(no-wait-for-multiple-assertions): migrate to v4 (#301)

* test: improve errors location asserts

* refactor: use new rule creator

* refactor: improve error reported location

* refactor: use new helpers for detection

* test: add more cases

* feat: detect properly if fireEvent and userEvent should be reported

* test: add cases for increasing coverage up to 100%

* refactor: rename rule for consistency

* docs: remove duplicated no-wait-for-snapshot row

* refactor: rename rule

* test: improve errors location asserts

* refactor: use new rule creator

* refactor: use new helpers for detection

* refactor: improve error reported location

* test: add more cases

* refactor(no-await-sync-events): migrate to v4 (#302)

* docs: update rule description

* test: improve current cases

* refactor: use new rule creator

* feat: avoid reporting type and keyboard with 0 delay

* refactor: use new helpers for detection

* test: split fire and user events cases

* test: improve errors location asserts

* feat: detect user-event import properly

* test: add cases for increasing coverage up to 100%

* test: assert error message data

* refactor: cleanup after migrating all rules to v4 (#303)

* docs: update rule description

* test: improve current cases

* refactor: use new rule creator

* feat: avoid reporting type and keyboard with 0 delay

* refactor: use new helpers for detection

* test: split fire and user events cases

* test: improve errors location asserts

* feat: detect user-event import properly

* test: add cases for increasing coverage up to 100%

* test: assert error message data

* test: set final threshold for node-utils

* chore: extract semantic release config to its own file

* docs: including testing-library prefix in all rules

* docs: including testing-library rule prefix in README

* fix(await-async-utils): reference correct node name

* fix(prefer-find-by): simplify error message

* fix(no-await-sync-query): avoid false positive from parent func

* test(no-await-sync-query): increase code coverage up to 100%

* feat(no-wait-for-multiple-assertions): report assertions

* test(no-wait-for-multiple-assertions): increase code coverage up to 100%

* fix(no-wait-for-side-effects): report on each side effect node

* test(no-await-sync-query): include extra case for disappearance

* fix: guard against null deepest identifier node

* fix: guard against null property identifier node

* ci: decrease coverage threshold

* fix: enable TS strict mode

* fix: remove closing comment leftover

* refactor: declare test cases typings as expected

* fix: remove wrong boolean check for detection

* fix(prefer-user-event): format list of userEvent methods correctly  (#311)

* fix(prefer-user-event): format list of userEvent methods correctly

* test(prefer-user-event): check error data in all invalid cases

Closes #310

* fix: second round of bugfixes for v4 (#314)

* fix: handle require without assignment properly

* fix: handle another require without assignment properly

* fix: update rule levels on presets

- remove prefer-user-event from presets
- report no-debug as error on presets

* docs: indicate prefer-user-event is not enabled in any preset

Closes #313

* docs: add guide for migrating to v4 (#312)

* docs: first steps for migrating to v4 guide

* docs: extract Aggressive Reporting Query info to its own section

* docs: explain Aggressive Reporting motivation and mechanism

* docs: describe each aggressive reporting mechanism

* docs: shared settings

* docs: update info related to Shareable Configs updated

* docs: fix typo

* docs: fix more typos

* docs: replace tho by though

* docs: fix wrong new lines entered

* ci: remove duplicated max-warnings param

* docs: update README for v4 (#317)

* docs: update README for v4

* docs: move detailed settings to migratuin guide

* docs: format md files with prettier

* chore: update dependencies (#319)

* fix: third round of bug fixes (#320)

* fix(prefer-screen-queries): improve error message

* chore: update package keywords

Closes #318

* docs: update contributing guidelines to v4 (#321)

* docs: update contributing guidelines to v4

* docs: contributing guidelines PR suggestion

Co-authored-by: Micha毛l De Boey <info@michaeldeboey.be>

* docs: more contributing guidelines PR suggestions

Co-authored-by: Micha毛l De Boey <info@michaeldeboey.be>

Co-authored-by: Micha毛l De Boey <info@michaeldeboey.be>

* ci: remove unnecessary quote marks for node versions

Co-authored-by: Micha毛l De Boey <info@michaeldeboey.be>

* Revert "ci: remove unnecessary quote marks for node versions"

This reverts commit b150663

* chore: revert node 10.22.1 as minimum version

Minimum node version required for using the plugin is still 10.12 but it
was up to 10.22.1 because of a dev dependency. This won't affect usages
of the plugin so I'm reverting it.
More details here: #234

* ci: include 12.0 in node versions matrix

* ci: wrap matrix values within quotes

Co-authored-by: Nick McCurdy <nick@nickmccurdy.com>
Co-authored-by: Mateus Felix <mateus.felix@c6bank.com>
Co-authored-by: Mateus Felix <mateus.cfoliveira@gmail.com>
Co-authored-by: Tim Deschryver <28659384+timdeschryver@users.noreply.github.com>
Co-authored-by: Gonzalo D'Elia <gonzalo.n.delia@gmail.com>
Co-authored-by: Renato Augusto Gama dos Santos <renato_0603@hotmail.com>
Co-authored-by: Micha毛l De Boey <info@michaeldeboey.be>
Co-authored-by: Spencer Miskoviak <5247455+skovy@users.noreply.github.com>
Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
Co-authored-by: Giorgio Polvara <polvara@gmail.com>
Co-authored-by: Josh David <joshua.david@uqconnect.edu.au>
Co-authored-by: Thomas Lombart <thomas.lombart@hey.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore Changes that affect the build system, CI config or other changes that don't modify src/test files dependencies Pull requests that update a dependency file enhancement New feature or request released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support ESLint 7.x
4 participants