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

feat(linter): allow fixing in files with source offsets #6197

Conversation

camchenry
Copy link
Collaborator

@camchenry camchenry commented Oct 1, 2024

This PR fixes the calculation of spans when dealing with files that have multiple sources and non-zero source start offsets. This is almost always the case for .vue, .astro, and .svelte files. This enables us to correctly apply fixes for these file types both in the CLI with oxlint and also in editors like VS Code.

Screen.Recording.2024-09-30.at.6.39.27.PM.mov

I'm open to ideas on how to improve testing in this area, as I don't think that we currently have any tests for fixing files end-to-end (beyond what the linter rules check). I did run this locally on the gitlab repository (which is written in Vue) and all of the fixes appeared to be applied correctly.

Copy link

graphite-app bot commented Oct 1, 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 the A-linter Area - Linter label Oct 1, 2024
Copy link
Collaborator Author

camchenry commented Oct 1, 2024

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

Join @camchenry and the rest of your teammates on Graphite Graphite

@Boshen Boshen changed the base branch from 09-30-fix_linter_get_correct_source_offsets_for_astro_files to graphite-base/6197 October 1, 2024 03:36
Copy link

codspeed-hq bot commented Oct 1, 2024

CodSpeed Performance Report

Merging #6197 will not alter performance

Comparing 09-30-feat_linter_allow_fixing_in_files_with_source_offsets (5957214) with main (099ff3a)

Summary

✅ 29 untouched benchmarks

@camchenry camchenry force-pushed the 09-30-feat_linter_allow_fixing_in_files_with_source_offsets branch from 272cec6 to cb3132a Compare October 1, 2024 03:41
@Boshen Boshen changed the base branch from graphite-base/6197 to main October 1, 2024 03:42
@Boshen Boshen force-pushed the 09-30-feat_linter_allow_fixing_in_files_with_source_offsets branch from cb3132a to ddd849b Compare October 1, 2024 03:42
@camchenry camchenry marked this pull request as ready for review October 1, 2024 03:58
@camchenry camchenry force-pushed the 09-30-feat_linter_allow_fixing_in_files_with_source_offsets branch from ddd849b to 1c92831 Compare October 1, 2024 04:29
@DonIsaac
Copy link
Collaborator

DonIsaac commented Oct 1, 2024

I like this. I'm currently working on a full re-write of source files and writing, but this is a good in-between. Excellent stuff @camchenry

@DonIsaac DonIsaac requested a review from camc314 October 1, 2024 05:01
@DonIsaac
Copy link
Collaborator

DonIsaac commented Oct 1, 2024

I'd like feedback from @camc314. After that, feel free to merge when you're ready

@Boshen Boshen added the 0-merge Merge with Graphite Merge Queue label Oct 3, 2024
Copy link

graphite-app bot commented Oct 3, 2024

Merge activity

  • Oct 2, 8:47 PM EDT: The merge label '0-merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Oct 2, 8:47 PM EDT: Boshen added this pull request to the Graphite merge queue.
  • Oct 2, 9:00 PM EDT: Boshen merged this pull request with the Graphite merge queue.

Boshen pushed a commit that referenced this pull request Oct 3, 2024
- fixes #5913

This PR fixes the calculation of spans when dealing with files that have multiple sources and non-zero source start offsets. This is almost always the case for `.vue`, `.astro`, and `.svelte` files. This enables us to correctly apply fixes for these file types both in the CLI with `oxlint` and also in editors like VS Code.

https://github.com/user-attachments/assets/2836c8bd-09be-4e59-801d-7c95f8c2491f

I'm open to ideas on how to improve testing in this area, as I don't think that we currently have any tests for fixing files end-to-end (beyond what the linter rules check). I did run this locally on the gitlab repository (which is written in Vue) and all of the fixes appeared to be applied correctly.
@Boshen Boshen force-pushed the 09-30-feat_linter_allow_fixing_in_files_with_source_offsets branch from 1c92831 to 9756aeb Compare October 3, 2024 00:51
- fixes #5913

This PR fixes the calculation of spans when dealing with files that have multiple sources and non-zero source start offsets. This is almost always the case for `.vue`, `.astro`, and `.svelte` files. This enables us to correctly apply fixes for these file types both in the CLI with `oxlint` and also in editors like VS Code.

https://github.com/user-attachments/assets/2836c8bd-09be-4e59-801d-7c95f8c2491f

I'm open to ideas on how to improve testing in this area, as I don't think that we currently have any tests for fixing files end-to-end (beyond what the linter rules check). I did run this locally on the gitlab repository (which is written in Vue) and all of the fixes appeared to be applied correctly.
@Boshen Boshen force-pushed the 09-30-feat_linter_allow_fixing_in_files_with_source_offsets branch from 9756aeb to 5957214 Compare October 3, 2024 00:53
@graphite-app graphite-app bot merged commit 5957214 into main Oct 3, 2024
26 checks passed
@graphite-app graphite-app bot deleted the 09-30-feat_linter_allow_fixing_in_files_with_source_offsets branch October 3, 2024 01:00
This was referenced Oct 7, 2024
Boshen added a commit that referenced this pull request Oct 8, 2024
## [0.9.10] - 2024-10-07

### Features

- f272137 editors/vscode: Clear diagnostics on file deletion (#6326)
(dalaoshu)
- 1a5f293 editors/vscode: Update VSCode extention to use project's
language server (#6132) (dalaoshu)
- 376cc09 linter: Implement `no-throw-literal` (#6144) (dalaoshu)
- 5957214 linter: Allow fixing in files with source offsets (#6197)
(camchenry)
- a089e19 linter: Eslint/no-else-return (#4305) (yoho)
- 183739f linter: Implement prefer-await-to-callbacks (#6153) (dalaoshu)
- ae539af linter: Implement no-return-assign (#6108) (Radu Baston)

### Bug Fixes

- 9e9808b linter: Fix regression when parsing ts in vue files (#6336)
(Boshen)
- 93c6db6 linter: Improve docs and diagnostics message for
no-else-return (#6327) (DonIsaac)
- e0a3378 linter: Correct false positive in
`unicorn/prefer-string-replace-all` (#6263) (H11)
- ea28ee9 linter: Improve the fixer of `prefer-namespace-keyword`
(#6230) (dalaoshu)
- f6a3450 linter: Get correct source offsets for astro files (#6196)
(camchenry)
- be0030c linter: Allow whitespace control characters in
`no-control-regex` (#6140) (camchenry)
- e7e8ead linter: False positive in `no-return-assign` (#6128)
(DonIsaac)

### Performance

- ac0a82a linter: Reuse allocator when there are multiple source texts
(#6337) (Boshen)
- 50a0029 linter: Do not concat vec in `no-useless-length-check` (#6276)
(camchenry)

### Documentation

- 7ca70dd linter: Add docs for `ContextHost` and `LintContext` (#6272)
(camchenry)
- a949ecb linter: Improve docs for `eslint/getter-return` (#6229)
(DonIsaac)
- 14ba263 linter: Improve docs for `eslint-plugin-import` rules (#6131)
(dalaoshu)

### Refactor

- 642725c linter: Rename vars from `ast_node_id` to `node_id` (#6305)
(overlookmotel)
- 8413175 linter: Move shared function from utils to rule (#6127)
(dalaoshu)
- ba9c372 linter: Make jest/vitest rule mapping more clear (#6273)
(camchenry)
- 82b8f21 linter: Add schemars and serde traits to AllowWarnDeny and
RuleCategories (#6119) (DonIsaac)
- ea908f7 linter: Consolidate file loading logic (#6130) (DonIsaac)
- db751f0 linter: Use regexp AST visitor in `no-control-regex` (#6129)
(camchenry)
- 3aa7e42 linter: Use RegExp AST visitor for `no-hex-escape` (#6117)
(camchenry)
- 9d5b44a linter: Use regex visitor in `no-regex-spaces` (#6063)
(camchenry)
- 0d44cf7 linter: Use regex visitor in `no-useless-escape` (#6062)
(camchenry)
- eeb8873 linter: Use regex visitor in `no-empty-character-class`
(#6058) (camchenry)

### Testing

- d883562 linter: Invalid `eslint/no-unused-vars` options (#6228)
(DonIsaac)

---------

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
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-linter Area - Linter
Projects
None yet
Development

Successfully merging this pull request may close these issues.

linter: no-useless-spread fixer clobbers code before span in Vue script block
3 participants