Skip to content

Commit 8862f06

Browse files
committed
chore(linter): update docs for declare_oxc_lint! (#4825)
1 parent 8ec7e12 commit 8862f06

File tree

1 file changed

+49
-4
lines changed

1 file changed

+49
-4
lines changed

crates/oxc_macros/src/lib.rs

+49-4
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,53 @@ mod declare_oxc_lint;
66

77
/// Macro used to declare an oxc lint rule
88
///
9-
/// Every lint declaration consists of 2 parts:
9+
/// Every lint declaration consists of 4 parts:
1010
///
1111
/// 1. The documentation
1212
/// 2. The lint's struct
13+
/// 3. The lint's category
14+
/// 4. What kind of auto-fixes the lint supports
1315
///
16+
/// ## Documentation
17+
/// Lint rule documentation added here will be used to build documentation pages
18+
/// for [our website](https://oxc.rs). Please make sure they are clear and
19+
/// concise. Remember, end users will depend on it to understand the purpose of
20+
/// the lint and how to use it!
21+
///
22+
/// ## Category
23+
/// Please see the [rule category
24+
/// documentation](https://oxc.rs/docs/contribute/linter.html#rule-category) for
25+
/// a full list of categories and their descriptions.
26+
///
27+
/// ## Auto-fixes
28+
///
29+
/// Lints that support auto-fixes **must** specify what kind of auto-fixes they
30+
/// support. Here are some examples:
31+
/// - `none`: no auto-fixes are available (default)
32+
/// - `pending`: auto-fixes are planned but not yet implemented
33+
/// - `fix`: safe, automatic fixes are available
34+
/// - `suggestion`: automatic fixes are available, but may not be safe
35+
/// - `conditional_fix`: automatic fixes are available in some cases
36+
/// - `dangerous_fix`: automatic fixes are available, but may be dangerous
37+
///
38+
/// More generally, auto-fix categories follow this pattern:
39+
/// ```text
40+
/// [conditional?]_[fix|suggestion|dangerous]
41+
/// ```
42+
/// ...meaning that these are also valid:
43+
/// - `suggestion_fix` (supports safe fixes and suggestions)
44+
/// - `conditional_dangerous_fix` (sometimes provides dangerous fixes)
45+
/// - `dangerous_fix_dangerous_suggestion` (provides dangerous fixes and suggestions in all cases)
46+
///
47+
/// `pending` and `none` are special cases that do not follow this pattern.
1448
/// # Example
1549
///
1650
/// ```
1751
/// use oxc_macros::declare_oxc_lint;
1852
///
53+
/// #[derive(Debug, Default, Clone)]
54+
/// pub struct NoDebugger;
55+
///
1956
/// declare_oxc_lint! {
2057
/// /// ### What it does
2158
/// /// Checks for usage of the `debugger` statement
@@ -25,15 +62,23 @@ mod declare_oxc_lint;
2562
/// /// They're most commonly an accidental debugging leftover.
2663
/// ///
2764
/// ///
28-
/// /// ### Example
29-
/// /// ```javascript
65+
/// /// ### Examples
66+
/// ///
67+
/// /// Examples of **incorrect** code for this rule:
68+
/// /// ```js
3069
/// /// const data = await getData();
3170
/// /// const result = complexCalculation(data);
3271
/// /// debugger;
3372
/// /// ```
3473
/// ///
74+
/// /// Examples of **correct** code for this rule:
75+
/// /// ```js
76+
/// /// // Not a debugger statement
77+
/// /// var debug = require('foo');
3578
/// /// ```
36-
/// pub struct NoDebugger
79+
/// NoDebugger,
80+
/// correctness,
81+
/// fix
3782
/// }
3883
/// ```
3984
#[proc_macro]

0 commit comments

Comments
 (0)