Files
payload/test/eslint.config.js
Jarrod Flesch 48115311e7 fix(ui): incorrect error states (#11574)
Fixes https://github.com/payloadcms/payload/issues/11568

### What? Out of sync errors states
- Collaspibles & Tabs were not reporting accurate child error counts
- Arrays could get into a state where they would not update their error
states
- Slight issue with toasts 

### Tabs & Collapsibles
The logic for determining matching field paths was not functioning as
intended. Fields were attempting to match with paths such as `_index-0`
which will not work.

### Arrays
The form state was not updating when the server sent back errorPaths.
This PR adds `errorPaths` to `serverPropsToAccept`.

### Toasts
Some toasts could report errors in the form of `my > > error`. This
ensures they will be `my > error`

### Misc
Removes 2 files that were not in use:
- `getFieldStateFromPaths.ts`
- `getNestedFieldState.ts`
2025-03-06 14:02:10 -05:00

85 lines
2.7 KiB
JavaScript

import { defaultESLintIgnores, rootEslintConfig, rootParserOptions } from '../eslint.config.js'
import payloadPlugin from '@payloadcms/eslint-plugin'
import playwright from 'eslint-plugin-playwright'
/** @typedef {import('eslint').Linter.Config} Config */
/** @type {Config[]} */
export const testEslintConfig = [
...rootEslintConfig,
{
ignores: [...defaultESLintIgnores, '**/payload-types.ts', 'jest.setup.js'],
},
{
languageOptions: {
parserOptions: {
...rootParserOptions,
tsconfigRootDir: import.meta.dirname,
},
},
rules: {
'payload/no-relative-monorepo-imports': 'error',
},
},
{
files: ['**/*.ts'],
rules: {
'payload/no-jsx-import-statements': 'warn',
'payload/no-relative-monorepo-imports': 'error',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-use-before-define': 'off',
// turn the @typescript-eslint/unbound-method rule off *only* for test files. See https://typescript-eslint.io/rules/unbound-method/#when-not-to-use-it
'@typescript-eslint/unbound-method': 'off',
'no-console': 'off',
'perfectionist/sort-objects': 'off',
},
},
{
files: ['**/*.int.spec.ts', '**/int.spec.ts'],
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'jest/prefer-strict-equal': 'off',
},
},
{
...playwright.configs['flat/recommended'],
files: ['**/*.e2e.spec.ts', '**/e2e.spec.ts', 'helpers.ts'],
},
{
files: ['**/*.e2e.spec.ts', '**/e2e.spec.ts', 'helpers.ts'],
rules: {
'payload/no-relative-monorepo-imports': 'error',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-use-before-define': 'off',
'jest/consistent-test-it': 'off',
'jest/expect-expect': 'off',
'jest/no-test-callback': 'off',
'jest/prefer-strict-equal': 'off',
'jest/require-top-level-describe': 'off',
'jest-dom/prefer-to-have-attribute': 'off',
'playwright/prefer-web-first-assertions': 'error',
'payload/no-flaky-assertions': 'warn',
'payload/no-wait-function': 'warn',
// Enable the no-non-retryable-assertions rule ONLY for hunting for flakes
// 'payload/no-non-retryable-assertions': 'error',
'playwright/expect-expect': [
'error',
{
assertFunctionNames: ['assertToastErrors', 'saveDocAndAssert', 'runFilterOptionsTest'],
},
],
},
},
{
files: ['*.e2e.ts'],
rules: {
'payload/no-relative-monorepo-imports': 'error',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-use-before-define': 'off',
'jest/expect-expect': 'off',
},
},
]
export default testEslintConfig