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

fix: Fix suggestion message in no-useless-escape #17339

Merged
merged 6 commits into from Jul 11, 2023

Conversation

fasttime
Copy link
Member

@fasttime fasttime commented Jul 4, 2023

Prerequisites checklist

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

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

Fixes #16988

What changes did you make? (Give an overview)

This PR changes the message of a suggestion reported by the no-useless-escape rule when the target node is a string in a directive. As per specification, "use strict" directives cannot contain escape sequences, and there is no guarantee about the evaluation of implementations-specific directives when the raw text is changed.

Since it cannot be assumed that replacing escape sequences in a directive will keep the existing functionality, the new message omits that information:

Remove the `\` if it was inserted by mistake.

instead of

Remove the `\`. This maintains the current functionality.

This is the last remaining effort to complete #16988.

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

I factored out the method isDirective from a rule into ast-utils.js, and noticed that a shorter implementation exists. I can't decide if the previous implementation should be kept as a fallback because I don't know what the requirements for custom parsers are. See https://github.com/eslint/eslint/pull/17339/files#r1251818127.

@eslint-github-bot eslint-github-bot bot added the bug ESLint is working incorrectly label Jul 4, 2023
@netlify
Copy link

netlify bot commented Jul 4, 2023

Deploy Preview for docs-eslint canceled.

Name Link
🔨 Latest commit c6e8fb6
🔍 Latest deploy log https://app.netlify.com/sites/docs-eslint/deploys/64a7e0b273d0e90008cd82d6

lib/rules/utils/ast-utils.js Outdated Show resolved Hide resolved
@fasttime fasttime added rule Relates to ESLint's core rules accepted There is consensus among the team that this change meets the criteria for inclusion labels Jul 4, 2023
@fasttime fasttime marked this pull request as ready for review July 4, 2023 17:22
@fasttime fasttime requested a review from a team as a code owner July 4, 2023 17:22
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! I'll leave this open for a couple of days if anyone else wants to review it before merging.

Copy link
Member

@nzakas nzakas 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 b79b6fb into main Jul 11, 2023
22 checks passed
@nzakas nzakas deleted the issue16988-no-useless-escape branch July 11, 2023 15:56
bmish added a commit to bmish/eslint that referenced this pull request Jul 23, 2023
* main: (101 commits)
  docs: Migrating `eslint-env` configuration comments (eslint#17390)
  Merge pull request from GHSA-qwh7-v8hg-w8rh
  feat: adds option for allowing empty object patterns as parameter (eslint#17365)
  fix: FlatESLint#getRulesMetaForResults shouldn't throw on unknown rules (eslint#17393)
  docs: fix Ignoring Files section in config migration guide (eslint#17392)
  docs: Update README
  feat: Improve config error messages (eslint#17385)
  fix: Update no-loop-func to not overlap with no-undef (eslint#17358)
  docs: Update README
  docs: Update README
  8.45.0
  Build: changelog update for 8.45.0
  chore: package.json update for @eslint/js release
  docs: add playground links to correct and incorrect code blocks (eslint#17306)
  docs: Expand rule option schema docs (eslint#17198)
  docs: Config Migration Guide (eslint#17230)
  docs: Update README
  fix: Fix suggestion message in `no-useless-escape` (eslint#17339)
  docs: Update README
  chore: update eslint-config-eslint exports (eslint#17336)
  ...
@eslint-github-bot eslint-github-bot bot locked and limited conversation to collaborators Jan 8, 2024
@eslint-github-bot eslint-github-bot bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Jan 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly rule Relates to ESLint's core rules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: rules should not introduce new directives
3 participants