Skip to content

Commit

Permalink
Merge pull request #1621 from kamataryo/master
Browse files Browse the repository at this point in the history
Add null avoidance in rule `require-optimization`
  • Loading branch information
ljharb authored Dec 22, 2017
2 parents f40b7b8 + 22c9237 commit 5f1ec80
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 5f1ec80

Please sign in to comment.