Skip to content

Latest commit

 

History

History
100 lines (78 loc) · 1.01 KB

no-useless-undefined.md

File metadata and controls

100 lines (78 loc) · 1.01 KB

Disallow useless undefined

This rule is fixable.

Fail

let foo = undefined;
const {foo = undefined} = bar;
const noop = () => undefined;
function foo() {
	return undefined;
}
function* foo() {
	yield undefined;
}
function foo(bar = undefined) {
}
function foo({bar = undefined}) {
}
foo(undefined);

Pass

let foo;
const {foo} = bar;
const noop = () => {};
function foo() {
	return;
}
function* foo() {
	yield;
}
function foo(bar) {
}
function foo({bar}) {
}
foo();

Conflict with ESLint array-callback-return rule

We recommend setting the ESLint array-callback-return rule option allowImplicit to true:

{
	"rules": {
		"array-callback-return": [
			"error",
			{
				"allowImplicit": true
			}
		]
	}
}