Skip to content

regexp/sort-character-class-elements: character class elements are ordered in a way that changes the class meaning #858

@andreww2012

Description

@andreww2012

Information:

  • ESLint version: 9.32.0
  • eslint-plugin-regexp version: 2.9.0

Description

regexp/sort-character-class-elements autofix might end up sorting the elements of the character class in a way that completely changes the meaning of the class, for example [~^*] is transformed to [^*~], but ^ at the beginning of the class inverts it. Note that /[*^~]/ is not reported by this rule, which I think what the autofix should turn the input into.

Reproduction: https://stackblitz.com/edit/vitejs-vite-vfsaxys1

Open test.js, run npx eslint --fix, then observe the changes in this file.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions