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(project): correctly ignore folders #2147

Merged
merged 4 commits into from
Mar 21, 2024
Merged

Conversation

ematipico
Copy link
Member

Summary

Fixes #2131

Maybe #2080 but I'll have to verify it.

Folders were ignored when one single feature was checked, which needed to be updated. Now folders are considered ignored only if ALL FEATURES are ignored for that folder/symbolic link

Test Plan

Added two test cases:

  • Format a folder that is ignored by the linter.
  • Check a folder that is ignored by the linter. It should show format diagnostics.

@github-actions github-actions bot added A-CLI Area: CLI A-Project Area: project A-Website Area: website A-Changelog Area: changelog labels Mar 21, 2024
@ematipico ematipico requested review from a team March 21, 2024 09:21
Copy link

netlify bot commented Mar 21, 2024

Deploy Preview for biomejs ready!

Name Link
🔨 Latest commit bb1ca3b
🔍 Latest deploy log https://app.netlify.com/sites/biomejs/deploys/65fc4bda2bd9bc0008d2d311
😎 Deploy Preview https://deploy-preview-2147--biomejs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 94 (🔴 down 6 from production)
Accessibility: 97 (no change from production)
Best Practices: 100 (no change from production)
SEO: 93 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify site configuration.

.with_formatter()
.with_linter()
.build(),
TraversalMode::Migrate { .. } => vec![],
Copy link
Member Author

Choose a reason for hiding this comment

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

Migrate should never reach this code path.

let mut ignored = false;
for feature in features {
// a path is ignored if it's ignored by all features
ignored &= self.is_ignored_by_feature_config(path, feature)
Copy link
Member Author

@ematipico ematipico Mar 21, 2024

Choose a reason for hiding this comment

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

I use a bitwise operation (bit AND) because a path is ignored only if ALL features ignore that path

@@ -2797,3 +2797,52 @@ fn use_literal_keys_should_emit_correct_ast_issue_266() {
result,
));
}

#[test]
fn should_show_diagnostics_for_linter_ignored_file_when_folder_is_ignored() {
Copy link
Contributor

Choose a reason for hiding this comment

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

As a user, I would expect the files inside any build dir to be ignored if I configured "ignore": ["**/build"] in the linter section. So it shouldn't show any diagnostics for the files inside any build dir.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah my bad, I poorly named the test file. Good catch. It should be formatter diagnostics, NOT linter diagnostics

Copy link
Contributor

Choose a reason for hiding this comment

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

But the snapshot shows the linter diagnostics are printed. Yeah you found it :)

@ematipico
Copy link
Member Author

Just noticed now that the diagnostics is showing linting diagnostics. Damn, the fix isn't enough lol

Copy link
Contributor

@Sec-ant Sec-ant left a comment

Choose a reason for hiding this comment

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

Thank you! Just left a few comments on naming things.

crates/biome_cli/src/execute/traverse.rs Outdated Show resolved Hide resolved
crates/biome_cli/tests/commands/check.rs Outdated Show resolved Hide resolved
crates/biome_cli/tests/commands/format.rs Outdated Show resolved Hide resolved
@ematipico ematipico requested a review from Sec-ant March 21, 2024 15:01
@github-actions github-actions bot added A-Formatter Area: formatter A-LSP Area: language server protocol labels Mar 21, 2024
@ematipico ematipico merged commit cd0bae1 into main Mar 21, 2024
19 checks passed
@ematipico ematipico deleted the fix/ignored-directories branch March 21, 2024 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Changelog Area: changelog A-CLI Area: CLI A-Formatter Area: formatter A-LSP Area: language server protocol A-Project Area: project A-Website Area: website
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🐛 Ignore pattern in linter feature wrongly applies to formatter
3 participants