Skip to content

Commit e394ce0

Browse files
skovyMichaelDeBoey
authored andcommitted
feat(no-debugging-utils): enable all debug methods in all configs by default (#663)
BREAKING CHANGE: `no-debugging-utils` now enables all debug methods in all configs by default
1 parent 8063f8f commit e394ce0

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

docs/rules/no-debugging-utils.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ This rule supports disallowing the following debugging utilities:
1313
- `logDOM`
1414
- `prettyFormat`
1515

16-
By default, only `debug` and `logTestingPlaygroundURL` are disallowed.
16+
By default, all are disallowed.
1717

1818
Examples of **incorrect** code for this rule:
1919

lib/rules/no-debugging-utils.ts

+12-6
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,22 @@ import {
1313
} from '../node-utils';
1414
import { DEBUG_UTILS } from '../utils';
1515

16-
type DebugUtilsToCheckFor = Partial<
17-
Record<typeof DEBUG_UTILS[number], boolean>
18-
>;
16+
type DebugUtilsToCheckForConfig = Record<typeof DEBUG_UTILS[number], boolean>;
17+
type DebugUtilsToCheckFor = Partial<DebugUtilsToCheckForConfig>;
1918

2019
export const RULE_NAME = 'no-debugging-utils';
2120
export type MessageIds = 'noDebug';
2221
type Options = [{ utilsToCheckFor?: DebugUtilsToCheckFor }];
2322

23+
const defaultUtilsToCheckFor: DebugUtilsToCheckForConfig = {
24+
debug: true,
25+
logTestingPlaygroundURL: true,
26+
prettyDOM: true,
27+
logRoles: true,
28+
logDOM: true,
29+
prettyFormat: true,
30+
};
31+
2432
export default createTestingLibraryRule<Options, MessageIds>({
2533
name: RULE_NAME,
2634
meta: {
@@ -60,9 +68,7 @@ export default createTestingLibraryRule<Options, MessageIds>({
6068
},
6169
],
6270
},
63-
defaultOptions: [
64-
{ utilsToCheckFor: { debug: true, logTestingPlaygroundURL: true } },
65-
],
71+
defaultOptions: [{ utilsToCheckFor: defaultUtilsToCheckFor }],
6672

6773
create(context, [{ utilsToCheckFor = {} }], helpers) {
6874
const suspiciousDebugVariableNames: string[] = [];

tests/lib/rules/no-debugging-utils.test.ts

-4
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,6 @@ ruleTester.run(RULE_NAME, rule, {
448448
import { screen } from '@testing-library/dom'
449449
screen.logTestingPlaygroundURL()
450450
`,
451-
options: [{ utilsToCheckFor: { logTestingPlaygroundURL: true } }],
452451
errors: [
453452
{
454453
line: 3,
@@ -462,7 +461,6 @@ ruleTester.run(RULE_NAME, rule, {
462461
import { logRoles } from '@testing-library/dom'
463462
logRoles(document.createElement('nav'))
464463
`,
465-
options: [{ utilsToCheckFor: { logRoles: true } }],
466464
errors: [
467465
{
468466
line: 3,
@@ -476,7 +474,6 @@ ruleTester.run(RULE_NAME, rule, {
476474
import { screen } from '@testing-library/dom'
477475
screen.logTestingPlaygroundURL()
478476
`,
479-
options: [{ utilsToCheckFor: { logRoles: true } }],
480477
errors: [
481478
{
482479
line: 3,
@@ -490,7 +487,6 @@ ruleTester.run(RULE_NAME, rule, {
490487
import { screen } from '@testing-library/dom'
491488
screen.logTestingPlaygroundURL()
492489
`,
493-
options: [{ utilsToCheckFor: { debug: false } }],
494490
errors: [
495491
{
496492
line: 3,

0 commit comments

Comments
 (0)