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

Docs: Mention workaround for escaping the slash character in selectors #14675

Merged
merged 2 commits into from Aug 5, 2021

Conversation

AriaMinaei
Copy link
Contributor

Prerequisites checklist

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

[x] Documentation update

What changes did you make? (Give an overview)

A small documentation change to mention the workaround for the esquery issue that prevents the forward-slash character to be escaped in regular expressions, when used in no-restricted-syntax.

@eslint-github-bot eslint-github-bot bot added the triage An ESLint team member will look at this issue soon label Jun 5, 2021
@eslint-github-bot
Copy link

Hi @AriaMinaei!, thanks for the Pull Request

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

  • The commit message tag must be one of the following:

    The Tag is one of the following:

    • Fix - for a bug fix.
    • Update - either for a backwards-compatible enhancement or for a rule change that adds reported problems.
    • New - implements a new feature.
    • Breaking - for a backwards-incompatible enhancement or feature.
    • Docs - changes to documentation only.
    • Build - changes to build process only.
    • Upgrade - for a dependency upgrade.
    • Chore - for anything that isn't user-facing (for example, refactoring, adding tests, etc.).

    You can use the labels of the issue you are working on to determine the best tag.

  • There should be a space following the initial tag and colon, for example 'New: Message'.

Read more about contributing to ESLint here

Copy link
Member

@aladdin-add aladdin-add left a comment

Choose a reason for hiding this comment

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

can this be fixed the the package?

@aladdin-add aladdin-add added documentation Relates to ESLint's documentation enhancement This change enhances an existing feature of ESLint evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion and removed triage An ESLint team member will look at this issue soon labels Jun 7, 2021
@AriaMinaei
Copy link
Contributor Author

Not sure, because the relevant bug has been unresolved for a couple of years already.

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. Thanks

docs/developer-guide/selectors.md Outdated Show resolved Hide resolved

### Known issues

Due to a [bug](https://github.com/estools/esquery/issues/68) in [esquery](https://github.com/estools/esquery), regular expressions that contain a forward-slash character `/` aren't porperly parsed, so `[value=/some\/path/]` will be a syntax error. As a [workaround](https://github.com/estools/esquery/issues/68), you can replace the `/` character with its unicode counterpart, like so: `[value=/some\\u002Fpath/]`.
Copy link
Member

Choose a reason for hiding this comment

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

\\ in [value=/some\\u002Fpath/] might be confusing. Selector itself should have only one \, while the other \ is required only if the selector is represented in a string literal?

Copy link
Member

Choose a reason for hiding this comment

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

I'd suggest only \ here (like it is in [value=/some\/path/]), and an example that disallows import from foo/bar:

{
  "rules": {
    "no-restricted-syntax": ["error", "ImportDeclaration[source.value=/foo\\u002Fbar/]"]
  }
}

Co-authored-by: Milos Djermanovic <milos.djermanovic@gmail.com>
@eslint-github-bot
Copy link

Hi @AriaMinaei!, thanks for the Pull Request

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

  • The commit message tag must be one of the following:

    The Tag is one of the following:

    • Fix - for a bug fix.
    • Update - either for a backwards-compatible enhancement or for a rule change that adds reported problems.
    • New - implements a new feature.
    • Breaking - for a backwards-incompatible enhancement or feature.
    • Docs - changes to documentation only.
    • Build - changes to build process only.
    • Upgrade - for a dependency upgrade.
    • Chore - for anything that isn't user-facing (for example, refactoring, adding tests, etc.).

    You can use the labels of the issue you are working on to determine the best tag.

  • There should be a space following the initial tag and colon, for example 'New: Message'.

Read more about contributing to ESLint here

@mdjermanovic mdjermanovic changed the title Mention workaround for the regex escape character Docs: Mention workaround for escaping the slash character in selectors Jun 14, 2021
@nzakas
Copy link
Member

nzakas commented Aug 5, 2021

I think this is close enough to merge. We can make other tweaks later.

@nzakas nzakas merged commit e037d61 into eslint:master Aug 5, 2021
@eslint-github-bot eslint-github-bot bot locked and limited conversation to collaborators Feb 2, 2022
@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 Feb 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion documentation Relates to ESLint's documentation enhancement This change enhances an existing feature of ESLint evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants