From ed9cad8de0f4e4266cc4e58db602d52819bf58c4 Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Fri, 27 Sep 2024 15:41:30 +1200 Subject: [PATCH 1/5] chore: upgrade to Prettier v3 --- package-lock.json | 94 ++++++++------------------------- package.json | 3 +- tools/generate-configs/index.ts | 21 +++++--- tools/generate-configs/utils.ts | 15 +++--- 4 files changed, 44 insertions(+), 89 deletions(-) diff --git a/package-lock.json b/package-lock.json index 594bf47d..4eecf6ad 100644 --- a/package-lock.json +++ b/package-lock.json @@ -32,7 +32,6 @@ "eslint-plugin-jest": "^27.2.1", "eslint-plugin-jest-formatting": "^3.1.0", "eslint-plugin-node": "^11.1.0", - "eslint-plugin-prettier": "^4.2.1", "eslint-plugin-promise": "^6.1.1", "eslint-remote-tester": "^3.0.0", "eslint-remote-tester-repositories": "^1.0.1", @@ -41,7 +40,7 @@ "jest": "^28.1.3", "lint-staged": "^13.2.1", "npm-run-all": "^4.1.5", - "prettier": "2.8.7", + "prettier": "^3.3.3", "semantic-release": "^19.0.5", "ts-node": "^10.9.1", "typescript": "^5.0.4" @@ -2937,11 +2936,6 @@ "dev": true, "license": "MIT" }, - "node_modules/@types/prettier": { - "version": "2.7.2", - "dev": true, - "license": "MIT" - }, "node_modules/@types/retry": { "version": "0.12.0", "dev": true, @@ -5323,26 +5317,6 @@ "node": ">=4" } }, - "node_modules/eslint-plugin-prettier": { - "version": "4.2.1", - "dev": true, - "license": "MIT", - "dependencies": { - "prettier-linter-helpers": "^1.0.0" - }, - "engines": { - "node": ">=12.0.0" - }, - "peerDependencies": { - "eslint": ">=7.28.0", - "prettier": ">=2.0.0" - }, - "peerDependenciesMeta": { - "eslint-config-prettier": { - "optional": true - } - } - }, "node_modules/eslint-plugin-promise": { "version": "6.1.1", "dev": true, @@ -5877,11 +5851,6 @@ "version": "3.1.3", "license": "MIT" }, - "node_modules/fast-diff": { - "version": "1.2.0", - "dev": true, - "license": "Apache-2.0" - }, "node_modules/fast-glob": { "version": "3.3.1", "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.1.tgz", @@ -8604,6 +8573,12 @@ "node": "^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0" } }, + "node_modules/jest-snapshot/node_modules/@types/prettier": { + "version": "2.7.3", + "resolved": "https://registry.npmjs.org/@types/prettier/-/prettier-2.7.3.tgz", + "integrity": "sha512-+68kP9yzs4LMp7VNh8gdzMSPZFL44MLGqiHWvttYJe+6qnuVr4Ek9wSBQoveqY/r+LwjCcU29kNVkidwim+kYA==", + "dev": true + }, "node_modules/jest-snapshot/node_modules/ansi-styles": { "version": "4.3.0", "dev": true, @@ -13353,31 +13328,20 @@ } }, "node_modules/prettier": { - "version": "2.8.7", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.7.tgz", - "integrity": "sha512-yPngTo3aXUUmyuTjeTUT75txrf+aMh9FiD7q9ZE/i6r0bPb22g4FsE6Y338PQX1bmfy08i9QQCB7/rcUAVntfw==", + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.3.3.tgz", + "integrity": "sha512-i2tDNA0O5IrMO757lfrdQZCc2jPNDVntV0m/+4whiDfWaTKfMNgR7Qz0NAeGz/nRqF4m5/6CLzbP4/liHt12Ew==", "dev": true, "bin": { - "prettier": "bin-prettier.js" + "prettier": "bin/prettier.cjs" }, "engines": { - "node": ">=10.13.0" + "node": ">=14" }, "funding": { "url": "https://github.com/prettier/prettier?sponsor=1" } }, - "node_modules/prettier-linter-helpers": { - "version": "1.0.0", - "dev": true, - "license": "MIT", - "dependencies": { - "fast-diff": "^1.1.2" - }, - "engines": { - "node": ">=6.0.0" - } - }, "node_modules/pretty-format": { "version": "27.5.1", "dev": true, @@ -17462,10 +17426,6 @@ "version": "4.0.0", "dev": true }, - "@types/prettier": { - "version": "2.7.2", - "dev": true - }, "@types/retry": { "version": "0.12.0", "dev": true @@ -19035,13 +18995,6 @@ } } }, - "eslint-plugin-prettier": { - "version": "4.2.1", - "dev": true, - "requires": { - "prettier-linter-helpers": "^1.0.0" - } - }, "eslint-plugin-promise": { "version": "6.1.1", "dev": true, @@ -19282,10 +19235,6 @@ "fast-deep-equal": { "version": "3.1.3" }, - "fast-diff": { - "version": "1.2.0", - "dev": true - }, "fast-glob": { "version": "3.3.1", "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.1.tgz", @@ -20986,6 +20935,12 @@ "semver": "^7.3.5" }, "dependencies": { + "@types/prettier": { + "version": "2.7.3", + "resolved": "https://registry.npmjs.org/@types/prettier/-/prettier-2.7.3.tgz", + "integrity": "sha512-+68kP9yzs4LMp7VNh8gdzMSPZFL44MLGqiHWvttYJe+6qnuVr4Ek9wSBQoveqY/r+LwjCcU29kNVkidwim+kYA==", + "dev": true + }, "ansi-styles": { "version": "4.3.0", "dev": true, @@ -24114,18 +24069,11 @@ "version": "1.2.1" }, "prettier": { - "version": "2.8.7", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.7.tgz", - "integrity": "sha512-yPngTo3aXUUmyuTjeTUT75txrf+aMh9FiD7q9ZE/i6r0bPb22g4FsE6Y338PQX1bmfy08i9QQCB7/rcUAVntfw==", + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.3.3.tgz", + "integrity": "sha512-i2tDNA0O5IrMO757lfrdQZCc2jPNDVntV0m/+4whiDfWaTKfMNgR7Qz0NAeGz/nRqF4m5/6CLzbP4/liHt12Ew==", "dev": true }, - "prettier-linter-helpers": { - "version": "1.0.0", - "dev": true, - "requires": { - "fast-diff": "^1.1.2" - } - }, "pretty-format": { "version": "27.5.1", "dev": true, diff --git a/package.json b/package.json index 1197df8b..370857ec 100644 --- a/package.json +++ b/package.json @@ -74,7 +74,6 @@ "eslint-plugin-jest": "^27.2.1", "eslint-plugin-jest-formatting": "^3.1.0", "eslint-plugin-node": "^11.1.0", - "eslint-plugin-prettier": "^4.2.1", "eslint-plugin-promise": "^6.1.1", "eslint-remote-tester": "^3.0.0", "eslint-remote-tester-repositories": "^1.0.1", @@ -83,7 +82,7 @@ "jest": "^28.1.3", "lint-staged": "^13.2.1", "npm-run-all": "^4.1.5", - "prettier": "2.8.7", + "prettier": "^3.3.3", "semantic-release": "^19.0.5", "ts-node": "^10.9.1", "typescript": "^5.0.4" diff --git a/tools/generate-configs/index.ts b/tools/generate-configs/index.ts index ef5f1abc..157226dc 100644 --- a/tools/generate-configs/index.ts +++ b/tools/generate-configs/index.ts @@ -11,7 +11,7 @@ import { LinterConfig, writeConfig } from './utils'; const RULE_NAME_PREFIX = 'testing-library/'; const getRecommendedRulesForTestingFramework = ( - framework: SupportedTestingFramework + framework: SupportedTestingFramework, ): Record => Object.entries(rules) .filter( @@ -20,7 +20,7 @@ const getRecommendedRulesForTestingFramework = ( { meta: { docs }, }, - ]) => Boolean(docs.recommendedConfig[framework]) + ]) => Boolean(docs.recommendedConfig[framework]), ) .reduce((allRules, [ruleName, { meta }]) => { const name = `${RULE_NAME_PREFIX}${ruleName}`; @@ -32,11 +32,16 @@ const getRecommendedRulesForTestingFramework = ( }; }, {}); -SUPPORTED_TESTING_FRAMEWORKS.forEach((framework) => { - const specificFrameworkConfig: LinterConfig = { - plugins: ['testing-library'], - rules: getRecommendedRulesForTestingFramework(framework), - }; +(async () => { + for (const framework of SUPPORTED_TESTING_FRAMEWORKS) { + const specificFrameworkConfig: LinterConfig = { + plugins: ['testing-library'], + rules: getRecommendedRulesForTestingFramework(framework), + }; - writeConfig(specificFrameworkConfig, framework); + await writeConfig(specificFrameworkConfig, framework); + } +})().catch((error) => { + console.error(error); + process.exitCode = 1; }); diff --git a/tools/generate-configs/utils.ts b/tools/generate-configs/utils.ts index b58c0cf8..c0ba493e 100644 --- a/tools/generate-configs/utils.ts +++ b/tools/generate-configs/utils.ts @@ -1,10 +1,10 @@ -import { writeFileSync } from 'fs'; +import { writeFile } from 'fs/promises'; import { resolve } from 'path'; import { type TSESLint } from '@typescript-eslint/utils'; import { format, resolveConfig } from 'prettier'; -const prettierConfig = resolveConfig.sync(__dirname); +const prettierConfig = resolveConfig(__dirname); export type LinterConfig = TSESLint.Linter.Config; @@ -20,14 +20,17 @@ const addAutoGeneratedComment = (code: string) => /** * Helper function writes configuration. */ -export const writeConfig = (config: LinterConfig, configName: string): void => { +export const writeConfig = async ( + config: LinterConfig, + configName: string, +): Promise => { // note: we use `export =` because ESLint will import these configs via a commonjs import const code = `export = ${JSON.stringify(config)};`; - const configStr = format(addAutoGeneratedComment(code), { + const configStr = await format(addAutoGeneratedComment(code), { parser: 'typescript', - ...prettierConfig, + ...(await prettierConfig), }); const filePath = resolve(__dirname, `../../lib/configs/${configName}.ts`); - writeFileSync(filePath, configStr); + await writeFile(filePath, configStr); }; From 2f65958f022267a3cd46356ebe6a8e3d85c97369 Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Fri, 27 Sep 2024 15:47:59 +1200 Subject: [PATCH 2/5] chore: revert new prettier defaults for now --- .prettierrc.js | 1 + 1 file changed, 1 insertion(+) diff --git a/.prettierrc.js b/.prettierrc.js index 4e57e1cf..d82995ee 100644 --- a/.prettierrc.js +++ b/.prettierrc.js @@ -1,4 +1,5 @@ module.exports = { + trailingComma: 'es5', singleQuote: true, useTabs: true, }; From 38b4ac8b637790600766a151311b9271af6a852f Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Fri, 27 Sep 2024 15:49:43 +1200 Subject: [PATCH 3/5] refactor: reformat everything with prettier --- .../detect-testing-library-utils.ts | 6 +- lib/create-testing-library-rule/index.ts | 2 +- lib/rules/await-async-events.ts | 2 +- lib/rules/consistent-data-testid.ts | 2 +- lib/rules/no-render-in-lifecycle.ts | 2 +- lib/rules/prefer-explicit-assert.ts | 2 +- lib/rules/prefer-presence-queries.ts | 2 +- lib/rules/prefer-query-matchers.ts | 2 +- lib/utils/types.ts | 2 +- tests/create-testing-library-rule.test.ts | 2 +- tests/lib/rules/await-async-events.test.ts | 44 +++++++------- tests/lib/rules/await-async-queries.test.ts | 20 +++---- tests/lib/rules/await-async-utils.test.ts | 32 +++++----- tests/lib/rules/no-await-sync-events.test.ts | 4 +- 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 | 2 +- tests/lib/rules/no-manual-cleanup.test.ts | 24 ++++---- .../lib/rules/no-render-in-lifecycle.test.ts | 14 ++--- tests/lib/rules/no-unnecessary-act.test.ts | 2 +- .../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 | 2 +- .../lib/rules/prefer-implicit-assert.test.ts | 60 +++++++++---------- tests/lib/rules/prefer-screen-queries.test.ts | 24 ++++---- tests/lib/rules/prefer-user-event.test.ts | 10 ++-- tools/generate-configs/index.ts | 4 +- tools/generate-configs/utils.ts | 2 +- 31 files changed, 168 insertions(+), 168 deletions(-) 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 9393a88b..af263a9d 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,7 +45,7 @@ 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, @@ -156,7 +156,7 @@ 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 = {} diff --git a/lib/create-testing-library-rule/index.ts b/lib/create-testing-library-rule/index.ts index 7a919447..c87f6415 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 = {}, diff --git a/lib/rules/await-async-events.ts b/lib/rules/await-async-events.ts index 06a80d78..219c45bf 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({ diff --git a/lib/rules/consistent-data-testid.ts b/lib/rules/consistent-data-testid.ts index 7760776c..2536706e 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/no-render-in-lifecycle.ts b/lib/rules/no-render-in-lifecycle.ts index 4496522c..2e5e52c1 100644 --- a/lib/rules/no-render-in-lifecycle.ts +++ b/lib/rules/no-render-in-lifecycle.ts @@ -14,7 +14,7 @@ export type MessageIds = 'noRenderInSetup'; type Options = [ { allowTestingFrameworkSetupHook?: string; - } + }, ]; export function findClosestBeforeHook( diff --git a/lib/rules/prefer-explicit-assert.ts b/lib/rules/prefer-explicit-assert.ts index 7a80e059..4b0d57ea 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-presence-queries.ts b/lib/rules/prefer-presence-queries.ts index dd816408..b654dd6a 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-matchers.ts b/lib/rules/prefer-query-matchers.ts index 3f94a8e9..80e819e9 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({ diff --git a/lib/utils/types.ts b/lib/utils/types.ts index 4a5a7283..1dd6d9d3 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/tests/create-testing-library-rule.test.ts b/tests/create-testing-library-rule.test.ts index 55a9f22c..c6e72252 100644 --- a/tests/create-testing-library-rule.test.ts +++ b/tests/create-testing-library-rule.test.ts @@ -459,7 +459,7 @@ ruleTester.run(RULE_NAME, rule, { messageId: 'renderError', }, ], - } as const) + }) as const ), { code: ` diff --git a/tests/lib/rules/await-async-events.test.ts b/tests/lib/rules/await-async-events.test.ts index 505e1972..82a9c347 100644 --- a/tests/lib/rules/await-async-events.test.ts +++ b/tests/lib/rules/await-async-events.test.ts @@ -427,7 +427,7 @@ ruleTester.run(RULE_NAME, rule, { await fireEvent.${eventMethod}(getByLabelText('username')) }) `, - } as const) + }) as const ), ...FIRE_EVENT_ASYNC_FUNCTIONS.map( (eventMethod) => @@ -452,7 +452,7 @@ ruleTester.run(RULE_NAME, rule, { fireEvent.${eventMethod}(getByLabelText('username')) `, - } as const) + }) as const ), ...FIRE_EVENT_ASYNC_FUNCTIONS.map( (eventMethod) => @@ -485,7 +485,7 @@ ruleTester.run(RULE_NAME, rule, { test('should handle external function', run) `, - } as const) + }) as const ), ...FIRE_EVENT_ASYNC_FUNCTIONS.map( (eventMethod) => @@ -512,7 +512,7 @@ ruleTester.run(RULE_NAME, rule, { await testingLibraryFireEvent.${eventMethod}(getByLabelText('username')) }) `, - } as const) + }) as const ), ...FIRE_EVENT_ASYNC_FUNCTIONS.map( (eventMethod) => @@ -539,7 +539,7 @@ ruleTester.run(RULE_NAME, rule, { await testingLibrary.fireEvent.${eventMethod}(getByLabelText('username')) }) `, - } as const) + }) as const ), ...FIRE_EVENT_ASYNC_FUNCTIONS.map( (eventMethod) => @@ -573,7 +573,7 @@ ruleTester.run(RULE_NAME, rule, { await fireEvent.${eventMethod}(getByLabelText('username')) }) `, - } as const) + }) as const ), ...FIRE_EVENT_ASYNC_FUNCTIONS.map( (eventMethod) => @@ -602,7 +602,7 @@ ruleTester.run(RULE_NAME, rule, { await fireEvent.${eventMethod}(getByLabelText('username')) }) `, - } as const) + }) as const ), ...FIRE_EVENT_ASYNC_FUNCTIONS.map( (eventMethod) => @@ -635,7 +635,7 @@ ruleTester.run(RULE_NAME, rule, { await fireEvent.${eventMethod}(getByLabelText('username')) }) `, - } as const) + }) as const ), ...FIRE_EVENT_ASYNC_FUNCTIONS.map( (eventMethod) => @@ -668,7 +668,7 @@ ruleTester.run(RULE_NAME, rule, { await fireEvent.${eventMethod}(getByLabelText('username')) }) `, - } as const) + }) as const ), ...FIRE_EVENT_ASYNC_FUNCTIONS.map( @@ -699,7 +699,7 @@ ruleTester.run(RULE_NAME, rule, { const promise = await fireEvent.${eventMethod}(getByLabelText('username')) }) `, - } as const) + }) as const ), ...FIRE_EVENT_ASYNC_FUNCTIONS.map( (eventMethod) => @@ -735,7 +735,7 @@ ruleTester.run(RULE_NAME, rule, { await triggerEvent() }) `, - } as const) + }) as const ), ...FIRE_EVENT_ASYNC_FUNCTIONS.map( (eventMethod) => @@ -769,7 +769,7 @@ ruleTester.run(RULE_NAME, rule, { triggerEvent() `, - } as const) + }) as const ), ]), ...USER_EVENT_ASYNC_FRAMEWORKS.flatMap((testingFramework) => [ @@ -798,7 +798,7 @@ ruleTester.run(RULE_NAME, rule, { await userEvent.${eventMethod}(getByLabelText('username')) }) `, - } as const) + }) as const ), ...USER_EVENT_ASYNC_FUNCTIONS.map( (eventMethod) => @@ -823,7 +823,7 @@ ruleTester.run(RULE_NAME, rule, { userEvent.${eventMethod}(getByLabelText('username')) `, - } as const) + }) as const ), ...USER_EVENT_ASYNC_FUNCTIONS.map( (eventMethod) => @@ -850,7 +850,7 @@ ruleTester.run(RULE_NAME, rule, { await testingLibraryUserEvent.${eventMethod}(getByLabelText('username')) }) `, - } as const) + }) as const ), ...USER_EVENT_ASYNC_FUNCTIONS.map( (eventMethod) => @@ -884,7 +884,7 @@ ruleTester.run(RULE_NAME, rule, { await userEvent.${eventMethod}(getByLabelText('username')) }) `, - } as const) + }) as const ), ...USER_EVENT_ASYNC_FUNCTIONS.map( (eventMethod) => @@ -914,7 +914,7 @@ ruleTester.run(RULE_NAME, rule, { const promise = await userEvent.${eventMethod}(getByLabelText('username')) }) `, - } as const) + }) as const ), ...USER_EVENT_ASYNC_FUNCTIONS.map( (eventMethod) => @@ -950,7 +950,7 @@ ruleTester.run(RULE_NAME, rule, { await triggerEvent() }) `, - } as const) + }) as const ), ...USER_EVENT_ASYNC_FUNCTIONS.map( (eventMethod) => @@ -984,7 +984,7 @@ ruleTester.run(RULE_NAME, rule, { triggerEvent() `, - } as const) + }) as const ), ...USER_EVENT_ASYNC_FUNCTIONS.map( (eventMethod) => @@ -1010,7 +1010,7 @@ ruleTester.run(RULE_NAME, rule, { condition ? null : (null, true && await userEvent.${eventMethod}(getByLabelText('username'))); }); `, - } as const) + }) as const ), ...USER_EVENT_ASYNC_FUNCTIONS.map( (eventMethod) => @@ -1036,7 +1036,7 @@ ruleTester.run(RULE_NAME, rule, { await (await userEvent.${eventMethod}(getByLabelText('username')) && userEvent.${eventMethod}(getByLabelText('username'))); }); `, - } as const) + }) as const ), ...USER_EVENT_ASYNC_FUNCTIONS.map( (eventMethod) => @@ -1070,7 +1070,7 @@ ruleTester.run(RULE_NAME, rule, { await (await userEvent.${eventMethod}(getByLabelText('username')), null); }); `, - } 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 799e5e70..efab2cbd 100644 --- a/tests/lib/rules/await-async-queries.test.ts +++ b/tests/lib/rules/await-async-queries.test.ts @@ -64,11 +64,11 @@ function createTestCase( ? { code: createTestCode({ code: test, isAsync, testingFramework }), errors: [], - } + } : { code: createTestCode({ code: test.code, isAsync, testingFramework }), errors: test.errors, - }; + }; }); } @@ -361,7 +361,7 @@ ruleTester.run(RULE_NAME, rule, { }); `, errors: [{ messageId: 'awaitAsyncQuery', line: 6, column: 21 }], - } as const) + }) as const ) ), ...ALL_ASYNC_COMBINATIONS_TO_TEST.map( @@ -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 e91517b3..1a5490c9 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) => @@ -460,7 +460,7 @@ ruleTester.run(RULE_NAME, rule, { data: { name: asyncUtil }, }, ], - } as const) + }) as const ), ...ASYNC_UTILS.map( (asyncUtil) => @@ -485,7 +485,7 @@ ruleTester.run(RULE_NAME, rule, { data: { name: 'waitForSomethingAsync' }, }, ], - } as const) + }) as const ), ...ASYNC_UTILS.map( (asyncUtil) => @@ -507,7 +507,7 @@ ruleTester.run(RULE_NAME, rule, { data: { name: asyncUtil }, }, ], - } as const) + }) as const ), ...ASYNC_UTILS.map( (asyncUtil) => @@ -532,7 +532,7 @@ ruleTester.run(RULE_NAME, rule, { data: { name: 'waitForSomethingAsync' }, }, ], - } as const) + }) as const ), ...ASYNC_UTILS.map( @@ -555,7 +555,7 @@ ruleTester.run(RULE_NAME, rule, { data: { name: asyncUtil }, }, ], - } as const) + }) as const ), ...ASYNC_UTILS.map( (asyncUtil) => @@ -584,7 +584,7 @@ ruleTester.run(RULE_NAME, rule, { data: { name: 'waitForAsyncUtil' }, }, ], - } as const) + }) as const ), ...ASYNC_UTILS.map( (asyncUtil) => @@ -614,7 +614,7 @@ ruleTester.run(RULE_NAME, rule, { data: { name: 'myAlias' }, }, ], - } as const) + }) as const ), ...ASYNC_UTILS.map( (asyncUtil) => @@ -643,7 +643,7 @@ ruleTester.run(RULE_NAME, rule, { data: { name: 'waitForAsyncUtil' }, }, ], - } as const) + }) as const ), ...ASYNC_UTILS.map( (asyncUtil) => @@ -672,7 +672,7 @@ ruleTester.run(RULE_NAME, rule, { data: { name: 'myAlias' }, }, ], - } as const) + }) as const ), ...ASYNC_UTILS.map( (asyncUtil) => @@ -700,7 +700,7 @@ ruleTester.run(RULE_NAME, rule, { data: { name: 'waitForAsyncUtil' }, }, ], - } as const) + }) as const ), ...ASYNC_UTILS.map( (asyncUtil) => @@ -729,7 +729,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 5116080e..da871acc 100644 --- a/tests/lib/rules/no-await-sync-events.test.ts +++ b/tests/lib/rules/no-await-sync-events.test.ts @@ -264,7 +264,7 @@ ruleTester.run(RULE_NAME, rule, { data: { name: `fireEvent.${func}` }, }, ], - } as const) + }) as const ) ), // sync userEvent sync methods with await operator are not valid @@ -286,7 +286,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 3b088ad0..0896f817 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 6967de9e..5f3596a6 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 c41c6423..7d6f1045 100644 --- a/tests/lib/rules/no-debugging-utils.test.ts +++ b/tests/lib/rules/no-debugging-utils.test.ts @@ -563,7 +563,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' }, @@ -590,7 +590,7 @@ ruleTester.run(RULE_NAME, rule, { utils.debug() `, errors: [{ line: 7, column: 13, messageId: 'noDebug' }], - } as const) + }) as const ), { settings: { @@ -626,7 +626,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 fd493ad6..e515eb5c 100644 --- a/tests/lib/rules/no-dom-import.test.ts +++ b/tests/lib/rules/no-dom-import.test.ts @@ -192,7 +192,7 @@ ruleTester.run(RULE_NAME, rule, { isOldImport ? oldName : newName }") `, - } as const) + }) as const ) ), { diff --git a/tests/lib/rules/no-manual-cleanup.test.ts b/tests/lib/rules/no-manual-cleanup.test.ts index 1f14312d..88fc87f6 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) => @@ -83,7 +83,7 @@ ruleTester.run(RULE_NAME, rule, { messageId: 'noManualCleanup', }, ], - } as const) + }) as const ), ...ALL_TESTING_LIBRARIES_WITH_CLEANUP.map( (lib) => @@ -99,7 +99,7 @@ ruleTester.run(RULE_NAME, rule, { messageId: 'noManualCleanup', }, ], - } as const) + }) as const ), ...ALL_TESTING_LIBRARIES_WITH_CLEANUP.map( (lib) => @@ -116,7 +116,7 @@ ruleTester.run(RULE_NAME, rule, { messageId: 'noManualCleanup', }, ], - } as const) + }) as const ), { settings: { @@ -138,7 +138,7 @@ ruleTester.run(RULE_NAME, rule, { messageId: 'noManualCleanup', }, ], - } as const) + }) as const ), { settings: { @@ -160,7 +160,7 @@ ruleTester.run(RULE_NAME, rule, { messageId: 'noManualCleanup', }, ], - } as const) + }) as const ), { settings: { @@ -185,7 +185,7 @@ ruleTester.run(RULE_NAME, rule, { messageId: 'noManualCleanup', }, ], - } as const) + }) as const ), { settings: { @@ -211,7 +211,7 @@ ruleTester.run(RULE_NAME, rule, { messageId: 'noManualCleanup', }, ], - } as const) + }) as const ), ...ALL_TESTING_LIBRARIES_WITH_CLEANUP.map( (lib) => @@ -224,7 +224,7 @@ ruleTester.run(RULE_NAME, rule, { messageId: 'noManualCleanup', }, ], - } as const) + }) as const ), { settings: { @@ -249,7 +249,7 @@ ruleTester.run(RULE_NAME, rule, { messageId: 'noManualCleanup', }, ], - } as const) + }) as const ), ...ALL_TESTING_LIBRARIES_WITH_CLEANUP.map( (lib) => @@ -265,7 +265,7 @@ ruleTester.run(RULE_NAME, rule, { messageId: 'noManualCleanup', }, ], - } as const) + }) as const ), ...ALL_TESTING_LIBRARIES_WITH_CLEANUP.map( (lib) => @@ -282,7 +282,7 @@ ruleTester.run(RULE_NAME, rule, { messageId: 'noManualCleanup', }, ], - } as const) + }) as const ), { code: ` diff --git a/tests/lib/rules/no-render-in-lifecycle.test.ts b/tests/lib/rules/no-render-in-lifecycle.test.ts index 9665afcc..1561b394 100644 --- a/tests/lib/rules/no-render-in-lifecycle.test.ts +++ b/tests/lib/rules/no-render-in-lifecycle.test.ts @@ -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,7 +186,7 @@ ruleTester.run(RULE_NAME, rule, { messageId: 'noRenderInSetup', }, ], - } as const) + }) as const ), ...TESTING_FRAMEWORK_SETUP_HOOKS.map((allowedSetupHook) => { const [disallowedHook] = TESTING_FRAMEWORK_SETUP_HOOKS.filter( @@ -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,7 +273,7 @@ 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 2f1bce65..3dcac3d8 100644 --- a/tests/lib/rules/no-unnecessary-act.test.ts +++ b/tests/lib/rules/no-unnecessary-act.test.ts @@ -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 8c3a3fec..46f30b7e 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 37f9a0ac..45475961 100644 --- a/tests/lib/rules/no-wait-for-side-effects.test.ts +++ b/tests/lib/rules/no-wait-for-side-effects.test.ts @@ -536,7 +536,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 02eefece..03eff8f4 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 0b65a72f..8cc09614 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 ), ...COMBINED_QUERIES_METHODS.map( (queryMethod) => @@ -345,7 +345,7 @@ ruleTester.run(RULE_NAME, rule, { data: { assertion: 'toBeInTheDocument' }, }, ], - } as const) + }) as const ), ...COMBINED_QUERIES_METHODS.map( (queryMethod) => @@ -362,7 +362,7 @@ ruleTester.run(RULE_NAME, rule, { data: { assertion: 'toBeInTheDocument' }, }, ], - } as const) + }) as const ), ...COMBINED_QUERIES_METHODS.map( (queryMethod) => @@ -379,7 +379,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 22a2eb4e..3bf6bed7 100644 --- a/tests/lib/rules/prefer-find-by.test.ts +++ b/tests/lib/rules/prefer-find-by.test.ts @@ -28,7 +28,7 @@ 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) diff --git a/tests/lib/rules/prefer-implicit-assert.test.ts b/tests/lib/rules/prefer-implicit-assert.test.ts index 973c45be..c73ac0c7 100644 --- a/tests/lib/rules/prefer-implicit-assert.test.ts +++ b/tests/lib/rules/prefer-implicit-assert.test.ts @@ -62,7 +62,7 @@ ruleTester.run(RULE_NAME, rule, { }, }, ], - } as const) + }) as const ), ...COMBINED_QUERIES_METHODS.map( (queryMethod) => @@ -78,7 +78,7 @@ ruleTester.run(RULE_NAME, rule, { }, }, ], - } as const) + }) as const ), ...COMBINED_QUERIES_METHODS.map( (queryMethod) => @@ -94,7 +94,7 @@ ruleTester.run(RULE_NAME, rule, { }, }, ], - } as const) + }) as const ), ...COMBINED_QUERIES_METHODS.map( (queryMethod) => @@ -110,7 +110,7 @@ ruleTester.run(RULE_NAME, rule, { }, }, ], - } as const) + }) as const ), ...COMBINED_QUERIES_METHODS.map( (queryMethod) => @@ -126,7 +126,7 @@ ruleTester.run(RULE_NAME, rule, { }, }, ], - } as const) + }) as const ), ...COMBINED_QUERIES_METHODS.map( (queryMethod) => @@ -142,7 +142,7 @@ ruleTester.run(RULE_NAME, rule, { }, }, ], - } as const) + }) as const ), ...COMBINED_QUERIES_METHODS.map( (queryMethod) => @@ -158,7 +158,7 @@ ruleTester.run(RULE_NAME, rule, { }, }, ], - } as const) + }) as const ), ...COMBINED_QUERIES_METHODS.map( (queryMethod) => @@ -174,7 +174,7 @@ ruleTester.run(RULE_NAME, rule, { }, }, ], - } as const) + }) as const ), ...COMBINED_QUERIES_METHODS.map( (queryMethod) => @@ -190,7 +190,7 @@ ruleTester.run(RULE_NAME, rule, { }, }, ], - } as const) + }) as const ), ...COMBINED_QUERIES_METHODS.map( (queryMethod) => @@ -206,7 +206,7 @@ ruleTester.run(RULE_NAME, rule, { }, }, ], - } as const) + }) as const ), ...COMBINED_QUERIES_METHODS.map( (queryMethod) => @@ -224,7 +224,7 @@ ruleTester.run(RULE_NAME, rule, { }, }, ], - } as const) + }) as const ), ...COMBINED_QUERIES_METHODS.map( (queryMethod) => @@ -242,7 +242,7 @@ ruleTester.run(RULE_NAME, rule, { }, }, ], - } as const) + }) as const ), ...COMBINED_QUERIES_METHODS.map( (queryMethod) => @@ -260,7 +260,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) => @@ -296,7 +296,7 @@ ruleTester.run(RULE_NAME, rule, { }, }, ], - } as const) + }) as const ), ...COMBINED_QUERIES_METHODS.map( (queryMethod) => @@ -312,7 +312,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 ), ...COMBINED_QUERIES_METHODS.map( (queryMethod) => @@ -344,7 +344,7 @@ ruleTester.run(RULE_NAME, rule, { }, }, ], - } as const) + }) as const ), ...COMBINED_QUERIES_METHODS.map( (queryMethod) => @@ -360,7 +360,7 @@ ruleTester.run(RULE_NAME, rule, { }, }, ], - } as const) + }) as const ), ...COMBINED_QUERIES_METHODS.map( (queryMethod) => @@ -376,7 +376,7 @@ ruleTester.run(RULE_NAME, rule, { }, }, ], - } as const) + }) as const ), ...COMBINED_QUERIES_METHODS.map( (queryMethod) => @@ -392,7 +392,7 @@ ruleTester.run(RULE_NAME, rule, { }, }, ], - } as const) + }) as const ), ...COMBINED_QUERIES_METHODS.map( (queryMethod) => @@ -408,7 +408,7 @@ ruleTester.run(RULE_NAME, rule, { }, }, ], - } as const) + }) as const ), ...COMBINED_QUERIES_METHODS.map( (queryMethod) => @@ -424,7 +424,7 @@ ruleTester.run(RULE_NAME, rule, { }, }, ], - } as const) + }) as const ), ...COMBINED_QUERIES_METHODS.map( (queryMethod) => @@ -440,7 +440,7 @@ ruleTester.run(RULE_NAME, rule, { }, }, ], - } as const) + }) as const ), ...COMBINED_QUERIES_METHODS.map( (queryMethod) => @@ -456,7 +456,7 @@ ruleTester.run(RULE_NAME, rule, { }, }, ], - } as const) + }) as const ), ...COMBINED_QUERIES_METHODS.map( (queryMethod) => @@ -474,7 +474,7 @@ ruleTester.run(RULE_NAME, rule, { }, }, ], - } as const) + }) as const ), ...COMBINED_QUERIES_METHODS.map( (queryMethod) => @@ -492,7 +492,7 @@ ruleTester.run(RULE_NAME, rule, { }, }, ], - } as const) + }) as const ), ...COMBINED_QUERIES_METHODS.map( (queryMethod) => @@ -510,7 +510,7 @@ ruleTester.run(RULE_NAME, rule, { }, }, ], - } as const) + }) as const ), ...COMBINED_QUERIES_METHODS.map( (queryMethod) => @@ -528,7 +528,7 @@ ruleTester.run(RULE_NAME, rule, { }, }, ], - } as const) + }) as const ), ...COMBINED_QUERIES_METHODS.map( (queryMethod) => @@ -546,7 +546,7 @@ ruleTester.run(RULE_NAME, rule, { }, }, ], - } as const) + }) as const ), ], }); diff --git a/tests/lib/rules/prefer-screen-queries.test.ts b/tests/lib/rules/prefer-screen-queries.test.ts index 4951233b..b49ae2ad 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,7 +275,7 @@ ruleTester.run(RULE_NAME, rule, { }, }, ], - } as const) + }) as const ) ), ...ALL_QUERIES_COMBINATIONS.map( @@ -290,7 +290,7 @@ ruleTester.run(RULE_NAME, rule, { }, }, ], - } as const) + }) as const ), ...ALL_QUERIES_COMBINATIONS.map( (queryMethod) => @@ -304,7 +304,7 @@ ruleTester.run(RULE_NAME, rule, { }, }, ], - } as const) + }) as const ), ...ALL_QUERIES_COMBINATIONS.map( (queryMethod) => @@ -318,7 +318,7 @@ ruleTester.run(RULE_NAME, rule, { }, }, ], - } as const) + }) as const ), ...ALL_QUERIES_COMBINATIONS.map( (queryMethod) => @@ -335,7 +335,7 @@ ruleTester.run(RULE_NAME, rule, { }, }, ], - } as const) + }) as const ), ...ALL_QUERIES_COMBINATIONS.map( (queryMethod) => @@ -352,7 +352,7 @@ ruleTester.run(RULE_NAME, rule, { }, }, ], - } as const) + }) as const ), ...ALL_QUERIES_COMBINATIONS.map( (queryMethod) => @@ -369,7 +369,7 @@ ruleTester.run(RULE_NAME, rule, { }, }, ], - } as const) + }) as const ), ...ALL_QUERIES_COMBINATIONS.map( (queryMethod) => @@ -386,7 +386,7 @@ ruleTester.run(RULE_NAME, rule, { }, }, ], - } as const) + }) as const ), ...ALL_QUERIES_COMBINATIONS.map( (queryMethod) => @@ -403,7 +403,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 61892761..aae52d9b 100644 --- a/tests/lib/rules/prefer-user-event.test.ts +++ b/tests/lib/rules/prefer-user-event.test.ts @@ -13,7 +13,7 @@ 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) => @@ -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/tools/generate-configs/index.ts b/tools/generate-configs/index.ts index 157226dc..ac439674 100644 --- a/tools/generate-configs/index.ts +++ b/tools/generate-configs/index.ts @@ -11,7 +11,7 @@ import { LinterConfig, writeConfig } from './utils'; const RULE_NAME_PREFIX = 'testing-library/'; const getRecommendedRulesForTestingFramework = ( - framework: SupportedTestingFramework, + framework: SupportedTestingFramework ): Record => Object.entries(rules) .filter( @@ -20,7 +20,7 @@ const getRecommendedRulesForTestingFramework = ( { meta: { docs }, }, - ]) => Boolean(docs.recommendedConfig[framework]), + ]) => Boolean(docs.recommendedConfig[framework]) ) .reduce((allRules, [ruleName, { meta }]) => { const name = `${RULE_NAME_PREFIX}${ruleName}`; diff --git a/tools/generate-configs/utils.ts b/tools/generate-configs/utils.ts index c0ba493e..9e979151 100644 --- a/tools/generate-configs/utils.ts +++ b/tools/generate-configs/utils.ts @@ -22,7 +22,7 @@ const addAutoGeneratedComment = (code: string) => */ export const writeConfig = async ( config: LinterConfig, - configName: string, + configName: string ): Promise => { // note: we use `export =` because ESLint will import these configs via a commonjs import const code = `export = ${JSON.stringify(config)};`; From 22e0bb892cbe86f59452d2777d1ce0ae9ba4eebd Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Fri, 27 Sep 2024 15:56:33 +1200 Subject: [PATCH 4/5] chore: update `eslint-config-prettier` --- package-lock.json | 14 +++++++------- package.json | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4eecf6ad..9470da49 100644 --- a/package-lock.json +++ b/package-lock.json @@ -25,7 +25,7 @@ "@typescript-eslint/parser": "^5.58.0", "del-cli": "^5.0.0", "eslint": "^8.38.0", - "eslint-config-prettier": "^8.8.0", + "eslint-config-prettier": "^9.1.0", "eslint-doc-generator": "^1.4.3", "eslint-import-resolver-typescript": "^3.6.1", "eslint-plugin-import": "^2.29.0", @@ -5014,9 +5014,9 @@ } }, "node_modules/eslint-config-prettier": { - "version": "8.8.0", - "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-8.8.0.tgz", - "integrity": "sha512-wLbQiFre3tdGgpDv67NQKnJuTlcUVYHas3k+DZCc2U2BadthoEY4B7hLPvAxaqdyOGCzuLfii2fqGph10va7oA==", + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-9.1.0.tgz", + "integrity": "sha512-NSWl5BFQWEPi1j4TjVNItzYV7dZXZ+wP6I6ZhrBGpChQhZRUaElihE9uRRkcbRnNb76UMKDF3r+WTmNcGPKsqw==", "dev": true, "bin": { "eslint-config-prettier": "bin/cli.js" @@ -18796,9 +18796,9 @@ } }, "eslint-config-prettier": { - "version": "8.8.0", - "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-8.8.0.tgz", - "integrity": "sha512-wLbQiFre3tdGgpDv67NQKnJuTlcUVYHas3k+DZCc2U2BadthoEY4B7hLPvAxaqdyOGCzuLfii2fqGph10va7oA==", + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-9.1.0.tgz", + "integrity": "sha512-NSWl5BFQWEPi1j4TjVNItzYV7dZXZ+wP6I6ZhrBGpChQhZRUaElihE9uRRkcbRnNb76UMKDF3r+WTmNcGPKsqw==", "dev": true, "requires": {} }, diff --git a/package.json b/package.json index 370857ec..80ce3c32 100644 --- a/package.json +++ b/package.json @@ -67,7 +67,7 @@ "@typescript-eslint/parser": "^5.58.0", "del-cli": "^5.0.0", "eslint": "^8.38.0", - "eslint-config-prettier": "^8.8.0", + "eslint-config-prettier": "^9.1.0", "eslint-doc-generator": "^1.4.3", "eslint-import-resolver-typescript": "^3.6.1", "eslint-plugin-import": "^2.29.0", From e6cc9dd5128716720b749b134a074b5292d54ee4 Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Fri, 18 Oct 2024 07:21:36 +1300 Subject: [PATCH 5/5] chore: ignore generated files --- .prettierignore | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .prettierignore diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 00000000..b9af36db --- /dev/null +++ b/.prettierignore @@ -0,0 +1,4 @@ +dist +node_modules +coverage +.all-contributorsrc