Skip to content

Commit

Permalink
feat(lint): add noProcessEnv (#3825)
Browse files Browse the repository at this point in the history
  • Loading branch information
unvalley authored Sep 14, 2024
1 parent ce7d090 commit f6d61b0
Show file tree
Hide file tree
Showing 26 changed files with 294 additions and 94 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ our [guidelines for writing a good changelog entry](https://github.com/biomejs/b

### Linter

#### New Features

- Add [nursery/noProcessEnv](https://biomejs.dev/linter/rules/no-process-env/). Contributed by @unvalley

#### Bug fixes

- [useSemanticElements](https://biomejs.dev/linter/rules/use-semantic-elements/): ignore `alert` and `alertdialog` roles ([3858](https://github.com/biomejs/biome/issues/3858)). Controbuted by @Conaclos
Expand Down
6 changes: 6 additions & 0 deletions crates/biome_analyze/src/rule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ pub enum RuleSource {
EslintMysticatea(&'static str),
/// Rules from [Eslint Plugin Barrel Files](https://github.com/thepassle/eslint-plugin-barrel-files)
EslintBarrelFiles(&'static str),
/// Rules from [Eslint Plugin N](https://github.com/eslint-community/eslint-plugin-n)
EslintN(&'static str),
/// Rules from [Stylelint](https://github.com/stylelint/stylelint)
Stylelint(&'static str),
}
Expand Down Expand Up @@ -152,6 +154,7 @@ impl std::fmt::Display for RuleSource {
Self::EslintUnusedImports(_) => write!(f, "eslint-plugin-unused-imports"),
Self::EslintMysticatea(_) => write!(f, "@mysticatea/eslint-plugin"),
Self::EslintBarrelFiles(_) => write!(f, "eslint-plugin-barrel-files"),
Self::EslintN(_) => write!(f, "eslint-plugin-n"),
Self::Stylelint(_) => write!(f, "Stylelint"),
}
}
Expand Down Expand Up @@ -199,6 +202,7 @@ impl RuleSource {
| Self::EslintUnusedImports(rule_name)
| Self::EslintMysticatea(rule_name)
| Self::EslintBarrelFiles(rule_name)
| Self::EslintN(rule_name)
| Self::Stylelint(rule_name) => rule_name,
}
}
Expand All @@ -221,6 +225,7 @@ impl RuleSource {
Self::EslintUnusedImports(rule_name) => format!("unused-imports/{rule_name}"),
Self::EslintMysticatea(rule_name) => format!("@mysticatea/{rule_name}"),
Self::EslintBarrelFiles(rule_name) => format!("barrel-files/{rule_name}"),
Self::EslintN(rule_name) => format!("n/{rule_name}"),
Self::Stylelint(rule_name) => format!("stylelint/{rule_name}"),
}
}
Expand All @@ -244,6 +249,7 @@ impl RuleSource {
Self::EslintUnusedImports(rule_name) => format!("https://github.com/sweepline/eslint-plugin-unused-imports/blob/master/docs/rules/{rule_name}.md"),
Self::EslintMysticatea(rule_name) => format!("https://github.com/mysticatea/eslint-plugin/blob/master/docs/rules/{rule_name}.md"),
Self::EslintBarrelFiles(rule_name) => format!("https://github.com/thepassle/eslint-plugin-barrel-files/blob/main/docs/rules/{rule_name}.md"),
Self::EslintN(rule_name) => format!("https://github.com/eslint-community/eslint-plugin-n/blob/master/docs/rules/{rule_name}.md"),
Self::Stylelint(rule_name) => format!("https://github.com/stylelint/stylelint/blob/main/lib/rules/{rule_name}/README.md"),
}
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ biome.json:7:9 deserialize ━━━━━━━━━━━━━━━━━
- noEnum
- noExportedImports
- noIrregularWhitespace
- noProcessEnv
- noRestrictedImports
- noRestrictedTypes
- noSecrets
Expand Down
103 changes: 61 additions & 42 deletions crates/biome_configuration/src/analyzer/linter/rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3301,6 +3301,9 @@ pub struct Nursery {
#[serde(skip_serializing_if = "Option::is_none")]
pub no_irregular_whitespace:
Option<RuleConfiguration<biome_css_analyze::options::NoIrregularWhitespace>>,
#[doc = "Disallow the use of process.env."]
#[serde(skip_serializing_if = "Option::is_none")]
pub no_process_env: Option<RuleConfiguration<biome_js_analyze::options::NoProcessEnv>>,
#[doc = "Disallow specified modules when loaded by import or require."]
#[serde(skip_serializing_if = "Option::is_none")]
pub no_restricted_imports:
Expand Down Expand Up @@ -3399,6 +3402,7 @@ impl Nursery {
"noEnum",
"noExportedImports",
"noIrregularWhitespace",
"noProcessEnv",
"noRestrictedImports",
"noRestrictedTypes",
"noSecrets",
Expand Down Expand Up @@ -3435,13 +3439,13 @@ impl Nursery {
RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[1]),
RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[2]),
RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[3]),
RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[13]),
RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[14]),
RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[15]),
RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[18]),
RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[20]),
RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[16]),
RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[19]),
RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[21]),
RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[24]),
RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[22]),
RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[25]),
];
const ALL_RULES_AS_FILTERS: &'static [RuleFilter<'static>] = &[
RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[0]),
Expand Down Expand Up @@ -3471,6 +3475,7 @@ impl Nursery {
RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[24]),
RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[25]),
RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[26]),
RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[27]),
];
#[doc = r" Retrieves the recommended rules"]
pub(crate) fn is_recommended_true(&self) -> bool {
Expand Down Expand Up @@ -3527,101 +3532,106 @@ impl Nursery {
index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[7]));
}
}
if let Some(rule) = self.no_restricted_imports.as_ref() {
if let Some(rule) = self.no_process_env.as_ref() {
if rule.is_enabled() {
index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[8]));
}
}
if let Some(rule) = self.no_restricted_types.as_ref() {
if let Some(rule) = self.no_restricted_imports.as_ref() {
if rule.is_enabled() {
index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[9]));
}
}
if let Some(rule) = self.no_secrets.as_ref() {
if let Some(rule) = self.no_restricted_types.as_ref() {
if rule.is_enabled() {
index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[10]));
}
}
if let Some(rule) = self.no_static_element_interactions.as_ref() {
if let Some(rule) = self.no_secrets.as_ref() {
if rule.is_enabled() {
index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[11]));
}
}
if let Some(rule) = self.no_substr.as_ref() {
if let Some(rule) = self.no_static_element_interactions.as_ref() {
if rule.is_enabled() {
index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[12]));
}
}
if let Some(rule) = self.no_unknown_pseudo_class.as_ref() {
if let Some(rule) = self.no_substr.as_ref() {
if rule.is_enabled() {
index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[13]));
}
}
if let Some(rule) = self.no_unknown_pseudo_element.as_ref() {
if let Some(rule) = self.no_unknown_pseudo_class.as_ref() {
if rule.is_enabled() {
index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[14]));
}
}
if let Some(rule) = self.no_useless_escape_in_regex.as_ref() {
if let Some(rule) = self.no_unknown_pseudo_element.as_ref() {
if rule.is_enabled() {
index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[15]));
}
}
if let Some(rule) = self.no_value_at_rule.as_ref() {
if let Some(rule) = self.no_useless_escape_in_regex.as_ref() {
if rule.is_enabled() {
index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[16]));
}
}
if let Some(rule) = self.use_adjacent_overload_signatures.as_ref() {
if let Some(rule) = self.no_value_at_rule.as_ref() {
if rule.is_enabled() {
index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[17]));
}
}
if let Some(rule) = self.use_aria_props_supported_by_role.as_ref() {
if let Some(rule) = self.use_adjacent_overload_signatures.as_ref() {
if rule.is_enabled() {
index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[18]));
}
}
if let Some(rule) = self.use_consistent_curly_braces.as_ref() {
if let Some(rule) = self.use_aria_props_supported_by_role.as_ref() {
if rule.is_enabled() {
index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[19]));
}
}
if let Some(rule) = self.use_consistent_member_accessibility.as_ref() {
if let Some(rule) = self.use_consistent_curly_braces.as_ref() {
if rule.is_enabled() {
index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[20]));
}
}
if let Some(rule) = self.use_deprecated_reason.as_ref() {
if let Some(rule) = self.use_consistent_member_accessibility.as_ref() {
if rule.is_enabled() {
index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[21]));
}
}
if let Some(rule) = self.use_import_restrictions.as_ref() {
if let Some(rule) = self.use_deprecated_reason.as_ref() {
if rule.is_enabled() {
index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[22]));
}
}
if let Some(rule) = self.use_sorted_classes.as_ref() {
if let Some(rule) = self.use_import_restrictions.as_ref() {
if rule.is_enabled() {
index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[23]));
}
}
if let Some(rule) = self.use_strict_mode.as_ref() {
if let Some(rule) = self.use_sorted_classes.as_ref() {
if rule.is_enabled() {
index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[24]));
}
}
if let Some(rule) = self.use_trim_start_end.as_ref() {
if let Some(rule) = self.use_strict_mode.as_ref() {
if rule.is_enabled() {
index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[25]));
}
}
if let Some(rule) = self.use_valid_autocomplete.as_ref() {
if let Some(rule) = self.use_trim_start_end.as_ref() {
if rule.is_enabled() {
index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[26]));
}
}
if let Some(rule) = self.use_valid_autocomplete.as_ref() {
if rule.is_enabled() {
index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[27]));
}
}
index_set
}
pub(crate) fn get_disabled_rules(&self) -> FxHashSet<RuleFilter<'static>> {
Expand Down Expand Up @@ -3666,101 +3676,106 @@ impl Nursery {
index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[7]));
}
}
if let Some(rule) = self.no_restricted_imports.as_ref() {
if let Some(rule) = self.no_process_env.as_ref() {
if rule.is_disabled() {
index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[8]));
}
}
if let Some(rule) = self.no_restricted_types.as_ref() {
if let Some(rule) = self.no_restricted_imports.as_ref() {
if rule.is_disabled() {
index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[9]));
}
}
if let Some(rule) = self.no_secrets.as_ref() {
if let Some(rule) = self.no_restricted_types.as_ref() {
if rule.is_disabled() {
index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[10]));
}
}
if let Some(rule) = self.no_static_element_interactions.as_ref() {
if let Some(rule) = self.no_secrets.as_ref() {
if rule.is_disabled() {
index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[11]));
}
}
if let Some(rule) = self.no_substr.as_ref() {
if let Some(rule) = self.no_static_element_interactions.as_ref() {
if rule.is_disabled() {
index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[12]));
}
}
if let Some(rule) = self.no_unknown_pseudo_class.as_ref() {
if let Some(rule) = self.no_substr.as_ref() {
if rule.is_disabled() {
index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[13]));
}
}
if let Some(rule) = self.no_unknown_pseudo_element.as_ref() {
if let Some(rule) = self.no_unknown_pseudo_class.as_ref() {
if rule.is_disabled() {
index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[14]));
}
}
if let Some(rule) = self.no_useless_escape_in_regex.as_ref() {
if let Some(rule) = self.no_unknown_pseudo_element.as_ref() {
if rule.is_disabled() {
index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[15]));
}
}
if let Some(rule) = self.no_value_at_rule.as_ref() {
if let Some(rule) = self.no_useless_escape_in_regex.as_ref() {
if rule.is_disabled() {
index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[16]));
}
}
if let Some(rule) = self.use_adjacent_overload_signatures.as_ref() {
if let Some(rule) = self.no_value_at_rule.as_ref() {
if rule.is_disabled() {
index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[17]));
}
}
if let Some(rule) = self.use_aria_props_supported_by_role.as_ref() {
if let Some(rule) = self.use_adjacent_overload_signatures.as_ref() {
if rule.is_disabled() {
index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[18]));
}
}
if let Some(rule) = self.use_consistent_curly_braces.as_ref() {
if let Some(rule) = self.use_aria_props_supported_by_role.as_ref() {
if rule.is_disabled() {
index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[19]));
}
}
if let Some(rule) = self.use_consistent_member_accessibility.as_ref() {
if let Some(rule) = self.use_consistent_curly_braces.as_ref() {
if rule.is_disabled() {
index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[20]));
}
}
if let Some(rule) = self.use_deprecated_reason.as_ref() {
if let Some(rule) = self.use_consistent_member_accessibility.as_ref() {
if rule.is_disabled() {
index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[21]));
}
}
if let Some(rule) = self.use_import_restrictions.as_ref() {
if let Some(rule) = self.use_deprecated_reason.as_ref() {
if rule.is_disabled() {
index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[22]));
}
}
if let Some(rule) = self.use_sorted_classes.as_ref() {
if let Some(rule) = self.use_import_restrictions.as_ref() {
if rule.is_disabled() {
index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[23]));
}
}
if let Some(rule) = self.use_strict_mode.as_ref() {
if let Some(rule) = self.use_sorted_classes.as_ref() {
if rule.is_disabled() {
index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[24]));
}
}
if let Some(rule) = self.use_trim_start_end.as_ref() {
if let Some(rule) = self.use_strict_mode.as_ref() {
if rule.is_disabled() {
index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[25]));
}
}
if let Some(rule) = self.use_valid_autocomplete.as_ref() {
if let Some(rule) = self.use_trim_start_end.as_ref() {
if rule.is_disabled() {
index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[26]));
}
}
if let Some(rule) = self.use_valid_autocomplete.as_ref() {
if rule.is_disabled() {
index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[27]));
}
}
index_set
}
#[doc = r" Checks if, given a rule name, matches one of the rules contained in this category"]
Expand Down Expand Up @@ -3829,6 +3844,10 @@ impl Nursery {
.no_irregular_whitespace
.as_ref()
.map(|conf| (conf.level(), conf.get_options())),
"noProcessEnv" => self
.no_process_env
.as_ref()
.map(|conf| (conf.level(), conf.get_options())),
"noRestrictedImports" => self
.no_restricted_imports
.as_ref()
Expand Down
2 changes: 2 additions & 0 deletions crates/biome_diagnostics_categories/src/categories.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ define_categories! {
"lint/nursery/noInvalidPositionAtImportRule": "https://biomejs.dev/linter/rules/no-invalid-position-at-import-rule",
"lint/nursery/noIrregularWhitespace": "https://biomejs.dev/linter/rules/no-irregular-whitespace",
"lint/nursery/noMissingGenericFamilyKeyword": "https://biomejs.dev/linter/rules/no-missing-generic-family-keyword",
"lint/nursery/noProcessEnv": "https://biomejs.dev/linter/rules/no-process-env",
"lint/nursery/noReactSpecificProps": "https://biomejs.dev/linter/rules/no-react-specific-props",
"lint/nursery/noRestrictedImports": "https://biomejs.dev/linter/rules/no-restricted-imports",
"lint/nursery/noRestrictedTypes": "https://biomejs.dev/linter/rules/no-restricted-types",
"lint/nursery/noSecrets": "https://biomejs.dev/linter/rules/no-secrets",
Expand Down
Loading

0 comments on commit f6d61b0

Please sign in to comment.