-
-
Notifications
You must be signed in to change notification settings - Fork 498
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
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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 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 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 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 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 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 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
61 changes: 61 additions & 0 deletions
61
...main_commands_check/should_show_diagnostics_for_formatter_when_linter_ignores_folder.snap
This file contains 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,61 @@ | ||
--- | ||
source: crates/biome_cli/tests/snap_test.rs | ||
expression: content | ||
--- | ||
## `biome.json` | ||
|
||
```json | ||
{ | ||
"$schema": "https://biomejs.dev/schemas/1.6.1/schema.json", | ||
"organizeImports": { | ||
"enabled": true | ||
}, | ||
"linter": { | ||
"ignore": ["build/**"], | ||
"enabled": true, | ||
"rules": { | ||
"recommended": true | ||
} | ||
} | ||
} | ||
``` | ||
|
||
## `build/file.js` | ||
|
||
```js | ||
|
||
value['optimizelyService'] = optimizelyService; | ||
|
||
``` | ||
|
||
# Termination Message | ||
|
||
```block | ||
check ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ | ||
|
||
× Some errors were emitted while running checks. | ||
|
||
|
||
|
||
``` | ||
|
||
# Emitted Messages | ||
|
||
```block | ||
build/file.js format ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ | ||
|
||
i Formatter would have printed the following content: | ||
|
||
1 │ - | ||
2 │ - → value['optimizelyService']·=·optimizelyService; | ||
3 │ - → → | ||
1 │ + value["optimizelyService"]·=·optimizelyService; | ||
2 │ + | ||
|
||
|
||
``` | ||
|
||
```block | ||
Checked 1 file in <TIME>. No fixes needed. | ||
Found 2 errors. | ||
``` |
34 changes: 34 additions & 0 deletions
34
...tests/snapshots/main_commands_format/should_fix_file_ignored_by_linter_inside_folder.snap
This file contains 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,34 @@ | ||
--- | ||
source: crates/biome_cli/tests/snap_test.rs | ||
expression: content | ||
--- | ||
## `biome.json` | ||
|
||
```json | ||
{ | ||
"$schema": "https://biomejs.dev/schemas/1.6.1/schema.json", | ||
"organizeImports": { | ||
"enabled": true | ||
}, | ||
"linter": { | ||
"ignore": ["**/build"], | ||
"enabled": true, | ||
"rules": { | ||
"recommended": true | ||
} | ||
} | ||
} | ||
``` | ||
|
||
## `build/file.js` | ||
|
||
```js | ||
value["optimizelyService"] = optimizelyService; | ||
|
||
``` | ||
|
||
# Emitted Messages | ||
|
||
```block | ||
Formatted 1 file in <TIME>. Fixed 1 file. | ||
``` |
This file contains 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 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 |
---|---|---|
|
@@ -243,14 +243,22 @@ impl WorkspaceServer { | |
|
||
/// Check whether a file is ignored in the top-level config `files.ignore`/`files.include` | ||
/// or in the feature `ignore`/`include` | ||
fn is_ignored(&self, path: &Path, feature: FeatureName) -> bool { | ||
fn is_ignored(&self, path: &Path, features: Vec<FeatureName>) -> bool { | ||
let file_name = path.file_name().and_then(|s| s.to_str()); | ||
let ignored_by_features = { | ||
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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
} | ||
ignored | ||
}; | ||
// Never ignore Biome's config file regardless `include`/`ignore` | ||
(file_name != Some(ConfigName::biome_json()) || file_name != Some(ConfigName::biome_jsonc())) && | ||
// Apply top-level `include`/`ignore` | ||
(self.is_ignored_by_top_level_config(path) || | ||
// Apply feature-level `include`/`ignore` | ||
self.is_ignored_by_feature_config(path, feature)) | ||
ignored_by_features) | ||
} | ||
|
||
/// Check whether a file is ignored in the top-level config `files.ignore`/`files.include` | ||
|
@@ -363,7 +371,7 @@ impl Workspace for WorkspaceServer { | |
} | ||
} | ||
fn is_path_ignored(&self, params: IsPathIgnoredParams) -> Result<bool, WorkspaceError> { | ||
Ok(self.is_ignored(params.biome_path.as_path(), params.feature)) | ||
Ok(self.is_ignored(params.biome_path.as_path(), params.features)) | ||
} | ||
/// Update the global settings for this workspace | ||
/// | ||
|
This file contains 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
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.
There was a problem hiding this comment.
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.