Skip to content

Commit

Permalink
fix feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
ngtan committed Sep 20, 2021
1 parent 6c06917 commit ba886fd
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rules/no-arrow-function-lifecycle.js
Expand Up @@ -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]];
Expand Down
30 changes: 30 additions & 0 deletions tests/lib/rules/no-typos.js
Expand Up @@ -1745,6 +1745,9 @@ ruleTester.run('no-typos', rule, {
proptypes: {},
childcontexttypes: {},
contexttypes: {},
getdefaultProps() { },
getinitialState() { },
getChildcontext() { },
ComponentWillMount() { },
ComponentDidMount() { },
ComponentWillReceiveProps() { },
Expand All @@ -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'},
Expand Down Expand Up @@ -1833,6 +1848,9 @@ ruleTester.run('no-typos', rule, {
proptypes: {},
childcontexttypes: {},
contexttypes: {},
getdefaultProps() { },
getinitialState() { },
getChildcontext() { },
ComponentWillMount() { },
ComponentDidMount() { },
ComponentWillReceiveProps() { },
Expand All @@ -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'},
Expand Down

0 comments on commit ba886fd

Please sign in to comment.