From 88c43bbc1a4404d806eb17a229a90f3b578e17ee Mon Sep 17 00:00:00 2001 From: Steven Lambert <2433219+straker@users.noreply.github.com> Date: Tue, 4 Jun 2024 07:55:14 -0600 Subject: [PATCH 1/2] chore: fix eslint errors and warnings --- eslint.config.js | 15 ++++++++++++--- packages/playwright/src/AxePartialRunner.ts | 1 - packages/puppeteer/src/axePartialRunner.ts | 1 - packages/puppeteer/test/load-page.spec.ts | 3 ++- packages/react/test/index.ts | 1 - packages/webdriverio/test/axe-webdriverio.spec.ts | 2 -- packages/webdriverjs/src/axe-injector.ts | 1 - 7 files changed, 14 insertions(+), 10 deletions(-) diff --git a/eslint.config.js b/eslint.config.js index 634d2c8b..59f59c4d 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -33,7 +33,8 @@ module.exports = [ '@typescript-eslint/ban-types': 'off', '@typescript-eslint/no-unused-vars': 'error', '@typescript-eslint/no-explicit-any': 'error', - '@typescript-eslint/no-non-null-assertion': 'error' + '@typescript-eslint/no-non-null-assertion': 'error', + '@typescript-eslint/no-require-imports': 'off' } }, { @@ -54,11 +55,19 @@ module.exports = [ } }, { - files: ['**/*.test.ts', '**/*.test.tsx', '**/*.spec.ts', '**/*.spec.tsx'], + files: [ + '**/*.test.ts', + '**/*.test.tsx', + '**/*.spec.ts', + '**/*.spec.tsx', + '**/test/**', + '**/tests/**' + ], rules: { '@typescript-eslint/no-empty-function': 'off', '@typescript-eslint/no-explicit-any': 'off', - '@typescript-eslint/no-non-null-assertion': 'off' + '@typescript-eslint/no-non-null-assertion': 'off', + '@typescript-eslint/no-unused-expressions': 'off' } }, { diff --git a/packages/playwright/src/AxePartialRunner.ts b/packages/playwright/src/AxePartialRunner.ts index 4b241caf..d7da41b2 100644 --- a/packages/playwright/src/AxePartialRunner.ts +++ b/packages/playwright/src/AxePartialRunner.ts @@ -47,5 +47,4 @@ export default class AxePartialRunner { // See: https://stackoverflow.com/questions/40920179/should-i-refrain-from-handling-promise-rejection-asynchronously export const caught = ((f: () => void) => { return (p: Promise): Promise => (p.catch(f), p); - /* eslint-disable @typescript-eslint/no-empty-function */ })(() => {}); diff --git a/packages/puppeteer/src/axePartialRunner.ts b/packages/puppeteer/src/axePartialRunner.ts index 4d31de58..7cd03f44 100644 --- a/packages/puppeteer/src/axePartialRunner.ts +++ b/packages/puppeteer/src/axePartialRunner.ts @@ -48,5 +48,4 @@ export class AxePartialRunner { // See: https://stackoverflow.com/questions/40920179/should-i-refrain-from-handling-promise-rejection-asynchronously export const caught = ((f: () => void) => { return (p: Promise): Promise => (p.catch(f), p); - /* eslint-disable @typescript-eslint/no-empty-function */ })(() => {}); diff --git a/packages/puppeteer/test/load-page.spec.ts b/packages/puppeteer/test/load-page.spec.ts index af376710..2c686e53 100644 --- a/packages/puppeteer/test/load-page.spec.ts +++ b/packages/puppeteer/test/load-page.spec.ts @@ -32,7 +32,8 @@ describe('loadPage', function () { it('handles creating a page for you', async function () { const url = fixtureFileURL('index.html'); - const results = await (await loadPage(browser, url)).analyze(); + const page = await loadPage(browser, url); + const results = await page.analyze(); expect(results).to.exist; }); diff --git a/packages/react/test/index.ts b/packages/react/test/index.ts index 931e79db..29bf3b5d 100644 --- a/packages/react/test/index.ts +++ b/packages/react/test/index.ts @@ -10,7 +10,6 @@ reactAxe(React, ReactDOM, 1000, { checks: [ { id: 'my-check', - // eslint-disable-next-line @typescript-eslint/explicit-function-return-type, @typescript-eslint/no-empty-function evaluate() {} } ], diff --git a/packages/webdriverio/test/axe-webdriverio.spec.ts b/packages/webdriverio/test/axe-webdriverio.spec.ts index 29236f33..42ed9b6f 100644 --- a/packages/webdriverio/test/axe-webdriverio.spec.ts +++ b/packages/webdriverio/test/axe-webdriverio.spec.ts @@ -18,8 +18,6 @@ import { fixturesPath } from 'axe-test-fixtures'; const connectToChromeDriver = (port: number): Promise => { let socket: net.Socket; return new Promise((resolve, reject) => { - // eslint-disable-next-line prefer-const - // Give up after 1s const timer = setTimeout(() => { socket.destroy(); diff --git a/packages/webdriverjs/src/axe-injector.ts b/packages/webdriverjs/src/axe-injector.ts index b42ed26d..da77fc1b 100644 --- a/packages/webdriverjs/src/axe-injector.ts +++ b/packages/webdriverjs/src/axe-injector.ts @@ -88,7 +88,6 @@ export default class AxeInjectorLegacy { // does not return a "real promise" (ManagedPromise) // and we want to await it. return new Promise((resolve, reject) => { - /* eslint-disable no-undef */ this.driver // https://github.com/vercel/pkg/issues/676 // we need to pass a string vs a function so we manually stringified the function From eda1d3b5719535fec597d98b17168523aca5fb85 Mon Sep 17 00:00:00 2001 From: Steven Lambert <2433219+straker@users.noreply.github.com> Date: Tue, 4 Jun 2024 07:56:43 -0600 Subject: [PATCH 2/2] revert --- packages/puppeteer/test/load-page.spec.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/puppeteer/test/load-page.spec.ts b/packages/puppeteer/test/load-page.spec.ts index 2c686e53..af376710 100644 --- a/packages/puppeteer/test/load-page.spec.ts +++ b/packages/puppeteer/test/load-page.spec.ts @@ -32,8 +32,7 @@ describe('loadPage', function () { it('handles creating a page for you', async function () { const url = fixtureFileURL('index.html'); - const page = await loadPage(browser, url); - const results = await page.analyze(); + const results = await (await loadPage(browser, url)).analyze(); expect(results).to.exist; });