From 7c44703a9f7f733ecfb795368d9260af7ea3a834 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20Beltr=C3=A1n?= Date: Tue, 3 Oct 2023 17:44:17 +0200 Subject: [PATCH] Revert "build(deps-dev): bump prettier from 2.8.7 to 3.0.3 (#825)" (#826) --- .all-contributorsrc | 1069 ++++++++++------- docs/rules/await-async-utils.md | 8 +- docs/rules/prefer-find-by.md | 12 +- lib/configs/index.ts | 2 +- .../detect-testing-library-utils.ts | 84 +- lib/create-testing-library-rule/index.ts | 4 +- lib/node-utils/index.ts | 48 +- lib/node-utils/is-node-of-type.ts | 40 +- lib/rules/await-async-events.ts | 10 +- lib/rules/await-async-queries.ts | 4 +- lib/rules/await-async-utils.ts | 6 +- lib/rules/consistent-data-testid.ts | 2 +- lib/rules/index.ts | 2 +- lib/rules/no-await-sync-events.ts | 10 +- lib/rules/no-container.ts | 10 +- lib/rules/no-debugging-utils.ts | 14 +- lib/rules/no-dom-import.ts | 10 +- lib/rules/no-global-regexp-flag-in-query.ts | 10 +- lib/rules/no-manual-cleanup.ts | 4 +- lib/rules/no-promise-in-fire-event.ts | 4 +- lib/rules/no-render-in-lifecycle.ts | 12 +- lib/rules/no-unnecessary-act.ts | 6 +- lib/rules/no-wait-for-multiple-assertions.ts | 2 +- lib/rules/no-wait-for-side-effects.ts | 14 +- lib/rules/no-wait-for-snapshot.ts | 4 +- lib/rules/prefer-explicit-assert.ts | 2 +- lib/rules/prefer-find-by.ts | 40 +- lib/rules/prefer-presence-queries.ts | 2 +- lib/rules/prefer-query-by-disappearance.ts | 12 +- lib/rules/prefer-query-matchers.ts | 4 +- lib/rules/prefer-screen-queries.ts | 4 +- lib/rules/prefer-user-event.ts | 6 +- lib/utils/index.ts | 4 +- lib/utils/types.ts | 2 +- lint-staged.config.js | 2 +- package-lock.json | 18 +- package.json | 2 +- tests/create-testing-library-rule.test.ts | 2 +- tests/eslint-remote-tester.config.js | 2 +- tests/index.test.ts | 6 +- tests/lib/rules/await-async-events.test.ts | 38 +- tests/lib/rules/await-async-queries.test.ts | 56 +- tests/lib/rules/await-async-utils.test.ts | 30 +- tests/lib/rules/no-await-sync-events.test.ts | 14 +- tests/lib/rules/no-await-sync-queries.test.ts | 10 +- tests/lib/rules/no-container.test.ts | 8 +- tests/lib/rules/no-debugging-utils.test.ts | 6 +- tests/lib/rules/no-dom-import.test.ts | 12 +- tests/lib/rules/no-manual-cleanup.test.ts | 18 +- tests/lib/rules/no-node-access.test.ts | 2 +- .../lib/rules/no-render-in-lifecycle.test.ts | 20 +- tests/lib/rules/no-unnecessary-act.test.ts | 4 +- .../no-wait-for-multiple-assertions.test.ts | 2 +- .../rules/no-wait-for-side-effects.test.ts | 2 +- tests/lib/rules/no-wait-for-snapshot.test.ts | 16 +- .../lib/rules/prefer-explicit-assert.test.ts | 24 +- tests/lib/rules/prefer-find-by.test.ts | 32 +- .../lib/rules/prefer-presence-queries.test.ts | 50 +- tests/lib/rules/prefer-query-matchers.test.ts | 18 +- tests/lib/rules/prefer-screen-queries.test.ts | 28 +- tests/lib/rules/prefer-user-event.test.ts | 32 +- tests/lib/test-utils.ts | 4 +- tools/generate-configs/index.ts | 4 +- 63 files changed, 1064 insertions(+), 865 deletions(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index 4a4a7bbe..f91d531b 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -1,437 +1,636 @@ { - "projectName": "eslint-plugin-testing-library", - "projectOwner": "testing-library", - "repoType": "github", - "repoHost": "https://github.com", - "files": ["README.md"], - "imageSize": 100, - "commit": true, - "commitConvention": "angular", - "contributors": [ - { - "login": "Belco90", - "name": "Mario Beltrán Alarcón", - "avatar_url": "https://avatars1.githubusercontent.com/u/2677072?v=4", - "profile": "https://mario.dev", - "contributions": ["code", "doc", "review", "test", "infra", "bug"] - }, - { - "login": "thomlom", - "name": "Thomas Lombart", - "avatar_url": "https://avatars3.githubusercontent.com/u/16003285?v=4", - "profile": "http://thomlom.dev", - "contributions": ["code", "doc", "review", "test", "infra"] - }, - { - "login": "benmonro", - "name": "Ben Monro", - "avatar_url": "https://avatars3.githubusercontent.com/u/399236?v=4", - "profile": "https://github.com/benmonro", - "contributions": ["code", "doc", "test"] - }, - { - "login": "emmenko", - "name": "Nicola Molinari", - "avatar_url": "https://avatars2.githubusercontent.com/u/1110551?v=4", - "profile": "https://emmenko.org/", - "contributions": ["code", "test", "doc", "review"] - }, - { - "login": "aarongarciah", - "name": "Aarón García Hervás", - "avatar_url": "https://avatars0.githubusercontent.com/u/7225802?v=4", - "profile": "https://aarongarciah.com", - "contributions": ["doc"] - }, - { - "login": "Meemaw", - "name": "Matej Šnuderl", - "avatar_url": "https://avatars3.githubusercontent.com/u/8524109?v=4", - "profile": "https://www.matej.snuderl.si/", - "contributions": ["ideas", "doc"] - }, - { - "login": "afontcu", - "name": "Adrià Fontcuberta", - "avatar_url": "https://avatars0.githubusercontent.com/u/9197791?v=4", - "profile": "https://afontcu.dev", - "contributions": ["code", "test"] - }, - { - "login": "jonaldinger", - "name": "Jon Aldinger", - "avatar_url": "https://avatars1.githubusercontent.com/u/663362?v=4", - "profile": "https://github.com/jonaldinger", - "contributions": ["doc"] - }, - { - "login": "tknickman", - "name": "Thomas Knickman", - "avatar_url": "https://avatars1.githubusercontent.com/u/2933988?v=4", - "profile": "http://www.thomasknickman.com", - "contributions": ["code", "doc", "test"] - }, - { - "login": "wolverineks", - "name": "Kevin Sullivan", - "avatar_url": "https://avatars2.githubusercontent.com/u/8462274?v=4", - "profile": "http://exercism.io/profiles/wolverineks/619ce225090a43cb891d2edcbbf50401", - "contributions": ["doc"] - }, - { - "login": "KubaJastrz", - "name": "Jakub Jastrzębski", - "avatar_url": "https://avatars0.githubusercontent.com/u/6443113?v=4", - "profile": "https://kubajastrz.com", - "contributions": ["code", "doc", "test"] - }, - { - "login": "arvigeus", - "name": "Nikolay Stoynov", - "avatar_url": "https://avatars2.githubusercontent.com/u/4872470?v=4", - "profile": "http://arvigeus.github.com", - "contributions": ["doc"] - }, - { - "login": "marudor", - "name": "marudor", - "avatar_url": "https://avatars0.githubusercontent.com/u/1881725?v=4", - "profile": "https://marudor.de", - "contributions": ["code", "test"] - }, - { - "login": "timdeschryver", - "name": "Tim Deschryver", - "avatar_url": "https://avatars1.githubusercontent.com/u/28659384?v=4", - "profile": "http://timdeschryver.dev", - "contributions": [ - "code", - "doc", - "ideas", - "review", - "test", - "bug", - "infra", - "platform" - ] - }, - { - "login": "tdeekens", - "name": "Tobias Deekens", - "avatar_url": "https://avatars3.githubusercontent.com/u/1877073?v=4", - "profile": "http://tdeekens.name", - "contributions": ["bug"] - }, - { - "login": "victorandcode", - "name": "Victor Cordova", - "avatar_url": "https://avatars0.githubusercontent.com/u/18427801?v=4", - "profile": "https://github.com/victorandcode", - "contributions": ["code", "test", "bug"] - }, - { - "login": "dmitry-lobanov", - "name": "Dmitry Lobanov", - "avatar_url": "https://avatars0.githubusercontent.com/u/7376755?v=4", - "profile": "https://github.com/dmitry-lobanov", - "contributions": ["code", "test"] - }, - { - "login": "kentcdodds", - "name": "Kent C. Dodds", - "avatar_url": "https://avatars0.githubusercontent.com/u/1500684?v=4", - "profile": "https://kentcdodds.com", - "contributions": ["bug"] - }, - { - "login": "gndelia", - "name": "Gonzalo D'Elia", - "avatar_url": "https://avatars1.githubusercontent.com/u/352474?v=4", - "profile": "https://github.com/gndelia", - "contributions": ["code", "test", "doc", "review"] - }, - { - "login": "jmcriffey", - "name": "Jeff Rifwald", - "avatar_url": "https://avatars0.githubusercontent.com/u/2831294?v=4", - "profile": "https://github.com/jmcriffey", - "contributions": ["doc"] - }, - { - "login": "lourenci", - "name": "Leandro Lourenci", - "avatar_url": "https://avatars3.githubusercontent.com/u/2339362?v=4", - "profile": "https://blog.lourenci.com/", - "contributions": ["bug", "code", "test"] - }, - { - "login": "miguelerja", - "name": "Miguel Erja González", - "avatar_url": "https://avatars2.githubusercontent.com/u/42043025?v=4", - "profile": "https://xxxl.digital/", - "contributions": ["bug"] - }, - { - "login": "pustovalov", - "name": "Pavel Pustovalov", - "avatar_url": "https://avatars2.githubusercontent.com/u/1568885?v=4", - "profile": "http://pustovalov.dev", - "contributions": ["bug"] - }, - { - "login": "jrparish", - "name": "Jacob Parish", - "avatar_url": "https://avatars3.githubusercontent.com/u/5173987?v=4", - "profile": "https://github.com/jrparish", - "contributions": ["bug", "code", "test"] - }, - { - "login": "nickmccurdy", - "name": "Nick McCurdy", - "avatar_url": "https://avatars0.githubusercontent.com/u/927220?v=4", - "profile": "https://nickmccurdy.com/", - "contributions": ["ideas", "code", "review"] - }, - { - "login": "stefcameron", - "name": "Stefan Cameron", - "avatar_url": "https://avatars3.githubusercontent.com/u/2855350?v=4", - "profile": "https://stefancameron.com/", - "contributions": ["bug"] - }, - { - "login": "thebinaryfelix", - "name": "Mateus Felix", - "avatar_url": "https://avatars2.githubusercontent.com/u/4968788?v=4", - "profile": "https://www.linkedin.com/in/mateusfelix/", - "contributions": ["code", "test", "doc"] - }, - { - "login": "renatoagds", - "name": "Renato Augusto Gama dos Santos", - "avatar_url": "https://avatars2.githubusercontent.com/u/1663717?v=4", - "profile": "https://github.com/renatoagds", - "contributions": ["ideas", "code", "doc", "test"] - }, - { - "login": "codecog", - "name": "Josh Kelly", - "avatar_url": "https://avatars0.githubusercontent.com/u/5106076?v=4", - "profile": "https://github.com/codecog", - "contributions": ["code"] - }, - { - "login": "alessbell", - "name": "Alessia Bellisario", - "avatar_url": "https://avatars0.githubusercontent.com/u/5139846?v=4", - "profile": "http://aless.co", - "contributions": ["code", "test", "doc"] - }, - { - "login": "skovy", - "name": "Spencer Miskoviak", - "avatar_url": "https://avatars1.githubusercontent.com/u/5247455?v=4", - "profile": "https://skovy.dev", - "contributions": ["code", "test", "doc", "ideas"] - }, - { - "login": "Gpx", - "name": "Giorgio Polvara", - "avatar_url": "https://avatars0.githubusercontent.com/u/767959?v=4", - "profile": "https://twitter.com/Gpx", - "contributions": ["code", "test", "doc"] - }, - { - "login": "jdanil", - "name": "Josh David", - "avatar_url": "https://avatars0.githubusercontent.com/u/8342105?v=4", - "profile": "https://github.com/jdanil", - "contributions": ["doc"] - }, - { - "login": "MichaelDeBoey", - "name": "Michaël De Boey", - "avatar_url": "https://avatars3.githubusercontent.com/u/6643991?v=4", - "profile": "https://michaeldeboey.be", - "contributions": ["code", "platform", "maintenance", "infra", "review"] - }, - { - "login": "J-Huang", - "name": "Jian Huang", - "avatar_url": "https://avatars0.githubusercontent.com/u/4263459?v=4", - "profile": "https://github.com/J-Huang", - "contributions": ["code", "test", "doc"] - }, - { - "login": "ph-fritsche", - "name": "Philipp Fritsche", - "avatar_url": "https://avatars.githubusercontent.com/u/39068198?v=4", - "profile": "https://github.com/ph-fritsche", - "contributions": ["code"] - }, - { - "login": "zaicevas", - "name": "Tomas Zaicevas", - "avatar_url": "https://avatars.githubusercontent.com/u/34719980?v=4", - "profile": "http://zaicevas.me", - "contributions": ["bug", "code", "test", "doc"] - }, - { - "login": "G-Rath", - "name": "Gareth Jones", - "avatar_url": "https://avatars.githubusercontent.com/u/3151613?v=4", - "profile": "https://github.com/G-Rath", - "contributions": ["code", "doc", "test"] - }, - { - "login": "HonkingGoose", - "name": "HonkingGoose", - "avatar_url": "https://avatars.githubusercontent.com/u/34918129?v=4", - "profile": "https://github.com/HonkingGoose", - "contributions": ["doc", "maintenance"] - }, - { - "login": "julienw", - "name": "Julien Wajsberg", - "avatar_url": "https://avatars.githubusercontent.com/u/454175?v=4", - "profile": "http://everlong.org/", - "contributions": ["bug", "code", "test"] - }, - { - "login": "dyatko", - "name": "Marat Dyatko", - "avatar_url": "https://avatars.githubusercontent.com/u/31615495?v=4", - "profile": "https://www.linkedin.com/in/maratdyatko/", - "contributions": ["bug", "code"] - }, - { - "login": "DaJoTo", - "name": "David Tolman", - "avatar_url": "https://avatars.githubusercontent.com/u/28302401?v=4", - "profile": "https://github.com/DaJoTo", - "contributions": ["bug"] - }, - { - "login": "AriPerkkio", - "name": "Ari Perkkiö", - "avatar_url": "https://avatars.githubusercontent.com/u/14806298?v=4", - "profile": "https://codepen.io/ariperkkio/", - "contributions": ["test"] - }, - { - "login": "diegocasmo", - "name": "Diego Castillo", - "avatar_url": "https://avatars.githubusercontent.com/u/4553097?v=4", - "profile": "https://diegocasmo.github.io/", - "contributions": ["code"] - }, - { - "login": "bpinto", - "name": "Bruno Pinto", - "avatar_url": "https://avatars.githubusercontent.com/u/526122?v=4", - "profile": "http://bpinto.github.com", - "contributions": ["code", "test"] - }, - { - "login": "themagickoala", - "name": "themagickoala", - "avatar_url": "https://avatars.githubusercontent.com/u/48416253?v=4", - "profile": "https://github.com/themagickoala", - "contributions": ["code", "test"] - }, - { - "login": "PrashantAshok", - "name": "Prashant Ashok", - "avatar_url": "https://avatars.githubusercontent.com/u/5200733?v=4", - "profile": "https://github.com/PrashantAshok", - "contributions": ["code", "test"] - }, - { - "login": "IvanAprea", - "name": "Ivan Aprea", - "avatar_url": "https://avatars.githubusercontent.com/u/54630721?v=4", - "profile": "https://github.com/IvanAprea", - "contributions": ["code", "test"] - }, - { - "login": "Semigradsky", - "name": "Dmitry Semigradsky", - "avatar_url": "https://avatars.githubusercontent.com/u/1198848?v=4", - "profile": "https://semigradsky.dev/", - "contributions": ["code", "test", "doc"] - }, - { - "login": "sjarva", - "name": "Senja", - "avatar_url": "https://avatars.githubusercontent.com/u/1133238?v=4", - "profile": "https://github.com/sjarva", - "contributions": ["code", "test", "doc"] - }, - { - "login": "brenocota-hotmart", - "name": "Breno Cota", - "avatar_url": "https://avatars.githubusercontent.com/u/106157862?v=4", - "profile": "https://dbrno.vercel.app", - "contributions": ["code", "test"] - }, - { - "login": "NickBolles", - "name": "Nick Bolles", - "avatar_url": "https://avatars.githubusercontent.com/u/7891759?v=4", - "profile": "https://nickbolles.com", - "contributions": ["code", "test", "doc"] - }, - { - "login": "bmish", - "name": "Bryan Mishkin", - "avatar_url": "https://avatars.githubusercontent.com/u/698306?v=4", - "profile": "http://www.linkedin.com/in/bmish", - "contributions": ["doc", "tool"] - }, - { - "login": "theredspoon", - "name": "Nim G", - "avatar_url": "https://avatars.githubusercontent.com/u/20975696?v=4", - "profile": "https://github.com/theredspoon", - "contributions": ["doc"] - }, - { - "login": "patriscus", - "name": "Patrick Ahmetovic", - "avatar_url": "https://avatars.githubusercontent.com/u/23729362?v=4", - "profile": "https://github.com/patriscus", - "contributions": ["ideas", "code", "test"] - }, - { - "login": "CodingItWrong", - "name": "Josh Justice", - "avatar_url": "https://avatars.githubusercontent.com/u/15832198?v=4", - "profile": "https://codingitwrong.com", - "contributions": ["code", "test", "doc", "ideas"] - }, - { - "login": "obsoke", - "name": "Dale Karp", - "avatar_url": "https://avatars.githubusercontent.com/u/389851?v=4", - "profile": "https://dale.io", - "contributions": ["code", "test", "doc"] - }, - { - "login": "nathanmmiller", - "name": "Nathan", - "avatar_url": "https://avatars.githubusercontent.com/u/37555055?v=4", - "profile": "https://github.com/nathanmmiller", - "contributions": ["code", "test"] - }, - { - "login": "justintoman", - "name": "justintoman", - "avatar_url": "https://avatars.githubusercontent.com/u/11649507?v=4", - "profile": "https://github.com/justintoman", - "contributions": ["code", "test"] - } - ], - "contributorsPerLine": 7, - "skipCi": true, - "commitType": "docs" + "projectName": "eslint-plugin-testing-library", + "projectOwner": "testing-library", + "repoType": "github", + "repoHost": "https://github.com", + "files": [ + "README.md" + ], + "imageSize": 100, + "commit": true, + "commitConvention": "angular", + "contributors": [ + { + "login": "Belco90", + "name": "Mario Beltrán Alarcón", + "avatar_url": "https://avatars1.githubusercontent.com/u/2677072?v=4", + "profile": "https://mario.dev", + "contributions": [ + "code", + "doc", + "review", + "test", + "infra", + "bug" + ] + }, + { + "login": "thomlom", + "name": "Thomas Lombart", + "avatar_url": "https://avatars3.githubusercontent.com/u/16003285?v=4", + "profile": "http://thomlom.dev", + "contributions": [ + "code", + "doc", + "review", + "test", + "infra" + ] + }, + { + "login": "benmonro", + "name": "Ben Monro", + "avatar_url": "https://avatars3.githubusercontent.com/u/399236?v=4", + "profile": "https://github.com/benmonro", + "contributions": [ + "code", + "doc", + "test" + ] + }, + { + "login": "emmenko", + "name": "Nicola Molinari", + "avatar_url": "https://avatars2.githubusercontent.com/u/1110551?v=4", + "profile": "https://emmenko.org/", + "contributions": [ + "code", + "test", + "doc", + "review" + ] + }, + { + "login": "aarongarciah", + "name": "Aarón García Hervás", + "avatar_url": "https://avatars0.githubusercontent.com/u/7225802?v=4", + "profile": "https://aarongarciah.com", + "contributions": [ + "doc" + ] + }, + { + "login": "Meemaw", + "name": "Matej Šnuderl", + "avatar_url": "https://avatars3.githubusercontent.com/u/8524109?v=4", + "profile": "https://www.matej.snuderl.si/", + "contributions": [ + "ideas", + "doc" + ] + }, + { + "login": "afontcu", + "name": "Adrià Fontcuberta", + "avatar_url": "https://avatars0.githubusercontent.com/u/9197791?v=4", + "profile": "https://afontcu.dev", + "contributions": [ + "code", + "test" + ] + }, + { + "login": "jonaldinger", + "name": "Jon Aldinger", + "avatar_url": "https://avatars1.githubusercontent.com/u/663362?v=4", + "profile": "https://github.com/jonaldinger", + "contributions": [ + "doc" + ] + }, + { + "login": "tknickman", + "name": "Thomas Knickman", + "avatar_url": "https://avatars1.githubusercontent.com/u/2933988?v=4", + "profile": "http://www.thomasknickman.com", + "contributions": [ + "code", + "doc", + "test" + ] + }, + { + "login": "wolverineks", + "name": "Kevin Sullivan", + "avatar_url": "https://avatars2.githubusercontent.com/u/8462274?v=4", + "profile": "http://exercism.io/profiles/wolverineks/619ce225090a43cb891d2edcbbf50401", + "contributions": [ + "doc" + ] + }, + { + "login": "KubaJastrz", + "name": "Jakub Jastrzębski", + "avatar_url": "https://avatars0.githubusercontent.com/u/6443113?v=4", + "profile": "https://kubajastrz.com", + "contributions": [ + "code", + "doc", + "test" + ] + }, + { + "login": "arvigeus", + "name": "Nikolay Stoynov", + "avatar_url": "https://avatars2.githubusercontent.com/u/4872470?v=4", + "profile": "http://arvigeus.github.com", + "contributions": [ + "doc" + ] + }, + { + "login": "marudor", + "name": "marudor", + "avatar_url": "https://avatars0.githubusercontent.com/u/1881725?v=4", + "profile": "https://marudor.de", + "contributions": [ + "code", + "test" + ] + }, + { + "login": "timdeschryver", + "name": "Tim Deschryver", + "avatar_url": "https://avatars1.githubusercontent.com/u/28659384?v=4", + "profile": "http://timdeschryver.dev", + "contributions": [ + "code", + "doc", + "ideas", + "review", + "test", + "bug", + "infra", + "platform" + ] + }, + { + "login": "tdeekens", + "name": "Tobias Deekens", + "avatar_url": "https://avatars3.githubusercontent.com/u/1877073?v=4", + "profile": "http://tdeekens.name", + "contributions": [ + "bug" + ] + }, + { + "login": "victorandcode", + "name": "Victor Cordova", + "avatar_url": "https://avatars0.githubusercontent.com/u/18427801?v=4", + "profile": "https://github.com/victorandcode", + "contributions": [ + "code", + "test", + "bug" + ] + }, + { + "login": "dmitry-lobanov", + "name": "Dmitry Lobanov", + "avatar_url": "https://avatars0.githubusercontent.com/u/7376755?v=4", + "profile": "https://github.com/dmitry-lobanov", + "contributions": [ + "code", + "test" + ] + }, + { + "login": "kentcdodds", + "name": "Kent C. Dodds", + "avatar_url": "https://avatars0.githubusercontent.com/u/1500684?v=4", + "profile": "https://kentcdodds.com", + "contributions": [ + "bug" + ] + }, + { + "login": "gndelia", + "name": "Gonzalo D'Elia", + "avatar_url": "https://avatars1.githubusercontent.com/u/352474?v=4", + "profile": "https://github.com/gndelia", + "contributions": [ + "code", + "test", + "doc", + "review" + ] + }, + { + "login": "jmcriffey", + "name": "Jeff Rifwald", + "avatar_url": "https://avatars0.githubusercontent.com/u/2831294?v=4", + "profile": "https://github.com/jmcriffey", + "contributions": [ + "doc" + ] + }, + { + "login": "lourenci", + "name": "Leandro Lourenci", + "avatar_url": "https://avatars3.githubusercontent.com/u/2339362?v=4", + "profile": "https://blog.lourenci.com/", + "contributions": [ + "bug", + "code", + "test" + ] + }, + { + "login": "miguelerja", + "name": "Miguel Erja González", + "avatar_url": "https://avatars2.githubusercontent.com/u/42043025?v=4", + "profile": "https://xxxl.digital/", + "contributions": [ + "bug" + ] + }, + { + "login": "pustovalov", + "name": "Pavel Pustovalov", + "avatar_url": "https://avatars2.githubusercontent.com/u/1568885?v=4", + "profile": "http://pustovalov.dev", + "contributions": [ + "bug" + ] + }, + { + "login": "jrparish", + "name": "Jacob Parish", + "avatar_url": "https://avatars3.githubusercontent.com/u/5173987?v=4", + "profile": "https://github.com/jrparish", + "contributions": [ + "bug", + "code", + "test" + ] + }, + { + "login": "nickmccurdy", + "name": "Nick McCurdy", + "avatar_url": "https://avatars0.githubusercontent.com/u/927220?v=4", + "profile": "https://nickmccurdy.com/", + "contributions": [ + "ideas", + "code", + "review" + ] + }, + { + "login": "stefcameron", + "name": "Stefan Cameron", + "avatar_url": "https://avatars3.githubusercontent.com/u/2855350?v=4", + "profile": "https://stefancameron.com/", + "contributions": [ + "bug" + ] + }, + { + "login": "thebinaryfelix", + "name": "Mateus Felix", + "avatar_url": "https://avatars2.githubusercontent.com/u/4968788?v=4", + "profile": "https://www.linkedin.com/in/mateusfelix/", + "contributions": [ + "code", + "test", + "doc" + ] + }, + { + "login": "renatoagds", + "name": "Renato Augusto Gama dos Santos", + "avatar_url": "https://avatars2.githubusercontent.com/u/1663717?v=4", + "profile": "https://github.com/renatoagds", + "contributions": [ + "ideas", + "code", + "doc", + "test" + ] + }, + { + "login": "codecog", + "name": "Josh Kelly", + "avatar_url": "https://avatars0.githubusercontent.com/u/5106076?v=4", + "profile": "https://github.com/codecog", + "contributions": [ + "code" + ] + }, + { + "login": "alessbell", + "name": "Alessia Bellisario", + "avatar_url": "https://avatars0.githubusercontent.com/u/5139846?v=4", + "profile": "http://aless.co", + "contributions": [ + "code", + "test", + "doc" + ] + }, + { + "login": "skovy", + "name": "Spencer Miskoviak", + "avatar_url": "https://avatars1.githubusercontent.com/u/5247455?v=4", + "profile": "https://skovy.dev", + "contributions": [ + "code", + "test", + "doc", + "ideas" + ] + }, + { + "login": "Gpx", + "name": "Giorgio Polvara", + "avatar_url": "https://avatars0.githubusercontent.com/u/767959?v=4", + "profile": "https://twitter.com/Gpx", + "contributions": [ + "code", + "test", + "doc" + ] + }, + { + "login": "jdanil", + "name": "Josh David", + "avatar_url": "https://avatars0.githubusercontent.com/u/8342105?v=4", + "profile": "https://github.com/jdanil", + "contributions": [ + "doc" + ] + }, + { + "login": "MichaelDeBoey", + "name": "Michaël De Boey", + "avatar_url": "https://avatars3.githubusercontent.com/u/6643991?v=4", + "profile": "https://michaeldeboey.be", + "contributions": [ + "code", + "platform", + "maintenance", + "infra", + "review" + ] + }, + { + "login": "J-Huang", + "name": "Jian Huang", + "avatar_url": "https://avatars0.githubusercontent.com/u/4263459?v=4", + "profile": "https://github.com/J-Huang", + "contributions": [ + "code", + "test", + "doc" + ] + }, + { + "login": "ph-fritsche", + "name": "Philipp Fritsche", + "avatar_url": "https://avatars.githubusercontent.com/u/39068198?v=4", + "profile": "https://github.com/ph-fritsche", + "contributions": [ + "code" + ] + }, + { + "login": "zaicevas", + "name": "Tomas Zaicevas", + "avatar_url": "https://avatars.githubusercontent.com/u/34719980?v=4", + "profile": "http://zaicevas.me", + "contributions": [ + "bug", + "code", + "test", + "doc" + ] + }, + { + "login": "G-Rath", + "name": "Gareth Jones", + "avatar_url": "https://avatars.githubusercontent.com/u/3151613?v=4", + "profile": "https://github.com/G-Rath", + "contributions": [ + "code", + "doc", + "test" + ] + }, + { + "login": "HonkingGoose", + "name": "HonkingGoose", + "avatar_url": "https://avatars.githubusercontent.com/u/34918129?v=4", + "profile": "https://github.com/HonkingGoose", + "contributions": [ + "doc", + "maintenance" + ] + }, + { + "login": "julienw", + "name": "Julien Wajsberg", + "avatar_url": "https://avatars.githubusercontent.com/u/454175?v=4", + "profile": "http://everlong.org/", + "contributions": [ + "bug", + "code", + "test" + ] + }, + { + "login": "dyatko", + "name": "Marat Dyatko", + "avatar_url": "https://avatars.githubusercontent.com/u/31615495?v=4", + "profile": "https://www.linkedin.com/in/maratdyatko/", + "contributions": [ + "bug", + "code" + ] + }, + { + "login": "DaJoTo", + "name": "David Tolman", + "avatar_url": "https://avatars.githubusercontent.com/u/28302401?v=4", + "profile": "https://github.com/DaJoTo", + "contributions": [ + "bug" + ] + }, + { + "login": "AriPerkkio", + "name": "Ari Perkkiö", + "avatar_url": "https://avatars.githubusercontent.com/u/14806298?v=4", + "profile": "https://codepen.io/ariperkkio/", + "contributions": [ + "test" + ] + }, + { + "login": "diegocasmo", + "name": "Diego Castillo", + "avatar_url": "https://avatars.githubusercontent.com/u/4553097?v=4", + "profile": "https://diegocasmo.github.io/", + "contributions": [ + "code" + ] + }, + { + "login": "bpinto", + "name": "Bruno Pinto", + "avatar_url": "https://avatars.githubusercontent.com/u/526122?v=4", + "profile": "http://bpinto.github.com", + "contributions": [ + "code", + "test" + ] + }, + { + "login": "themagickoala", + "name": "themagickoala", + "avatar_url": "https://avatars.githubusercontent.com/u/48416253?v=4", + "profile": "https://github.com/themagickoala", + "contributions": [ + "code", + "test" + ] + }, + { + "login": "PrashantAshok", + "name": "Prashant Ashok", + "avatar_url": "https://avatars.githubusercontent.com/u/5200733?v=4", + "profile": "https://github.com/PrashantAshok", + "contributions": [ + "code", + "test" + ] + }, + { + "login": "IvanAprea", + "name": "Ivan Aprea", + "avatar_url": "https://avatars.githubusercontent.com/u/54630721?v=4", + "profile": "https://github.com/IvanAprea", + "contributions": [ + "code", + "test" + ] + }, + { + "login": "Semigradsky", + "name": "Dmitry Semigradsky", + "avatar_url": "https://avatars.githubusercontent.com/u/1198848?v=4", + "profile": "https://semigradsky.dev/", + "contributions": [ + "code", + "test", + "doc" + ] + }, + { + "login": "sjarva", + "name": "Senja", + "avatar_url": "https://avatars.githubusercontent.com/u/1133238?v=4", + "profile": "https://github.com/sjarva", + "contributions": [ + "code", + "test", + "doc" + ] + }, + { + "login": "brenocota-hotmart", + "name": "Breno Cota", + "avatar_url": "https://avatars.githubusercontent.com/u/106157862?v=4", + "profile": "https://dbrno.vercel.app", + "contributions": [ + "code", + "test" + ] + }, + { + "login": "NickBolles", + "name": "Nick Bolles", + "avatar_url": "https://avatars.githubusercontent.com/u/7891759?v=4", + "profile": "https://nickbolles.com", + "contributions": [ + "code", + "test", + "doc" + ] + }, + { + "login": "bmish", + "name": "Bryan Mishkin", + "avatar_url": "https://avatars.githubusercontent.com/u/698306?v=4", + "profile": "http://www.linkedin.com/in/bmish", + "contributions": [ + "doc", + "tool" + ] + }, + { + "login": "theredspoon", + "name": "Nim G", + "avatar_url": "https://avatars.githubusercontent.com/u/20975696?v=4", + "profile": "https://github.com/theredspoon", + "contributions": [ + "doc" + ] + }, + { + "login": "patriscus", + "name": "Patrick Ahmetovic", + "avatar_url": "https://avatars.githubusercontent.com/u/23729362?v=4", + "profile": "https://github.com/patriscus", + "contributions": [ + "ideas", + "code", + "test" + ] + }, + { + "login": "CodingItWrong", + "name": "Josh Justice", + "avatar_url": "https://avatars.githubusercontent.com/u/15832198?v=4", + "profile": "https://codingitwrong.com", + "contributions": [ + "code", + "test", + "doc", + "ideas" + ] + }, + { + "login": "obsoke", + "name": "Dale Karp", + "avatar_url": "https://avatars.githubusercontent.com/u/389851?v=4", + "profile": "https://dale.io", + "contributions": [ + "code", + "test", + "doc" + ] + }, + { + "login": "nathanmmiller", + "name": "Nathan", + "avatar_url": "https://avatars.githubusercontent.com/u/37555055?v=4", + "profile": "https://github.com/nathanmmiller", + "contributions": [ + "code", + "test" + ] + }, + { + "login": "justintoman", + "name": "justintoman", + "avatar_url": "https://avatars.githubusercontent.com/u/11649507?v=4", + "profile": "https://github.com/justintoman", + "contributions": [ + "code", + "test" + ] + } + ], + "contributorsPerLine": 7, + "skipCi": true, + "commitType": "docs" } diff --git a/docs/rules/await-async-utils.md b/docs/rules/await-async-utils.md index 5a58c625..b5433d83 100644 --- a/docs/rules/await-async-utils.md +++ b/docs/rules/await-async-utils.md @@ -36,7 +36,7 @@ test('something incorrectly', async () => { getByLabelText(container, 'username'), getByLabelText(container, 'password'), ], - { container }, + { container } ); waitFor(() => {}, { timeout: 100 }); @@ -46,7 +46,7 @@ test('something incorrectly', async () => { // wrap an async util within a function... const makeCustomWait = () => { return waitForElementToBeRemoved(() => - document.querySelector('div.getOuttaHere'), + document.querySelector('div.getOuttaHere') ); }; makeCustomWait(); // ...but not handling promise from it is incorrect @@ -66,7 +66,7 @@ test('something correctly', async () => { getByLabelText(container, 'username'), getByLabelText(container, 'password'), ], - { container }, + { container } ); // `then` chained method is correct @@ -77,7 +77,7 @@ test('something correctly', async () => { // wrap an async util within a function... const makeCustomWait = () => { return waitForElementToBeRemoved(() => - document.querySelector('div.getOuttaHere'), + document.querySelector('div.getOuttaHere') ); }; await makeCustomWait(); // ...and handling promise from it is correct diff --git a/docs/rules/prefer-find-by.md b/docs/rules/prefer-find-by.md index 62e45995..1cc5b217 100644 --- a/docs/rules/prefer-find-by.md +++ b/docs/rules/prefer-find-by.md @@ -18,28 +18,28 @@ Examples of **incorrect** code for this rule ```js // arrow functions with one statement, using screen and any sync query method const submitButton = await waitFor(() => - screen.getByRole('button', { name: /submit/i }), + screen.getByRole('button', { name: /submit/i }) ); const submitButton = await waitFor(() => - screen.getAllByTestId('button', { name: /submit/i }), + screen.getAllByTestId('button', { name: /submit/i }) ); // arrow functions with one statement, calling any sync query method const submitButton = await waitFor(() => - queryByLabel('button', { name: /submit/i }), + queryByLabel('button', { name: /submit/i }) ); const submitButton = await waitFor(() => - queryAllByText('button', { name: /submit/i }), + queryAllByText('button', { name: /submit/i }) ); // arrow functions with one statement, calling any sync query method with presence assertion const submitButton = await waitFor(() => - expect(queryByLabel('button', { name: /submit/i })).toBeInTheDocument(), + expect(queryByLabel('button', { name: /submit/i })).toBeInTheDocument() ); const submitButton = await waitFor(() => - expect(queryByLabel('button', { name: /submit/i })).not.toBeFalsy(), + expect(queryByLabel('button', { name: /submit/i })).not.toBeFalsy() ); ``` diff --git a/lib/configs/index.ts b/lib/configs/index.ts index 524524eb..c36314e8 100644 --- a/lib/configs/index.ts +++ b/lib/configs/index.ts @@ -20,5 +20,5 @@ export default SUPPORTED_TESTING_FRAMEWORKS.reduce( ...allConfigs, [framework]: getConfigForFramework(framework), }), - {}, + {} ) as Record; diff --git a/lib/create-testing-library-rule/detect-testing-library-utils.ts b/lib/create-testing-library-rule/detect-testing-library-utils.ts index c8186590..9393a88b 100644 --- a/lib/create-testing-library-rule/detect-testing-library-utils.ts +++ b/lib/create-testing-library-rule/detect-testing-library-utils.ts @@ -35,7 +35,7 @@ export type TestingLibrarySettings = { export type TestingLibraryContext< TOptions extends readonly unknown[], - TMessageIds extends string, + TMessageIds extends string > = Readonly< TSESLint.RuleContext & { settings: TestingLibrarySettings; @@ -45,11 +45,11 @@ export type TestingLibraryContext< export type EnhancedRuleCreate< TOptions extends readonly unknown[], TMessageIds extends string, - TRuleListener extends TSESLint.RuleListener = TSESLint.RuleListener, + TRuleListener extends TSESLint.RuleListener = TSESLint.RuleListener > = ( context: TestingLibraryContext, optionsWithDefault: Readonly, - detectionHelpers: Readonly, + detectionHelpers: Readonly ) => TRuleListener; // Helpers methods @@ -69,33 +69,33 @@ type IsCustomQueryFn = (node: TSESTree.Identifier) => boolean; type IsBuiltInQueryFn = (node: TSESTree.Identifier) => boolean; type IsAsyncUtilFn = ( node: TSESTree.Identifier, - validNames?: readonly (typeof ASYNC_UTILS)[number][], + validNames?: readonly (typeof ASYNC_UTILS)[number][] ) => boolean; type IsFireEventMethodFn = (node: TSESTree.Identifier) => boolean; type IsUserEventMethodFn = (node: TSESTree.Identifier) => boolean; type IsRenderUtilFn = (node: TSESTree.Identifier) => boolean; type IsCreateEventUtil = ( - node: TSESTree.CallExpression | TSESTree.Identifier, + node: TSESTree.CallExpression | TSESTree.Identifier ) => boolean; type IsRenderVariableDeclaratorFn = ( - node: TSESTree.VariableDeclarator, + node: TSESTree.VariableDeclarator ) => boolean; type IsDebugUtilFn = ( identifierNode: TSESTree.Identifier, - validNames?: ReadonlyArray<(typeof DEBUG_UTILS)[number]>, + validNames?: ReadonlyArray<(typeof DEBUG_UTILS)[number]> ) => boolean; type IsPresenceAssertFn = (node: TSESTree.MemberExpression) => boolean; type IsMatchingAssertFn = ( node: TSESTree.MemberExpression, - matcherName: string, + matcherName: string ) => boolean; type IsAbsenceAssertFn = (node: TSESTree.MemberExpression) => boolean; type CanReportErrorsFn = () => boolean; type FindImportedTestingLibraryUtilSpecifierFn = ( - specifierName: string, + specifierName: string ) => TSESTree.Identifier | TSESTree.ImportClause | undefined; type IsNodeComingFromTestingLibraryFn = ( - node: TSESTree.Identifier | TSESTree.MemberExpression, + node: TSESTree.Identifier | TSESTree.MemberExpression ) => boolean; export interface DetectionHelpers { @@ -156,14 +156,14 @@ export type DetectionOptions = { export function detectTestingLibraryUtils< TOptions extends readonly unknown[], TMessageIds extends string, - TRuleListener extends TSESLint.RuleListener = TSESLint.RuleListener, + TRuleListener extends TSESLint.RuleListener = TSESLint.RuleListener >( ruleCreate: EnhancedRuleCreate, - { skipRuleReportingCheck = false }: Partial = {}, + { skipRuleReportingCheck = false }: Partial = {} ) { return ( context: TestingLibraryContext, - optionsWithDefault: Readonly, + optionsWithDefault: Readonly ): TSESLint.RuleListener => { const importedTestingLibraryNodes: ImportModuleNode[] = []; let importedCustomModuleNode: ImportModuleNode | null = null; @@ -192,8 +192,8 @@ export function detectTestingLibraryUtils< node: TSESTree.Identifier | null | undefined, isPotentialFunctionCallback: ( identifierNodeName: string, - originalNodeName?: string, - ) => boolean, + originalNodeName?: string + ) => boolean ): boolean { if (!node) { return false; @@ -207,7 +207,7 @@ export function detectTestingLibraryUtils< } const importedUtilSpecifier = getTestingLibraryImportedUtilSpecifier( - referenceNodeIdentifier, + referenceNodeIdentifier ); const originalNodeName = @@ -340,7 +340,7 @@ export function detectTestingLibraryUtils< * or custom module are imported. */ const isTestingLibraryImported: IsTestingLibraryImportedFn = ( - isStrict = false, + isStrict = false ) => { const isSomeModuleImported = importedTestingLibraryNodes.length !== 0 || !!importedCustomModuleNode; @@ -371,7 +371,7 @@ export function detectTestingLibraryUtils< const customQueries = getCustomQueries(); const isBuiltInQuery = ALL_QUERIES_COMBINATIONS.includes(node.name); const isReportableCustomQuery = customQueries.some((pattern) => - new RegExp(pattern).test(node.name), + new RegExp(pattern).test(node.name) ); return isBuiltInQuery || isReportableCustomQuery; }; @@ -441,7 +441,7 @@ export function detectTestingLibraryUtils< (!!originalNodeName && (validNames as string[]).includes(originalNodeName)) ); - }, + } ); }; @@ -455,7 +455,7 @@ export function detectTestingLibraryUtils< node, (identifierNodeName, originalNodeName) => { return [identifierNodeName, originalNodeName].includes('fireEvent'); - }, + } ); }; @@ -625,15 +625,15 @@ export function detectTestingLibraryUtils< (validRenderName) => validRenderName === identifierNodeName || (Boolean(originalNodeName) && - validRenderName === originalNodeName), + validRenderName === originalNodeName) ); - }, + } ); const isCreateEventUtil: IsCreateEventUtil = (node) => { const isCreateEventCallback = ( identifierNodeName: string, - originalNodeName?: string, + originalNodeName?: string ) => [identifierNodeName, originalNodeName].includes(CREATE_EVENT_NAME); if ( isCallExpression(node) && @@ -642,7 +642,7 @@ export function detectTestingLibraryUtils< ) { return isPotentialTestingLibraryFunction( node.callee.object, - isCreateEventCallback, + isCreateEventCallback ); } @@ -654,13 +654,13 @@ export function detectTestingLibraryUtils< ) { return isPotentialTestingLibraryFunction( node.callee.object.property, - isCreateEventCallback, + isCreateEventCallback ); } const identifier = getDeepestIdentifierNode(node); return isPotentialTestingLibraryFunction( identifier, - isCreateEventCallback, + isCreateEventCallback ); }; @@ -679,7 +679,7 @@ export function detectTestingLibraryUtils< const isDebugUtil: IsDebugUtilFn = ( identifierNode, - validNames = DEBUG_UTILS, + validNames = DEBUG_UTILS ) => { const isBuiltInConsole = isMemberExpression(identifierNode.parent) && @@ -696,7 +696,7 @@ export function detectTestingLibraryUtils< (!!originalNodeName && (validNames as string[]).includes(originalNodeName)) ); - }, + } ) ); }; @@ -715,7 +715,7 @@ export function detectTestingLibraryUtils< return [identifierNodeName, originalNodeName] .filter(Boolean) .includes('act'); - }, + } ); const isReactDomTestUtilsAct = (() => { @@ -731,7 +731,7 @@ export function detectTestingLibraryUtils< const importedUtilSpecifier = findImportSpecifier( node.name, - importedReactDomTestUtilsNode, + importedReactDomTestUtilsNode ); if (!importedUtilSpecifier) { return false; @@ -743,7 +743,7 @@ export function detectTestingLibraryUtils< } const variableDeclarator = findClosestVariableDeclaratorNode( - importedUtilSpecifier, + importedUtilSpecifier ); if (isCallExpression(variableDeclarator?.init)) { @@ -767,7 +767,7 @@ export function detectTestingLibraryUtils< return hasImportMatch( importedUtilSpecifier, - referenceNodeIdentifier.name, + referenceNodeIdentifier.name ); })(); @@ -839,7 +839,7 @@ export function detectTestingLibraryUtils< */ const findImportedTestingLibraryUtilSpecifier: FindImportedTestingLibraryUtilSpecifierFn = ( - specifierName, + specifierName ): TSESTree.Identifier | TSESTree.ImportClause | undefined => { const node = getCustomModuleImportNode() ?? getTestingLibraryImportNode(); @@ -860,7 +860,7 @@ export function detectTestingLibraryUtils< if (isImportDeclaration(importedUserEventLibraryNode)) { const userEventIdentifier = importedUserEventLibraryNode.specifiers.find((specifier) => - isImportDefaultSpecifier(specifier), + isImportDefaultSpecifier(specifier) ); if (userEventIdentifier) { @@ -885,7 +885,7 @@ export function detectTestingLibraryUtils< }; const getTestingLibraryImportedUtilSpecifier = ( - node: TSESTree.Identifier | TSESTree.MemberExpression, + node: TSESTree.Identifier | TSESTree.MemberExpression ): TSESTree.Identifier | TSESTree.ImportClause | undefined => { const identifierName: string | undefined = getPropertyIdentifierNode(node)?.name; @@ -911,7 +911,7 @@ export function detectTestingLibraryUtils< * and also make sure the name is a valid match in case it's been renamed. */ const isNodeComingFromTestingLibrary: IsNodeComingFromTestingLibraryFn = ( - node, + node ) => { const importNode = getTestingLibraryImportedUtilSpecifier(node); @@ -1050,7 +1050,7 @@ export function detectTestingLibraryUtils< // Check if Testing Library related modules are loaded with required. [`CallExpression > Identifier[name="require"]`]( - node: TSESTree.Identifier, + node: TSESTree.Identifier ) { const callExpression = node.parent as TSESTree.CallExpression; const { arguments: args } = callExpression; @@ -1060,7 +1060,7 @@ export function detectTestingLibraryUtils< (arg) => isLiteral(arg) && typeof arg.value === 'string' && - /testing-library/g.test(arg.value), + /testing-library/g.test(arg.value) ) ) { importedTestingLibraryNodes.push(callExpression); @@ -1074,7 +1074,7 @@ export function detectTestingLibraryUtils< customModule && isLiteral(arg) && typeof arg.value === 'string' && - arg.value.endsWith(customModule), + arg.value.endsWith(customModule) ) ) { importedCustomModuleNode = callExpression; @@ -1086,7 +1086,7 @@ export function detectTestingLibraryUtils< (arg) => isLiteral(arg) && typeof arg.value === 'string' && - arg.value === USER_EVENT_PACKAGE, + arg.value === USER_EVENT_PACKAGE ) ) { importedUserEventLibraryNode = callExpression; @@ -1098,7 +1098,7 @@ export function detectTestingLibraryUtils< (arg) => isLiteral(arg) && typeof arg.value === 'string' && - arg.value === REACT_DOM_TEST_UTILS_PACKAGE, + arg.value === REACT_DOM_TEST_UTILS_PACKAGE ) ) { importedReactDomTestUtilsNode = callExpression; @@ -1111,7 +1111,7 @@ export function detectTestingLibraryUtils< const enhancedRuleInstructions: TSESLint.RuleListener = {}; const allKeys = new Set( - Object.keys(detectionInstructions).concat(Object.keys(ruleInstructions)), + Object.keys(detectionInstructions).concat(Object.keys(ruleInstructions)) ); // Iterate over ALL instructions keys so we can override original rule instructions diff --git a/lib/create-testing-library-rule/index.ts b/lib/create-testing-library-rule/index.ts index 1d2da9ac..7a919447 100644 --- a/lib/create-testing-library-rule/index.ts +++ b/lib/create-testing-library-rule/index.ts @@ -11,7 +11,7 @@ import { export function createTestingLibraryRule< TOptions extends readonly unknown[], TMessageIds extends string, - TRuleListener extends TSESLint.RuleListener = TSESLint.RuleListener, + TRuleListener extends TSESLint.RuleListener = TSESLint.RuleListener >({ create, detectionOptions = {}, @@ -29,7 +29,7 @@ export function createTestingLibraryRule< ...remainingConfig, create: detectTestingLibraryUtils( create, - detectionOptions, + detectionOptions ), meta: { ...meta, diff --git a/lib/node-utils/index.ts b/lib/node-utils/index.ts index ca8e9eb7..0b41bd4a 100644 --- a/lib/node-utils/index.ts +++ b/lib/node-utils/index.ts @@ -63,7 +63,7 @@ const ValidLeftHandSideExpressions = [ */ export function findClosestCallExpressionNode( node: TSESTree.Node | null | undefined, - shouldRestrictInnerScope = false, + shouldRestrictInnerScope = false ): TSESTree.CallExpression | null { if (isCallExpression(node)) { return node; @@ -84,7 +84,7 @@ export function findClosestCallExpressionNode( } export function findClosestVariableDeclaratorNode( - node: TSESTree.Node | undefined, + node: TSESTree.Node | undefined ): TSESTree.VariableDeclarator | null { if (!node) { return null; @@ -98,7 +98,7 @@ export function findClosestVariableDeclaratorNode( } export function findClosestFunctionExpressionNode( - node: TSESTree.Node | undefined, + node: TSESTree.Node | undefined ): | TSESTree.ArrowFunctionExpression | TSESTree.FunctionExpression @@ -124,7 +124,7 @@ export function findClosestFunctionExpressionNode( */ export function findClosestCallNode( node: TSESTree.Node, - name: string, + name: string ): TSESTree.CallExpression | null { if (!node.parent) { return null; @@ -162,7 +162,7 @@ export function hasChainedThen(node: TSESTree.Node): boolean { } export function isPromiseIdentifier( - node: TSESTree.Node, + node: TSESTree.Node ): node is TSESTree.Identifier & { name: 'Promise' } { return ASTUtils.isIdentifier(node) && node.name === 'Promise'; } @@ -220,11 +220,11 @@ export function isPromisesArrayResolved(node: TSESTree.Node): boolean { export function isPromiseHandled(nodeIdentifier: TSESTree.Identifier): boolean { const closestCallExpressionNode = findClosestCallExpressionNode( nodeIdentifier, - true, + true ); const suspiciousNodes = [nodeIdentifier, closestCallExpressionNode].filter( - Boolean, + Boolean ); for (const node of suspiciousNodes) { @@ -260,7 +260,7 @@ export function isPromiseHandled(nodeIdentifier: TSESTree.Identifier): boolean { export function getVariableReferences( context: TSESLint.RuleContext, - node: TSESTree.Node, + node: TSESTree.Node ): TSESLint.Scope.Reference[] { if (ASTUtils.isVariableDeclarator(node)) { // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition @@ -279,11 +279,11 @@ interface InnermostFunctionScope extends TSESLintScope.FunctionScope { export function getInnermostFunctionScope( context: TSESLint.RuleContext, - asyncQueryNode: TSESTree.Identifier, + asyncQueryNode: TSESTree.Identifier ): InnermostFunctionScope | null { const innermostScope = ASTUtils.getInnermostScope( context.getScope(), - asyncQueryNode, + asyncQueryNode ); if ( @@ -300,12 +300,12 @@ export function getFunctionReturnStatementNode( functionNode: | TSESTree.ArrowFunctionExpression | TSESTree.FunctionDeclaration - | TSESTree.FunctionExpression, + | TSESTree.FunctionExpression ): TSESTree.Node | null { if (isBlockStatement(functionNode.body)) { // regular function or arrow function with block const returnStatementNode = functionNode.body.body.find((statement) => - isReturnStatement(statement), + isReturnStatement(statement) ) as TSESTree.ReturnStatement | undefined; if (!returnStatementNode) { @@ -331,7 +331,7 @@ export function getFunctionReturnStatementNode( * it will return `rtl` identifier node */ export function getPropertyIdentifierNode( - node: TSESTree.Node, + node: TSESTree.Node ): TSESTree.Identifier | null { if (ASTUtils.isIdentifier(node)) { return node; @@ -363,7 +363,7 @@ export function getPropertyIdentifierNode( * it will return `getByRole` identifier */ export function getDeepestIdentifierNode( - node: TSESTree.Node, + node: TSESTree.Node ): TSESTree.Identifier | null { if (ASTUtils.isIdentifier(node)) { return node; @@ -398,7 +398,7 @@ export function getReferenceNode( node: | TSESTree.CallExpression | TSESTree.Identifier - | TSESTree.MemberExpression, + | TSESTree.MemberExpression ): TSESTree.CallExpression | TSESTree.Identifier | TSESTree.MemberExpression { if ( node.parent && @@ -414,7 +414,7 @@ export function getFunctionName( node: | TSESTree.ArrowFunctionExpression | TSESTree.FunctionDeclaration - | TSESTree.FunctionExpression, + | TSESTree.FunctionExpression ): string { return ( ASTUtils.getFunctionNameWithKind(node) @@ -429,7 +429,7 @@ export type ImportModuleNode = | TSESTree.ImportDeclaration; export function getImportModuleName( - node: ImportModuleNode | null | undefined, + node: ImportModuleNode | null | undefined ): string | undefined { // import node of shape: import { foo } from 'bar' if (isImportDeclaration(node) && typeof node.source.value === 'string') { @@ -456,7 +456,7 @@ type AssertNodeInfo = { * Extracts matcher info from MemberExpression node representing an assert. */ export function getAssertNodeInfo( - node: TSESTree.MemberExpression, + node: TSESTree.MemberExpression ): AssertNodeInfo { const emptyInfo = { matcher: null, isNegated: false } as AssertNodeInfo; @@ -527,7 +527,7 @@ export function hasClosestExpectResolvesRejects(node: TSESTree.Node): boolean { */ export function getInnermostReturningFunction( context: TSESLint.RuleContext, - node: TSESTree.Identifier, + node: TSESTree.Identifier ): | TSESTree.ArrowFunctionExpression | TSESTree.FunctionDeclaration @@ -540,7 +540,7 @@ export function getInnermostReturningFunction( } const returnStatementNode = getFunctionReturnStatementNode( - functionScope.block, + functionScope.block ); if (!returnStatementNode) { @@ -559,7 +559,7 @@ export function getInnermostReturningFunction( export function hasImportMatch( importNode: TSESTree.Identifier | TSESTree.ImportClause, - identifierName: string, + identifierName: string ): boolean { if (ASTUtils.isIdentifier(importNode)) { return importNode.name === identifierName; @@ -569,7 +569,7 @@ export function hasImportMatch( } export function getStatementCallExpression( - statement: TSESTree.Statement, + statement: TSESTree.Statement ): TSESTree.CallExpression | undefined { if (isExpressionStatement(statement)) { const { expression } = statement; @@ -634,7 +634,7 @@ export function isEmptyFunction(node: TSESTree.Node): boolean | undefined { */ export function findImportSpecifier( specifierName: string, - node: ImportModuleNode, + node: ImportModuleNode ): TSESTree.Identifier | TSESTree.ImportClause | undefined { if (isImportDeclaration(node)) { const namedExport = node.specifiers.find((n) => { @@ -671,7 +671,7 @@ export function findImportSpecifier( (n) => isProperty(n) && ASTUtils.isIdentifier(n.key) && - n.key.name === specifierName, + n.key.name === specifierName ); if (!property) { return undefined; diff --git a/lib/node-utils/is-node-of-type.ts b/lib/node-utils/is-node-of-type.ts index 6ccffc34..afa2b3fc 100644 --- a/lib/node-utils/is-node-of-type.ts +++ b/lib/node-utils/is-node-of-type.ts @@ -1,64 +1,64 @@ import { AST_NODE_TYPES, ASTUtils } from '@typescript-eslint/utils'; export const isArrayExpression = ASTUtils.isNodeOfType( - AST_NODE_TYPES.ArrayExpression, + AST_NODE_TYPES.ArrayExpression ); export const isArrowFunctionExpression = ASTUtils.isNodeOfType( - AST_NODE_TYPES.ArrowFunctionExpression, + AST_NODE_TYPES.ArrowFunctionExpression ); export const isBlockStatement = ASTUtils.isNodeOfType( - AST_NODE_TYPES.BlockStatement, + AST_NODE_TYPES.BlockStatement ); export const isCallExpression = ASTUtils.isNodeOfType( - AST_NODE_TYPES.CallExpression, + AST_NODE_TYPES.CallExpression ); export const isExpressionStatement = ASTUtils.isNodeOfType( - AST_NODE_TYPES.ExpressionStatement, + AST_NODE_TYPES.ExpressionStatement ); export const isVariableDeclaration = ASTUtils.isNodeOfType( - AST_NODE_TYPES.VariableDeclaration, + AST_NODE_TYPES.VariableDeclaration ); export const isAssignmentExpression = ASTUtils.isNodeOfType( - AST_NODE_TYPES.AssignmentExpression, + AST_NODE_TYPES.AssignmentExpression ); export const isSequenceExpression = ASTUtils.isNodeOfType( - AST_NODE_TYPES.SequenceExpression, + AST_NODE_TYPES.SequenceExpression ); export const isImportDeclaration = ASTUtils.isNodeOfType( - AST_NODE_TYPES.ImportDeclaration, + AST_NODE_TYPES.ImportDeclaration ); export const isImportDefaultSpecifier = ASTUtils.isNodeOfType( - AST_NODE_TYPES.ImportDefaultSpecifier, + AST_NODE_TYPES.ImportDefaultSpecifier ); export const isImportNamespaceSpecifier = ASTUtils.isNodeOfType( - AST_NODE_TYPES.ImportNamespaceSpecifier, + AST_NODE_TYPES.ImportNamespaceSpecifier ); export const isImportSpecifier = ASTUtils.isNodeOfType( - AST_NODE_TYPES.ImportSpecifier, + AST_NODE_TYPES.ImportSpecifier ); export const isJSXAttribute = ASTUtils.isNodeOfType( - AST_NODE_TYPES.JSXAttribute, + AST_NODE_TYPES.JSXAttribute ); export const isLiteral = ASTUtils.isNodeOfType(AST_NODE_TYPES.Literal); export const isMemberExpression = ASTUtils.isNodeOfType( - AST_NODE_TYPES.MemberExpression, + AST_NODE_TYPES.MemberExpression ); export const isNewExpression = ASTUtils.isNodeOfType( - AST_NODE_TYPES.NewExpression, + AST_NODE_TYPES.NewExpression ); export const isObjectExpression = ASTUtils.isNodeOfType( - AST_NODE_TYPES.ObjectExpression, + AST_NODE_TYPES.ObjectExpression ); export const isObjectPattern = ASTUtils.isNodeOfType( - AST_NODE_TYPES.ObjectPattern, + AST_NODE_TYPES.ObjectPattern ); export const isProperty = ASTUtils.isNodeOfType(AST_NODE_TYPES.Property); export const isReturnStatement = ASTUtils.isNodeOfType( - AST_NODE_TYPES.ReturnStatement, + AST_NODE_TYPES.ReturnStatement ); export const isFunctionExpression = ASTUtils.isNodeOfType( - AST_NODE_TYPES.FunctionExpression, + AST_NODE_TYPES.FunctionExpression ); export const isFunctionDeclaration = ASTUtils.isNodeOfType( - AST_NODE_TYPES.FunctionDeclaration, + AST_NODE_TYPES.FunctionDeclaration ); diff --git a/lib/rules/await-async-events.ts b/lib/rules/await-async-events.ts index a49d43b9..96adfcb2 100644 --- a/lib/rules/await-async-events.ts +++ b/lib/rules/await-async-events.ts @@ -21,7 +21,7 @@ type EventModules = (typeof EVENTS_SIMULATORS)[number]; export type Options = [ { eventModule: EventModules | EventModules[]; - }, + } ]; export default createTestingLibraryRule({ @@ -129,7 +129,7 @@ export default createTestingLibraryRule({ const closestCallExpression = findClosestCallExpressionNode( node, - true, + true ); if (!closestCallExpression?.parent) { @@ -138,7 +138,7 @@ export default createTestingLibraryRule({ const references = getVariableReferences( context, - closestCallExpression.parent, + closestCallExpression.parent ); if (references.length === 0) { @@ -153,7 +153,7 @@ export default createTestingLibraryRule({ if (functionExpression) { const memberExpressionFixer = fixer.insertTextBefore( node.parent, - 'await ', + 'await ' ); if (functionExpression.async) { @@ -189,7 +189,7 @@ export default createTestingLibraryRule({ // previously detected const closestCallExpression = findClosestCallExpressionNode( node, - true, + true ); if (!closestCallExpression) { diff --git a/lib/rules/await-async-queries.ts b/lib/rules/await-async-queries.ts index 3af1d069..6da6b0d2 100644 --- a/lib/rules/await-async-queries.ts +++ b/lib/rules/await-async-queries.ts @@ -62,7 +62,7 @@ export default createTestingLibraryRule({ const closestCallExpressionNode = findClosestCallExpressionNode( node, - true, + true ); if (!closestCallExpressionNode?.parent) { @@ -71,7 +71,7 @@ export default createTestingLibraryRule({ const references = getVariableReferences( context, - closestCallExpressionNode.parent, + closestCallExpressionNode.parent ); // check direct usage of async query: diff --git a/lib/rules/await-async-utils.ts b/lib/rules/await-async-utils.ts index cfb698c2..a52e96d0 100644 --- a/lib/rules/await-async-utils.ts +++ b/lib/rules/await-async-utils.ts @@ -62,7 +62,7 @@ export default createTestingLibraryRule({ Detects `myRenamedValue` and adds it to the known async wrapper names. */ function detectDestructuredAsyncUtilWrapperAliases( - node: TSESTree.ObjectPattern, + node: TSESTree.ObjectPattern ) { for (const property of node.properties) { if (!isProperty(property)) { @@ -110,7 +110,7 @@ export default createTestingLibraryRule({ ASTUtils.isIdentifier(node.id) && node.init !== null && functionWrappersNames.includes( - getDeepestIdentifierNode(node.init)?.name ?? '', + getDeepestIdentifierNode(node.init)?.name ?? '' ); if (isAssigningKnownAsyncFunctionWrapper) { @@ -138,7 +138,7 @@ export default createTestingLibraryRule({ const references = getVariableReferences( context, - closestCallExpression.parent, + closestCallExpression.parent ); if (references.length === 0) { diff --git a/lib/rules/consistent-data-testid.ts b/lib/rules/consistent-data-testid.ts index 2536706e..7760776c 100644 --- a/lib/rules/consistent-data-testid.ts +++ b/lib/rules/consistent-data-testid.ts @@ -10,7 +10,7 @@ export type Options = [ testIdAttribute?: string[] | string; testIdPattern: string; customMessage?: string; - }, + } ]; const FILENAME_PLACEHOLDER = '{fileName}'; diff --git a/lib/rules/index.ts b/lib/rules/index.ts index f0ac5ad8..7a340ac0 100644 --- a/lib/rules/index.ts +++ b/lib/rules/index.ts @@ -22,5 +22,5 @@ export default readdirSync(rulesDir) ...allRules, [ruleName]: importDefault(join(rulesDir, ruleName)), }), - {}, + {} ); diff --git a/lib/rules/no-await-sync-events.ts b/lib/rules/no-await-sync-events.ts index 94b37149..989ddcda 100644 --- a/lib/rules/no-await-sync-events.ts +++ b/lib/rules/no-await-sync-events.ts @@ -76,7 +76,7 @@ export default createTestingLibraryRule({ property.id.name === 'delay' && isLiteral(property.init) && property.init.value && - property.init.value > 0, + property.init.value > 0 ); }, AssignmentExpression(node: TSESTree.AssignmentExpression) { @@ -99,10 +99,10 @@ export default createTestingLibraryRule({ } const isUserEventMethod = helpers.isUserEventMethod( - simulateEventFunctionIdentifier, + simulateEventFunctionIdentifier ); const isFireEventMethod = helpers.isFireEventMethod( - simulateEventFunctionIdentifier, + simulateEventFunctionIdentifier ); const isSimulateEventMethod = isUserEventMethod || isFireEventMethod; @@ -128,7 +128,7 @@ export default createTestingLibraryRule({ (property) => isProperty(property) && ASTUtils.isIdentifier(property.key) && - property.key.name === 'delay', + property.key.name === 'delay' ); // In case delay's value has been declared as a literal @@ -141,7 +141,7 @@ export default createTestingLibraryRule({ property.key.name === 'delay' && isLiteral(property.value) && !!property.value.value && - property.value.value > 0, + property.value.value > 0 ); const simulateEventFunctionName = simulateEventFunctionIdentifier.name; diff --git a/lib/rules/no-container.ts b/lib/rules/no-container.ts index 4ce2e620..54423db5 100644 --- a/lib/rules/no-container.ts +++ b/lib/rules/no-container.ts @@ -52,7 +52,7 @@ export default createTestingLibraryRule({ } function showErrorIfChainedContainerMethod( - innerNode: TSESTree.MemberExpression, + innerNode: TSESTree.MemberExpression ) { if (isMemberExpression(innerNode)) { if (ASTUtils.isIdentifier(innerNode.object)) { @@ -81,7 +81,7 @@ export default createTestingLibraryRule({ } } showErrorIfChainedContainerMethod( - innerNode.object as TSESTree.MemberExpression, + innerNode.object as TSESTree.MemberExpression ); } } @@ -122,7 +122,7 @@ export default createTestingLibraryRule({ } const isRenderWrapperVariableDeclarator = renderWrapperNames.includes( - initIdentifierNode.name, + initIdentifierNode.name ); if ( @@ -137,7 +137,7 @@ export default createTestingLibraryRule({ (property) => isProperty(property) && ASTUtils.isIdentifier(property.key) && - property.key.name === 'container', + property.key.name === 'container' ); const nodeValue = @@ -154,7 +154,7 @@ export default createTestingLibraryRule({ (property) => isProperty(property) && ASTUtils.isIdentifier(property.key) && - destructuredContainerPropNames.push(property.key.name), + destructuredContainerPropNames.push(property.key.name) ); } } else if (ASTUtils.isIdentifier(node.id)) { diff --git a/lib/rules/no-debugging-utils.ts b/lib/rules/no-debugging-utils.ts index 84543d3e..d9ed3040 100644 --- a/lib/rules/no-debugging-utils.ts +++ b/lib/rules/no-debugging-utils.ts @@ -59,7 +59,7 @@ export default createTestingLibraryRule({ [name]: { type: 'boolean' }, ...obj, }), - {}, + {} ), additionalProperties: false, }, @@ -105,7 +105,7 @@ export default createTestingLibraryRule({ } const isRenderWrapperVariableDeclarator = renderWrapperNames.includes( - initIdentifierNode.name, + initIdentifierNode.name ); if ( @@ -159,10 +159,10 @@ export default createTestingLibraryRule({ const isDebugUtil = helpers.isDebugUtil( callExpressionIdentifier, - utilsToReport as Array<(typeof DEBUG_UTILS)[number]>, + utilsToReport as Array<(typeof DEBUG_UTILS)[number]> ); const isDeclaredDebugVariable = suspiciousDebugVariableNames.includes( - callExpressionIdentifier.name, + callExpressionIdentifier.name ); const isChainedReferenceDebug = suspiciousReferenceNodes.some( (suspiciousReferenceIdentifier) => { @@ -170,7 +170,7 @@ export default createTestingLibraryRule({ utilsToReport.includes(callExpressionIdentifier.name) && suspiciousReferenceIdentifier.name === referenceIdentifier.name ); - }, + } ); const isVariableFromBuiltInConsole = builtInConsoleNodes.some( @@ -179,9 +179,9 @@ export default createTestingLibraryRule({ return variables.some( ({ name }) => name === callExpressionIdentifier.name && - isCallExpression(callExpressionIdentifier.parent), + isCallExpression(callExpressionIdentifier.parent) ); - }, + } ); if ( diff --git a/lib/rules/no-dom-import.ts b/lib/rules/no-dom-import.ts index 52e2891b..a095e013 100644 --- a/lib/rules/no-dom-import.ts +++ b/lib/rules/no-dom-import.ts @@ -21,7 +21,7 @@ const CORRECT_MODULE_NAME_BY_FRAMEWORK: Record< }; const getCorrectModuleName = ( moduleName: string, - framework: string, + framework: string ): string => { return ( CORRECT_MODULE_NAME_BY_FRAMEWORK[framework] ?? @@ -57,7 +57,7 @@ export default createTestingLibraryRule({ create(context, [framework], helpers) { function report( node: TSESTree.CallExpression | TSESTree.ImportDeclaration, - moduleName: string, + moduleName: string ) { if (!framework) { return context.report({ @@ -76,13 +76,13 @@ export default createTestingLibraryRule({ // Replace the module name with the raw module name as we can't predict which punctuation the user is going to use return fixer.replaceText( name, - name.raw.replace(moduleName, correctModuleName), + name.raw.replace(moduleName, correctModuleName) ); } else { const name = node.source; return fixer.replaceText( name, - name.raw.replace(moduleName, correctModuleName), + name.raw.replace(moduleName, correctModuleName) ); } }, @@ -100,7 +100,7 @@ export default createTestingLibraryRule({ importName = getImportModuleName(importNode); const domModuleName = DOM_TESTING_LIBRARY_MODULES.find( - (module) => module === importName, + (module) => module === importName ); if (!domModuleName) { diff --git a/lib/rules/no-global-regexp-flag-in-query.ts b/lib/rules/no-global-regexp-flag-in-query.ts index 6e7d42f2..f69894d6 100644 --- a/lib/rules/no-global-regexp-flag-in-query.ts +++ b/lib/rules/no-global-regexp-flag-in-query.ts @@ -60,7 +60,7 @@ export default createTestingLibraryRule({ return fixer.replaceText( literalNode, - `${raw}/${flagsWithoutGlobal}`, + `${raw}/${flagsWithoutGlobal}` ); }, }); @@ -87,7 +87,7 @@ export default createTestingLibraryRule({ const variableNodesWithRegexs: TSESTree.VariableDeclarator[] = []; function hasRegexInVariable( - identifier: TSESTree.Identifier, + identifier: TSESTree.Identifier ): TSESTree.VariableDeclarator | undefined { return variableNodesWithRegexs.find((varNode) => { if ( @@ -144,13 +144,13 @@ export default createTestingLibraryRule({ const splitter = regexVariableNode.init.raw.lastIndexOf('/'); const raw = regexVariableNode.init.raw.substring(0, splitter); const flags = regexVariableNode.init.raw.substring( - splitter + 1, + splitter + 1 ); const flagsWithoutGlobal = flags.replace('g', ''); return fixer.replaceText( regexVariableNode.init, - `${raw}/${flagsWithoutGlobal}`, + `${raw}/${flagsWithoutGlobal}` ); } return null; @@ -165,7 +165,7 @@ export default createTestingLibraryRule({ isProperty(p) && ASTUtils.isIdentifier(p.key) && p.key.name === 'name' && - isLiteral(p.value), + isLiteral(p.value) ) as TSESTree.Property | undefined; if (namePropertyNode) { diff --git a/lib/rules/no-manual-cleanup.ts b/lib/rules/no-manual-cleanup.ts index 7eba082a..833fa147 100644 --- a/lib/rules/no-manual-cleanup.ts +++ b/lib/rules/no-manual-cleanup.ts @@ -73,7 +73,7 @@ export default createTestingLibraryRule({ const cleanupSpecifier = moduleNode.specifiers.find( (specifier) => isImportSpecifier(specifier) && - specifier.imported.name === 'cleanup', + specifier.imported.name === 'cleanup' ); if (cleanupSpecifier) { @@ -91,7 +91,7 @@ export default createTestingLibraryRule({ (property) => isProperty(property) && ASTUtils.isIdentifier(property.key) && - property.key.name === 'cleanup', + property.key.name === 'cleanup' ); if (cleanupProperty) { diff --git a/lib/rules/no-promise-in-fire-event.ts b/lib/rules/no-promise-in-fire-event.ts index 4258f9a2..c3c7eb4d 100644 --- a/lib/rules/no-promise-in-fire-event.ts +++ b/lib/rules/no-promise-in-fire-event.ts @@ -39,7 +39,7 @@ export default createTestingLibraryRule({ create(context, _, helpers) { function checkSuspiciousNode( node: TSESTree.Node, - originalNode?: TSESTree.Node, + originalNode?: TSESTree.Node ): void { if (ASTUtils.isAwaitExpression(node)) { return; @@ -77,7 +77,7 @@ export default createTestingLibraryRule({ if (ASTUtils.isIdentifier(node)) { const nodeVariable = ASTUtils.findVariable( context.getScope(), - node.name, + node.name ); if (!nodeVariable) { return; diff --git a/lib/rules/no-render-in-lifecycle.ts b/lib/rules/no-render-in-lifecycle.ts index b13b2003..4496522c 100644 --- a/lib/rules/no-render-in-lifecycle.ts +++ b/lib/rules/no-render-in-lifecycle.ts @@ -14,12 +14,12 @@ export type MessageIds = 'noRenderInSetup'; type Options = [ { allowTestingFrameworkSetupHook?: string; - }, + } ]; export function findClosestBeforeHook( node: TSESTree.Node | null, - testingFrameworkSetupHooksToFilter: string[], + testingFrameworkSetupHooksToFilter: string[] ): TSESTree.Identifier | null { if (node === null) { return null; @@ -36,7 +36,7 @@ export function findClosestBeforeHook( if (node.parent) { return findClosestBeforeHook( node.parent, - testingFrameworkSetupHooksToFilter, + testingFrameworkSetupHooksToFilter ); } @@ -94,7 +94,7 @@ export default createTestingLibraryRule({ CallExpression(node) { const testingFrameworkSetupHooksToFilter = TESTING_FRAMEWORK_SETUP_HOOKS.filter( - (hook) => hook !== allowTestingFrameworkSetupHook, + (hook) => hook !== allowTestingFrameworkSetupHook ); const callExpressionIdentifier = getDeepestIdentifierNode(node); @@ -103,7 +103,7 @@ export default createTestingLibraryRule({ } const isRenderIdentifier = helpers.isRenderUtil( - callExpressionIdentifier, + callExpressionIdentifier ); if (isRenderIdentifier) { @@ -119,7 +119,7 @@ export default createTestingLibraryRule({ const beforeHook = findClosestBeforeHook( node, - testingFrameworkSetupHooksToFilter, + testingFrameworkSetupHooksToFilter ); if (!beforeHook) { diff --git a/lib/rules/no-unnecessary-act.ts b/lib/rules/no-unnecessary-act.ts index 64088d1e..3d4317b5 100644 --- a/lib/rules/no-unnecessary-act.ts +++ b/lib/rules/no-unnecessary-act.ts @@ -87,7 +87,7 @@ export default createTestingLibraryRule({ * Determines whether some call is non Testing Library related for a given list of statements. */ function hasSomeNonTestingLibraryCall( - statements: TSESTree.Statement[], + statements: TSESTree.Statement[] ): boolean { return statements.some((statement) => { const identifier = getStatementIdentifier(statement); @@ -113,7 +113,7 @@ export default createTestingLibraryRule({ } function checkNoUnnecessaryActFromBlockStatement( - blockStatementNode: TSESTree.BlockStatement, + blockStatementNode: TSESTree.BlockStatement ) { const functionNode = blockStatementNode.parent as | TSESTree.ArrowFunctionExpression @@ -157,7 +157,7 @@ export default createTestingLibraryRule({ } function checkNoUnnecessaryActFromImplicitReturn( - node: TSESTree.CallExpression, + node: TSESTree.CallExpression ) { const nodeIdentifier = getDeepestIdentifierNode(node); diff --git a/lib/rules/no-wait-for-multiple-assertions.ts b/lib/rules/no-wait-for-multiple-assertions.ts index a87d25f9..df9c1f52 100644 --- a/lib/rules/no-wait-for-multiple-assertions.ts +++ b/lib/rules/no-wait-for-multiple-assertions.ts @@ -34,7 +34,7 @@ export default createTestingLibraryRule({ defaultOptions: [], create(context, _, helpers) { function getExpectNodes( - body: Array, + body: Array ): Array { return body.filter((node) => { if (!isExpressionStatement(node)) { diff --git a/lib/rules/no-wait-for-side-effects.ts b/lib/rules/no-wait-for-side-effects.ts index 89cd036b..a6673409 100644 --- a/lib/rules/no-wait-for-side-effects.ts +++ b/lib/rules/no-wait-for-side-effects.ts @@ -42,7 +42,7 @@ export default createTestingLibraryRule({ | TSESTree.AssignmentExpression | TSESTree.BlockStatement | TSESTree.CallExpression - | TSESTree.SequenceExpression, + | TSESTree.SequenceExpression ): boolean { if (!node.parent) { return false; @@ -62,7 +62,7 @@ export default createTestingLibraryRule({ | TSESTree.AssignmentExpression | TSESTree.BlockStatement | TSESTree.CallExpression - | TSESTree.SequenceExpression, + | TSESTree.SequenceExpression ): boolean { if (!node.parent) { return false; @@ -89,7 +89,7 @@ export default createTestingLibraryRule({ } const expressionIdentifier = getPropertyIdentifierNode( - node.expression.right, + node.expression.right ); if (!expressionIdentifier) { @@ -132,7 +132,7 @@ export default createTestingLibraryRule({ * @returns {Boolean} Boolean indicating if variable declarataion has side effects */ function isSideEffectInVariableDeclaration( - node: TSESTree.VariableDeclaration, + node: TSESTree.VariableDeclaration ): boolean { return node.declarations.some((declaration) => { if (isCallExpression(declaration.init)) { @@ -155,7 +155,7 @@ export default createTestingLibraryRule({ } function getSideEffectNodes( - body: TSESTree.Node[], + body: TSESTree.Node[] ): TSESTree.ExpressionStatement[] { return body.filter((node) => { if (!isExpressionStatement(node) && !isVariableDeclaration(node)) { @@ -203,7 +203,7 @@ export default createTestingLibraryRule({ context.report({ node: sideEffectNode, messageId: 'noSideEffectsWaitFor', - }), + }) ); } @@ -211,7 +211,7 @@ export default createTestingLibraryRule({ node: | TSESTree.AssignmentExpression | TSESTree.CallExpression - | TSESTree.SequenceExpression, + | TSESTree.SequenceExpression ) { if (!isCallerWaitFor(node)) { return; diff --git a/lib/rules/no-wait-for-snapshot.ts b/lib/rules/no-wait-for-snapshot.ts index e7ffbf04..4e2b84ef 100644 --- a/lib/rules/no-wait-for-snapshot.ts +++ b/lib/rules/no-wait-for-snapshot.ts @@ -37,7 +37,7 @@ export default createTestingLibraryRule({ create(context, _, helpers) { function getClosestAsyncUtil( - node: TSESTree.Node, + node: TSESTree.Node ): TSESTree.Identifier | null { let n: TSESTree.Node | null = node; do { @@ -69,7 +69,7 @@ export default createTestingLibraryRule({ return { [`Identifier[name=${String(SNAPSHOT_REGEXP)}]`]( - node: TSESTree.Identifier, + node: TSESTree.Identifier ) { const closestAsyncUtil = getClosestAsyncUtil(node); if (closestAsyncUtil === null) { diff --git a/lib/rules/prefer-explicit-assert.ts b/lib/rules/prefer-explicit-assert.ts index 4b0d57ea..7a80e059 100644 --- a/lib/rules/prefer-explicit-assert.ts +++ b/lib/rules/prefer-explicit-assert.ts @@ -16,7 +16,7 @@ type Options = [ { assertion?: string; includeFindQueries?: boolean; - }, + } ]; const isAtTopLevel = (node: TSESTree.Node) => diff --git a/lib/rules/prefer-find-by.ts b/lib/rules/prefer-find-by.ts index cfbd9951..f9d951e0 100644 --- a/lib/rules/prefer-find-by.ts +++ b/lib/rules/prefer-find-by.ts @@ -15,21 +15,21 @@ export type MessageIds = 'preferFindBy'; type Options = []; export function getFindByQueryVariant( - queryMethod: string, + queryMethod: string ): 'findAllBy' | 'findBy' { return queryMethod.includes('All') ? 'findAllBy' : 'findBy'; } function findRenderDefinitionDeclaration( scope: TSESLint.Scope.Scope | null, - query: string, + query: string ): TSESTree.Identifier | null { if (!scope) { return null; } const variable = scope.variables.find( - (v: TSESLint.Scope.Variable) => v.name === query, + (v: TSESLint.Scope.Variable) => v.name === query ); if (variable) { @@ -87,7 +87,7 @@ export default createTestingLibraryRule({ queryMethod: string; prevQuery: string; fix: TSESLint.ReportFixFunction; - }, + } ) { const { queryMethod, queryVariant, prevQuery, fix } = replacementParams; context.report({ @@ -103,7 +103,7 @@ export default createTestingLibraryRule({ } function getWrongQueryNameInAssertion( - node: TSESTree.ArrowFunctionExpression, + node: TSESTree.ArrowFunctionExpression ) { if ( !isCallExpression(node.body) || @@ -131,7 +131,7 @@ export default createTestingLibraryRule({ isCallExpression(node.body.callee.object.arguments[0]) && isMemberExpression(node.body.callee.object.arguments[0].callee) && ASTUtils.isIdentifier( - node.body.callee.object.arguments[0].callee.property, + node.body.callee.object.arguments[0].callee.property ) ) { return node.body.callee.object.arguments[0].callee.property.name; @@ -143,10 +143,10 @@ export default createTestingLibraryRule({ isCallExpression(node.body.callee.object.object) && isCallExpression(node.body.callee.object.object.arguments[0]) && isMemberExpression( - node.body.callee.object.object.arguments[0].callee, + node.body.callee.object.object.arguments[0].callee ) && ASTUtils.isIdentifier( - node.body.callee.object.object.arguments[0].callee.property, + node.body.callee.object.object.arguments[0].callee.property ) ) { return node.body.callee.object.object.arguments[0].callee.property.name; @@ -158,7 +158,7 @@ export default createTestingLibraryRule({ isCallExpression(node.body.callee.object.object) && isCallExpression(node.body.callee.object.object.arguments[0]) && ASTUtils.isIdentifier( - node.body.callee.object.object.arguments[0].callee, + node.body.callee.object.object.arguments[0].callee ) ) { return node.body.callee.object.object.arguments[0].callee.name; @@ -203,7 +203,7 @@ export default createTestingLibraryRule({ isCallExpression(node.body.callee.object.arguments[0]) && isMemberExpression(node.body.callee.object.arguments[0].callee) && ASTUtils.isIdentifier( - node.body.callee.object.arguments[0].callee.object, + node.body.callee.object.arguments[0].callee.object ) ) { return node.body.callee.object.arguments[0].callee.object.name; @@ -215,10 +215,10 @@ export default createTestingLibraryRule({ isCallExpression(node.body.callee.object.object) && isCallExpression(node.body.callee.object.object.arguments[0]) && isMemberExpression( - node.body.callee.object.object.arguments[0].callee, + node.body.callee.object.object.arguments[0].callee ) && ASTUtils.isIdentifier( - node.body.callee.object.object.arguments[0].callee.object, + node.body.callee.object.object.arguments[0].callee.object ) ) { return node.body.callee.object.object.arguments[0].callee.object.name; @@ -250,10 +250,10 @@ export default createTestingLibraryRule({ isCallExpression(node.body.callee.object.object) && isCallExpression(node.body.callee.object.object.arguments[0]) && ASTUtils.isIdentifier( - node.body.callee.object.object.arguments[0].callee, + node.body.callee.object.object.arguments[0].callee ) && helpers.isSyncQuery( - node.body.callee.object.object.arguments[0].callee, + node.body.callee.object.object.arguments[0].callee ) && helpers.isPresenceAssert(node.body.callee.object); @@ -288,7 +288,7 @@ export default createTestingLibraryRule({ isCallExpression(node.body.callee.object.arguments[0]) && isMemberExpression(node.body.callee.object.arguments[0].callee) && ASTUtils.isIdentifier( - node.body.callee.object.arguments[0].callee.object, + node.body.callee.object.arguments[0].callee.object ); const isWrappedInNegatedPresenceAssert = @@ -419,7 +419,7 @@ export default createTestingLibraryRule({ if ( helpers.isCustomQuery( (argument.body as TSESTree.CallExpression) - .callee as TSESTree.Identifier, + .callee as TSESTree.Identifier ) ) { return null; @@ -435,7 +435,7 @@ export default createTestingLibraryRule({ // this adds the findBy* declaration - adding it to the list of destructured variables { findBy* } = render() const definition = findRenderDefinitionDeclaration( context.getScope(), - fullQueryMethod, + fullQueryMethod ); // I think it should always find it, otherwise code should not be valid (it'd be using undeclared variables) if (!definition) { @@ -453,18 +453,18 @@ export default createTestingLibraryRule({ (p) => isProperty(p) && ASTUtils.isIdentifier(p.key) && - p.key.name === findByMethod, + p.key.name === findByMethod ) ) { return allFixes; } // the last character of a destructuring is always a "}", so we should replace it with the findBy* declaration const textDestructuring = sourceCode.getText( - allVariableDeclarations, + allVariableDeclarations ); const text = textDestructuring.replace( /(\s*})$/, - `, ${findByMethod}$1`, + `, ${findByMethod}$1` ); allFixes.push(fixer.replaceText(allVariableDeclarations, text)); } diff --git a/lib/rules/prefer-presence-queries.ts b/lib/rules/prefer-presence-queries.ts index b654dd6a..dd816408 100644 --- a/lib/rules/prefer-presence-queries.ts +++ b/lib/rules/prefer-presence-queries.ts @@ -9,7 +9,7 @@ export type Options = [ { presence?: boolean; absence?: boolean; - }, + } ]; export default createTestingLibraryRule({ diff --git a/lib/rules/prefer-query-by-disappearance.ts b/lib/rules/prefer-query-by-disappearance.ts index 6db106bc..f19b3796 100644 --- a/lib/rules/prefer-query-by-disappearance.ts +++ b/lib/rules/prefer-query-by-disappearance.ts @@ -121,31 +121,31 @@ export default createTestingLibraryRule({ } function checkFunctionExpressionViolation( - node: TSESTree.CallExpressionArgument, + node: TSESTree.CallExpressionArgument ) { if (!isFunctionExpression(node)) { return false; } return node.body.body.some((statement) => - isStatementViolation(statement), + isStatementViolation(statement) ); } function isArrowFunctionBodyViolation( - node: TSESTree.CallExpressionArgument, + node: TSESTree.CallExpressionArgument ) { if (!isArrowFunctionExpression(node) || !isBlockStatement(node.body)) { return false; } return node.body.body.some((statement) => - isStatementViolation(statement), + isStatementViolation(statement) ); } function isArrowFunctionImplicitReturnViolation( - node: TSESTree.CallExpressionArgument, + node: TSESTree.CallExpressionArgument ) { if (!isArrowFunctionExpression(node) || !isCallExpression(node.body)) { return false; @@ -162,7 +162,7 @@ export default createTestingLibraryRule({ } function checkArrowFunctionViolation( - node: TSESTree.CallExpressionArgument, + node: TSESTree.CallExpressionArgument ) { return ( isArrowFunctionBodyViolation(node) || diff --git a/lib/rules/prefer-query-matchers.ts b/lib/rules/prefer-query-matchers.ts index 83d51844..3f94a8e9 100644 --- a/lib/rules/prefer-query-matchers.ts +++ b/lib/rules/prefer-query-matchers.ts @@ -11,7 +11,7 @@ export type Options = [ query: 'get' | 'query'; matcher: string; }[]; - }, + } ]; export default createTestingLibraryRule({ @@ -83,7 +83,7 @@ export default createTestingLibraryRule({ const { query, matcher } = entry; const isMatchingAssertForThisEntry = helpers.isMatchingAssert( expectStatement, - matcher, + matcher ); if (!isMatchingAssertForThisEntry) { diff --git a/lib/rules/prefer-screen-queries.ts b/lib/rules/prefer-screen-queries.ts index 6af01752..0d49d426 100644 --- a/lib/rules/prefer-screen-queries.ts +++ b/lib/rules/prefer-screen-queries.ts @@ -29,7 +29,7 @@ function usesContainerOrBaseElement(node: TSESTree.CallExpression) { (property) => isProperty(property) && ASTUtils.isIdentifier(property.key) && - ALLOWED_RENDER_PROPERTIES_FOR_DESTRUCTURING.includes(property.key.name), + ALLOWED_RENDER_PROPERTIES_FOR_DESTRUCTURING.includes(property.key.name) ) ); } @@ -157,7 +157,7 @@ export default createTestingLibraryRule({ if (!isMemberExpression(identifierNode.parent)) { const isSafeDestructuredQuery = safeDestructuredQueries.some( - (queryName) => queryName === identifierNode.name, + (queryName) => queryName === identifierNode.name ); if (isSafeDestructuredQuery) { return; diff --git a/lib/rules/prefer-user-event.ts b/lib/rules/prefer-user-event.ts index c869be79..daf408d1 100644 --- a/lib/rules/prefer-user-event.ts +++ b/lib/rules/prefer-user-event.ts @@ -55,7 +55,7 @@ export const MAPPING_TO_USER_EVENT: Record = { function buildErrorMessage(fireEventMethod: string) { const userEventMethods = MAPPING_TO_USER_EVENT[fireEventMethod].map( - (methodName) => `userEvent.${methodName}`, + (methodName) => `userEvent.${methodName}` ); // TODO: when min node version is 13, we can reimplement this using `Intl.ListFormat` @@ -104,7 +104,7 @@ export default createTestingLibraryRule({ const getFireEventMethodName = ( callExpressionNode: TSESTree.CallExpression, - node: TSESTree.Identifier, + node: TSESTree.Identifier ) => { if ( !ASTUtils.isIdentifier(callExpressionNode.callee) && @@ -149,7 +149,7 @@ export default createTestingLibraryRule({ const fireEventMethodName = getFireEventMethodName( closestCallExpression, - node, + node ); if ( diff --git a/lib/utils/index.ts b/lib/utils/index.ts index b38fc608..7ed659f7 100644 --- a/lib/utils/index.ts +++ b/lib/utils/index.ts @@ -46,12 +46,12 @@ const ALL_QUERIES_METHODS = [ const SYNC_QUERIES_COMBINATIONS = combineQueries( SYNC_QUERIES_VARIANTS, - ALL_QUERIES_METHODS, + ALL_QUERIES_METHODS ); const ASYNC_QUERIES_COMBINATIONS = combineQueries( ASYNC_QUERIES_VARIANTS, - ALL_QUERIES_METHODS, + ALL_QUERIES_METHODS ); const ALL_QUERIES_COMBINATIONS = [ diff --git a/lib/utils/types.ts b/lib/utils/types.ts index 1dd6d9d3..4a5a7283 100644 --- a/lib/utils/types.ts +++ b/lib/utils/types.ts @@ -20,7 +20,7 @@ export type TestingLibraryRuleMetaDocs = }; export type TestingLibraryRuleMeta< TMessageIds extends string, - TOptions extends readonly unknown[], + TOptions extends readonly unknown[] > = Omit, 'docs'> & { docs: TestingLibraryRuleMetaDocs; }; diff --git a/lint-staged.config.js b/lint-staged.config.js index f3c99a18..bbbe515d 100644 --- a/lint-staged.config.js +++ b/lint-staged.config.js @@ -4,7 +4,7 @@ const { ESLint } = require('eslint'); const removeIgnoredFiles = async (files) => { const eslint = new ESLint(); const ignoredFiles = await Promise.all( - files.map((file) => eslint.isPathIgnored(file)), + files.map((file) => eslint.isPathIgnored(file)) ); const filteredFiles = files.filter((_, i) => !ignoredFiles[i]); return filteredFiles.join(' '); diff --git a/package-lock.json b/package-lock.json index b107c2c0..d061205a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -41,7 +41,7 @@ "jest": "^28.1.3", "lint-staged": "^13.2.1", "npm-run-all": "^4.1.5", - "prettier": "3.0.3", + "prettier": "2.8.7", "semantic-release": "^19.0.5", "ts-node": "^10.9.1", "typescript": "^4.9.5" @@ -13815,15 +13815,15 @@ } }, "node_modules/prettier": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.0.3.tgz", - "integrity": "sha512-L/4pUDMxcNa8R/EthV08Zt42WBO4h1rarVtK0K+QJG0X187OLo7l699jWw0GKuwzkPQ//jMFA/8Xm6Fh3J/DAg==", + "version": "2.8.7", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.7.tgz", + "integrity": "sha512-yPngTo3aXUUmyuTjeTUT75txrf+aMh9FiD7q9ZE/i6r0bPb22g4FsE6Y338PQX1bmfy08i9QQCB7/rcUAVntfw==", "dev": true, "bin": { - "prettier": "bin/prettier.cjs" + "prettier": "bin-prettier.js" }, "engines": { - "node": ">=14" + "node": ">=10.13.0" }, "funding": { "url": "https://github.com/prettier/prettier?sponsor=1" @@ -24909,9 +24909,9 @@ "version": "1.2.1" }, "prettier": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.0.3.tgz", - "integrity": "sha512-L/4pUDMxcNa8R/EthV08Zt42WBO4h1rarVtK0K+QJG0X187OLo7l699jWw0GKuwzkPQ//jMFA/8Xm6Fh3J/DAg==", + "version": "2.8.7", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.7.tgz", + "integrity": "sha512-yPngTo3aXUUmyuTjeTUT75txrf+aMh9FiD7q9ZE/i6r0bPb22g4FsE6Y338PQX1bmfy08i9QQCB7/rcUAVntfw==", "dev": true }, "prettier-linter-helpers": { diff --git a/package.json b/package.json index c0128d43..e157ac24 100644 --- a/package.json +++ b/package.json @@ -83,7 +83,7 @@ "jest": "^28.1.3", "lint-staged": "^13.2.1", "npm-run-all": "^4.1.5", - "prettier": "3.0.3", + "prettier": "2.8.7", "semantic-release": "^19.0.5", "ts-node": "^10.9.1", "typescript": "^4.9.5" diff --git a/tests/create-testing-library-rule.test.ts b/tests/create-testing-library-rule.test.ts index 9c2c210a..43b74f70 100644 --- a/tests/create-testing-library-rule.test.ts +++ b/tests/create-testing-library-rule.test.ts @@ -460,7 +460,7 @@ ruleTester.run(RULE_NAME, rule, { messageId: 'renderError', }, ], - }) as const, + } as const) ), { code: ` diff --git a/tests/eslint-remote-tester.config.js b/tests/eslint-remote-tester.config.js index 137121b7..730b5579 100644 --- a/tests/eslint-remote-tester.config.js +++ b/tests/eslint-remote-tester.config.js @@ -33,7 +33,7 @@ module.exports = { ...all, [`testing-library/${rule}`]: 'error', }), - {}, + {} ), // Rules with required options without default values diff --git a/tests/index.test.ts b/tests/index.test.ts index 6be29826..c69e0c6a 100644 --- a/tests/index.test.ts +++ b/tests/index.test.ts @@ -13,7 +13,7 @@ it('should have a corresponding doc for each rule', () => { if (!existsSync(docPath)) { throw new Error( - `Could not find documentation file for rule "${rule}" in path "${docPath}"`, + `Could not find documentation file for rule "${rule}" in path "${docPath}"` ); } }); @@ -26,7 +26,7 @@ it('should have a corresponding test for each rule', () => { if (!existsSync(testPath)) { throw new Error( - `Could not find test file for rule "${rule}" in path "${testPath}"`, + `Could not find test file for rule "${rule}" in path "${testPath}"` ); } }); @@ -38,7 +38,7 @@ it('should have the correct amount of rules', () => { if (length !== numberOfRules) { throw new Error( - `There should be exactly ${numberOfRules} rules, but there are ${length}. If you've added a new rule, please update this number.`, + `There should be exactly ${numberOfRules} rules, but there are ${length}. If you've added a new rule, please update this number.` ); } }); diff --git a/tests/lib/rules/await-async-events.test.ts b/tests/lib/rules/await-async-events.test.ts index 50bcf77b..2f0ce78e 100644 --- a/tests/lib/rules/await-async-events.test.ts +++ b/tests/lib/rules/await-async-events.test.ts @@ -391,7 +391,7 @@ ruleTester.run(RULE_NAME, rule, { await fireEvent.${eventMethod}(getByLabelText('username')) }) `, - }) as const, + } as const) ), ...FIRE_EVENT_ASYNC_FUNCTIONS.map( (eventMethod) => @@ -416,7 +416,7 @@ ruleTester.run(RULE_NAME, rule, { fireEvent.${eventMethod}(getByLabelText('username')) `, - }) as const, + } as const) ), ...FIRE_EVENT_ASYNC_FUNCTIONS.map( (eventMethod) => @@ -449,7 +449,7 @@ ruleTester.run(RULE_NAME, rule, { test('should handle external function', run) `, - }) as const, + } as const) ), ...FIRE_EVENT_ASYNC_FUNCTIONS.map( (eventMethod) => @@ -476,7 +476,7 @@ ruleTester.run(RULE_NAME, rule, { await testingLibraryFireEvent.${eventMethod}(getByLabelText('username')) }) `, - }) as const, + } as const) ), ...FIRE_EVENT_ASYNC_FUNCTIONS.map( (eventMethod) => @@ -503,7 +503,7 @@ ruleTester.run(RULE_NAME, rule, { await testingLibrary.fireEvent.${eventMethod}(getByLabelText('username')) }) `, - }) as const, + } as const) ), ...FIRE_EVENT_ASYNC_FUNCTIONS.map( (eventMethod) => @@ -537,7 +537,7 @@ ruleTester.run(RULE_NAME, rule, { await fireEvent.${eventMethod}(getByLabelText('username')) }) `, - }) as const, + } as const) ), ...FIRE_EVENT_ASYNC_FUNCTIONS.map( (eventMethod) => @@ -566,7 +566,7 @@ ruleTester.run(RULE_NAME, rule, { await fireEvent.${eventMethod}(getByLabelText('username')) }) `, - }) as const, + } as const) ), ...FIRE_EVENT_ASYNC_FUNCTIONS.map( (eventMethod) => @@ -599,7 +599,7 @@ ruleTester.run(RULE_NAME, rule, { await fireEvent.${eventMethod}(getByLabelText('username')) }) `, - }) as const, + } as const) ), ...FIRE_EVENT_ASYNC_FUNCTIONS.map( (eventMethod) => @@ -632,7 +632,7 @@ ruleTester.run(RULE_NAME, rule, { await fireEvent.${eventMethod}(getByLabelText('username')) }) `, - }) as const, + } as const) ), ...FIRE_EVENT_ASYNC_FUNCTIONS.map( @@ -663,7 +663,7 @@ ruleTester.run(RULE_NAME, rule, { const promise = await fireEvent.${eventMethod}(getByLabelText('username')) }) `, - }) as const, + } as const) ), ...FIRE_EVENT_ASYNC_FUNCTIONS.map( (eventMethod) => @@ -699,7 +699,7 @@ ruleTester.run(RULE_NAME, rule, { await triggerEvent() }) `, - }) as const, + } as const) ), ...FIRE_EVENT_ASYNC_FUNCTIONS.map( (eventMethod) => @@ -733,7 +733,7 @@ ruleTester.run(RULE_NAME, rule, { triggerEvent() `, - }) as const, + } as const) ), ]), ...USER_EVENT_ASYNC_FRAMEWORKS.flatMap((testingFramework) => [ @@ -762,7 +762,7 @@ ruleTester.run(RULE_NAME, rule, { await userEvent.${eventMethod}(getByLabelText('username')) }) `, - }) as const, + } as const) ), ...USER_EVENT_ASYNC_FUNCTIONS.map( (eventMethod) => @@ -787,7 +787,7 @@ ruleTester.run(RULE_NAME, rule, { userEvent.${eventMethod}(getByLabelText('username')) `, - }) as const, + } as const) ), ...USER_EVENT_ASYNC_FUNCTIONS.map( (eventMethod) => @@ -814,7 +814,7 @@ ruleTester.run(RULE_NAME, rule, { await testingLibraryUserEvent.${eventMethod}(getByLabelText('username')) }) `, - }) as const, + } as const) ), ...USER_EVENT_ASYNC_FUNCTIONS.map( (eventMethod) => @@ -848,7 +848,7 @@ ruleTester.run(RULE_NAME, rule, { await userEvent.${eventMethod}(getByLabelText('username')) }) `, - }) as const, + } as const) ), ...USER_EVENT_ASYNC_FUNCTIONS.map( (eventMethod) => @@ -878,7 +878,7 @@ ruleTester.run(RULE_NAME, rule, { const promise = await userEvent.${eventMethod}(getByLabelText('username')) }) `, - }) as const, + } as const) ), ...USER_EVENT_ASYNC_FUNCTIONS.map( (eventMethod) => @@ -914,7 +914,7 @@ ruleTester.run(RULE_NAME, rule, { await triggerEvent() }) `, - }) as const, + } as const) ), ...USER_EVENT_ASYNC_FUNCTIONS.map( (eventMethod) => @@ -948,7 +948,7 @@ ruleTester.run(RULE_NAME, rule, { triggerEvent() `, - }) as const, + } as const) ), ]), { diff --git a/tests/lib/rules/await-async-queries.test.ts b/tests/lib/rules/await-async-queries.test.ts index 387d4d82..799e5e70 100644 --- a/tests/lib/rules/await-async-queries.test.ts +++ b/tests/lib/rules/await-async-queries.test.ts @@ -47,7 +47,7 @@ interface TestCaseParams { function createTestCase( getTest: ( - query: string, + query: string ) => | string | { code: string; errors?: TSESLint.TestCaseError<'awaitAsyncQuery'>[] }, @@ -55,7 +55,7 @@ function createTestCase( combinations = ALL_ASYNC_COMBINATIONS_TO_TEST, isAsync, testingFramework = '', - }: TestCaseParams = {}, + }: TestCaseParams = {} ) { return combinations.map((query) => { const test = getTest(query); @@ -74,7 +74,7 @@ function createTestCase( const CUSTOM_ASYNC_QUERIES_COMBINATIONS = combineQueries( ASYNC_QUERIES_VARIANTS, - ['ByIcon', 'ByButton'], + ['ByIcon', 'ByButton'] ); // built-in queries + custom queries @@ -103,7 +103,7 @@ ruleTester.run(RULE_NAME, rule, { (query) => ` doSomething() await ${query}('foo') - `, + ` ), // async queries are valid when saved in a variable with await operator @@ -112,7 +112,7 @@ ruleTester.run(RULE_NAME, rule, { doSomething() const foo = await ${query}('foo') expect(foo).toBeInTheDocument(); - `, + ` ), // async queries are valid when saved in a promise variable immediately resolved @@ -120,7 +120,7 @@ ruleTester.run(RULE_NAME, rule, { (query) => ` const promise = ${query}('foo') await promise - `, + ` ), // async queries are valid when used with then method @@ -129,7 +129,7 @@ ruleTester.run(RULE_NAME, rule, { ${query}('foo').then(() => { done() }) - `, + ` ), // async queries are valid with promise in variable resolved by then method @@ -137,7 +137,7 @@ ruleTester.run(RULE_NAME, rule, { (query) => ` const promise = ${query}('foo') promise.then((done) => done()) - `, + ` ), // async queries are valid when wrapped within Promise.all + await expression @@ -149,7 +149,7 @@ ruleTester.run(RULE_NAME, rule, { ${query}('foo'), ${query}('bar'), ]); - `, + ` ), // async queries are valid when wrapped within Promise.all + then chained @@ -161,7 +161,7 @@ ruleTester.run(RULE_NAME, rule, { ${query}('foo'), ${query}('bar'), ]).then() - `, + ` ), // async queries are valid when wrapped within Promise.allSettled + await expression @@ -173,7 +173,7 @@ ruleTester.run(RULE_NAME, rule, { ${query}('foo'), ${query}('bar'), ]); - `, + ` ), // async queries are valid when wrapped within Promise.allSettled + then chained @@ -185,12 +185,12 @@ ruleTester.run(RULE_NAME, rule, { ${query}('foo'), ${query}('bar'), ]).then() - `, + ` ), // async queries are valid with promise returned in arrow function ...createTestCase( - (query) => `const anArrowFunction = () => ${query}('foo')`, + (query) => `const anArrowFunction = () => ${query}('foo')` ), // async queries are valid with promise returned in regular function @@ -203,7 +203,7 @@ ruleTester.run(RULE_NAME, rule, { const promise = ${query}('foo') return promise } - `, + ` ), // sync queries are valid @@ -212,7 +212,7 @@ ruleTester.run(RULE_NAME, rule, { doSomething() ${query}('foo') `, - { combinations: SYNC_QUERIES_COMBINATIONS }, + { combinations: SYNC_QUERIES_COMBINATIONS } ), // async queries with resolves matchers are valid @@ -220,14 +220,14 @@ ruleTester.run(RULE_NAME, rule, { (query) => ` expect(${query}("foo")).resolves.toBe("bar") expect(wrappedQuery(${query}("foo"))).resolves.toBe("bar") - `, + ` ), // async queries with toResolve matchers are valid ...createTestCase( (query) => ` expect(${query}("foo")).toResolve() expect(wrappedQuery(${query}("foo"))).toResolve() - `, + ` ), // async queries with rejects matchers are valid @@ -235,7 +235,7 @@ ruleTester.run(RULE_NAME, rule, { (query) => ` expect(${query}("foo")).rejects.toBe("bar") expect(wrappedQuery(${query}("foo"))).rejects.toBe("bar") - `, + ` ), // async queries with toReject matchers are valid @@ -243,7 +243,7 @@ ruleTester.run(RULE_NAME, rule, { (query) => ` expect(${query}("foo")).toReject() expect(wrappedQuery(${query}("foo"))).toReject() - `, + ` ), // unresolved async queries with aggressive reporting opted-out are valid @@ -361,8 +361,8 @@ ruleTester.run(RULE_NAME, rule, { }); `, errors: [{ messageId: 'awaitAsyncQuery', line: 6, column: 21 }], - }) as const, - ), + } as const) + ) ), ...ALL_ASYNC_COMBINATIONS_TO_TEST.map( (query) => @@ -382,7 +382,7 @@ ruleTester.run(RULE_NAME, rule, { data: { name: query }, }, ], - }) as const, + } as const) ), ...ALL_ASYNC_COMBINATIONS_TO_TEST.map( (query) => @@ -403,7 +403,7 @@ ruleTester.run(RULE_NAME, rule, { data: { name: query }, }, ], - }) as const, + } as const) ), ...ALL_ASYNC_COMBINATIONS_TO_TEST.map( (query) => @@ -425,7 +425,7 @@ ruleTester.run(RULE_NAME, rule, { data: { name: query }, }, ], - }) as const, + } as const) ), // unresolved async queries are not valid (aggressive reporting) @@ -440,7 +440,7 @@ ruleTester.run(RULE_NAME, rule, { }) `, errors: [{ messageId: 'awaitAsyncQuery', line: 5, column: 27 }], - }) as const, + } as const) ), // unhandled promise from async query function wrapper is invalid @@ -463,7 +463,7 @@ ruleTester.run(RULE_NAME, rule, { }) `, errors: [{ messageId: 'asyncQueryWrapper', line: 9, column: 27 }], - }) as const, + } as const) ), // unhandled promise from async query arrow function wrapper is invalid ...ALL_ASYNC_COMBINATIONS_TO_TEST.map( @@ -485,7 +485,7 @@ ruleTester.run(RULE_NAME, rule, { }) `, errors: [{ messageId: 'asyncQueryWrapper', line: 9, column: 27 }], - }) as const, + } as const) ), // unhandled promise implicitly returned from async query arrow function wrapper is invalid ...ALL_ASYNC_COMBINATIONS_TO_TEST.map( @@ -503,7 +503,7 @@ ruleTester.run(RULE_NAME, rule, { }) `, errors: [{ messageId: 'asyncQueryWrapper', line: 5, column: 27 }], - }) as const, + } as const) ), // unhandled promise from custom query matching custom-queries setting is invalid diff --git a/tests/lib/rules/await-async-utils.test.ts b/tests/lib/rules/await-async-utils.test.ts index 37f31b78..7eb211bb 100644 --- a/tests/lib/rules/await-async-utils.test.ts +++ b/tests/lib/rules/await-async-utils.test.ts @@ -346,7 +346,7 @@ ruleTester.run(RULE_NAME, rule, { data: { name: asyncUtil }, }, ], - }) as const, + } as const) ), ...ASYNC_UTILS.map( (asyncUtil) => @@ -366,7 +366,7 @@ ruleTester.run(RULE_NAME, rule, { data: { name: asyncUtil }, }, ], - }) as const, + } as const) ), ...ASYNC_UTILS.map( (asyncUtil) => @@ -386,7 +386,7 @@ ruleTester.run(RULE_NAME, rule, { data: { name: asyncUtil }, }, ], - }) as const, + } as const) ), ...ASYNC_UTILS.map( (asyncUtil) => @@ -406,7 +406,7 @@ ruleTester.run(RULE_NAME, rule, { data: { name: asyncUtil }, }, ], - }) as const, + } as const) ), ...ASYNC_UTILS.map( (asyncUtil) => @@ -433,7 +433,7 @@ ruleTester.run(RULE_NAME, rule, { data: { name: asyncUtil }, }, ], - }) as const, + } as const) ), ...ASYNC_UTILS.map( (asyncUtil) => @@ -458,7 +458,7 @@ ruleTester.run(RULE_NAME, rule, { data: { name: 'waitForSomethingAsync' }, }, ], - }) as const, + } as const) ), ...ASYNC_UTILS.map( (asyncUtil) => @@ -480,7 +480,7 @@ ruleTester.run(RULE_NAME, rule, { data: { name: asyncUtil }, }, ], - }) as const, + } as const) ), ...ASYNC_UTILS.map( (asyncUtil) => @@ -505,7 +505,7 @@ ruleTester.run(RULE_NAME, rule, { data: { name: 'waitForSomethingAsync' }, }, ], - }) as const, + } as const) ), ...ASYNC_UTILS.map( @@ -528,7 +528,7 @@ ruleTester.run(RULE_NAME, rule, { data: { name: asyncUtil }, }, ], - }) as const, + } as const) ), ...ASYNC_UTILS.map( (asyncUtil) => @@ -557,7 +557,7 @@ ruleTester.run(RULE_NAME, rule, { data: { name: 'waitForAsyncUtil' }, }, ], - }) as const, + } as const) ), ...ASYNC_UTILS.map( (asyncUtil) => @@ -587,7 +587,7 @@ ruleTester.run(RULE_NAME, rule, { data: { name: 'myAlias' }, }, ], - }) as const, + } as const) ), ...ASYNC_UTILS.map( (asyncUtil) => @@ -616,7 +616,7 @@ ruleTester.run(RULE_NAME, rule, { data: { name: 'waitForAsyncUtil' }, }, ], - }) as const, + } as const) ), ...ASYNC_UTILS.map( (asyncUtil) => @@ -645,7 +645,7 @@ ruleTester.run(RULE_NAME, rule, { data: { name: 'myAlias' }, }, ], - }) as const, + } as const) ), ...ASYNC_UTILS.map( (asyncUtil) => @@ -673,7 +673,7 @@ ruleTester.run(RULE_NAME, rule, { data: { name: 'waitForAsyncUtil' }, }, ], - }) as const, + } as const) ), ...ASYNC_UTILS.map( (asyncUtil) => @@ -702,7 +702,7 @@ ruleTester.run(RULE_NAME, rule, { data: { name: 'myAlias' }, }, ], - }) as const, + } as const) ), ]), }); diff --git a/tests/lib/rules/no-await-sync-events.test.ts b/tests/lib/rules/no-await-sync-events.test.ts index 6dac7f08..a7a93125 100644 --- a/tests/lib/rules/no-await-sync-events.test.ts +++ b/tests/lib/rules/no-await-sync-events.test.ts @@ -206,7 +206,7 @@ ruleTester.run(RULE_NAME, rule, { }); `, options: [{ eventModules: ['user-event'] }], - })), + })) ), // valid tests for user-event when only fire-event set in eventModules @@ -251,8 +251,8 @@ ruleTester.run(RULE_NAME, rule, { data: { name: `fireEvent.${func}` }, }, ], - }) as const, - ), + } as const) + ) ), // sync userEvent sync methods with await operator are not valid ...USER_EVENT_SYNC_FUNCTIONS.map( @@ -273,7 +273,7 @@ ruleTester.run(RULE_NAME, rule, { data: { name: `userEvent.${func}` }, }, ], - }) as const, + } as const) ), // sync fireEvent methods with await operator are not valid @@ -296,8 +296,8 @@ ruleTester.run(RULE_NAME, rule, { data: { name: `fireEvent.${func}` }, }, ], - }) as const, - ), + } as const) + ) ), ...USER_EVENT_SYNC_FUNCTIONS.map( @@ -318,7 +318,7 @@ ruleTester.run(RULE_NAME, rule, { data: { name: `userEvent.${func}` }, }, ], - }) as const, + } as const) ), { diff --git a/tests/lib/rules/no-await-sync-queries.test.ts b/tests/lib/rules/no-await-sync-queries.test.ts index e478cfa3..3b088ad0 100644 --- a/tests/lib/rules/no-await-sync-queries.test.ts +++ b/tests/lib/rules/no-await-sync-queries.test.ts @@ -142,7 +142,7 @@ ruleTester.run(RULE_NAME, rule, { column: 31, }, ], - }) as const, + } as const) ), // custom sync queries with await operator are not valid { @@ -192,7 +192,7 @@ ruleTester.run(RULE_NAME, rule, { column: 22, }, ], - }) as const, + } as const) ), // sync queries in screen with await operator are not valid @@ -210,7 +210,7 @@ ruleTester.run(RULE_NAME, rule, { column: 38, }, ], - }) as const, + } as const) ), // sync queries in screen with await operator inside assert are not valid @@ -228,7 +228,7 @@ ruleTester.run(RULE_NAME, rule, { column: 29, }, ], - }) as const, + } as const) ), // sync query awaited and related to testing library module @@ -244,7 +244,7 @@ ruleTester.run(RULE_NAME, rule, { } `, errors: [{ messageId: 'noAwaitSyncQuery', line: 4, column: 38 }], - }) as const, + } as const) ), // sync query awaited and related to custom module is not valid { diff --git a/tests/lib/rules/no-container.test.ts b/tests/lib/rules/no-container.test.ts index 33c32ccc..6967de9e 100644 --- a/tests/lib/rules/no-container.test.ts +++ b/tests/lib/rules/no-container.test.ts @@ -65,7 +65,7 @@ ruleTester.run(RULE_NAME, rule, { const { container } = render(); const button = container.querySelector('.btn-primary'); `, - }) as const, + } as const) ), { settings: { @@ -123,7 +123,7 @@ ruleTester.run(RULE_NAME, rule, { messageId: 'noContainer', }, ], - }) as const, + } as const) ), ...SUPPORTED_TESTING_FRAMEWORKS.map( (testingFramework) => @@ -144,7 +144,7 @@ ruleTester.run(RULE_NAME, rule, { messageId: 'noContainer', }, ], - }) as const, + } as const) ), { code: ` @@ -214,7 +214,7 @@ ruleTester.run(RULE_NAME, rule, { messageId: 'noContainer', }, ], - }) as const, + } as const) ), { settings: { diff --git a/tests/lib/rules/no-debugging-utils.test.ts b/tests/lib/rules/no-debugging-utils.test.ts index 90e4b139..b31861a7 100644 --- a/tests/lib/rules/no-debugging-utils.test.ts +++ b/tests/lib/rules/no-debugging-utils.test.ts @@ -602,7 +602,7 @@ ruleTester.run(RULE_NAME, rule, { debug() `, errors: [{ line: 7, column: 7, messageId: 'noDebug' }], - }) as const, + } as const) ), { settings: { 'testing-library/utils-module': 'test-utils' }, @@ -629,7 +629,7 @@ ruleTester.run(RULE_NAME, rule, { utils.debug() `, errors: [{ line: 7, column: 13, messageId: 'noDebug' }], - }) as const, + } as const) ), { settings: { @@ -665,7 +665,7 @@ ruleTester.run(RULE_NAME, rule, { renamedDestructuredDebug('foo') `, errors: [{ line: 12, column: 13, messageId: 'noDebug' }], - }) as const, + } as const) ), ], }); diff --git a/tests/lib/rules/no-dom-import.test.ts b/tests/lib/rules/no-dom-import.test.ts index 8b872479..fd493ad6 100644 --- a/tests/lib/rules/no-dom-import.test.ts +++ b/tests/lib/rules/no-dom-import.test.ts @@ -35,7 +35,7 @@ ruleTester.run(RULE_NAME, rule, { `import { fireEvent } from "${testingFramework}"`, `import * as testing from "${testingFramework}"`, `import "${testingFramework}"`, - ]), + ]) ), 'const { foo } = require("foo")', 'require("foo")', @@ -46,7 +46,7 @@ ruleTester.run(RULE_NAME, rule, { `const { fireEvent } = require("${testingFramework}")`, `const { fireEvent: testing } = require("${testingFramework}")`, `require("${testingFramework}")`, - ]), + ]) ), { code: 'import { fireEvent } from "test-utils"', @@ -115,8 +115,8 @@ ruleTester.run(RULE_NAME, rule, { isOldImport ? oldName : newName }${quote}`, } as const, - ]), - ), + ]) + ) ), { code: 'import * as testing from "dom-testing-library"', @@ -192,8 +192,8 @@ ruleTester.run(RULE_NAME, rule, { isOldImport ? oldName : newName }") `, - }) as const, - ), + } as const) + ) ), { code: 'require("dom-testing-library")', diff --git a/tests/lib/rules/no-manual-cleanup.test.ts b/tests/lib/rules/no-manual-cleanup.test.ts index 4e042666..0b22ce6a 100644 --- a/tests/lib/rules/no-manual-cleanup.test.ts +++ b/tests/lib/rules/no-manual-cleanup.test.ts @@ -67,7 +67,7 @@ ruleTester.run(RULE_NAME, rule, { messageId: 'noManualCleanup', }, ], - }) as const, + } as const) ), ...ALL_TESTING_LIBRARIES_WITH_CLEANUP.map( (lib) => @@ -84,7 +84,7 @@ ruleTester.run(RULE_NAME, rule, { messageId: 'noManualCleanup', }, ], - }) as const, + } as const) ), { settings: { @@ -106,7 +106,7 @@ ruleTester.run(RULE_NAME, rule, { messageId: 'noManualCleanup', }, ], - }) as const, + } as const) ), { settings: { @@ -128,7 +128,7 @@ ruleTester.run(RULE_NAME, rule, { messageId: 'noManualCleanup', }, ], - }) as const, + } as const) ), { settings: { @@ -153,7 +153,7 @@ ruleTester.run(RULE_NAME, rule, { messageId: 'noManualCleanup', }, ], - }) as const, + } as const) ), { settings: { @@ -179,7 +179,7 @@ ruleTester.run(RULE_NAME, rule, { messageId: 'noManualCleanup', }, ], - }) as const, + } as const) ), ...ALL_TESTING_LIBRARIES_WITH_CLEANUP.map( (lib) => @@ -192,7 +192,7 @@ ruleTester.run(RULE_NAME, rule, { messageId: 'noManualCleanup', }, ], - }) as const, + } as const) ), { settings: { @@ -217,7 +217,7 @@ ruleTester.run(RULE_NAME, rule, { messageId: 'noManualCleanup', }, ], - }) as const, + } as const) ), ...ALL_TESTING_LIBRARIES_WITH_CLEANUP.map( (lib) => @@ -233,7 +233,7 @@ ruleTester.run(RULE_NAME, rule, { messageId: 'noManualCleanup', }, ], - }) as const, + } as const) ), ], }); diff --git a/tests/lib/rules/no-node-access.test.ts b/tests/lib/rules/no-node-access.test.ts index 1cfc2ab6..f3216e7e 100644 --- a/tests/lib/rules/no-node-access.test.ts +++ b/tests/lib/rules/no-node-access.test.ts @@ -157,7 +157,7 @@ ruleTester.run(RULE_NAME, rule, { expect(screen.getByText('SomeComponent')).toBeInTheDocument(); `, }, - ], + ] ), invalid: SUPPORTED_TESTING_FRAMEWORKS.flatMap((testingFramework) => [ { diff --git a/tests/lib/rules/no-render-in-lifecycle.test.ts b/tests/lib/rules/no-render-in-lifecycle.test.ts index cae4814d..9665afcc 100644 --- a/tests/lib/rules/no-render-in-lifecycle.test.ts +++ b/tests/lib/rules/no-render-in-lifecycle.test.ts @@ -62,7 +62,7 @@ ruleTester.run(RULE_NAME, rule, { })), ...TESTING_FRAMEWORK_SETUP_HOOKS.map((allowedSetupHook) => { const [disallowedHook] = TESTING_FRAMEWORK_SETUP_HOOKS.filter( - (setupHook) => setupHook !== allowedSetupHook, + (setupHook) => setupHook !== allowedSetupHook ); return { settings: { @@ -121,7 +121,7 @@ ruleTester.run(RULE_NAME, rule, { messageId: 'noRenderInSetup', }, ], - }) as const, + } as const) ), ...TESTING_FRAMEWORK_SETUP_HOOKS.map( (setupHook) => @@ -139,7 +139,7 @@ ruleTester.run(RULE_NAME, rule, { messageId: 'noRenderInSetup', }, ], - }) as const, + } as const) ), ]), // custom render function @@ -164,7 +164,7 @@ ruleTester.run(RULE_NAME, rule, { messageId: 'noRenderInSetup', }, ], - }) as const, + } as const) ), ...SUPPORTED_TESTING_FRAMEWORKS.flatMap((testingFramework) => [ ...TESTING_FRAMEWORK_SETUP_HOOKS.map( @@ -186,11 +186,11 @@ ruleTester.run(RULE_NAME, rule, { messageId: 'noRenderInSetup', }, ], - }) as const, + } as const) ), ...TESTING_FRAMEWORK_SETUP_HOOKS.map((allowedSetupHook) => { const [disallowedHook] = TESTING_FRAMEWORK_SETUP_HOOKS.filter( - (setupHook) => setupHook !== allowedSetupHook, + (setupHook) => setupHook !== allowedSetupHook ); return { code: ` @@ -229,7 +229,7 @@ ruleTester.run(RULE_NAME, rule, { messageId: 'noRenderInSetup', }, ], - }) as const, + } as const) ), ]), ...TESTING_FRAMEWORK_SETUP_HOOKS.map( @@ -253,7 +253,7 @@ ruleTester.run(RULE_NAME, rule, { messageId: 'noRenderInSetup', }, ], - }) as const, + } as const) ), ...SUPPORTED_TESTING_FRAMEWORKS.flatMap((testingFramework) => TESTING_FRAMEWORK_SETUP_HOOKS.map( @@ -273,8 +273,8 @@ ruleTester.run(RULE_NAME, rule, { messageId: 'noRenderInSetup', }, ], - }) as const, - ), + } as const) + ) ), ], }); diff --git a/tests/lib/rules/no-unnecessary-act.test.ts b/tests/lib/rules/no-unnecessary-act.test.ts index 00c07f23..2f1bce65 100644 --- a/tests/lib/rules/no-unnecessary-act.test.ts +++ b/tests/lib/rules/no-unnecessary-act.test.ts @@ -15,7 +15,7 @@ type TestCase = InvalidTestCase | ValidTestCase; const addOptions = ( array: T[], - options?: Options[number], + options?: Options[number] ): T[] => array.map((testCase) => ({ ...testCase, @@ -330,7 +330,7 @@ const invalidTestCases: InvalidTestCase[] = [ column: 9, }, ], - }) as const, + } as const) ), { settings: { diff --git a/tests/lib/rules/no-wait-for-multiple-assertions.test.ts b/tests/lib/rules/no-wait-for-multiple-assertions.test.ts index b8e98aaa..8c3a3fec 100644 --- a/tests/lib/rules/no-wait-for-multiple-assertions.test.ts +++ b/tests/lib/rules/no-wait-for-multiple-assertions.test.ts @@ -125,7 +125,7 @@ ruleTester.run(RULE_NAME, rule, { errors: [ { line: 5, column: 11, messageId: 'noWaitForMultipleAssertion' }, ], - }) as const, + } as const) ), { settings: { 'testing-library/utils-module': 'test-utils' }, diff --git a/tests/lib/rules/no-wait-for-side-effects.test.ts b/tests/lib/rules/no-wait-for-side-effects.test.ts index 1fd105c6..869dfb2b 100644 --- a/tests/lib/rules/no-wait-for-side-effects.test.ts +++ b/tests/lib/rules/no-wait-for-side-effects.test.ts @@ -554,7 +554,7 @@ ruleTester.run(RULE_NAME, rule, { await waitFor(() => fireEvent.keyDown(input, {key: 'ArrowDown'})) `, errors: [{ line: 3, column: 29, messageId: 'noSideEffectsWaitFor' }], - }) as const, + } as const) ), { settings: { 'testing-library/utils-module': '~/test-utils' }, diff --git a/tests/lib/rules/no-wait-for-snapshot.test.ts b/tests/lib/rules/no-wait-for-snapshot.test.ts index 57fbc94c..02eefece 100644 --- a/tests/lib/rules/no-wait-for-snapshot.test.ts +++ b/tests/lib/rules/no-wait-for-snapshot.test.ts @@ -179,7 +179,7 @@ ruleTester.run(RULE_NAME, rule, { column: 36 + asyncUtil.length, }, ], - }) as const, + } as const) ), ...ASYNC_UTILS.map( (asyncUtil) => @@ -200,7 +200,7 @@ ruleTester.run(RULE_NAME, rule, { column: 27, }, ], - }) as const, + } as const) ), ...ASYNC_UTILS.map( (asyncUtil) => @@ -219,7 +219,7 @@ ruleTester.run(RULE_NAME, rule, { column: 47 + asyncUtil.length, }, ], - }) as const, + } as const) ), ...ASYNC_UTILS.map( (asyncUtil) => @@ -240,7 +240,7 @@ ruleTester.run(RULE_NAME, rule, { column: 27, }, ], - }) as const, + } as const) ), ...ASYNC_UTILS.map( (asyncUtil) => @@ -259,7 +259,7 @@ ruleTester.run(RULE_NAME, rule, { column: 36 + asyncUtil.length, }, ], - }) as const, + } as const) ), ...ASYNC_UTILS.map( (asyncUtil) => @@ -280,7 +280,7 @@ ruleTester.run(RULE_NAME, rule, { column: 27, }, ], - }) as const, + } as const) ), ...ASYNC_UTILS.map( (asyncUtil) => @@ -299,7 +299,7 @@ ruleTester.run(RULE_NAME, rule, { column: 47 + asyncUtil.length, }, ], - }) as const, + } as const) ), ...ASYNC_UTILS.map( (asyncUtil) => @@ -320,7 +320,7 @@ ruleTester.run(RULE_NAME, rule, { column: 27, }, ], - }) as const, + } as const) ), ]), }); diff --git a/tests/lib/rules/prefer-explicit-assert.test.ts b/tests/lib/rules/prefer-explicit-assert.test.ts index c7b3a9ee..952f770d 100644 --- a/tests/lib/rules/prefer-explicit-assert.test.ts +++ b/tests/lib/rules/prefer-explicit-assert.test.ts @@ -187,7 +187,7 @@ ruleTester.run(RULE_NAME, rule, { }, }, ], - }) as const, + } as const) ), ...COMBINED_QUERIES_METHODS.map( (queryMethod) => @@ -199,7 +199,7 @@ ruleTester.run(RULE_NAME, rule, { data: { queryType: 'findBy*' }, }, ], - }) as const, + } as const) ), ...COMBINED_QUERIES_METHODS.map( (queryMethod) => @@ -211,7 +211,7 @@ ruleTester.run(RULE_NAME, rule, { data: { queryType: 'findBy*' }, }, ], - }) as const, + } as const) ), ...COMBINED_QUERIES_METHODS.map( (queryMethod) => @@ -227,7 +227,7 @@ ruleTester.run(RULE_NAME, rule, { data: { queryType: 'findBy*' }, }, ], - }) as const, + } as const) ), ...COMBINED_QUERIES_METHODS.map( (queryMethod) => @@ -243,7 +243,7 @@ ruleTester.run(RULE_NAME, rule, { data: { queryType: 'findBy*' }, }, ], - }) as const, + } as const) ), ...COMBINED_QUERIES_METHODS.map( (queryMethod) => @@ -262,7 +262,7 @@ ruleTester.run(RULE_NAME, rule, { }, }, ], - }) as const, + } as const) ), ...COMBINED_QUERIES_METHODS.map( (queryMethod) => @@ -278,7 +278,7 @@ ruleTester.run(RULE_NAME, rule, { }, }, ], - }) as const, + } as const) ), ...COMBINED_QUERIES_METHODS.map( (queryMethod) => @@ -308,7 +308,7 @@ ruleTester.run(RULE_NAME, rule, { }, }, ], - }) as const, + } as const) ), ...COMBINED_QUERIES_METHODS.map( (queryMethod) => @@ -328,7 +328,7 @@ ruleTester.run(RULE_NAME, rule, { }, }, ], - }) as const, + } as const) ), { code: `getByIcon('foo')`, // custom `getBy` query extended through options @@ -353,7 +353,7 @@ ruleTester.run(RULE_NAME, rule, { data: { assertion: 'toBeInTheDocument' }, }, ], - }) as const, + } as const) ), ...COMBINED_QUERIES_METHODS.map( (queryMethod) => @@ -370,7 +370,7 @@ ruleTester.run(RULE_NAME, rule, { data: { assertion: 'toBeInTheDocument' }, }, ], - }) as const, + } as const) ), ...COMBINED_QUERIES_METHODS.map( (queryMethod) => @@ -387,7 +387,7 @@ ruleTester.run(RULE_NAME, rule, { data: { assertion: 'toBeInTheDocument' }, }, ], - }) as const, + } as const) ), ], }); diff --git a/tests/lib/rules/prefer-find-by.test.ts b/tests/lib/rules/prefer-find-by.test.ts index 33ca90da..22a2eb4e 100644 --- a/tests/lib/rules/prefer-find-by.test.ts +++ b/tests/lib/rules/prefer-find-by.test.ts @@ -28,10 +28,10 @@ function buildFindByMethod(queryMethod: string) { function createScenario< T extends | TSESLint.InvalidTestCase - | TSESLint.ValidTestCase<[]>, + | TSESLint.ValidTestCase<[]> >(callback: (waitMethod: string, queryMethod: string) => T) { return SYNC_QUERIES_COMBINATIONS.map((queryMethod) => - callback('waitFor', queryMethod), + callback('waitFor', queryMethod) ); } @@ -190,7 +190,7 @@ ruleTester.run(RULE_NAME, rule, { import {${waitMethod}, screen} from '${testingFramework}'; it('tests', async () => { const submitButton = await screen.${buildFindByMethod( - queryMethod, + queryMethod )}('foo', { name: 'baz' }) }) `, @@ -366,7 +366,7 @@ ruleTester.run(RULE_NAME, rule, { it('tests', async () => { const { ${queryMethod}, ${buildFindByMethod(queryMethod)} } = render() const submitButton = await ${buildFindByMethod( - queryMethod, + queryMethod )}('foo', { name: 'baz' }) }) `, @@ -395,7 +395,7 @@ ruleTester.run(RULE_NAME, rule, { it('tests', async () => { const { ${queryMethod}, ${buildFindByMethod(queryMethod)} } = render() const submitButton = await ${buildFindByMethod( - queryMethod, + queryMethod )}('foo', { name: 'baz' }) }) `, @@ -424,7 +424,7 @@ ruleTester.run(RULE_NAME, rule, { it('tests', async () => { const { ${queryMethod}, ${buildFindByMethod(queryMethod)} } = render() const submitButton = await ${buildFindByMethod( - queryMethod, + queryMethod )}('foo', { name: 'baz' }) }) `, @@ -453,7 +453,7 @@ ruleTester.run(RULE_NAME, rule, { it('tests', async () => { const { ${queryMethod}, ${buildFindByMethod(queryMethod)} } = render() const submitButton = await ${buildFindByMethod( - queryMethod, + queryMethod )}('foo', { name: 'baz' }) }) `, @@ -482,7 +482,7 @@ ruleTester.run(RULE_NAME, rule, { it('tests', async () => { const {${queryMethod}, ${buildFindByMethod(queryMethod)}} = render() const submitButton = await ${buildFindByMethod( - queryMethod, + queryMethod )}('foo', { name: 'baz' }) }) `, @@ -511,7 +511,7 @@ ruleTester.run(RULE_NAME, rule, { it('tests', async () => { const { ${queryMethod}, ${buildFindByMethod(queryMethod)} } = render() const submitButton = await ${buildFindByMethod( - queryMethod, + queryMethod )}('foo', { name: 'baz' }) }) `, @@ -540,7 +540,7 @@ ruleTester.run(RULE_NAME, rule, { it('tests', async () => { const { ${queryMethod}, ${buildFindByMethod(queryMethod)} } = render() const submitButton = await ${buildFindByMethod( - queryMethod, + queryMethod )}('foo', { name: 'baz' }) }) `, @@ -567,7 +567,7 @@ ruleTester.run(RULE_NAME, rule, { import {${waitMethod}} from '${testingFramework}'; it('tests', async () => { const submitButton = await screen.${buildFindByMethod( - queryMethod, + queryMethod )}('foo', { name: 'baz' }) }) `, @@ -594,7 +594,7 @@ ruleTester.run(RULE_NAME, rule, { import {${waitMethod}} from '${testingFramework}'; it('tests', async () => { const submitButton = await screen.${buildFindByMethod( - queryMethod, + queryMethod )}('foo', { name: 'baz' }) }) `, @@ -621,7 +621,7 @@ ruleTester.run(RULE_NAME, rule, { import {${waitMethod}} from '${testingFramework}'; it('tests', async () => { const submitButton = await screen.${buildFindByMethod( - queryMethod, + queryMethod )}('foo', { name: 'baz' }) }) `, @@ -648,7 +648,7 @@ ruleTester.run(RULE_NAME, rule, { import {${waitMethod}} from '${testingFramework}'; it('tests', async () => { const submitButton = await screen.${buildFindByMethod( - queryMethod, + queryMethod )}('foo', { name: 'baz' }) }) `, @@ -675,7 +675,7 @@ ruleTester.run(RULE_NAME, rule, { import {${waitMethod}} from '${testingFramework}'; it('tests', async () => { const submitButton = await screen.${buildFindByMethod( - queryMethod, + queryMethod )}('foo', { name: 'baz' }) }) `, @@ -699,7 +699,7 @@ ruleTester.run(RULE_NAME, rule, { ], output: `import {${waitMethod}} from '${testingFramework}'; const button = await screen.${buildFindByMethod( - queryMethod, + queryMethod )}('Count is: 0', { timeout: 100, interval: 200 }) `, })), diff --git a/tests/lib/rules/prefer-presence-queries.test.ts b/tests/lib/rules/prefer-presence-queries.test.ts index 26429641..a5e8b3c9 100644 --- a/tests/lib/rules/prefer-presence-queries.test.ts +++ b/tests/lib/rules/prefer-presence-queries.test.ts @@ -14,7 +14,7 @@ const getByQueries = ALL_QUERIES_METHODS.map((method) => `get${method}`); const getAllByQueries = ALL_QUERIES_METHODS.map((method) => `getAll${method}`); const queryByQueries = ALL_QUERIES_METHODS.map((method) => `query${method}`); const queryAllByQueries = ALL_QUERIES_METHODS.map( - (method) => `queryAll${method}`, + (method) => `queryAll${method}` ); type RuleValidTestCase = TSESLint.ValidTestCase; @@ -179,7 +179,7 @@ ruleTester.run(RULE_NAME, rule, { assertionType: 'presence', }), ], - [], + [] ), // cases: asserting presence correctly with `screen.getBy*` queries ...getByQueries.reduce( @@ -240,7 +240,7 @@ ruleTester.run(RULE_NAME, rule, { assertionType: 'presence', }), ], - [], + [] ), // cases: asserting presence correctly with `getAllBy*` queries ...getAllByQueries.reduce( @@ -292,7 +292,7 @@ ruleTester.run(RULE_NAME, rule, { assertionType: 'presence', }), ], - [], + [] ), // cases: asserting presence correctly with `screen.getAllBy*` queries ...getAllByQueries.reduce( @@ -353,7 +353,7 @@ ruleTester.run(RULE_NAME, rule, { assertionType: 'presence', }), ], - [], + [] ), // cases: asserting absence correctly with `queryBy*` queries ...queryByQueries.reduce( @@ -395,7 +395,7 @@ ruleTester.run(RULE_NAME, rule, { assertionType: 'absence', }), ], - [], + [] ), // cases: asserting absence correctly with `screen.queryBy*` queries ...queryByQueries.reduce( @@ -444,7 +444,7 @@ ruleTester.run(RULE_NAME, rule, { assertionType: 'absence', }), ], - [], + [] ), // cases: asserting absence correctly with `queryAllBy*` queries ...queryAllByQueries.reduce( @@ -486,7 +486,7 @@ ruleTester.run(RULE_NAME, rule, { assertionType: 'absence', }), ], - [], + [] ), // cases: asserting absence correctly with `screen.queryAllBy*` queries ...queryAllByQueries.reduce( @@ -535,7 +535,7 @@ ruleTester.run(RULE_NAME, rule, { assertionType: 'absence', }), ], - [], + [] ), // cases: asserting absence incorrectly with `getBy*` queries with absence rule disabled @@ -568,7 +568,7 @@ ruleTester.run(RULE_NAME, rule, { assertionType: 'absence', }), ], - [], + [] ), // cases: asserting absence incorrectly with `screen.getBy*` queries with absence rule disabled ...getByQueries.reduce( @@ -605,7 +605,7 @@ ruleTester.run(RULE_NAME, rule, { assertionType: 'absence', }), ], - [], + [] ), // cases: asserting absence incorrectly with `getAllBy*` queries with absence rule disabled ...getAllByQueries.reduce( @@ -637,7 +637,7 @@ ruleTester.run(RULE_NAME, rule, { assertionType: 'absence', }), ], - [], + [] ), // cases: asserting absence incorrectly with `screen.getAllBy*` queries with absence rule disabled ...getAllByQueries.reduce( @@ -674,7 +674,7 @@ ruleTester.run(RULE_NAME, rule, { assertionType: 'absence', }), ], - [], + [] ), // cases: asserting presence incorrectly with `queryBy*` queries with presence rule disabled ...queryByQueries.reduce( @@ -706,7 +706,7 @@ ruleTester.run(RULE_NAME, rule, { assertionType: 'presence', }), ], - [], + [] ), // cases: asserting presence incorrectly with `screen.queryBy*` queries with presence rule disabled ...queryByQueries.reduce( @@ -743,7 +743,7 @@ ruleTester.run(RULE_NAME, rule, { assertionType: 'presence', }), ], - [], + [] ), // cases: asserting presence incorrectly with `queryAllBy*` queries with presence rule disabled ...queryAllByQueries.reduce( @@ -775,7 +775,7 @@ ruleTester.run(RULE_NAME, rule, { assertionType: 'presence', }), ], - [], + [] ), // cases: asserting presence incorrectly with `screen.queryAllBy*` queries with presence rule disabled ...queryAllByQueries.reduce( @@ -812,7 +812,7 @@ ruleTester.run(RULE_NAME, rule, { assertionType: 'presence', }), ], - [], + [] ), { @@ -880,7 +880,7 @@ ruleTester.run(RULE_NAME, rule, { assertionType: 'absence', }), ], - [], + [] ), // cases: asserting absence incorrectly with `screen.getBy*` queries ...getByQueries.reduce( @@ -922,7 +922,7 @@ ruleTester.run(RULE_NAME, rule, { assertionType: 'absence', }), ], - [], + [] ), // cases: asserting absence incorrectly with `getAllBy*` queries ...getAllByQueries.reduce( @@ -959,7 +959,7 @@ ruleTester.run(RULE_NAME, rule, { assertionType: 'absence', }), ], - [], + [] ), // cases: asserting absence incorrectly with `screen.getAllBy*` queries ...getAllByQueries.reduce( @@ -1001,7 +1001,7 @@ ruleTester.run(RULE_NAME, rule, { assertionType: 'absence', }), ], - [], + [] ), // cases: asserting presence incorrectly with `queryBy*` queries ...queryByQueries.reduce( @@ -1038,7 +1038,7 @@ ruleTester.run(RULE_NAME, rule, { assertionType: 'presence', }), ], - [], + [] ), // cases: asserting presence incorrectly with `screen.queryBy*` queries ...queryByQueries.reduce( @@ -1080,7 +1080,7 @@ ruleTester.run(RULE_NAME, rule, { assertionType: 'presence', }), ], - [], + [] ), // cases: asserting presence incorrectly with `queryAllBy*` queries ...queryAllByQueries.reduce( @@ -1117,7 +1117,7 @@ ruleTester.run(RULE_NAME, rule, { assertionType: 'presence', }), ], - [], + [] ), // cases: asserting presence incorrectly with `screen.queryAllBy*` queries ...queryAllByQueries.reduce( @@ -1159,7 +1159,7 @@ ruleTester.run(RULE_NAME, rule, { assertionType: 'presence', }), ], - [], + [] ), { code: 'expect(screen.getAllByText("button")[1]).not.toBeInTheDocument()', diff --git a/tests/lib/rules/prefer-query-matchers.test.ts b/tests/lib/rules/prefer-query-matchers.test.ts index 5df714f9..e16cf983 100644 --- a/tests/lib/rules/prefer-query-matchers.test.ts +++ b/tests/lib/rules/prefer-query-matchers.test.ts @@ -14,7 +14,7 @@ const getByQueries = ALL_QUERIES_METHODS.map((method) => `get${method}`); const getAllByQueries = ALL_QUERIES_METHODS.map((method) => `getAll${method}`); const queryByQueries = ALL_QUERIES_METHODS.map((method) => `query${method}`); const queryAllByQueries = ALL_QUERIES_METHODS.map( - (method) => `queryAll${method}`, + (method) => `queryAll${method}` ); type RuleValidTestCase = TSESLint.ValidTestCase; @@ -152,7 +152,7 @@ ruleTester.run(RULE_NAME, rule, { ], }), ], - [], + [] ), // cases: asserting with a configured allowed `[screen.]getAllBy*` query ...getAllByQueries.reduce( @@ -194,7 +194,7 @@ ruleTester.run(RULE_NAME, rule, { ], }), ], - [], + [] ), // cases: asserting with a configured allowed `[screen.]queryBy*` query ...queryByQueries.reduce( @@ -236,7 +236,7 @@ ruleTester.run(RULE_NAME, rule, { ], }), ], - [], + [] ), // cases: asserting with a configured allowed `[screen.]queryAllBy*` query ...queryAllByQueries.reduce( @@ -278,7 +278,7 @@ ruleTester.run(RULE_NAME, rule, { ], }), ], - [], + [] ), // case: getting outside an expectation { @@ -324,7 +324,7 @@ ruleTester.run(RULE_NAME, rule, { ], }), ], - [], + [] ), // cases: asserting with a disallowed `[screen.]getAllBy*` query ...getAllByQueries.reduce( @@ -338,7 +338,7 @@ ruleTester.run(RULE_NAME, rule, { ], }), ], - [], + [] ), // cases: asserting with a disallowed `[screen.]getBy*` query ...queryByQueries.reduce( @@ -352,7 +352,7 @@ ruleTester.run(RULE_NAME, rule, { ], }), ], - [], + [] ), // cases: asserting with a disallowed `[screen.]queryAllBy*` query ...queryAllByQueries.reduce( @@ -366,7 +366,7 @@ ruleTester.run(RULE_NAME, rule, { ], }), ], - [], + [] ), // cases: indexing into an `AllBy` result within the expectation { diff --git a/tests/lib/rules/prefer-screen-queries.test.ts b/tests/lib/rules/prefer-screen-queries.test.ts index ba701b85..7c3b4a93 100644 --- a/tests/lib/rules/prefer-screen-queries.test.ts +++ b/tests/lib/rules/prefer-screen-queries.test.ts @@ -211,7 +211,7 @@ ruleTester.run(RULE_NAME, rule, { }, }, ], - }) as const, + } as const) ), ...ALL_QUERIES_COMBINATIONS.map( (queryMethod) => @@ -231,7 +231,7 @@ ruleTester.run(RULE_NAME, rule, { }, }, ], - }) as const, + } as const) ), ...ALL_QUERIES_COMBINATIONS.map( @@ -254,7 +254,7 @@ ruleTester.run(RULE_NAME, rule, { }, }, ], - }) as const, + } as const) ), ...SUPPORTED_TESTING_FRAMEWORKS.flatMap((testingFramework) => ALL_QUERIES_COMBINATIONS.map( @@ -275,8 +275,8 @@ ruleTester.run(RULE_NAME, rule, { }, }, ], - }) as const, - ), + } as const) + ) ), ...ALL_QUERIES_COMBINATIONS.map( (queryMethod) => @@ -296,7 +296,7 @@ ruleTester.run(RULE_NAME, rule, { }, }, ], - }) as const, + } as const) ), ...ALL_QUERIES_COMBINATIONS.map( (queryMethod) => @@ -310,7 +310,7 @@ ruleTester.run(RULE_NAME, rule, { }, }, ], - }) as const, + } as const) ), ...ALL_QUERIES_COMBINATIONS.map( (queryMethod) => @@ -324,7 +324,7 @@ ruleTester.run(RULE_NAME, rule, { }, }, ], - }) as const, + } as const) ), ...ALL_QUERIES_COMBINATIONS.map( (queryMethod) => @@ -338,7 +338,7 @@ ruleTester.run(RULE_NAME, rule, { }, }, ], - }) as const, + } as const) ), ...ALL_QUERIES_COMBINATIONS.map( (queryMethod) => @@ -355,7 +355,7 @@ ruleTester.run(RULE_NAME, rule, { }, }, ], - }) as const, + } as const) ), ...ALL_QUERIES_COMBINATIONS.map( (queryMethod) => @@ -372,7 +372,7 @@ ruleTester.run(RULE_NAME, rule, { }, }, ], - }) as const, + } as const) ), ...ALL_QUERIES_COMBINATIONS.map( (queryMethod) => @@ -389,7 +389,7 @@ ruleTester.run(RULE_NAME, rule, { }, }, ], - }) as const, + } as const) ), ...ALL_QUERIES_COMBINATIONS.map( (queryMethod) => @@ -406,7 +406,7 @@ ruleTester.run(RULE_NAME, rule, { }, }, ], - }) as const, + } as const) ), ...ALL_QUERIES_COMBINATIONS.map( (queryMethod) => @@ -423,7 +423,7 @@ ruleTester.run(RULE_NAME, rule, { }, }, ], - }) as const, + } as const) ), ...SUPPORTED_TESTING_FRAMEWORKS.flatMap((testingFramework) => [ { diff --git a/tests/lib/rules/prefer-user-event.test.ts b/tests/lib/rules/prefer-user-event.test.ts index 5a22e4f8..61892761 100644 --- a/tests/lib/rules/prefer-user-event.test.ts +++ b/tests/lib/rules/prefer-user-event.test.ts @@ -13,16 +13,16 @@ import { createRuleTester } from '../test-utils'; function createScenarioWithImport< T extends | TSESLint.InvalidTestCase - | TSESLint.ValidTestCase, + | TSESLint.ValidTestCase >(callback: (libraryModule: string, fireEventMethod: string) => T) { return LIBRARY_MODULES.reduce( (acc: Array, libraryModule) => acc.concat( Object.keys(MAPPING_TO_USER_EVENT).map((fireEventMethod) => - callback(libraryModule, fireEventMethod), - ), + callback(libraryModule, fireEventMethod) + ) ), - [], + [] ); } @@ -30,7 +30,7 @@ const ruleTester = createRuleTester(); function formatUserEventMethodsMessage(fireEventMethod: string): string { const userEventMethods = MAPPING_TO_USER_EVENT[fireEventMethod].map( - (methodName) => `userEvent.${methodName}`, + (methodName) => `userEvent.${methodName}` ); let joinedList = ''; @@ -77,7 +77,7 @@ ruleTester.run(RULE_NAME, rule, { fireEvent.${fireEventMethod}(foo) `, options: [{ allowedMethods: [fireEventMethod] }], - }), + }) ), ...createScenarioWithImport>( (libraryModule: string, fireEventMethod: string) => ({ @@ -87,7 +87,7 @@ ruleTester.run(RULE_NAME, rule, { fireEventAliased.${fireEventMethod}(foo) `, options: [{ allowedMethods: [fireEventMethod] }], - }), + }) ), ...createScenarioWithImport>( (libraryModule: string, fireEventMethod: string) => ({ @@ -96,7 +96,7 @@ ruleTester.run(RULE_NAME, rule, { dom.fireEvent.${fireEventMethod}(foo) `, options: [{ allowedMethods: [fireEventMethod] }], - }), + }) ), ...LIBRARY_MODULES.map((libraryModule) => ({ // imported fireEvent and not used, @@ -291,7 +291,7 @@ ruleTester.run(RULE_NAME, rule, { }, }, ], - }), + }) ), ...createScenarioWithImport>( (libraryModule: string, fireEventMethod: string) => ({ @@ -310,7 +310,7 @@ ruleTester.run(RULE_NAME, rule, { }, }, ], - }), + }) ), ...createScenarioWithImport>( (libraryModule: string, fireEventMethod: string) => ({ @@ -329,7 +329,7 @@ ruleTester.run(RULE_NAME, rule, { }, }, ], - }), + }) ), ...createScenarioWithImport>( (libraryModule: string, fireEventMethod: string) => ({ @@ -348,7 +348,7 @@ ruleTester.run(RULE_NAME, rule, { }, }, ], - }), + }) ), ...Object.keys(MAPPING_TO_USER_EVENT).map( (fireEventMethod: string) => @@ -372,7 +372,7 @@ ruleTester.run(RULE_NAME, rule, { }, }, ], - }) as const, + } as const) ), ...Object.keys(MAPPING_TO_USER_EVENT).map( (fireEventMethod: string) => @@ -396,7 +396,7 @@ ruleTester.run(RULE_NAME, rule, { }, }, ], - }) as const, + } as const) ), ...Object.keys(MAPPING_TO_USER_EVENT).map( (fireEventMethod: string) => @@ -419,7 +419,7 @@ ruleTester.run(RULE_NAME, rule, { }, }, ], - }) as const, + } as const) ), ...Object.keys(MAPPING_TO_USER_EVENT).map( (fireEventMethod: string) => @@ -443,7 +443,7 @@ ruleTester.run(RULE_NAME, rule, { }, }, ], - }) as const, + } as const) ), { code: ` // simple test to check error in detail diff --git a/tests/lib/test-utils.ts b/tests/lib/test-utils.ts index 520eae45..c9640129 100644 --- a/tests/lib/test-utils.ts +++ b/tests/lib/test-utils.ts @@ -10,7 +10,7 @@ class TestingLibraryRuleTester extends TSESLint.RuleTester { run>( ruleName: string, rule: TSESLint.RuleModule, - tests: TSESLint.RunTests, + tests: TSESLint.RunTests ): void { const { valid, invalid } = tests; @@ -34,7 +34,7 @@ class TestingLibraryRuleTester extends TSESLint.RuleTester { } export const createRuleTester = ( - parserOptions: Partial = {}, + parserOptions: Partial = {} ): TSESLint.RuleTester => { return new TestingLibraryRuleTester({ parser: resolve('./node_modules/@typescript-eslint/parser'), diff --git a/tools/generate-configs/index.ts b/tools/generate-configs/index.ts index 35205ba4..87c773c2 100644 --- a/tools/generate-configs/index.ts +++ b/tools/generate-configs/index.ts @@ -10,7 +10,7 @@ import { LinterConfig, writeConfig } from './utils'; const RULE_NAME_PREFIX = 'testing-library/'; const getRecommendedRulesForTestingFramework = ( - framework: SupportedTestingFramework, + framework: SupportedTestingFramework ): LinterConfigRules => Object.entries(rules) .filter( @@ -19,7 +19,7 @@ const getRecommendedRulesForTestingFramework = ( { meta: { docs }, }, - ]) => Boolean(docs.recommendedConfig[framework]), + ]) => Boolean(docs.recommendedConfig[framework]) ) .reduce((allRules, [ruleName, { meta }]) => { const name = `${RULE_NAME_PREFIX}${ruleName}`;