summaryrefslogtreecommitdiff
path: root/cli/tools
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2024-03-25 18:20:15 -0400
committerGitHub <noreply@github.com>2024-03-25 18:20:15 -0400
commit0346e597bf2d95f5bfce20d3aadf697e9ee45fe4 (patch)
tree68acec662839ebc5f61cd9f5377b0277dac9ee42 /cli/tools
parentfb1aa4e6d2339f0a62aa33e19ea403c059b38d43 (diff)
feat(lint): automatically opt-in packages to `jsr` lint tag (#23072)
This automatically opts packages (deno.json's with a name, version, and exports field) into the "jsr" lint tag.
Diffstat (limited to 'cli/tools')
-rw-r--r--cli/tools/lint/mod.rs69
1 files changed, 37 insertions, 32 deletions
diff --git a/cli/tools/lint/mod.rs b/cli/tools/lint/mod.rs
index bf96eca06..cb282663c 100644
--- a/cli/tools/lint/mod.rs
+++ b/cli/tools/lint/mod.rs
@@ -878,39 +878,44 @@ pub fn get_configured_rules(
let implicit_no_slow_types = maybe_config_file
.map(|c| c.is_package() || !c.json.workspaces.is_empty())
.unwrap_or(false);
- if rules.tags.is_none() && rules.include.is_none() && rules.exclude.is_none()
- {
- ConfiguredRules {
- rules: rules::get_recommended_rules(),
- no_slow_types: implicit_no_slow_types,
- }
- } else {
- let no_slow_types = implicit_no_slow_types
- && !rules
- .exclude
- .as_ref()
- .map(|exclude| exclude.iter().any(|i| i == NO_SLOW_TYPES_NAME))
- .unwrap_or(false);
- let rules = rules::get_filtered_rules(
- rules.tags.or_else(|| Some(vec!["recommended".to_string()])),
- rules.exclude.map(|exclude| {
- exclude
- .into_iter()
- .filter(|c| c != NO_SLOW_TYPES_NAME)
- .collect()
- }),
- rules.include.map(|include| {
- include
- .into_iter()
- .filter(|c| c != NO_SLOW_TYPES_NAME)
- .collect()
- }),
- );
- ConfiguredRules {
- rules,
- no_slow_types,
- }
+ let no_slow_types = implicit_no_slow_types
+ && !rules
+ .exclude
+ .as_ref()
+ .map(|exclude| exclude.iter().any(|i| i == NO_SLOW_TYPES_NAME))
+ .unwrap_or(false);
+ let rules = rules::get_filtered_rules(
+ rules
+ .tags
+ .or_else(|| Some(get_default_tags(maybe_config_file))),
+ rules.exclude.map(|exclude| {
+ exclude
+ .into_iter()
+ .filter(|c| c != NO_SLOW_TYPES_NAME)
+ .collect()
+ }),
+ rules.include.map(|include| {
+ include
+ .into_iter()
+ .filter(|c| c != NO_SLOW_TYPES_NAME)
+ .collect()
+ }),
+ );
+ ConfiguredRules {
+ rules,
+ no_slow_types,
+ }
+}
+
+fn get_default_tags(
+ maybe_config_file: Option<&deno_config::ConfigFile>,
+) -> Vec<String> {
+ let mut tags = Vec::with_capacity(2);
+ tags.push("recommended".to_string());
+ if maybe_config_file.map(|c| c.is_package()).unwrap_or(false) {
+ tags.push("jsr".to_string());
}
+ tags
}
#[cfg(test)]