Skip to content

Commit ba886fd

Browse files
committed
fix feedback
1 parent 6c06917 commit ba886fd

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

lib/rules/no-arrow-function-lifecycle.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ module.exports = {
4444
properties.forEach((node) => {
4545
const propertyName = astUtil.getPropertyName(node);
4646
const nodeType = node.value.type;
47-
const isLifecycleMethod = lifecycleMethods.includes(propertyName);
47+
const isLifecycleMethod = lifecycleMethods.indexOf(propertyName) > -1;
4848

4949
if (nodeType === 'ArrowFunctionExpression' && isLifecycleMethod) {
5050
const range = [node.key.range[1], node.value.body.range[0]];

tests/lib/rules/no-typos.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1745,6 +1745,9 @@ ruleTester.run('no-typos', rule, {
17451745
proptypes: {},
17461746
childcontexttypes: {},
17471747
contexttypes: {},
1748+
getdefaultProps() { },
1749+
getinitialState() { },
1750+
getChildcontext() { },
17481751
ComponentWillMount() { },
17491752
ComponentDidMount() { },
17501753
ComponentWillReceiveProps() { },
@@ -1767,6 +1770,18 @@ ruleTester.run('no-typos', rule, {
17671770
}, {
17681771
messageId: 'typoPropDeclaration',
17691772
type: 'Identifier'
1773+
}, {
1774+
messageId: 'typoLifecycleMethod',
1775+
data: {actual: 'getdefaultProps', expected: 'getDefaultProps'},
1776+
type: 'Property'
1777+
}, {
1778+
messageId: 'typoLifecycleMethod',
1779+
data: {actual: 'getinitialState', expected: 'getInitialState'},
1780+
type: 'Property'
1781+
}, {
1782+
messageId: 'typoLifecycleMethod',
1783+
data: {actual: 'getChildcontext', expected: 'getChildContext'},
1784+
type: 'Property'
17701785
}, {
17711786
messageId: 'typoLifecycleMethod',
17721787
data: {actual: 'ComponentWillMount', expected: 'componentWillMount'},
@@ -1833,6 +1848,9 @@ ruleTester.run('no-typos', rule, {
18331848
proptypes: {},
18341849
childcontexttypes: {},
18351850
contexttypes: {},
1851+
getdefaultProps() { },
1852+
getinitialState() { },
1853+
getChildcontext() { },
18361854
ComponentWillMount() { },
18371855
ComponentDidMount() { },
18381856
ComponentWillReceiveProps() { },
@@ -1856,6 +1874,18 @@ ruleTester.run('no-typos', rule, {
18561874
}, {
18571875
messageId: 'typoPropDeclaration',
18581876
type: 'Identifier'
1877+
}, {
1878+
messageId: 'typoLifecycleMethod',
1879+
data: {actual: 'getdefaultProps', expected: 'getDefaultProps'},
1880+
type: 'Property'
1881+
}, {
1882+
messageId: 'typoLifecycleMethod',
1883+
data: {actual: 'getinitialState', expected: 'getInitialState'},
1884+
type: 'Property'
1885+
}, {
1886+
messageId: 'typoLifecycleMethod',
1887+
data: {actual: 'getChildcontext', expected: 'getChildContext'},
1888+
type: 'Property'
18591889
}, {
18601890
messageId: 'typoLifecycleMethod',
18611891
data: {actual: 'ComponentWillMount', expected: 'componentWillMount'},

0 commit comments

Comments
 (0)