@@ -6,16 +6,53 @@ mod declare_oxc_lint;
6
6
7
7
/// Macro used to declare an oxc lint rule
8
8
///
9
- /// Every lint declaration consists of 2 parts:
9
+ /// Every lint declaration consists of 4 parts:
10
10
///
11
11
/// 1. The documentation
12
12
/// 2. The lint's struct
13
+ /// 3. The lint's category
14
+ /// 4. What kind of auto-fixes the lint supports
13
15
///
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.
14
48
/// # Example
15
49
///
16
50
/// ```
17
51
/// use oxc_macros::declare_oxc_lint;
18
52
///
53
+ /// #[derive(Debug, Default, Clone)]
54
+ /// pub struct NoDebugger;
55
+ ///
19
56
/// declare_oxc_lint! {
20
57
/// /// ### What it does
21
58
/// /// Checks for usage of the `debugger` statement
@@ -25,15 +62,23 @@ mod declare_oxc_lint;
25
62
/// /// They're most commonly an accidental debugging leftover.
26
63
/// ///
27
64
/// ///
28
- /// /// ### Example
29
- /// /// ```javascript
65
+ /// /// ### Examples
66
+ /// ///
67
+ /// /// Examples of **incorrect** code for this rule:
68
+ /// /// ```js
30
69
/// /// const data = await getData();
31
70
/// /// const result = complexCalculation(data);
32
71
/// /// debugger;
33
72
/// /// ```
34
73
/// ///
74
+ /// /// Examples of **correct** code for this rule:
75
+ /// /// ```js
76
+ /// /// // Not a debugger statement
77
+ /// /// var debug = require('foo');
35
78
/// /// ```
36
- /// pub struct NoDebugger
79
+ /// NoDebugger,
80
+ /// correctness,
81
+ /// fix
37
82
/// }
38
83
/// ```
39
84
#[ proc_macro]
0 commit comments