Skip to content

Commit

Permalink
feat(no-debugging-utils): enable all debug methods in all configs by …
Browse files Browse the repository at this point in the history
…default (#663)

BREAKING CHANGE: `no-debugging-utils` now enables all debug methods in all configs by default
  • Loading branch information
skovy authored and MichaelDeBoey committed Oct 4, 2022
1 parent 8063f8f commit e394ce0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion docs/rules/no-debugging-utils.md
Expand Up @@ -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:

Expand Down
18 changes: 12 additions & 6 deletions lib/rules/no-debugging-utils.ts
Expand Up @@ -13,14 +13,22 @@ import {
} from '../node-utils';
import { DEBUG_UTILS } from '../utils';

type DebugUtilsToCheckFor = Partial<
Record<typeof DEBUG_UTILS[number], boolean>
>;
type DebugUtilsToCheckForConfig = Record<typeof DEBUG_UTILS[number], boolean>;
type DebugUtilsToCheckFor = Partial<DebugUtilsToCheckForConfig>;

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<Options, MessageIds>({
name: RULE_NAME,
meta: {
Expand Down Expand Up @@ -60,9 +68,7 @@ export default createTestingLibraryRule<Options, MessageIds>({
},
],
},
defaultOptions: [
{ utilsToCheckFor: { debug: true, logTestingPlaygroundURL: true } },
],
defaultOptions: [{ utilsToCheckFor: defaultUtilsToCheckFor }],

create(context, [{ utilsToCheckFor = {} }], helpers) {
const suspiciousDebugVariableNames: string[] = [];
Expand Down
4 changes: 0 additions & 4 deletions tests/lib/rules/no-debugging-utils.test.ts
Expand Up @@ -448,7 +448,6 @@ ruleTester.run(RULE_NAME, rule, {
import { screen } from '@testing-library/dom'
screen.logTestingPlaygroundURL()
`,
options: [{ utilsToCheckFor: { logTestingPlaygroundURL: true } }],
errors: [
{
line: 3,
Expand All @@ -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,
Expand All @@ -476,7 +474,6 @@ ruleTester.run(RULE_NAME, rule, {
import { screen } from '@testing-library/dom'
screen.logTestingPlaygroundURL()
`,
options: [{ utilsToCheckFor: { logRoles: true } }],
errors: [
{
line: 3,
Expand All @@ -490,7 +487,6 @@ ruleTester.run(RULE_NAME, rule, {
import { screen } from '@testing-library/dom'
screen.logTestingPlaygroundURL()
`,
options: [{ utilsToCheckFor: { debug: false } }],
errors: [
{
line: 3,
Expand Down

0 comments on commit e394ce0

Please sign in to comment.