fix: add eqeqeq lint rule (#5106)

This commit is contained in:
LongYinan 2023-11-29 04:43:31 +00:00
parent a843dcd851
commit 923844f302
No known key found for this signature in database
GPG Key ID: 30B1140CE1C07C99
12 changed files with 18 additions and 16 deletions

View File

@ -127,6 +127,7 @@ const config = {
'no-constant-binary-expression': 'error',
'no-constructor-return': 'error',
'no-self-compare': 'error',
eqeqeq: ['error', 'always', { null: 'ignore' }],
'react/prop-types': 'off',
'react/jsx-no-useless-fragment': 'error',
'@typescript-eslint/consistent-type-imports': 'error',

View File

@ -42,7 +42,7 @@ function compare(yBinary: Buffer, jwstBinary: Buffer, strict = false): boolean {
function isEmptyBuffer(buf: Buffer): boolean {
return (
buf.length == 0 ||
buf.length === 0 ||
// 0x0000
(buf.length === 2 && buf[0] === 0 && buf[1] === 0)
);

View File

@ -50,7 +50,7 @@ function migrateDatabase(data: YMap<unknown>) {
update: (cell: { id: string; value: unknown }) => void
) => {
Object.values(cells).forEach(row => {
if (row[id] != null) {
if (row[id] !== null && row[id] !== undefined) {
update(row[id]);
}
});

View File

@ -195,7 +195,7 @@ export class Typesystem {
): boolean {
if (superType.type === 'typeRef') {
// TODO both are ref
if (context && sub.type != 'typeRef') {
if (context && sub.type !== 'typeRef') {
context[superType.name] = sub;
}
// TODO bound

View File

@ -141,7 +141,7 @@ filterMatcher.register(
name: 'is',
defaultArgs: () => [true],
impl: (value, target) => {
return value == target;
return value === target;
},
}
);
@ -209,7 +209,7 @@ filterMatcher.register(
defaultArgs: () => [],
impl: tags => {
const safeTags = safeArray(tags);
return safeTags.length == 0;
return safeTags.length === 0;
},
}
);

View File

@ -10,9 +10,9 @@ import * as styles from './page-list.css';
export function isToday(date: Date): boolean {
const today = new Date();
return (
date.getDate() == today.getDate() &&
date.getMonth() == today.getMonth() &&
date.getFullYear() == today.getFullYear()
date.getDate() === today.getDate() &&
date.getMonth() === today.getMonth() &&
date.getFullYear() === today.getFullYear()
);
}

View File

@ -179,7 +179,7 @@ export const PlanCard = (props: PlanCardProps) => {
{detail.benefits.map((content, i) => (
<div key={i} className={styles.planBenefit}>
<div className={styles.planBenefitIcon}>
{detail.type == 'dynamic' ? (
{detail.type === 'dynamic' ? (
<BulledListIcon color="var(--affine-processing-color)" />
) : (
<DoneIcon

View File

@ -85,7 +85,7 @@ const CollectionRenderer = ({
async (id: string) => {
await setting.updateCollection({
...collection,
allowList: collection.allowList?.filter(v => v != id),
allowList: collection.allowList?.filter(v => v !== id),
});
},
[collection, setting]

View File

@ -194,7 +194,8 @@ export const WorkspaceLayoutInner = ({
const blockVersions = meta.get('blockVersions');
if (
!(blockVersions instanceof YMap) &&
blockVersions != null &&
blockVersions !== null &&
blockVersions !== undefined &&
typeof blockVersions === 'object'
) {
meta.set(

View File

@ -105,7 +105,7 @@ export class CustomGitHubProvider extends BaseGitHubProvider<GithubUpdateInfo> {
);
}
if (tag == null) {
if (tag === null || tag === undefined) {
throw newError(
`No published versions on GitHub`,
'ERR_UPDATER_NO_PUBLISHED_VERSIONS'
@ -154,7 +154,7 @@ export class CustomGitHubProvider extends BaseGitHubProvider<GithubUpdateInfo> {
}
const result = parseUpdateInfo(rawData, channelFile, channelFileUrl);
if (result.releaseName == null) {
if (result.releaseName === null) {
result.releaseName = latestRelease.elementValueOrEmpty('title');
}

View File

@ -186,13 +186,13 @@ export class SyncEngine {
}
async waitForSynced(abort?: AbortSignal) {
if (this.status.step == SyncEngineStep.Synced) {
if (this.status.step === SyncEngineStep.Synced) {
return;
} else {
return Promise.race([
new Promise<void>(resolve => {
this.onStatusChange.on(status => {
if (status.step == SyncEngineStep.Synced) {
if (status.step === SyncEngineStep.Synced) {
resolve();
}
});

View File

@ -65,7 +65,7 @@ async function waitForScrollToFinish(page: Page) {
let lastScrollTop: number;
const interval = setInterval(() => {
const { scrollTop } = document.documentElement;
if (scrollTop != lastScrollTop) {
if (scrollTop !== lastScrollTop) {
lastScrollTop = scrollTop;
} else {
clearInterval(interval);