diff --git a/docs/rules/no-debugging-utils.md b/docs/rules/no-debugging-utils.md index 7628e04a..e8b0922a 100644 --- a/docs/rules/no-debugging-utils.md +++ b/docs/rules/no-debugging-utils.md @@ -13,7 +13,7 @@ This rule supports disallowing the following debugging utilities: - `logDOM` - `prettyFormat` -By default, only `debug` and `logTestingPlaygroundURL` are disallowed. +By default, all are disallowed. Examples of **incorrect** code for this rule: diff --git a/lib/rules/no-debugging-utils.ts b/lib/rules/no-debugging-utils.ts index 05e95c06..5d18499b 100644 --- a/lib/rules/no-debugging-utils.ts +++ b/lib/rules/no-debugging-utils.ts @@ -13,14 +13,22 @@ import { } from '../node-utils'; import { DEBUG_UTILS } from '../utils'; -type DebugUtilsToCheckFor = Partial< - Record ->; +type DebugUtilsToCheckForConfig = Record; +type DebugUtilsToCheckFor = Partial; export const RULE_NAME = 'no-debugging-utils'; export type MessageIds = 'noDebug'; type Options = [{ utilsToCheckFor?: DebugUtilsToCheckFor }]; +const defaultUtilsToCheckFor: DebugUtilsToCheckForConfig = { + debug: true, + logTestingPlaygroundURL: true, + prettyDOM: true, + logRoles: true, + logDOM: true, + prettyFormat: true, +}; + export default createTestingLibraryRule({ name: RULE_NAME, meta: { @@ -60,9 +68,7 @@ export default createTestingLibraryRule({ }, ], }, - defaultOptions: [ - { utilsToCheckFor: { debug: true, logTestingPlaygroundURL: true } }, - ], + defaultOptions: [{ utilsToCheckFor: defaultUtilsToCheckFor }], create(context, [{ utilsToCheckFor = {} }], helpers) { const suspiciousDebugVariableNames: string[] = []; diff --git a/tests/lib/rules/no-debugging-utils.test.ts b/tests/lib/rules/no-debugging-utils.test.ts index 3879d9e2..b31861a7 100644 --- a/tests/lib/rules/no-debugging-utils.test.ts +++ b/tests/lib/rules/no-debugging-utils.test.ts @@ -448,7 +448,6 @@ ruleTester.run(RULE_NAME, rule, { import { screen } from '@testing-library/dom' screen.logTestingPlaygroundURL() `, - options: [{ utilsToCheckFor: { logTestingPlaygroundURL: true } }], errors: [ { line: 3, @@ -462,7 +461,6 @@ ruleTester.run(RULE_NAME, rule, { import { logRoles } from '@testing-library/dom' logRoles(document.createElement('nav')) `, - options: [{ utilsToCheckFor: { logRoles: true } }], errors: [ { line: 3, @@ -476,7 +474,6 @@ ruleTester.run(RULE_NAME, rule, { import { screen } from '@testing-library/dom' screen.logTestingPlaygroundURL() `, - options: [{ utilsToCheckFor: { logRoles: true } }], errors: [ { line: 3, @@ -490,7 +487,6 @@ ruleTester.run(RULE_NAME, rule, { import { screen } from '@testing-library/dom' screen.logTestingPlaygroundURL() `, - options: [{ utilsToCheckFor: { debug: false } }], errors: [ { line: 3,