diff --git a/lib/rules/no-identical-tests.js b/lib/rules/no-identical-tests.js index 10b6d99d..d278b3de 100644 --- a/lib/rules/no-identical-tests.js +++ b/lib/rules/no-identical-tests.js @@ -37,6 +37,11 @@ module.exports = { *@returns {boolean} if eq, return true, else return false. */ function eq (testA, testB) { + // https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/issues/35 + if (!testA || !testB) { + return testA === testB; + } + if (testA.type !== testB.type) { return false; } diff --git a/lib/rules/test-case-property-ordering.js b/lib/rules/test-case-property-ordering.js index 7c16a66e..c1f60f02 100644 --- a/lib/rules/test-case-property-ordering.js +++ b/lib/rules/test-case-property-ordering.js @@ -38,7 +38,7 @@ module.exports = { utils.getTestInfo(context, ast).forEach(testRun => { [testRun.valid, testRun.invalid].forEach(tests => { (tests || []).forEach(test => { - const properties = test.properties || []; + const properties = (test && test.properties) || []; const keyNames = properties.map(utils.getKeyName); for (let i = 0, lastChecked; i < keyNames.length; i++) { diff --git a/lib/rules/test-case-shorthand-strings.js b/lib/rules/test-case-shorthand-strings.js index 863f86ad..f20a8c2f 100644 --- a/lib/rules/test-case-shorthand-strings.js +++ b/lib/rules/test-case-shorthand-strings.js @@ -37,15 +37,17 @@ module.exports = { */ function reportTestCases (cases) { const caseInfoList = cases.map(testCase => { - if (testCase.type === 'Literal' || testCase.type === 'TemplateLiteral') { - return { node: testCase, shorthand: true, needsLongform: false }; - } - if (testCase.type === 'ObjectExpression') { - return { - node: testCase, - shorthand: false, - needsLongform: !(testCase.properties.length === 1 && utils.getKeyName(testCase.properties[0]) === 'code'), - }; + if (testCase) { + if (testCase.type === 'Literal' || testCase.type === 'TemplateLiteral') { + return { node: testCase, shorthand: true, needsLongform: false }; + } + if (testCase.type === 'ObjectExpression') { + return { + node: testCase, + shorthand: false, + needsLongform: !(testCase.properties.length === 1 && utils.getKeyName(testCase.properties[0]) === 'code'), + }; + } } return null; }).filter(Boolean);