Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Report allowed methods for no-console rule #19306

Merged
merged 7 commits into from
Jan 3, 2025

Conversation

RobinTail
Copy link
Contributor

@RobinTail RobinTail commented Jan 3, 2025

Fixes #19229

Prerequisites checklist

What is the purpose of this pull request? (put an "X" next to an item)

[ ] Documentation update
[ ] Bug fix (template)
[ ] New rule (template)
[X] Changes an existing rule (template)
[ ] Add autofix to a rule
[ ] Add a CLI option
[ ] Add something to the core
[ ] Other, please explain:

What rule do you want to change?

no-console

What change do you want to make (place an "X" next to just one item)?

[ ] Generate more warnings
[ ] Generate fewer warnings
[ ] Implement autofix
[X] Implement suggestions

How will the change be implemented (place an "X" next to just one item)?

[ ] A new option
[X] A new default behavior
[ ] Other

Please provide some example code that this change will affect:

console.log(foo)

having options

{ allow: ["info", "warn"] }

What does the rule currently do for this code?

The message is Unexpected console statement.

What will the rule do after it's changed?

The reported message will be: Unexpected console statement. Only these console methods are allowed: info, warn.

What changes did you make? (Give an overview)

  • If allow option is not empty, the message contains the list of allowed methods.

Is there anything you'd like reviewers to focus on?

Please check if the implementation is missing some important requirement.

@eslint-github-bot
Copy link

Hi @RobinTail!, thanks for the Pull Request

The pull request title isn't properly formatted. We ask that you update the pull request title to match this format, as we use it to generate changelogs and automate releases.

  • The commit message tag wasn't recognized. Did you mean "docs", "fix", or "feat"?
  • There should be a space following the initial tag and colon, for example 'feat: Message'.

To Fix: You can fix this problem by clicking 'Edit' next to the pull request title at the top of this page.

Read more about contributing to ESLint here

@github-actions github-actions bot added the rule Relates to ESLint's core rules label Jan 3, 2025
Copy link

netlify bot commented Jan 3, 2025

Deploy Preview for docs-eslint canceled.

Name Link
🔨 Latest commit b5ae19d
🔍 Latest deploy log https://app.netlify.com/sites/docs-eslint/deploys/6777c663e4d80500087afa37

@eslint-github-bot
Copy link

Hi @RobinTail!, thanks for the Pull Request

The pull request title isn't properly formatted. We ask that you update the pull request title to match this format, as we use it to generate changelogs and automate releases.

  • The commit message tag wasn't recognized. Did you mean "docs", "fix", or "feat"?
  • There should be a space following the initial tag and colon, for example 'feat: Message'.

To Fix: You can fix this problem by clicking 'Edit' next to the pull request title at the top of this page.

Read more about contributing to ESLint here

1 similar comment
@eslint-github-bot
Copy link

Hi @RobinTail!, thanks for the Pull Request

The pull request title isn't properly formatted. We ask that you update the pull request title to match this format, as we use it to generate changelogs and automate releases.

  • The commit message tag wasn't recognized. Did you mean "docs", "fix", or "feat"?
  • There should be a space following the initial tag and colon, for example 'feat: Message'.

To Fix: You can fix this problem by clicking 'Edit' next to the pull request title at the top of this page.

Read more about contributing to ESLint here

@RobinTail RobinTail changed the title feat(no-console): Suggestions on method replacement feat: Suggestions on method replacement for no-console rule Jan 3, 2025
@eslint-github-bot eslint-github-bot bot added the feature This change adds a new feature to ESLint label Jan 3, 2025
@RobinTail
Copy link
Contributor Author

I'm going also to add this:

And the message indicates which options are allowed.

@RobinTail RobinTail force-pushed the issue-19229-no-console-suggestions branch from 78d187b to e68214b Compare January 3, 2025 08:58
@RobinTail RobinTail force-pushed the issue-19229-no-console-suggestions branch from 104aec5 to 8875a89 Compare January 3, 2025 09:12
@RobinTail
Copy link
Contributor Author

Just noticed this:

we've agreed to update the error message to include allowed methods and not to provide additional suggestions.

Let me know if you'd really like me to remove the suggestions and limit this PR only to the message

@RobinTail RobinTail marked this pull request as ready for review January 3, 2025 09:13
@RobinTail RobinTail requested a review from a team as a code owner January 3, 2025 09:13
lib/rules/no-console.js Outdated Show resolved Hide resolved
@RobinTail RobinTail changed the title feat: Suggestions on method replacement for no-console rule feat: Report allowed methods for no-console rule Jan 3, 2025
@RobinTail RobinTail force-pushed the issue-19229-no-console-suggestions branch from a1ebdf1 to d4078f9 Compare January 3, 2025 10:46
@RobinTail
Copy link
Contributor Author

that "Browser test" seems to be unstable, it fails 50% times in CI

@RobinTail RobinTail force-pushed the issue-19229-no-console-suggestions branch from d4078f9 to c84f930 Compare January 3, 2025 10:49
@mdjermanovic mdjermanovic added accepted There is consensus among the team that this change meets the criteria for inclusion contributor pool labels Jan 3, 2025
@RobinTail RobinTail force-pushed the issue-19229-no-console-suggestions branch from 4f0ac8f to 14bdec9 Compare January 3, 2025 11:07
Co-authored-by: Milos Djermanovic <milos.djermanovic@gmail.com>
@RobinTail RobinTail force-pushed the issue-19229-no-console-suggestions branch from 14bdec9 to b5ae19d Compare January 3, 2025 11:13
Copy link
Member

@mdjermanovic mdjermanovic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks! Since this is a feat, leaving it open for a second review.

Copy link
Contributor

@Tanujkanti4441 Tanujkanti4441 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

Copy link
Member

@amareshsm amareshsm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@nzakas nzakas merged commit e84e6e2 into eslint:main Jan 3, 2025
29 checks passed
cswimr pushed a commit to cswimr/gauntlet-cswimr-plugins that referenced this pull request Jan 11, 2025
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [@eslint/js](https://eslint.org) ([source](https://github.com/eslint/eslint/tree/HEAD/packages/js)) | devDependencies | minor | [`9.17.0` -> `9.18.0`](https://renovatebot.com/diffs/npm/@eslint%2fjs/9.17.0/9.18.0) |
| [eslint](https://eslint.org) ([source](https://github.com/eslint/eslint)) | devDependencies | minor | [`9.17.0` -> `9.18.0`](https://renovatebot.com/diffs/npm/eslint/9.17.0/9.18.0) |

---

### Release Notes

<details>
<summary>eslint/eslint (@&#8203;eslint/js)</summary>

### [`v9.18.0`](https://github.com/eslint/eslint/releases/tag/v9.18.0)

[Compare Source](eslint/eslint@v9.17.0...v9.18.0)

##### Features

-   [`e84e6e2`](eslint/eslint@e84e6e2) feat: Report allowed methods for `no-console` rule ([#&#8203;19306](eslint/eslint#19306)) (Anna Bocharova)
-   [`8efc2d0`](eslint/eslint@8efc2d0) feat: unflag TypeScript config files ([#&#8203;19266](eslint/eslint#19266)) (Francesco Trotta)
-   [`87a9352`](eslint/eslint@87a9352) feat: check imports and class names in `no-shadow-restricted-names` ([#&#8203;19272](eslint/eslint#19272)) (Milos Djermanovic)

##### Bug Fixes

-   [`da768d4`](eslint/eslint@da768d4) fix: correct `overrideConfigFile` type ([#&#8203;19289](eslint/eslint#19289)) (Francesco Trotta)

##### Documentation

-   [`d9c23c5`](eslint/eslint@d9c23c5) docs: replace `var` with `const` in rule examples ([#&#8203;19325](eslint/eslint#19325)) (Tanuj Kanti)
-   [`8e1a898`](eslint/eslint@8e1a898) docs: add tabs to cli code blocks ([#&#8203;18784](eslint/eslint#18784)) (Jay)
-   [`f3aeefb`](eslint/eslint@f3aeefb) docs: rewrite using let and const in rule examples ([#&#8203;19320](eslint/eslint#19320)) (PoloSpark)
-   [`0b680b3`](eslint/eslint@0b680b3) docs: Update README (GitHub Actions Bot)
-   [`98c86a9`](eslint/eslint@98c86a9) docs: `Edit this page` button link to different branches ([#&#8203;19228](eslint/eslint#19228)) (Tanuj Kanti)
-   [`6947901`](eslint/eslint@6947901) docs: remove hardcoded edit link ([#&#8203;19323](eslint/eslint#19323)) (Milos Djermanovic)
-   [`03f2f44`](eslint/eslint@03f2f44) docs: rewrite var with const in rules examples ([#&#8203;19317](eslint/eslint#19317)) (Thiago)
-   [`26c3003`](eslint/eslint@26c3003) docs: Clarify dangers of eslint:all ([#&#8203;19318](eslint/eslint#19318)) (Nicholas C. Zakas)
-   [`c038257`](eslint/eslint@c038257) docs: add `eqeqeq` in related rules to `no-eq-null` ([#&#8203;19310](eslint/eslint#19310)) (루밀LuMir)
-   [`89c8fc5`](eslint/eslint@89c8fc5) docs: rewrite examples with var using let and const ([#&#8203;19315](eslint/eslint#19315)) (Amaresh  S M)
-   [`db574c4`](eslint/eslint@db574c4) docs: add missing backticks to `no-void` ([#&#8203;19313](eslint/eslint#19313)) (루밀LuMir)
-   [`8d943c3`](eslint/eslint@8d943c3) docs: add missing backticks to `default-case-last` ([#&#8203;19311](eslint/eslint#19311)) (루밀LuMir)
-   [`36ef8bb`](eslint/eslint@36ef8bb) docs: rewrite examples with var using let and const ([#&#8203;19298](eslint/eslint#19298)) (Amaresh  S M)
-   [`1610c9e`](eslint/eslint@1610c9e) docs: add missing backticks to `no-else-return` ([#&#8203;19309](eslint/eslint#19309)) (루밀LuMir)
-   [`df409d8`](eslint/eslint@df409d8) docs: Update README (GitHub Actions Bot)
-   [`2e84213`](eslint/eslint@2e84213) docs: Fix Horizontal Scroll Overflow in Rule Description on Mobile View ([#&#8203;19304](eslint/eslint#19304)) (Amaresh  S M)
-   [`6e7361b`](eslint/eslint@6e7361b) docs: replace `var` with `let` and `const` in rule example ([#&#8203;19302](eslint/eslint#19302)) (Tanuj Kanti)
-   [`069af5e`](eslint/eslint@069af5e) docs: rewrite `var` using `const` in rule examples ([#&#8203;19303](eslint/eslint#19303)) (Kim GyeonWon)
-   [`064e35d`](eslint/eslint@064e35d) docs: remove 'I hope to' comments from scope-manager-interface ([#&#8203;19300](eslint/eslint#19300)) (Josh Goldberg ✨)
-   [`8e00305`](eslint/eslint@8e00305) docs: replace `var` with `const` in rule examples ([#&#8203;19299](eslint/eslint#19299)) (Tanuj Kanti)
-   [`a559009`](eslint/eslint@a559009) docs: Add warning about extending core rules ([#&#8203;19295](eslint/eslint#19295)) (Nicholas C. Zakas)
-   [`0bfdf6c`](eslint/eslint@0bfdf6c) docs: Update README (GitHub Actions Bot)
-   [`ce0b9ff`](eslint/eslint@ce0b9ff) docs: add navigation link for `code explorer` ([#&#8203;19285](eslint/eslint#19285)) (Tanuj Kanti)
-   [`e255cc9`](eslint/eslint@e255cc9) docs: add bluesky icon to footer ([#&#8203;19290](eslint/eslint#19290)) (Tanuj Kanti)
-   [`5d64851`](eslint/eslint@5d64851) docs: remove outdated info about environments ([#&#8203;19296](eslint/eslint#19296)) (Francesco Trotta)
-   [`eec01f0`](eslint/eslint@eec01f0) docs: switch rule examples config format to `languageOptions` ([#&#8203;19277](eslint/eslint#19277)) (Milos Djermanovic)
-   [`b36ca0a`](eslint/eslint@b36ca0a) docs: Fixing Focus Order by Rearranging Element Sequence ([#&#8203;19241](eslint/eslint#19241)) (Amaresh  S M)
-   [`d122c8a`](eslint/eslint@d122c8a) docs: add missing backticks to `sort-imports` ([#&#8203;19282](eslint/eslint#19282)) (루밀LuMir)
-   [`0367a70`](eslint/eslint@0367a70) docs: update custom parser docs ([#&#8203;19288](eslint/eslint#19288)) (Francesco Trotta)
-   [`8c07ebb`](eslint/eslint@8c07ebb) docs: add `border-radius` to `hX:target` selector styles ([#&#8203;19270](eslint/eslint#19270)) (루밀LuMir)
-   [`eff7c57`](eslint/eslint@eff7c57) docs: add limitation section in `no-loop-func` ([#&#8203;19287](eslint/eslint#19287)) (Tanuj Kanti)
-   [`5db226f`](eslint/eslint@5db226f) docs: add missing backticks in various parts of the documentation ([#&#8203;19269](eslint/eslint#19269)) (루밀LuMir)
-   [`789edbb`](eslint/eslint@789edbb) docs: Update README (GitHub Actions Bot)
-   [`613c06a`](eslint/eslint@613c06a) docs: mark rules that are frozen with ❄️ ([#&#8203;19231](eslint/eslint#19231)) (Amaresh  S M)
-   [`43172ec`](eslint/eslint@43172ec) docs: Update README (GitHub Actions Bot)
-   [`ac8b3c4`](eslint/eslint@ac8b3c4) docs: fix description of `overrideConfigFile` option ([#&#8203;19262](eslint/eslint#19262)) (Milos Djermanovic)
-   [`bbb9b46`](eslint/eslint@bbb9b46) docs: Update README (GitHub Actions Bot)
-   [`995b492`](eslint/eslint@995b492) docs: fix inconsistent divider in rule categories box ([#&#8203;19249](eslint/eslint#19249)) (Tanuj Kanti)
-   [`f76d05d`](eslint/eslint@f76d05d) docs: Refactor search result handling with better event listener cleanup ([#&#8203;19252](eslint/eslint#19252)) (Amaresh  S M)
-   [`c5f3d7d`](eslint/eslint@c5f3d7d) docs: Update README (GitHub Actions Bot)

##### Chores

-   [`c52be85`](eslint/eslint@c52be85) chore: upgrade to `@eslint/js@9.18.0` ([#&#8203;19330](eslint/eslint#19330)) (Francesco Trotta)
-   [`362099c`](eslint/eslint@362099c) chore: package.json update for [@&#8203;eslint/js](https://github.com/eslint/js) release (Jenkins)
-   [`495aa49`](eslint/eslint@495aa49) chore: extract package `name` from `package.json` for public interface ([#&#8203;19314](eslint/eslint#19314)) (루밀LuMir)
-   [`6fe0e72`](eslint/eslint@6fe0e72) chore: update dependency [@&#8203;eslint/json](https://github.com/eslint/json) to ^0.9.0 ([#&#8203;19263](eslint/eslint#19263)) (renovate\[bot])

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about these updates again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS44Ny4wIiwidXBkYXRlZEluVmVyIjoiMzkuODcuMCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==-->

Reviewed-on: https://www.coastalcommits.com/cswimr/gauntlet-cswimr-plugins/pulls/21
Reviewed-by: cswimr <seaswimmerthefsh@gmail.com>
Co-authored-by: Renovate <renovate@coastalcommits.com>
Co-committed-by: Renovate <renovate@coastalcommits.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion contributor pool feature This change adds a new feature to ESLint rule Relates to ESLint's core rules
Projects
Status: Complete
Development

Successfully merging this pull request may close these issues.

Rule Change: update message for no-console when there is allow option
5 participants