diff --git a/crates/biome_js_analyze/src/syntax.rs b/crates/biome_js_analyze/src/syntax.rs index f40efc76b722..45f668adced2 100644 --- a/crates/biome_js_analyze/src/syntax.rs +++ b/crates/biome_js_analyze/src/syntax.rs @@ -1,4 +1,4 @@ //! Generated file, do not edit by hand, see `xtask/codegen` -pub(crate) mod nursery; -::biome_analyze::declare_category! { pub (crate) Syntax { kind : Syntax , groups : [self :: nursery :: Nursery ,] } } +pub(crate) mod correctness; +::biome_analyze::declare_category! { pub (crate) Syntax { kind : Syntax , groups : [self :: correctness :: Correctness ,] } } diff --git a/crates/biome_js_analyze/src/syntax/nursery.rs b/crates/biome_js_analyze/src/syntax/correctness.rs similarity index 86% rename from crates/biome_js_analyze/src/syntax/nursery.rs rename to crates/biome_js_analyze/src/syntax/correctness.rs index d5d7c7247d98..e0bacf3eb101 100644 --- a/crates/biome_js_analyze/src/syntax/nursery.rs +++ b/crates/biome_js_analyze/src/syntax/correctness.rs @@ -6,8 +6,8 @@ pub(crate) mod no_duplicate_private_class_members; pub(crate) mod no_super_without_extends; declare_group! { - pub (crate) Nursery { - name : "nursery" , + pub (crate) Correctness { + name : "correctness" , rules : [ self :: no_duplicate_private_class_members :: NoDuplicatePrivateClassMembers , self :: no_super_without_extends :: NoSuperWithoutExtends , diff --git a/crates/biome_js_analyze/src/syntax/nursery/no_duplicate_private_class_members.rs b/crates/biome_js_analyze/src/syntax/correctness/no_duplicate_private_class_members.rs similarity index 94% rename from crates/biome_js_analyze/src/syntax/nursery/no_duplicate_private_class_members.rs rename to crates/biome_js_analyze/src/syntax/correctness/no_duplicate_private_class_members.rs index 9550669bfc67..c41e623865a4 100644 --- a/crates/biome_js_analyze/src/syntax/nursery/no_duplicate_private_class_members.rs +++ b/crates/biome_js_analyze/src/syntax/correctness/no_duplicate_private_class_members.rs @@ -1,6 +1,6 @@ use std::collections::{HashMap, HashSet}; -use biome_analyze::{context::RuleContext, declare_rule, Ast, FixKind, Rule, RuleDiagnostic}; +use biome_analyze::{context::RuleContext, declare_rule, Ast, Rule, RuleDiagnostic}; use biome_diagnostics::category; use biome_js_syntax::{AnyJsClassMember, JsClassMemberList, TextRange}; @@ -20,8 +20,6 @@ declare_rule! { pub(crate) NoDuplicatePrivateClassMembers { version: "1.0.0", name: "noDuplicatePrivateClassMembers", - recommended: false, - fix_kind: FixKind::Unsafe, } } diff --git a/crates/biome_js_analyze/src/syntax/nursery/no_super_without_extends.rs b/crates/biome_js_analyze/src/syntax/correctness/no_super_without_extends.rs similarity index 98% rename from crates/biome_js_analyze/src/syntax/nursery/no_super_without_extends.rs rename to crates/biome_js_analyze/src/syntax/correctness/no_super_without_extends.rs index b46eaed8de30..d2883843bbc3 100644 --- a/crates/biome_js_analyze/src/syntax/nursery/no_super_without_extends.rs +++ b/crates/biome_js_analyze/src/syntax/correctness/no_super_without_extends.rs @@ -20,7 +20,6 @@ declare_rule! { pub(crate) NoSuperWithoutExtends { version: "1.0.0", name: "noSuperWithoutExtends", - recommended: false, } } diff --git a/crates/biome_js_analyze/tests/specs/nursery/noDuplicatePrivateClassMembers/invalid.js b/crates/biome_js_analyze/tests/specs/correctness/noDuplicatePrivateClassMembers/invalid.js similarity index 100% rename from crates/biome_js_analyze/tests/specs/nursery/noDuplicatePrivateClassMembers/invalid.js rename to crates/biome_js_analyze/tests/specs/correctness/noDuplicatePrivateClassMembers/invalid.js diff --git a/crates/biome_js_analyze/tests/specs/nursery/noDuplicatePrivateClassMembers/invalid.js.snap b/crates/biome_js_analyze/tests/specs/correctness/noDuplicatePrivateClassMembers/invalid.js.snap similarity index 100% rename from crates/biome_js_analyze/tests/specs/nursery/noDuplicatePrivateClassMembers/invalid.js.snap rename to crates/biome_js_analyze/tests/specs/correctness/noDuplicatePrivateClassMembers/invalid.js.snap diff --git a/crates/biome_js_analyze/tests/specs/nursery/noDuplicatePrivateClassMembers/valid.js b/crates/biome_js_analyze/tests/specs/correctness/noDuplicatePrivateClassMembers/valid.js similarity index 100% rename from crates/biome_js_analyze/tests/specs/nursery/noDuplicatePrivateClassMembers/valid.js rename to crates/biome_js_analyze/tests/specs/correctness/noDuplicatePrivateClassMembers/valid.js diff --git a/crates/biome_js_analyze/tests/specs/nursery/noDuplicatePrivateClassMembers/valid.js.snap b/crates/biome_js_analyze/tests/specs/correctness/noDuplicatePrivateClassMembers/valid.js.snap similarity index 100% rename from crates/biome_js_analyze/tests/specs/nursery/noDuplicatePrivateClassMembers/valid.js.snap rename to crates/biome_js_analyze/tests/specs/correctness/noDuplicatePrivateClassMembers/valid.js.snap diff --git a/crates/biome_js_analyze/tests/specs/nursery/noSuperWithoutExtends/invalid.js b/crates/biome_js_analyze/tests/specs/correctness/noSuperWithoutExtends/invalid.js similarity index 100% rename from crates/biome_js_analyze/tests/specs/nursery/noSuperWithoutExtends/invalid.js rename to crates/biome_js_analyze/tests/specs/correctness/noSuperWithoutExtends/invalid.js diff --git a/crates/biome_js_analyze/tests/specs/nursery/noSuperWithoutExtends/invalid.js.snap b/crates/biome_js_analyze/tests/specs/correctness/noSuperWithoutExtends/invalid.js.snap similarity index 100% rename from crates/biome_js_analyze/tests/specs/nursery/noSuperWithoutExtends/invalid.js.snap rename to crates/biome_js_analyze/tests/specs/correctness/noSuperWithoutExtends/invalid.js.snap diff --git a/website/src/content/docs/linter/rules/index.mdx b/website/src/content/docs/linter/rules/index.mdx index 7cccc92539de..a079b5598efc 100644 --- a/website/src/content/docs/linter/rules/index.mdx +++ b/website/src/content/docs/linter/rules/index.mdx @@ -14,19 +14,19 @@ Rules focused on preventing accessibility problems. | Rule name | Properties | Description | | --- | --- | --- | | [noAccessKey](/linter/rules/no-access-key) | Enforce that the accessKey attribute is not used on any HTML element. | ⚠️ | -| [noAriaUnsupportedElements](/linter/rules/no-aria-unsupported-elements) | Enforce that elements that do not support ARIA roles, states, and properties do not have those attributes. | | +| [noAriaUnsupportedElements](/linter/rules/no-aria-unsupported-elements) | Enforce that elements that do not support ARIA roles, states, and properties do not have those attributes. | ⚠️ | | [noAutofocus](/linter/rules/no-autofocus) | Enforce that autoFocus prop is not used on elements. | ⚠️ | | [noBlankTarget](/linter/rules/no-blank-target) | Disallow target="_blank" attribute without rel="noreferrer" | 🔧 | | [noDistractingElements](/linter/rules/no-distracting-elements) | Enforces that no distracting elements are used. | ⚠️ | | [noHeaderScope](/linter/rules/no-header-scope) | The scope prop should be used only on <th> elements. | ⚠️ | | [noNoninteractiveElementToInteractiveRole](/linter/rules/no-noninteractive-element-to-interactive-role) | Enforce that interactive ARIA roles are not assigned to non-interactive HTML elements. | | | [noNoninteractiveTabindex](/linter/rules/no-noninteractive-tabindex) | Enforce that tabIndex is not assigned to non-interactive HTML elements. | | -| [noPositiveTabindex](/linter/rules/no-positive-tabindex) | Prevent the usage of positive integers on tabIndex property | | +| [noPositiveTabindex](/linter/rules/no-positive-tabindex) | Prevent the usage of positive integers on tabIndex property | ⚠️ | | [noRedundantAlt](/linter/rules/no-redundant-alt) | Enforce img alt prop does not contain the word "image", "picture", or "photo". | | | [noRedundantRoles](/linter/rules/no-redundant-roles) | Enforce explicit role property is not the same as implicit/default role property on an element. | ⚠️ | | [noSvgWithoutTitle](/linter/rules/no-svg-without-title) | Enforces the usage of the title element for the svg element. | | | [useAltText](/linter/rules/use-alt-text) | Enforce that all elements that require alternative text have meaningful information to relay back to the end user. | | -| [useAnchorContent](/linter/rules/use-anchor-content) | Enforce that anchors have content and that the content is accessible to screen readers. | | +| [useAnchorContent](/linter/rules/use-anchor-content) | Enforce that anchors have content and that the content is accessible to screen readers. | ⚠️ | | [useAriaPropsForRole](/linter/rules/use-aria-props-for-role) | Enforce that elements with ARIA roles must have all required ARIA attributes for that role. | | | [useButtonType](/linter/rules/use-button-type) | Enforces the usage of the attribute type for the element button | | | [useHeadingContent](/linter/rules/use-heading-content) | Enforce that heading elements (h1, h2, etc.) have content and that the content is accessible to screen readers. Accessible means that it is not hidden using the aria-hidden prop. | | @@ -36,7 +36,7 @@ Rules focused on preventing accessibility problems. | [useKeyWithMouseEvents](/linter/rules/use-key-with-mouse-events) | Enforce onMouseOver / onMouseOut are accompanied by onFocus / onBlur. | | | [useMediaCaption](/linter/rules/use-media-caption) | Enforces that audio and video elements must have a track for captions. | | | [useValidAnchor](/linter/rules/use-valid-anchor) | Enforce that all anchors are valid, and they are navigable elements. | | -| [useValidAriaProps](/linter/rules/use-valid-aria-props) | Ensures that ARIA properties aria-* are all valid. | | +| [useValidAriaProps](/linter/rules/use-valid-aria-props) | Ensures that ARIA properties aria-* are all valid. | ⚠️ | | [useValidAriaValues](/linter/rules/use-valid-aria-values) | Enforce that ARIA state and property values are valid. | | | [useValidLang](/linter/rules/use-valid-lang) | Ensure that the attribute passed to the lang attribute is a correct ISO language and/or country. | | @@ -46,8 +46,9 @@ Rules that focus on inspecting complex code that could be simplified. | Rule name | Properties | Description | | --- | --- | --- | | [noBannedTypes](/linter/rules/no-banned-types) | Disallow primitive type aliases and misleading types. | 🔧 | +| [noExcessiveComplexity](/linter/rules/no-excessive-complexity) | Disallow functions that exceed a given Cognitive Complexity score. | | | [noExtraBooleanCast](/linter/rules/no-extra-boolean-cast) | Disallow unnecessary boolean casts | ⚠️ | -| [noForEach](/linter/rules/no-for-each) | Prefer for...of statement instead of Array.forEach. | | +| [noForEach](/linter/rules/no-for-each) | Prefer for...of statement instead of Array.forEach. | | | [noMultipleSpacesInRegularExpressionLiterals](/linter/rules/no-multiple-spaces-in-regular-expression-literals) | Disallow unclear usage of consecutive space characters in regular expression literals | ⚠️ | | [noStaticOnlyClass](/linter/rules/no-static-only-class) | This rule reports when a class has no non-static members, such as for a class used exclusively as a static namespace. | | | [noUselessCatch](/linter/rules/no-useless-catch) | Disallow unnecessary catch clauses. | | @@ -59,6 +60,7 @@ Rules that focus on inspecting complex code that could be simplified. | [noUselessSwitchCase](/linter/rules/no-useless-switch-case) | Disallow useless case in switch statements. | ⚠️ | | [noUselessThisAlias](/linter/rules/no-useless-this-alias) | Disallow useless this aliasing. | 🔧 | | [noUselessTypeConstraint](/linter/rules/no-useless-type-constraint) | Disallow using any or unknown as type constraint. | 🔧 | +| [noVoid](/linter/rules/no-void) | Disallow the use of void operators, which is not a familiar operator. | | | [noWith](/linter/rules/no-with) | Disallow with statements in non-strict contexts. | | | [useFlatMap](/linter/rules/use-flat-map) | Promotes the use of .flatMap() when map().flat() are used together. | 🔧 | | [useLiteralKeys](/linter/rules/use-literal-keys) | Enforce the usage of a literal access to properties over computed property access. | ⚠️ | @@ -97,6 +99,8 @@ Rules that detect code that is guaranteed to be incorrect or useless. | [noUnusedVariables](/linter/rules/no-unused-variables) | Disallow unused variables. | ⚠️ | | [noVoidElementsWithChildren](/linter/rules/no-void-elements-with-children) | This rules prevents void elements (AKA self-closing elements) from having children. | ⚠️ | | [noVoidTypeReturn](/linter/rules/no-void-type-return) | Disallow returning a value from a function with the return type 'void' | | +| [useExhaustiveDependencies](/linter/rules/use-exhaustive-dependencies) | Enforce all dependencies are correctly specified in a React hook. | | +| [useHookAtTopLevel](/linter/rules/use-hook-at-top-level) | Enforce that all React hooks are being called from the Top Level component functions. | | | [useIsNan](/linter/rules/use-is-nan) | Require calls to isNaN() when checking for NaN. | ⚠️ | | [useValidForDirection](/linter/rules/use-valid-for-direction) | Enforce "for" loop update clause moving the counter in the right direction. | | | [useYield](/linter/rules/use-yield) | Require generator functions to contain yield. | | @@ -106,6 +110,7 @@ Rules that detect code that is guaranteed to be incorrect or useless. Rules catching ways your code could be written to run faster, or generally be more efficient. | Rule name | Properties | Description | | --- | --- | --- | +| [noAccumulatingSpread](/linter/rules/no-accumulating-spread) | Disallow the use of spread (...) syntax on accumulators. | | | [noDelete](/linter/rules/no-delete) | Disallow the use of the delete operator. | ⚠️ | ## Security @@ -135,9 +140,10 @@ Rules enforcing a consistent and idiomatic way of writing your code. | [noUnusedTemplateLiteral](/linter/rules/no-unused-template-literal) | Disallow template literals if interpolation and special-character handling are not needed | ⚠️ | | [noVar](/linter/rules/no-var) | Disallow the use of var | ⚠️ | | [useBlockStatements](/linter/rules/use-block-statements) | Requires following curly brace conventions. | ⚠️ | +| [useCollapsedElseIf](/linter/rules/use-collapsed-else-if) | Enforce using else if instead of nested if in else clauses. | 🔧 | | [useConst](/linter/rules/use-const) | Require const declarations for variables that are never reassigned after declared. | 🔧 | | [useDefaultParameterLast](/linter/rules/use-default-parameter-last) | Enforce default function parameters and optional function parameters to be last. | ⚠️ | -| [useEnumInitializers](/linter/rules/use-enum-initializers) | Require that each enum member value be explicitly initialized. | | +| [useEnumInitializers](/linter/rules/use-enum-initializers) | Require that each enum member value be explicitly initialized. | 🔧 | | [useExponentiationOperator](/linter/rules/use-exponentiation-operator) | Disallow the use of Math.pow in favor of the ** operator. | ⚠️ | | [useFragmentSyntax](/linter/rules/use-fragment-syntax) | This rule enforces the use of <>...</> over <Fragment>...</Fragment>. | ⚠️ | | [useLiteralEnumMembers](/linter/rules/use-literal-enum-members) | Require all enum members to be literal values. | | @@ -163,6 +169,7 @@ Rules that detect code that is likely to be incorrect or useless. | [noCommentText](/linter/rules/no-comment-text) | Prevent comments from being inserted as text nodes | ⚠️ | | [noCompareNegZero](/linter/rules/no-compare-neg-zero) | Disallow comparing against -0 | 🔧 | | [noConfusingLabels](/linter/rules/no-confusing-labels) | Disallow labeled statements that are not loops. | | +| [noConfusingVoidType](/linter/rules/no-confusing-void-type) | Disallow void type outside of generic or return types. | | | [noConsoleLog](/linter/rules/no-console-log) | Disallow the use of console.log | | | [noConstEnum](/linter/rules/no-const-enum) | Disallow TypeScript const enum | 🔧 | | [noControlCharactersInRegex](/linter/rules/no-control-characters-in-regex) | Prevents from having control characters and some escape sequences that match control characters in regular expressions. | | @@ -176,7 +183,9 @@ Rules that detect code that is likely to be incorrect or useless. | [noEmptyInterface](/linter/rules/no-empty-interface) | Disallow the declaration of empty interfaces. | 🔧 | | [noExplicitAny](/linter/rules/no-explicit-any) | Disallow the any type usage. | | | [noExtraNonNullAssertion](/linter/rules/no-extra-non-null-assertion) | Prevents the wrong usage of the non-null assertion operator (!) in TypeScript files. | 🔧 | +| [noFallthroughSwitchClause](/linter/rules/no-fallthrough-switch-clause) | Disallow fallthrough of switch clauses. | | | [noFunctionAssign](/linter/rules/no-function-assign) | Disallow reassigning function declarations. | | +| [noGlobalIsNan](/linter/rules/no-global-is-nan) | Use Number.isNaN instead of global isNaN. | ⚠️ | | [noImportAssign](/linter/rules/no-import-assign) | Disallow assigning to imported bindings | | | [noLabelVar](/linter/rules/no-label-var) | Disallow labels that share a name with a variable | | | [noPrototypeBuiltins](/linter/rules/no-prototype-builtins) | Disallow direct use of Object.prototype builtins. | | @@ -189,6 +198,7 @@ Rules that detect code that is likely to be incorrect or useless. | [noUnsafeNegation](/linter/rules/no-unsafe-negation) | Disallow using unsafe negation. | ⚠️ | | [useDefaultSwitchClauseLast](/linter/rules/use-default-switch-clause-last) | Enforce default clauses in switch statements to be last | | | [useGetterReturn](/linter/rules/use-getter-return) | Enforce get methods to always return a value. | | +| [useIsArray](/linter/rules/use-is-array) | Use Array.isArray() instead of instanceof Array. | ⚠️ | | [useNamespaceKeyword](/linter/rules/use-namespace-keyword) | Require using the namespace keyword over the module keyword to declare TypeScript namespaces. | 🔧 | | [useValidTypeof](/linter/rules/use-valid-typeof) | This rule verifies the result of typeof $expr unary expressions is being compared to valid values, either string literals containing valid type names or other typeof expressions | ⚠️ | @@ -204,15 +214,10 @@ Nursery rules get promoted to other groups once they become stable or may be rem Rules that belong to this group are not subject to semantic version. | Rule name | Properties | Description | | --- | --- | --- | -| [noAccumulatingSpread](/linter/rules/no-accumulating-spread) | Disallow the use of spread (...) syntax on accumulators. | | | [noApproximativeNumericConstant](/linter/rules/no-approximative-numeric-constant) | Usually, the definition in the standard library is more precise than what people come up with or the used constant exceeds the maximum precision of the number type. | | -| [noConfusingVoidType](/linter/rules/no-confusing-void-type) | Disallow void type outside of generic or return types. | | | [noDuplicateJsonKeys](/linter/rules/no-duplicate-json-keys) | Disallow two keys with the same name inside a JSON object. | | | [noEmptyCharacterClassInRegex](/linter/rules/no-empty-character-class-in-regex) | Disallow empty character classes in regular expression literals. | | -| [noExcessiveComplexity](/linter/rules/no-excessive-complexity) | Disallow functions that exceed a given Cognitive Complexity score. | | -| [noFallthroughSwitchClause](/linter/rules/no-fallthrough-switch-clause) | Disallow fallthrough of switch clauses. | | | [noGlobalIsFinite](/linter/rules/no-global-is-finite) | Use Number.isFinite instead of global isFinite. | ⚠️ | -| [noGlobalIsNan](/linter/rules/no-global-is-nan) | Use Number.isNaN instead of global isNaN. | ⚠️ | | [noInteractiveElementToNoninteractiveRole](/linter/rules/no-interactive-element-to-noninteractive-role) | Enforce that non-interactive ARIA roles are not assigned to interactive HTML elements. | | | [noInvalidNewBuiltin](/linter/rules/no-invalid-new-builtin) | Disallow new operators with global non-constructor functions. | ⚠️ | | [noMisleadingInstantiator](/linter/rules/no-misleading-instantiator) | Enforce proper usage of new and constructor. | | @@ -220,14 +225,9 @@ Rules that belong to this group are not subject to semantic version🔧 | | [noUselessElse](/linter/rules/no-useless-else) | Disallow else block when the if block breaks early. | ⚠️ | | [noUselessLoneBlockStatements](/linter/rules/no-useless-lone-block-statements) | Disallow unnecessary nested block statements. | ⚠️ | -| [noVoid](/linter/rules/no-void) | Disallow the use of void operators, which is not a familiar operator. | | | [useAriaActivedescendantWithTabindex](/linter/rules/use-aria-activedescendant-with-tabindex) | Enforce that tabIndex is assigned to non-interactive HTML elements with aria-activedescendant. | | | [useArrowFunction](/linter/rules/use-arrow-function) | Use arrow functions over function expressions. | 🔧 | | [useAsConstAssertion](/linter/rules/use-as-const-assertion) | Enforce the use of as const over literal type and type annotation. | 🔧 | -| [useCollapsedElseIf](/linter/rules/use-collapsed-else-if) | Enforce using else if instead of nested if in else clauses. | 🔧 | -| [useExhaustiveDependencies](/linter/rules/use-exhaustive-dependencies) | Enforce all dependencies are correctly specified in a React hook. | | | [useGroupedTypeImport](/linter/rules/use-grouped-type-import) | Enforce the use of import type when an import only has specifiers with type qualifier. | ⚠️ | -| [useHookAtTopLevel](/linter/rules/use-hook-at-top-level) | Enforce that all React hooks are being called from the Top Level component functions. | | | [useImportRestrictions](/linter/rules/use-import-restrictions) | Disallows package private imports. | | -| [useIsArray](/linter/rules/use-is-array) | Use Array.isArray() instead of instanceof Array. | ⚠️ | -| [useShorthandAssign](/linter/rules/use-shorthand-assign) | Require assignment operator shorthand where possible. | | +| [useShorthandAssign](/linter/rules/use-shorthand-assign) | Require assignment operator shorthand where possible. | ⚠️ |