diff --git a/lib/rules/no-arrow-function-lifecycle.js b/lib/rules/no-arrow-function-lifecycle.js index 1e8cebc7ca..5cd5691f1d 100644 --- a/lib/rules/no-arrow-function-lifecycle.js +++ b/lib/rules/no-arrow-function-lifecycle.js @@ -44,7 +44,7 @@ module.exports = { properties.forEach((node) => { const propertyName = astUtil.getPropertyName(node); const nodeType = node.value.type; - const isLifecycleMethod = lifecycleMethods.includes(propertyName); + const isLifecycleMethod = lifecycleMethods.indexOf(propertyName) > -1; if (nodeType === 'ArrowFunctionExpression' && isLifecycleMethod) { const range = [node.key.range[1], node.value.body.range[0]]; diff --git a/tests/lib/rules/no-typos.js b/tests/lib/rules/no-typos.js index bf67682454..bf9239beee 100644 --- a/tests/lib/rules/no-typos.js +++ b/tests/lib/rules/no-typos.js @@ -1745,6 +1745,9 @@ ruleTester.run('no-typos', rule, { proptypes: {}, childcontexttypes: {}, contexttypes: {}, + getdefaultProps() { }, + getinitialState() { }, + getChildcontext() { }, ComponentWillMount() { }, ComponentDidMount() { }, ComponentWillReceiveProps() { }, @@ -1767,6 +1770,18 @@ ruleTester.run('no-typos', rule, { }, { messageId: 'typoPropDeclaration', type: 'Identifier' + }, { + messageId: 'typoLifecycleMethod', + data: {actual: 'getdefaultProps', expected: 'getDefaultProps'}, + type: 'Property' + }, { + messageId: 'typoLifecycleMethod', + data: {actual: 'getinitialState', expected: 'getInitialState'}, + type: 'Property' + }, { + messageId: 'typoLifecycleMethod', + data: {actual: 'getChildcontext', expected: 'getChildContext'}, + type: 'Property' }, { messageId: 'typoLifecycleMethod', data: {actual: 'ComponentWillMount', expected: 'componentWillMount'}, @@ -1833,6 +1848,9 @@ ruleTester.run('no-typos', rule, { proptypes: {}, childcontexttypes: {}, contexttypes: {}, + getdefaultProps() { }, + getinitialState() { }, + getChildcontext() { }, ComponentWillMount() { }, ComponentDidMount() { }, ComponentWillReceiveProps() { }, @@ -1856,6 +1874,18 @@ ruleTester.run('no-typos', rule, { }, { messageId: 'typoPropDeclaration', type: 'Identifier' + }, { + messageId: 'typoLifecycleMethod', + data: {actual: 'getdefaultProps', expected: 'getDefaultProps'}, + type: 'Property' + }, { + messageId: 'typoLifecycleMethod', + data: {actual: 'getinitialState', expected: 'getInitialState'}, + type: 'Property' + }, { + messageId: 'typoLifecycleMethod', + data: {actual: 'getChildcontext', expected: 'getChildContext'}, + type: 'Property' }, { messageId: 'typoLifecycleMethod', data: {actual: 'ComponentWillMount', expected: 'componentWillMount'},