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: support absolute filename in preprocessor #14205

Closed
wants to merge 1 commit into from
Closed

Fix: support absolute filename in preprocessor #14205

wants to merge 1 commit into from

Conversation

JounQin
Copy link
Contributor

@JounQin JounQin commented Mar 12, 2021

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)
  • Changes an existing rule (template)
  • Add autofixing to a rule
  • Add a CLI option
  • Add something to the core
  • Other, please explain:

What changes did you make? (Give an overview)

fix #11989 (comment)

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

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

Hi @JounQin!, 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'.

  • The first letter of the tag should be in uppercase

Read more about contributing to ESLint here

@JounQin JounQin changed the title fix: support absolute filename in preprocessor Fix: support absolute filename in preprocessor Mar 12, 2021
@mdjermanovic mdjermanovic added core Relates to ESLint's core APIs and features 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 Mar 16, 2021
@mdjermanovic mdjermanovic added this to Evaluating in Triage Mar 16, 2021
@mdjermanovic mdjermanovic added the enhancement This change enhances an existing feature of ESLint label Mar 16, 2021
@mdjermanovic
Copy link
Member

We intentionally don't allow absolute paths, because the processor can then return any path, while it must be a child file of the original file, as specified in the Specifying Processor user documentation:

ESLint handles such a named code block as a child file of the original file. You can specify additional configurations for named code blocks in the overrides section of the config.

The returned path also shouldn't contain any path separators (e.g., ../filename.js or \dir\filename.js).

@JounQin
Copy link
Contributor Author

JounQin commented Mar 16, 2021

This limitation breaks rules which require file exist like typescript-eslint/typescript-eslint#3174

I was thinking to create a temporary file for typescript-eslint.

I don't understand why it should be limited, what's the benif?

@mdjermanovic
Copy link
Member

I don't understand why it should be limited, what's the benif?

  • Expected behavior, so that users can configure overrides accordingly, knowing that the exported code blocks are child paths.
  • Performance. If the path can be anything, our config system would have to determine the configuration for a path that might be unrelated to the original path, and that may include config files lookup.

@JounQin
Copy link
Contributor Author

JounQin commented Mar 16, 2021

OK, fair enough to me. Let's continue to discuss it on the original issue for getting real path.

@JounQin JounQin closed this Mar 16, 2021
Triage automation moved this from Evaluating to Complete Mar 16, 2021
@JounQin JounQin deleted the fix/code-block branch March 16, 2021 17:58
@eslint-github-bot eslint-github-bot bot locked and limited conversation to collaborators Sep 13, 2021
@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 Sep 13, 2021
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 core Relates to ESLint's core APIs and features 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
Archived in project
Triage
Complete
Development

Successfully merging this pull request may close these issues.

Expose true filename to rules
2 participants