Skip to content

Commit 2f2a8a8

Browse files
author
Ev Haus
committed
Fixes #1369
1 parent 8511835 commit 2f2a8a8

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

lib/rules/boolean-prop-naming.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @fileoverview Enforces consistent naming for boolean props
3-
* @author Evgueni Naverniouk
3+
* @author Ev Haus
44
*/
55
'use strict';
66

@@ -57,7 +57,7 @@ module.exports = {
5757
function isPropTypesDeclaration(node) {
5858
// Special case for class properties
5959
// (babel-eslint does not expose property name so we have to rely on tokens)
60-
if (node.type === 'ClassProperty') {
60+
if (node && node.type === 'ClassProperty') {
6161
const tokens = context.getFirstTokens(node, 2);
6262
if (tokens[0].value === 'propTypes' || (tokens[1] && tokens[1].value === 'propTypes')) {
6363
return true;

tests/lib/rules/boolean-prop-naming.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @fileoverview Enforces consistent naming for boolean props
3-
* @author Evgueni Naverniouk
3+
* @author Ev Haus
44
*/
55
'use strict';
66

@@ -247,6 +247,16 @@ ruleTester.run('boolean-prop-naming', rule, {
247247
rule: '^is[A-Z]([A-Za-z0-9]?)+'
248248
}],
249249
parser: 'babel-eslint'
250+
}, {
251+
// Ensure rule doesn't crash on destructured objects [Issue #1369]
252+
code: [
253+
'var x = {a: 1}',
254+
'var y = {...x}'
255+
].join('\n'),
256+
options: [{
257+
rule: '^is[A-Z]([A-Za-z0-9]?)+'
258+
}],
259+
parser: 'babel-eslint'
250260
}],
251261

252262
invalid: [{

0 commit comments

Comments
 (0)