Skip to content

Commit e168494

Browse files
ematipicoNetaildyc3
authored
feat(linter): add rule noUntrustedLicenses (#9474)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Netail <11695769+Netail@users.noreply.github.com> Co-authored-by: dyc3 <1808807+dyc3@users.noreply.github.com>
1 parent cddaa44 commit e168494

63 files changed

Lines changed: 1725 additions & 5 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.changeset/forty-women-move.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
"@biomejs/biome": patch
3+
---
4+
5+
Added the new nursery rule [`noUntrustedLicenses`](https://biomejs.dev/linter/rules/no-untrusted-licenses/). This rule disallows dependencies that ship with invalid licenses or licenses that don't meet the criteria of your project/organisation.
6+
7+
The rule has the following options:
8+
- `allow`: a list of licenses that can be allowed. Useful to bypass possible invalid licenses from downstream dependencies.
9+
- `deny`: a list of licenses that should trigger the rule. Useful to deny licenses that don't fit your project/organisation.
10+
When both `deny` and `allow` are provided, `deny` takes precedence.
11+
- `requireOsiApproved`: whether the licenses need to be approved by the [Open Source Initiative](https://opensource.org/).
12+
- `requireFsfLibre`: whether the licenses need to be approved by the [Free Software Foundation](https://www.gnu.org/licenses/license-list.html).

Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/biome_configuration/src/analyzer/linter/rules.rs

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/biome_configuration/src/generated/linter_options_check.rs

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/biome_diagnostics_categories/src/categories.rs

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/biome_json_analyze/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ biome_deserialize = { workspace = true }
2525
biome_diagnostics = { workspace = true }
2626
biome_json_factory = { workspace = true }
2727
biome_json_syntax = { workspace = true }
28+
biome_package = { workspace = true }
29+
biome_project_layout = { workspace = true }
2830
biome_rowan = { workspace = true }
2931
biome_rule_options = { workspace = true }
3032
biome_string_case = { workspace = true }

crates/biome_json_analyze/benches/json_analyzer.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ fn bench_analyzer(criterion: &mut Criterion) {
6464
let json_services = JsonAnalyzeServices {
6565
file_source,
6666
configuration_provider: None,
67+
project_layout: None,
6768
};
6869

6970
biome_json_analyze::analyze(

crates/biome_json_analyze/src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use biome_analyze::{
1919
};
2020
use biome_diagnostics::Error;
2121
use biome_json_syntax::{JsonFileSource, JsonLanguage, TextRange};
22+
use biome_project_layout::ProjectLayout;
2223
use biome_suppression::{SuppressionDiagnostic, parse_suppression_comment};
2324
use std::ops::Deref;
2425
use std::sync::{Arc, LazyLock};
@@ -37,6 +38,9 @@ pub struct JsonAnalyzeServices {
3738

3839
/// The source file
3940
pub file_source: JsonFileSource,
41+
42+
/// The project layout, providing access to package manifests.
43+
pub project_layout: Option<Arc<ProjectLayout>>,
4044
}
4145

4246
/// Run the analyzer on the provided `root`: this process will use the given `filter`
@@ -150,6 +154,7 @@ where
150154

151155
services.insert_service(json_services.configuration_provider);
152156
services.insert_service(json_services.file_source);
157+
services.insert_service(json_services.project_layout);
153158

154159
(
155160
analyzer.run(biome_analyze::AnalyzerContext {
@@ -202,6 +207,7 @@ mod tests {
202207
let services = JsonAnalyzeServices {
203208
file_source: JsonFileSource::json(),
204209
configuration_provider: None,
210+
project_layout: None,
205211
};
206212
analyze(
207213
&parsed.tree(),

0 commit comments

Comments
 (0)