Skip to content

Commit

Permalink
docs: update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
vohoanglong0107 committed Apr 30, 2024
1 parent 3dd1652 commit 0d48b11
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 13 deletions.

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

2 changes: 1 addition & 1 deletion crates/biome_configuration/src/linter/rules.rs

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

81 changes: 71 additions & 10 deletions crates/biome_js_analyze/src/lint/nursery/use_jsx_sort_props.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use std::cmp::Ordering;

use biome_analyze::{
context::RuleContext, declare_rule, ActionCategory, Ast, FixKind, Rule, RuleDiagnostic,
RuleSource, RuleSourceKind,
};
use biome_console::markup;
use biome_deserialize_macros::Deserializable;
Expand All @@ -15,33 +16,93 @@ use serde::{Deserialize, Serialize};
use crate::JsRuleAction;

declare_rule! {
/// Succinct description of the rule.
/// Enforce props sorting in JSX elements.
///
/// Put context and details about the rule.
/// As a starting point, you can take the description of the corresponding _ESLint_ rule (if any).
///
/// Try to stay consistent with the descriptions of implemented rules.
///
/// Add a link to the corresponding ESLint rule (if any):
/// This rule checks if the JSX props are sorted in a consistent way.
/// A spread prop resets the sorting order.
/// The rule can be configured to sort props alphabetically, ignore case, and more.
///
/// ## Examples
///
/// ### Invalid
///
/// ```js,expect_diagnostic
/// var a = 1;
/// a = 2;
/// <Hello lastName="Smith" firstName="John" />;
/// ```
///
/// ### Valid
///
/// ```js
/// // var a = 1;
/// <Hello firstName="John" lastName="Smith" />;
/// <Hello tel={5555555} {...this.props} firstName="John" lastName="Smith" />;
/// ```
///
/// ## Options
///
/// ### `callbacksLast`
///
/// When `true`, callback props are sorted last.
///
/// #### Example
///
/// ```js
/// <Hello tel={5555555} onClick={this._handleClick} />;
/// ```
///
/// ### `shorthand`
///
/// When `first`, shorthand props are sorted first.
/// When `last`, shorthand props are sorted last, unless `callbacksLast` is `true`,
/// in which case they are sorted before callbacks.
/// Default is `ignore`.
///
/// #### Example
///
/// ```js
/// // shorthand first
/// <Hello active validate name="John" tel={5555555} />;
/// // shorthand last
/// <Hello name="John" tel={5555555} active validate />;
/// ```
///
/// ### `multiline`
///
/// When `first`, multiline props are sorted first, unless `shorthand` is `first`,
/// in which case they are sorted after shorthand props.
/// When `last`, multiline props are sorted last, unless `shorthand` is `last` or `callbacksLast` is `true`,
/// in which case they are sorted before shorthand props or callbacks.
/// Default is `ignore`.
///
/// #### Example
///
/// ```js
/// // multiline first
/// <Hello
/// classes={{
/// greetings: classes.greetings,
/// }}
/// name="John"
/// tel={5555555}
/// active
/// validate
/// />;
/// // multiline last
/// <Hello
/// name="John"
/// tel={5555555}
/// active
/// validate
/// classes={{
/// greetings: classes.greetings,
/// }}
/// />;
/// ```
///
pub UseJsxSortProps {
version: "next",
name: "useJsxSortProps",
sources: &[RuleSource::EslintReact("jsx-sort-props")],
source_kind: RuleSourceKind::SameLogic,
recommended: false,
fix_kind: FixKind::Safe,
}
Expand Down
2 changes: 1 addition & 1 deletion packages/@biomejs/backend-jsonrpc/src/workspace.ts

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

2 changes: 1 addition & 1 deletion packages/@biomejs/biome/configuration_schema.json

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

0 comments on commit 0d48b11

Please sign in to comment.