From 8a7b2e3d524513e5a75f836152b58ade177f2fad Mon Sep 17 00:00:00 2001 From: Tan Nguyen Date: Mon, 17 Sep 2018 09:22:59 +0700 Subject: [PATCH] lifecycle methods util --- lib/rules/no-arrow-function-lifecycle.js | 21 +------------------- lib/util/lifecycleMethods.js | 25 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 20 deletions(-) create mode 100644 lib/util/lifecycleMethods.js diff --git a/lib/rules/no-arrow-function-lifecycle.js b/lib/rules/no-arrow-function-lifecycle.js index b10a4ffd12..6666f40b4c 100644 --- a/lib/rules/no-arrow-function-lifecycle.js +++ b/lib/rules/no-arrow-function-lifecycle.js @@ -7,26 +7,7 @@ const Components = require('../util/Components'); const astUtil = require('../util/ast'); const docsUrl = require('../util/docsUrl'); - -const lifecycleMethods = [ - 'getDefaultProps', - 'getInitialState', - 'getChildContext', - 'getDerivedStateFromProps', - 'componentWillMount', - 'UNSAFE_componentWillMount', - 'componentDidMount', - 'componentWillReceiveProps', - 'UNSAFE_componentWillReceiveProps', - 'shouldComponentUpdate', - 'componentWillUpdate', - 'UNSAFE_componentWillUpdate', - 'getSnapshotBeforeUpdate', - 'componentDidUpdate', - 'componentDidCatch', - 'componentWillUnmount', - 'render' -]; +const lifecycleMethods = require('../util/lifecycleMethods'); module.exports = { meta: { diff --git a/lib/util/lifecycleMethods.js b/lib/util/lifecycleMethods.js new file mode 100644 index 0000000000..2fed165647 --- /dev/null +++ b/lib/util/lifecycleMethods.js @@ -0,0 +1,25 @@ +/** + * @fileoverview lifecycle methods + * @author Tan Nguyen + */ +'use strict'; + +module.exports = [ + 'getDefaultProps', + 'getInitialState', + 'getChildContext', + 'getDerivedStateFromProps', + 'componentWillMount', + 'UNSAFE_componentWillMount', + 'componentDidMount', + 'componentWillReceiveProps', + 'UNSAFE_componentWillReceiveProps', + 'shouldComponentUpdate', + 'componentWillUpdate', + 'UNSAFE_componentWillUpdate', + 'getSnapshotBeforeUpdate', + 'componentDidUpdate', + 'componentDidCatch', + 'componentWillUnmount', + 'render' +];