diff --git a/crates/oxc_linter/src/rules/react/no_is_mounted.rs b/crates/oxc_linter/src/rules/react/no_is_mounted.rs
index 969ebf21ff763..be76412d62f6a 100644
--- a/crates/oxc_linter/src/rules/react/no_is_mounted.rs
+++ b/crates/oxc_linter/src/rules/react/no_is_mounted.rs
@@ -10,8 +10,8 @@ use crate::{
};
fn no_is_mounted_diagnostic(span: Span) -> OxcDiagnostic {
- OxcDiagnostic::warn("Do not use isMounted")
- .with_help("isMounted is on its way to being officially deprecated. You can use a _isMounted property to track the mounted status yourself.")
+ OxcDiagnostic::warn("Do not use `isMounted`")
+ .with_help("`isMounted` is on its way to being officially deprecated. You can use an `_isMounted` property to track the mounted status yourself.")
.with_label(span)
}
@@ -21,16 +21,17 @@ pub struct NoIsMounted;
declare_oxc_lint!(
/// ### What it does
///
- /// This rule prevents using isMounted in classes
+ /// This rule prevents using `isMounted` in classes.
///
/// ### Why is this bad?
///
- /// isMounted is an anti-pattern, is not available when using classes,
- /// and it is on its way to being officially deprecated.///
+ /// `isMounted` is an anti-pattern, is not available when using classes,
+ /// and it is on its way to being officially deprecated.
///
/// ### Examples
///
/// Examples of **incorrect** code for this rule:
+ ///
/// ```jsx
/// class Hello extends React.Component {
/// someMethod() {
@@ -102,6 +103,18 @@ fn test() {
",
None,
),
+ (
+ "
+ class Hello extends React.Component {
+ notIsMounted() {}
+ render() {
+ this.notIsMounted();
+ return
Hello
;
+ }
+ };
+ ",
+ None,
+ ),
];
let fail = vec![
diff --git a/crates/oxc_linter/src/snapshots/react_no_is_mounted.snap b/crates/oxc_linter/src/snapshots/react_no_is_mounted.snap
index 5f0809fe305c9..e86995e9496da 100644
--- a/crates/oxc_linter/src/snapshots/react_no_is_mounted.snap
+++ b/crates/oxc_linter/src/snapshots/react_no_is_mounted.snap
@@ -1,29 +1,29 @@
---
source: crates/oxc_linter/src/tester.rs
---
- ⚠ eslint-plugin-react(no-is-mounted): Do not use isMounted
+ ⚠ eslint-plugin-react(no-is-mounted): Do not use `isMounted`
╭─[no_is_mounted.tsx:4:24]
3 │ componentDidUpdate: function() {
4 │ if (!this.isMounted()) {
· ────────────────
5 │ return;
╰────
- help: isMounted is on its way to being officially deprecated. You can use a _isMounted property to track the mounted status yourself.
+ help: `isMounted` is on its way to being officially deprecated. You can use an `_isMounted` property to track the mounted status yourself.
- ⚠ eslint-plugin-react(no-is-mounted): Do not use isMounted
+ ⚠ eslint-plugin-react(no-is-mounted): Do not use `isMounted`
╭─[no_is_mounted.tsx:4:24]
3 │ someMethod: function() {
4 │ if (!this.isMounted()) {
· ────────────────
5 │ return;
╰────
- help: isMounted is on its way to being officially deprecated. You can use a _isMounted property to track the mounted status yourself.
+ help: `isMounted` is on its way to being officially deprecated. You can use an `_isMounted` property to track the mounted status yourself.
- ⚠ eslint-plugin-react(no-is-mounted): Do not use isMounted
+ ⚠ eslint-plugin-react(no-is-mounted): Do not use `isMounted`
╭─[no_is_mounted.tsx:4:24]
3 │ someMethod() {
4 │ if (!this.isMounted()) {
· ────────────────
5 │ return;
╰────
- help: isMounted is on its way to being officially deprecated. You can use a _isMounted property to track the mounted status yourself.
+ help: `isMounted` is on its way to being officially deprecated. You can use an `_isMounted` property to track the mounted status yourself.