Add eqeqeq rule but require == for null

This commit is contained in:
Jamie Kyle 2022-09-14 14:40:44 -07:00 committed by GitHub
parent 64a4d2e717
commit 0086216c9d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
30 changed files with 64 additions and 63 deletions

View file

@ -8,6 +8,7 @@ export type NullToUndefined<T> = Extract<T, null> extends never
export function dropNull<T>(
value: NonNullable<T> | null | undefined
): T | undefined {
// eslint-disable-next-line eqeqeq
if (value === null) {
return undefined;
}
@ -22,7 +23,7 @@ export function shallowDropNull<O extends { [key: string]: any }>(
[Property in keyof O]: NullToUndefined<O[Property]>;
}
| undefined {
if (value === null || value === undefined) {
if (value == null) {
return undefined;
}

View file

@ -2,7 +2,7 @@
// SPDX-License-Identifier: AGPL-3.0-only
export function isNotNil<T>(value: T | null | undefined): value is T {
if (value === null || value === undefined) {
if (value == null) {
return false;
}
return true;

View file

@ -2,4 +2,4 @@
// SPDX-License-Identifier: AGPL-3.0-only
export const isRecord = (value: unknown): value is Record<string, unknown> =>
typeof value === 'object' && !Array.isArray(value) && value !== null;
typeof value === 'object' && !Array.isArray(value) && value != null;

View file

@ -7,7 +7,7 @@ import { getOwn } from './getOwn';
export function isIterable(value: unknown): value is Iterable<unknown> {
return (
(typeof value === 'object' && value !== null && Symbol.iterator in value) ||
(typeof value === 'object' && value != null && Symbol.iterator in value) ||
typeof value === 'string'
);
}

View file

@ -27,7 +27,7 @@ export function memoizeByRoot<F extends Function>(
const wrap = (root: unknown, ...rest: Array<unknown>): unknown => {
strictAssert(
typeof root === 'object' && root !== null,
typeof root === 'object' && root != null,
'Root is not object'
);

View file

@ -336,7 +336,7 @@ function binaryToUint8Array(
length: number
): Uint8Array {
const target = get(object, path);
if (target === null || target === undefined) {
if (target == null) {
throw new Error(`binaryToUint8Array: Falsey path ${path}`);
}
@ -357,7 +357,7 @@ function binaryToUint8Array(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function getInteger(object: any, path: string): number {
const target = get(object, path);
if (target === null || target === undefined) {
if (target == null) {
throw new Error(`getInteger: Falsey path ${path}`);
}