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: no-misleading-character-class edge cases with granular errors #17970

Merged
merged 1 commit into from Jan 8, 2024

Conversation

mdjermanovic
Copy link
Member

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:

Follow-up for #17515 (comment).

Tell us about your environment (npx eslint --env-info):

  • Node version: v20.9.0
  • npm version: v10.1.0
  • Local ESLint version: main
  • Global ESLint version:
  • Operating System: Windows

What parser are you using (place an "X" next to just one item)?

[x] Default (Espree)
[ ] @typescript-eslint/parser
[ ] @babel/eslint-parser
[ ] vue-eslint-parser
[ ] @angular-eslint/template-parser
[ ] Other

Please show your full configuration:

Configuration
module.exports = [];

What did you do? Please include the actual source code causing the issue.

/* eslint "no-misleading-character-class": "error" */

var r = /   [👩‍👦]    [👩‍👦]  /u;

What did you expect to happen?

Two errors that underline one ZWJ sequence each.

What actually happened? Please include the actual, raw output from ESLint.

One error that underlines range from the start of the first till the end of the second sequence, including unrelated characters between.

$ node bin/eslint a.js -f json
[{"filePath":"C:\\projects\\eslint\\a.js","messages":[{"ruleId":"no-misleading-character-class","severity":2,"message":"Unexpected joined character sequence in character class.","line":3,"column":14,"nodeType":null,"messageId":"zwj","endLine":3,"endColumn":30}],"suppressedMessages":[],"errorCount":1,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"source":"/* eslint \"no-misleading-character-class\": \"error\" */\n\nvar r = /   [�‍�]    [�‍�]  /u;\n\n\n\n","usedDeprecatedRules":[]}]

What changes did you make? (Give an overview)

Refactored the code and fixed the problem with reporting granular errors in patterns with multiple ZWJ sequences.

Before this change:

image

After this change:

image

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

@mdjermanovic mdjermanovic added bug ESLint is working incorrectly rule Relates to ESLint's core rules labels Jan 7, 2024
@mdjermanovic mdjermanovic requested a review from a team as a code owner January 7, 2024 23:30
Copy link

netlify bot commented Jan 7, 2024

Deploy Preview for docs-eslint canceled.

Name Link
🔨 Latest commit c54f15f
🔍 Latest deploy log https://app.netlify.com/sites/docs-eslint/deploys/659b34094ae009000716d9f3

Copy link
Contributor

@snitin315 snitin315 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!

@snitin315 snitin315 added the accepted There is consensus among the team that this change meets the criteria for inclusion label Jan 8, 2024
@snitin315 snitin315 merged commit 806f708 into main Jan 8, 2024
17 checks passed
@snitin315 snitin315 deleted the 17515-followup branch January 8, 2024 10:14
bmish added a commit to bmish/eslint that referenced this pull request Jan 16, 2024
* main:
  chore: Split Docs CI from core CI (eslint#17897)
  fix: Ensure config keys are printed for config errors (eslint#17980)
  chore: delete relative-module-resolver.js (eslint#17981)
  docs: migration guide entry for `no-inner-declarations` (eslint#17977)
  docs: Update README
  feat: maintain latest ecma version in ESLint (eslint#17958)
  feat!: no-inner-declaration new default behaviour and option (eslint#17885)
  feat: add `no-useless-assignment` rule (eslint#17625)
  fix: `no-misleading-character-class` edge cases with granular errors (eslint#17970)
  feat: `no-misleading-character-class` granular errors (eslint#17515)
  docs: fix number of code-path events on custom rules page (eslint#17969)
  docs: reorder entries in v9 migration guide (eslint#17967)
  fix!: handle `--output-file` for empty output when saving to disk (eslint#17957)
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 bug ESLint is working incorrectly rule Relates to ESLint's core rules
Projects
Status: Complete
Development

Successfully merging this pull request may close these issues.

None yet

2 participants