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(linter): make overrides globs relative to config path #7407

Conversation

camchenry
Copy link
Collaborator

@camchenry camchenry commented Nov 21, 2024

currently, we are matching globs on the absolute path to the file, which means that in order to properly match, all globs would need to start with **/. this is not consistent with the behavior in ESLint, which is defined here: https://eslint.org/docs/v8.x/use/configure/configuration-files#how-do-overrides-work

The patterns are applied against the file path relative to the directory of the config file. For example, if your config file has the path /Users/john/workspace/any-project/.eslintrc.js and the file you want to lint has the path /Users/john/workspace/any-project/lib/util.js, then the pattern provided in .eslintrc.js is executed against the relative path lib/util.js.

This PR adds the ability to store the path to the configuration file along with the configuration data, so that we can later use it to resolve the relative paths of the files in the overrides section.

I'm not exactly sure if this will still make sense with nested configuration files, but I think it makes sense to store a path to each configuration file, alongside where the overrides are stored.

Copy link

graphite-app bot commented Nov 21, 2024

Your org has enabled the Graphite merge queue for merging into main

Add the label “0-merge” to the PR and Graphite will automatically add it to the merge queue when it’s ready to merge. Or use the label “hotfix” to add to the merge queue as a hot fix.

You must have a Graphite account and log in to Graphite in order to use the merge queue. Sign up using this link.

@github-actions github-actions bot added A-linter Area - Linter A-cli Area - CLI C-bug Category - Bug labels Nov 21, 2024
Copy link
Collaborator Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@camchenry camchenry marked this pull request as ready for review November 21, 2024 19:07
Copy link

codspeed-hq bot commented Nov 21, 2024

CodSpeed Performance Report

Merging #7407 will not alter performance

Comparing 11-21-fix_linter_make_overrides_globs_relative_to_config_path (e88cf1b) with main (52784d2)

Summary

✅ 30 untouched benchmarks

@Boshen Boshen added the 0-merge Merge with Graphite Merge Queue label Nov 22, 2024
Copy link
Member

Boshen commented Nov 22, 2024

Merge activity

  • Nov 22, 9:37 AM EST: The merge label '0-merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Nov 22, 9:37 AM EST: A user added this pull request to the Graphite merge queue.
  • Nov 22, 9:43 AM EST: A user merged this pull request with the Graphite merge queue.

- fixes #7365

currently, we are matching globs on the absolute path to the file, which means that in order to properly match, all globs would need to start with `**/`. this is not consistent with the behavior in ESLint, which is defined here:  https://eslint.org/docs/v8.x/use/configure/configuration-files#how-do-overrides-work

> **The patterns are applied against the file path relative to the directory of the config file.** For example, if your config file has the path `/Users/john/workspace/any-project/.eslintrc.js` and the file you want to lint has the path `/Users/john/workspace/any-project/lib/util.js`, then the pattern provided in `.eslintrc.js` is executed against the relative path `lib/util.js`.

This PR adds the ability to store the path to the configuration file along with the configuration data, so that we can later use it to resolve the relative paths of the files in the overrides section.

I'm not exactly sure if this will still make sense with nested configuration files, but I think it makes sense to store a path to each configuration file, alongside where the overrides are stored.
@Boshen Boshen force-pushed the 11-21-fix_linter_make_overrides_globs_relative_to_config_path branch from 1cae468 to e88cf1b Compare November 22, 2024 14:37
@graphite-app graphite-app bot merged commit e88cf1b into main Nov 22, 2024
26 checks passed
@graphite-app graphite-app bot deleted the 11-21-fix_linter_make_overrides_globs_relative_to_config_path branch November 22, 2024 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0-merge Merge with Graphite Merge Queue A-cli Area - CLI A-linter Area - Linter C-bug Category - Bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

linter: overrides path without ** prefix does not seem to work
2 participants