testing-library / testing-library/eslint-plugin-testing-library

no-debug also affects log.debug() custom logger

Open
#845 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

awaiting response question
Dominant language
TypeScript
Stars
1.1k
Forks
168
Avg merge
15h 44m
Merged PRs (30d)
14

Description

Have you read the Troubleshooting section?

Yes

Plugin version

6.2.0

ESLint version

8.54.0

Node.js version

20.2.0

package manager and version

9.6.6

Operating system

macOS Monterey, 12.7

Bug description

Using a logger in my code, specifically log.debug('')

Steps to reproduce
  1. Set up eslint-plugin-testing-library
  2. import or write a logger library that uses log.debug (example)
  3. type log.debug()
  4. Error will fire when linting
Error output/screenshots

error Unexpected debug statement testing-library/no-debugging-utils

ESLint configuration
{
  "env": {
    "shared-node-browser": true,
    "es2022": true
  },
  "ignorePatterns": ["src/app/index.css", "public"],
  "parser": "@typescript-eslint/parser",
  "parserOptions": {
    "ecmaVersion": "latest",
    "tsconfigRootDir": ".",
    "project": ["./tsconfig.json", "./tsconfig.node.json"]
  },
  "settings": {
    "react": {
      "version": "detect"
    }
  },
  "plugins": ["testing-library"],
  "testing-library/no-debugging-utils": "error",
}
Rule(s) affected

testing-library/no-debugging-utils

Anything else?

Ideally it would only affect .debug() or when it is using screen or a testing-library helper method.
Alternatively having an option to be able to limit it to screen.debug() would also suffice

Do you want to submit a pull request to fix this bug?

Yes

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the testing-library/no-debugging-utils rule and reproduce the reported configuration using a custom logger's log.debug() call. Done means custom logger debug calls are not reported while the rule continues to catch the intended Testing Library debugging usage.

Written by the indexing model from the issue text.

Assessment

Tech stack
eslint, typescript
Domain
testing-qa, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.