Skip to content

Commit

Permalink
Add null avoidance
Browse files Browse the repository at this point in the history
  • Loading branch information
kamataryo committed Dec 22, 2017
1 parent f40b7b8 commit 22c9237
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rules/require-optimization.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ module.exports = {
let hasPR = false;
if (node.value && node.value.elements) {
for (let i = 0, l = node.value.elements.length; i < l; i++) {
if (node.value.elements[i].name === 'PureRenderMixin') {
if (node.value.elements[i] && node.value.elements[i].name === 'PureRenderMixin') {
hasPR = true;
break;
}
Expand Down
4 changes: 4 additions & 0 deletions tests/lib/rules/require-optimization.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ ruleTester.run('react-require-optimization', rule, {
`,
parser: 'babel-eslint',
options: [{allowDecorators: ['renderPure', 'pureRender']}]
}, {
code: `
const obj = { prop: [,,,,,] }
`
}],

invalid: [{
Expand Down

0 comments on commit 22c9237

Please sign in to comment.