From f2dc5043a1038a2db58c3e9c59102f96c960d8f2 Mon Sep 17 00:00:00 2001 From: Joe Lencioni Date: Tue, 22 Dec 2015 11:46:17 -0800 Subject: [PATCH] [eslint-config] [minor] Enable react/no-is-mounted rule isMounted is an anti-pattern [0], is not available when using ES6 classes, and is on its way to being officially deprecated. eslint-plugin-react recently added the react/no-is-mounted rule in 3.12.0 that prevents its use. [0]: https://facebook.github.io/react/blog/2015/12/16/ismounted-antipattern.html Finishes #633 --- packages/eslint-config-airbnb/rules/react.js | 3 +++ react/README.md | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index 4cc9e0d1..bc71327c 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -48,6 +48,9 @@ module.exports = { // Prevent usage of setState in componentDidUpdate // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-did-update-set-state.md 'react/no-did-update-set-state': [2, 'allow-in-func'], + // Prevent usage of isMounted + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-is-mounted.md + 'react/no-is-mounted': 2, // Prevent multiple component definition per file // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-multi-comp.md 'react/no-multi-comp': 2, diff --git a/react/README.md b/react/README.md index 3b53d2c0..549e853d 100644 --- a/react/README.md +++ b/react/README.md @@ -15,6 +15,7 @@ 1. [Tags](#tags) 1. [Methods](#methods) 1. [Ordering](#ordering) + 1. [`isMounted`](#ismounted) ## Basic Rules @@ -334,4 +335,12 @@ eslint rules: [`react/sort-comp`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/sort-comp.md). +## `isMounted` + + [`isMounted` is an anti-pattern][anti-pattern], is not available when using ES6 classes, and is on its way to being officially deprecated. Its use should be avoided. + + [anti-pattern]: https://facebook.github.io/react/blog/2015/12/16/ismounted-antipattern.html + + eslint rules: [`react/no-is-mounted`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-is-mounted.md). + **[⬆ back to top](#table-of-contents)**