Skip to content

Commit 533610d

Browse files
committed
Chore: remove unused null check.
1 parent 617d1cc commit 533610d

5 files changed

+12
-23
lines changed

lib/rules/consistent-output.js

-3
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ module.exports = {
3030
return {
3131
Program (ast) {
3232
utils.getTestInfo(context, ast).forEach(testRun => {
33-
if (!testRun.invalid) {
34-
return;
35-
}
3633
const readableCases = testRun.invalid.filter(testCase => testCase.type === 'ObjectExpression');
3734
const casesWithoutOutput = readableCases
3835
.filter(testCase => testCase.properties.map(utils.getKeyName).indexOf('output') === -1);

lib/rules/no-identical-tests.js

+1-7
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,6 @@ module.exports = {
3737
*@returns {boolean} if eq, return true, else return false.
3838
*/
3939
function eq (testA, testB) {
40-
// https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/issues/35
41-
if (!testA || !testB) {
42-
return testA === testB;
43-
}
44-
4540
if (testA.type !== testB.type) {
4641
return false;
4742
}
@@ -78,8 +73,7 @@ module.exports = {
7873
utils.getTestInfo(context, ast).forEach(testRun => {
7974
[testRun.valid, testRun.invalid].forEach(tests => {
8075
const cache = [];
81-
// to avoid tests being null
82-
(tests || []).forEach(test => {
76+
tests.forEach(test => {
8377
if (cache.some(item => eq(item, test))) {
8478
context.report({
8579
node: test,

lib/rules/prefer-output-null.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ module.exports = {
3333
return {
3434
Program (ast) {
3535
utils.getTestInfo(context, ast).forEach(testRun => {
36-
(testRun.invalid || []).forEach(test => {
36+
testRun.invalid.forEach(test => {
3737
/**
3838
* Get a test case's giving keyname node.
3939
* @param {string} the keyname to find.

lib/rules/test-case-property-ordering.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ module.exports = {
3737
Program (ast) {
3838
utils.getTestInfo(context, ast).forEach(testRun => {
3939
[testRun.valid, testRun.invalid].forEach(tests => {
40-
(tests || []).forEach(test => {
40+
tests.forEach(test => {
4141
const properties = (test && test.properties) || [];
4242
const keyNames = properties.map(utils.getKeyName);
4343

lib/rules/test-case-shorthand-strings.js

+9-11
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,15 @@ module.exports = {
3737
*/
3838
function reportTestCases (cases) {
3939
const caseInfoList = cases.map(testCase => {
40-
if (testCase) {
41-
if (testCase.type === 'Literal' || testCase.type === 'TemplateLiteral') {
42-
return { node: testCase, shorthand: true, needsLongform: false };
43-
}
44-
if (testCase.type === 'ObjectExpression') {
45-
return {
46-
node: testCase,
47-
shorthand: false,
48-
needsLongform: !(testCase.properties.length === 1 && utils.getKeyName(testCase.properties[0]) === 'code'),
49-
};
50-
}
40+
if (testCase.type === 'Literal' || testCase.type === 'TemplateLiteral') {
41+
return { node: testCase, shorthand: true, needsLongform: false };
42+
}
43+
if (testCase.type === 'ObjectExpression') {
44+
return {
45+
node: testCase,
46+
shorthand: false,
47+
needsLongform: !(testCase.properties.length === 1 && utils.getKeyName(testCase.properties[0]) === 'code'),
48+
};
5149
}
5250
return null;
5351
}).filter(Boolean);

0 commit comments

Comments
 (0)