-
-
Notifications
You must be signed in to change notification settings - Fork 951
feat(formatter): add oxfmt-ignore ignore comment support
#17916
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
Merged
graphite-app
merged 1 commit into
main
from
01-12-feat_formatter_add_oxfmt-ignore_ignore_comment_support
Jan 13, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| // This file copies from https://github.com/prettier/prettier/blob/main/tests/format/js/ignore/ignore.js, | ||
| // and replace all `oxfmt-ignore` to `oxfmt-ignore` to verify that oxfmt correctly ignores those comments. | ||
| function a() { | ||
| // oxfmt-ignore | ||
| var fnString = | ||
| '"' + this.USE + ' ' + this.STRICT + '";\n' + | ||
| this.filterPrefix() + | ||
| 'var fn=' + this.generateFunction('fn', 's,l,a,i') + | ||
| extra + | ||
| this.watchFns() + | ||
| 'return fn;'; | ||
|
|
||
| // oxfmt-ignore | ||
| const identity = Matrix.create( | ||
| 1, 0, 0, | ||
| 0, 1, 0, | ||
| 0, 0, 0 | ||
| ); | ||
|
|
||
| // Let's make sure that this comment doesn't interfere | ||
|
|
||
| // oxfmt-ignore | ||
| const commentsWithPrettierIgnore = { | ||
| "ewww": | ||
| "gross-formatting", | ||
| }; | ||
|
|
||
| function giveMeSome() { | ||
| a( a ); // oxfmt-ignore | ||
| // shouldn't I return something? :shrug: | ||
| } | ||
|
|
||
| // oxfmt-ignore | ||
| console.error( | ||
| 'In order to use ' + prompt + ', you need to configure a ' + | ||
| 'few environment variables to be able to commit to the ' + | ||
| 'repository. Follow those steps to get you setup:\n' + | ||
| '\n' + | ||
| 'Go to https://github.com/settings/tokens/new\n' + | ||
| ' - Fill "Token description" with "' + prompt + ' for ' + | ||
| repoSlug + '"\n' + | ||
| ' - Check "public_repo"\n' + | ||
| ' - Press "Generate Token"\n' + | ||
| '\n' + | ||
| 'In a different tab, go to https://travis-ci.org/' + | ||
| repoSlug + '/settings\n' + | ||
| ' - Make sure "Build only if .travis.yml is present" is ON\n' + | ||
| ' - Fill "Name" with "GITHUB_USER" and "Value" with the name of the ' + | ||
| 'account you generated the token with. Press "Add"\n' + | ||
| '\n' + | ||
| 'Once this is done, commit anything to the repository to restart ' + | ||
| 'Travis and it should work :)' | ||
| ); | ||
| } | ||
|
|
||
| const response = { | ||
| // oxfmt-ignore | ||
| '_text': 'Turn on the lights', | ||
| intent: 'lights', | ||
| }; |
195 changes: 195 additions & 0 deletions
195
crates/oxc_formatter/tests/fixtures/js/ignore/oxfmt.js.snap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,195 @@ | ||
| --- | ||
| source: crates/oxc_formatter/tests/fixtures/mod.rs | ||
| --- | ||
| ==================== Input ==================== | ||
| // This file copies from https://github.com/prettier/prettier/blob/main/tests/format/js/ignore/ignore.js, | ||
| // and replace all `oxfmt-ignore` to `oxfmt-ignore` to verify that oxfmt correctly ignores those comments. | ||
| function a() { | ||
| // oxfmt-ignore | ||
| var fnString = | ||
| '"' + this.USE + ' ' + this.STRICT + '";\n' + | ||
| this.filterPrefix() + | ||
| 'var fn=' + this.generateFunction('fn', 's,l,a,i') + | ||
| extra + | ||
| this.watchFns() + | ||
| 'return fn;'; | ||
|
|
||
| // oxfmt-ignore | ||
| const identity = Matrix.create( | ||
| 1, 0, 0, | ||
| 0, 1, 0, | ||
| 0, 0, 0 | ||
| ); | ||
|
|
||
| // Let's make sure that this comment doesn't interfere | ||
|
|
||
| // oxfmt-ignore | ||
| const commentsWithPrettierIgnore = { | ||
| "ewww": | ||
| "gross-formatting", | ||
| }; | ||
|
|
||
| function giveMeSome() { | ||
| a( a ); // oxfmt-ignore | ||
| // shouldn't I return something? :shrug: | ||
| } | ||
|
|
||
| // oxfmt-ignore | ||
| console.error( | ||
| 'In order to use ' + prompt + ', you need to configure a ' + | ||
| 'few environment variables to be able to commit to the ' + | ||
| 'repository. Follow those steps to get you setup:\n' + | ||
| '\n' + | ||
| 'Go to https://github.com/settings/tokens/new\n' + | ||
| ' - Fill "Token description" with "' + prompt + ' for ' + | ||
| repoSlug + '"\n' + | ||
| ' - Check "public_repo"\n' + | ||
| ' - Press "Generate Token"\n' + | ||
| '\n' + | ||
| 'In a different tab, go to https://travis-ci.org/' + | ||
| repoSlug + '/settings\n' + | ||
| ' - Make sure "Build only if .travis.yml is present" is ON\n' + | ||
| ' - Fill "Name" with "GITHUB_USER" and "Value" with the name of the ' + | ||
| 'account you generated the token with. Press "Add"\n' + | ||
| '\n' + | ||
| 'Once this is done, commit anything to the repository to restart ' + | ||
| 'Travis and it should work :)' | ||
| ); | ||
| } | ||
|
|
||
| const response = { | ||
| // oxfmt-ignore | ||
| '_text': 'Turn on the lights', | ||
| intent: 'lights', | ||
| }; | ||
|
|
||
| ==================== Output ==================== | ||
| ------------------ | ||
| { printWidth: 80 } | ||
| ------------------ | ||
| // This file copies from https://github.com/prettier/prettier/blob/main/tests/format/js/ignore/ignore.js, | ||
| // and replace all `oxfmt-ignore` to `oxfmt-ignore` to verify that oxfmt correctly ignores those comments. | ||
| function a() { | ||
| // oxfmt-ignore | ||
| var fnString = | ||
| '"' + this.USE + ' ' + this.STRICT + '";\n' + | ||
| this.filterPrefix() + | ||
| 'var fn=' + this.generateFunction('fn', 's,l,a,i') + | ||
| extra + | ||
| this.watchFns() + | ||
| 'return fn;'; | ||
|
|
||
| // oxfmt-ignore | ||
| const identity = Matrix.create( | ||
| 1, 0, 0, | ||
| 0, 1, 0, | ||
| 0, 0, 0 | ||
| ); | ||
|
|
||
| // Let's make sure that this comment doesn't interfere | ||
|
|
||
| // oxfmt-ignore | ||
| const commentsWithPrettierIgnore = { | ||
| "ewww": | ||
| "gross-formatting", | ||
| }; | ||
|
|
||
| function giveMeSome() { | ||
| a(a); // oxfmt-ignore | ||
| // shouldn't I return something? :shrug: | ||
| } | ||
|
|
||
| // oxfmt-ignore | ||
| console.error( | ||
| 'In order to use ' + prompt + ', you need to configure a ' + | ||
| 'few environment variables to be able to commit to the ' + | ||
| 'repository. Follow those steps to get you setup:\n' + | ||
| '\n' + | ||
| 'Go to https://github.com/settings/tokens/new\n' + | ||
| ' - Fill "Token description" with "' + prompt + ' for ' + | ||
| repoSlug + '"\n' + | ||
| ' - Check "public_repo"\n' + | ||
| ' - Press "Generate Token"\n' + | ||
| '\n' + | ||
| 'In a different tab, go to https://travis-ci.org/' + | ||
| repoSlug + '/settings\n' + | ||
| ' - Make sure "Build only if .travis.yml is present" is ON\n' + | ||
| ' - Fill "Name" with "GITHUB_USER" and "Value" with the name of the ' + | ||
| 'account you generated the token with. Press "Add"\n' + | ||
| '\n' + | ||
| 'Once this is done, commit anything to the repository to restart ' + | ||
| 'Travis and it should work :)' | ||
| ); | ||
| } | ||
|
|
||
| const response = { | ||
| // oxfmt-ignore | ||
| '_text': 'Turn on the lights', | ||
| intent: "lights", | ||
| }; | ||
|
|
||
| ------------------- | ||
| { printWidth: 100 } | ||
| ------------------- | ||
| // This file copies from https://github.com/prettier/prettier/blob/main/tests/format/js/ignore/ignore.js, | ||
| // and replace all `oxfmt-ignore` to `oxfmt-ignore` to verify that oxfmt correctly ignores those comments. | ||
| function a() { | ||
| // oxfmt-ignore | ||
| var fnString = | ||
| '"' + this.USE + ' ' + this.STRICT + '";\n' + | ||
| this.filterPrefix() + | ||
| 'var fn=' + this.generateFunction('fn', 's,l,a,i') + | ||
| extra + | ||
| this.watchFns() + | ||
| 'return fn;'; | ||
|
|
||
| // oxfmt-ignore | ||
| const identity = Matrix.create( | ||
| 1, 0, 0, | ||
| 0, 1, 0, | ||
| 0, 0, 0 | ||
| ); | ||
|
|
||
| // Let's make sure that this comment doesn't interfere | ||
|
|
||
| // oxfmt-ignore | ||
| const commentsWithPrettierIgnore = { | ||
| "ewww": | ||
| "gross-formatting", | ||
| }; | ||
|
|
||
| function giveMeSome() { | ||
| a(a); // oxfmt-ignore | ||
| // shouldn't I return something? :shrug: | ||
| } | ||
|
|
||
| // oxfmt-ignore | ||
| console.error( | ||
| 'In order to use ' + prompt + ', you need to configure a ' + | ||
| 'few environment variables to be able to commit to the ' + | ||
| 'repository. Follow those steps to get you setup:\n' + | ||
| '\n' + | ||
| 'Go to https://github.com/settings/tokens/new\n' + | ||
| ' - Fill "Token description" with "' + prompt + ' for ' + | ||
| repoSlug + '"\n' + | ||
| ' - Check "public_repo"\n' + | ||
| ' - Press "Generate Token"\n' + | ||
| '\n' + | ||
| 'In a different tab, go to https://travis-ci.org/' + | ||
| repoSlug + '/settings\n' + | ||
| ' - Make sure "Build only if .travis.yml is present" is ON\n' + | ||
| ' - Fill "Name" with "GITHUB_USER" and "Value" with the name of the ' + | ||
| 'account you generated the token with. Press "Add"\n' + | ||
| '\n' + | ||
| 'Once this is done, commit anything to the repository to restart ' + | ||
| 'Travis and it should work :)' | ||
| ); | ||
| } | ||
|
|
||
| const response = { | ||
| // oxfmt-ignore | ||
| '_text': 'Turn on the lights', | ||
| intent: "lights", | ||
| }; | ||
|
|
||
| ===================== End ===================== |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.