docs: fix order of sections for lint rules
MODIFY
crates/rome_js_analyze/src/analyzers/no_async_promise_executor.rs
crates/rome_js_analyze/src/analyzers/no_async_promise_executor.rs
@@ -11,14 +11,6 @@ declare_rule! {
/// 2. If a Promise executor function is using `await`, this is usually a sign that it is not actually necessary to use the `new Promise` constructor, or the scope of the `new Promise` constructor can be reduced.
///
/// ## Examples
- /// ### Valid
- ///
- /// ```js
- /// new Promise((resolve, reject) => {})
- /// new Promise((resolve, reject) => {}, async function unrelated() {})
- /// new Foo(async (resolve, reject) => {})
- /// new Foo((( (resolve, reject) => {} )))
- /// ```
///
/// ### Invalid
///
@@ -33,6 +25,15 @@ declare_rule! {
/// ```js,expect_diagnostic
/// new Promise(((((async () => {})))))
/// ```
+ ///
+ /// ### Valid
+ ///
+ /// ```js
+ /// new Promise((resolve, reject) => {})
+ /// new Promise((resolve, reject) => {}, async function unrelated() {})
+ /// new Foo(async (resolve, reject) => {})
+ /// new Foo((( (resolve, reject) => {} )))
+ /// ```
pub(crate) NoAsyncPromiseExecutor = "noAsyncPromiseExecutor"
}

MODIFY
crates/rome_js_analyze/src/analyzers/no_empty_pattern.rs
crates/rome_js_analyze/src/analyzers/no_empty_pattern.rs
@@ -7,18 +7,6 @@ declare_rule! {
/// Disallows empty destructuring patterns.
/// ## Examples
///
- /// ### Valid
- /// The following cases are valid because they create new bindings.
- ///
- /// ```js
- /// var {a = {}} = foo;
- /// var {a, b = {}} = foo;
- /// var {a = []} = foo;
- /// function foo({a = {}}) {}
- /// function foo({a = []}) {}
- /// var [a] = foo;
- /// ```
- ///
/// ### Invalid
///
/// ```js,expect_diagnostic
@@ -33,6 +21,17 @@ declare_rule! {
/// function foo({}) {}
/// ```
///
+ /// ### Valid
+ /// The following cases are valid because they create new bindings.
+ ///
+ /// ```js
+ /// var {a = {}} = foo;
+ /// var {a, b = {}} = foo;
+ /// var {a = []} = foo;
+ /// function foo({a = {}}) {}
+ /// function foo({a = []}) {}
+ /// var [a] = foo;
+ /// ```
pub(crate) NoEmptyPattern = "noEmptyPattern"
}

MODIFY
crates/rome_js_analyze/src/analyzers/no_unsafe_negation.rs
crates/rome_js_analyze/src/analyzers/no_unsafe_negation.rs
@@ -13,6 +13,16 @@ declare_rule! {
///
/// ## Examples
///
+ /// ### Invalid
+ ///
+ /// ```js,expect_diagnostic
+ /// !1 in [1,2];
+ /// ```
+ ///
+ /// ```js,expect_diagnostic
+ /// /**test*/!/** test*/1 instanceof [1,2];
+ /// ```
+ ///
/// ### Valid
/// ```js
/// -1 in [1,2];
@@ -22,13 +32,6 @@ declare_rule! {
/// delete 1 in [1,2];
/// +1 instanceof [1,2];
/// ```
- /// ### Invalid
- /// ```js,expect_diagnostic
- /// !1 in [1,2];
- /// ```
- /// ```js,expect_diagnostic
- /// /**test*/!/** test*/1 instanceof [1,2];
- /// ```
pub(crate) NoUnsafeNegation = "noUnsafeNegation"
}

MODIFY
crates/rome_js_analyze/src/analyzers/use_shorthand_array_type.rs
crates/rome_js_analyze/src/analyzers/use_shorthand_array_type.rs
@@ -15,14 +15,6 @@ declare_rule! {
///
/// ## Examples
///
- /// ### Valid
- ///
- /// ```ts
- /// let valid: Array<Foo | Bar>;
- /// let valid: Array<keyof Bar>;
- /// let valid: Array<foo | bar>;
- /// ```
- ///
/// ### Invalid
/// ```ts,expect_diagnostic
/// let valid: Array<foo>;
@@ -43,6 +35,14 @@ declare_rule! {
/// ```ts,expect_diagnostic
/// let invalid: Array<[number, number]>;
/// ```
+ ///
+ /// ### Valid
+ ///
+ /// ```ts
+ /// let valid: Array<Foo | Bar>;
+ /// let valid: Array<keyof Bar>;
+ /// let valid: Array<foo | bar>;
+ /// ```
pub(crate) UseShorthandArrayType = "useShorthandArrayType"
}

MODIFY
website/src/docs/lint/rules/noAsyncPromiseExecutor.md
website/src/docs/lint/rules/noAsyncPromiseExecutor.md
@@ -13,15 +13,6 @@ The executor function can also be an async function. However, this is usually a
2. If a Promise executor function is using `await`, this is usually a sign that it is not actually necessary to use the `new Promise` constructor, or the scope of the `new Promise` constructor can be reduced.
## Examples
-### Valid
-
-```jsx
- new Promise((resolve, reject) => {})
- new Promise((resolve, reject) => {}, async function unrelated() {})
- new Foo(async (resolve, reject) => {})
- new Foo((( (resolve, reject) => {} )))
-```
-
### Invalid
```jsx
@@ -60,3 +51,12 @@ new Promise(async function foo(resolve, reject) {})
</code></pre>{% endraw %}
+### Valid
+
+```jsx
+ new Promise((resolve, reject) => {})
+ new Promise((resolve, reject) => {}, async function unrelated() {})
+ new Foo(async (resolve, reject) => {})
+ new Foo((( (resolve, reject) => {} )))
+```
+

MODIFY
website/src/docs/lint/rules/noEmptyPattern.md
website/src/docs/lint/rules/noEmptyPattern.md
@@ -9,19 +9,6 @@ Disallows empty destructuring patterns.
## Examples
-### Valid
-
-The following cases are valid because they create new bindings.
-
-```jsx
-var {a = {}} = foo;
-var {a, b = {}} = foo;
-var {a = []} = foo;
-function foo({a = {}}) {}
-function foo({a = []}) {}
-var [a] = foo;
-```
-
### Invalid
```jsx
@@ -60,3 +47,16 @@ function foo({}) {}
</code></pre>{% endraw %}
+### Valid
+
+The following cases are valid because they create new bindings.
+
+```jsx
+var {a = {}} = foo;
+var {a, b = {}} = foo;
+var {a = []} = foo;
+function foo({a = {}}) {}
+function foo({a = []}) {}
+var [a] = foo;
+```
+

MODIFY
website/src/docs/lint/rules/noUnsafeNegation.md
website/src/docs/lint/rules/noUnsafeNegation.md
@@ -9,17 +9,6 @@ Disallow using unsafe negation.
## Examples
-### Valid
-
-```jsx
--1 in [1,2];
-~1 in [1,2];
-typeof 1 in [1,2];
-void 1 in [1,2];
-delete 1 in [1,2];
-+1 instanceof [1,2];
-```
-
### Invalid
```jsx
@@ -56,3 +45,14 @@ delete 1 in [1,2];
</code></pre>{% endraw %}
+### Valid
+
+```jsx
+-1 in [1,2];
+~1 in [1,2];
+typeof 1 in [1,2];
+void 1 in [1,2];
+delete 1 in [1,2];
++1 instanceof [1,2];
+```
+

MODIFY
website/src/docs/lint/rules/useShorthandArrayType.md
website/src/docs/lint/rules/useShorthandArrayType.md
@@ -9,14 +9,6 @@ When expressing array types, this rule promotes the usage of `T[]` shorthand ins
## Examples
-### Valid
-
-```ts
-let valid: Array<Foo | Bar>;
-let valid: Array<keyof Bar>;
-let valid: Array<foo | bar>;
-```
-
### Invalid
```ts
@@ -104,3 +96,11 @@ let invalid: Array<[number, number]>;
</code></pre>{% endraw %}
+### Valid
+
+```ts
+let valid: Array<Foo | Bar>;
+let valid: Array<keyof Bar>;
+let valid: Array<foo | bar>;
+```
+

docs: fix order of sections for lint rules (#2798)