From e1851e205fc267f0d80242806bb7289ee3746785 Mon Sep 17 00:00:00 2001 From: togami <62130798+togami2864@users.noreply.github.com> Date: Tue, 17 Sep 2024 23:04:46 +0900 Subject: [PATCH] feat(linter): add noMissingVarFunction (#3779) Co-authored-by: Emanuele Stoppa --- CHANGELOG.md | 4 + crates/biome_cli/tests/commands/lint.rs | 2 +- .../no_unused_dependencies.snap | 58 ++-- .../src/analyzer/linter/rules.rs | 110 +++++--- crates/biome_css_analyze/src/lint/nursery.rs | 2 + .../lint/nursery/no_missing_var_function.rs | 247 ++++++++++++++++ crates/biome_css_analyze/src/options.rs | 2 + .../nursery/noMissingVarFunction/invalid.css | 69 +++++ .../noMissingVarFunction/invalid.css.snap | 265 ++++++++++++++++++ .../nursery/noMissingVarFunction/valid.css | 68 +++++ .../noMissingVarFunction/valid.css.snap | 76 +++++ .../src/categories.rs | 7 +- .../@biomejs/backend-jsonrpc/src/workspace.ts | 11 +- .../@biomejs/biome/configuration_schema.json | 7 + 14 files changed, 835 insertions(+), 93 deletions(-) create mode 100644 crates/biome_css_analyze/src/lint/nursery/no_missing_var_function.rs create mode 100644 crates/biome_css_analyze/tests/specs/nursery/noMissingVarFunction/invalid.css create mode 100644 crates/biome_css_analyze/tests/specs/nursery/noMissingVarFunction/invalid.css.snap create mode 100644 crates/biome_css_analyze/tests/specs/nursery/noMissingVarFunction/valid.css create mode 100644 crates/biome_css_analyze/tests/specs/nursery/noMissingVarFunction/valid.css.snap diff --git a/CHANGELOG.md b/CHANGELOG.md index 7739124eed5e..80a15c009a0e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,10 @@ our [guidelines for writing a good changelog entry](https://github.com/biomejs/b ### Linter +#### New features + +- Add [nursery/noMissingVarFunction](https://biomejs.dev/linter/rules/no-missing-var-function). Contributed by @michellocana + ### Parser #### Bug fixes diff --git a/crates/biome_cli/tests/commands/lint.rs b/crates/biome_cli/tests/commands/lint.rs index 2d94067b0a9d..fe207e43d4b9 100644 --- a/crates/biome_cli/tests/commands/lint.rs +++ b/crates/biome_cli/tests/commands/lint.rs @@ -3266,7 +3266,7 @@ fn no_unused_dependencies() { "enabled": true, "rules": { "all": false, - "nursery": { + "correctness": { "noUndeclaredDependencies": "error" } } diff --git a/crates/biome_cli/tests/snapshots/main_commands_lint/no_unused_dependencies.snap b/crates/biome_cli/tests/snapshots/main_commands_lint/no_unused_dependencies.snap index 9b737233f1b8..d88b03abcf3b 100644 --- a/crates/biome_cli/tests/snapshots/main_commands_lint/no_unused_dependencies.snap +++ b/crates/biome_cli/tests/snapshots/main_commands_lint/no_unused_dependencies.snap @@ -10,7 +10,7 @@ expression: content "enabled": true, "rules": { "all": false, - "nursery": { + "correctness": { "noUndeclaredDependencies": "error" } } @@ -37,9 +37,9 @@ import "lodash"; # Termination Message ```block -configuration ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +lint ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - × Biome exited because the configuration resulted in errors. Please fix them. + × Some errors were emitted while running checks. @@ -48,49 +48,23 @@ configuration ━━━━━━━━━━━━━━━━━━━━━━ # Emitted Messages ```block -biome.json:7:9 deserialize ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +fix.js:2:8 lint/correctness/noUndeclaredDependencies ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - × Found an unknown key `noUndeclaredDependencies`. + × The current dependency isn't specified in your package.json. - 5 │ "all": false, - 6 │ "nursery": { - > 7 │ "noUndeclaredDependencies": "error" - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ - 8 │ } - 9 │ } + 1 │ import "react"; + > 2 │ import "lodash"; + │ ^^^^^^^^ + 3 │ - i Known keys: + i This could lead to errors. - - recommended - - all - - noCommonJs - - noDuplicateCustomProperties - - noDuplicateElseIf - - noDuplicatedFields - - noDynamicNamespaceImportAccess - - noEnum - - noExportedImports - - noIrregularWhitespace - - noProcessEnv - - noRestrictedImports - - noRestrictedTypes - - noSecrets - - noStaticElementInteractions - - noSubstr - - noUnknownPseudoClass - - noUnknownPseudoElement - - noUselessEscapeInRegex - - noValueAtRule - - useAdjacentOverloadSignatures - - useAriaPropsSupportedByRole - - useConsistentCurlyBraces - - useConsistentMemberAccessibility - - useDeprecatedReason - - useImportRestrictions - - useSortedClasses - - useStrictMode - - useTrimStartEnd - - useValidAutocomplete + i Add the dependency in your manifest. ``` + +```block +Checked 1 file in