chore(eslint-config): disable broken jest/prefer-spy-on rule

This commit is contained in:
Alessio Gravili
2024-07-11 15:44:18 -04:00
parent 29205cd209
commit ebcfc2d284
4 changed files with 9 additions and 8 deletions

View File

@@ -14,7 +14,7 @@ import { getValidTemplates } from './templates.js'
describe('createProject', () => { describe('createProject', () => {
let projectDir: string let projectDir: string
beforeAll(() => { beforeAll(() => {
jest.spyOn(console, 'log').mockImplementation() console.log = jest.fn()
}) })
beforeEach(() => { beforeEach(() => {

View File

@@ -22,7 +22,7 @@ export const index = {
'jest/prefer-called-with': 'error', 'jest/prefer-called-with': 'error',
'jest/prefer-expect-assertions': 'off', 'jest/prefer-expect-assertions': 'off',
'jest/prefer-hooks-on-top': 'error', 'jest/prefer-hooks-on-top': 'error',
'jest/prefer-spy-on': 'error', 'jest/prefer-spy-on': 'off', // broken in packages/create-payload-app/src/lib/create-project.spec.ts
'jest/prefer-strict-equal': 'warn', 'jest/prefer-strict-equal': 'warn',
'jest/prefer-to-contain': 'error', 'jest/prefer-to-contain': 'error',
'jest/prefer-to-have-length': 'error', 'jest/prefer-to-have-length': 'error',

View File

@@ -92,9 +92,7 @@ function $splitNodeContainingQuery(match: MenuTextMatch): TextNode | null {
} }
const selectionOffset = anchor.offset const selectionOffset = anchor.offset
const textContent = anchorNode.getTextContent().slice(0, selectionOffset) const textContent = anchorNode.getTextContent().slice(0, selectionOffset)
// eslint-disable-next-line react/destructuring-assignment
const characterOffset = match.replaceableString.length const characterOffset = match.replaceableString.length
// eslint-disable-next-line react/destructuring-assignment
const queryOffset = getFullMatchOffset(textContent, match.matchingString, characterOffset) const queryOffset = getFullMatchOffset(textContent, match.matchingString, characterOffset)
const startOffset = selectionOffset - queryOffset const startOffset = selectionOffset - queryOffset
if (startOffset < 0) { if (startOffset < 0) {

View File

@@ -1,5 +1,5 @@
import type { I18nClient } from '@payloadcms/translations' import type { I18nClient } from '@payloadcms/translations'
import type { LexicalEditor } from 'lexical' import type { LexicalEditor, Spread } from 'lexical'
import type { MutableRefObject } from 'react' import type { MutableRefObject } from 'react'
import type React from 'react' import type React from 'react'
@@ -37,6 +37,9 @@ export type SlashMenuItemInternal = {
ref: MutableRefObject<HTMLButtonElement | null> ref: MutableRefObject<HTMLButtonElement | null>
} & SlashMenuItem } & SlashMenuItem
export type SlashMenuGroupInternal = { export type SlashMenuGroupInternal = Spread<
{
items: Array<SlashMenuItemInternal> items: Array<SlashMenuItemInternal>
} & SlashMenuGroup },
SlashMenuGroup
>