The `localized` properly was not stripped out of referenced block fields, if any parent was localized. For normal fields, this is done in sanitizeConfig. As the same referenced block config can be used in both a localized and non-localized config, we are not able to strip it out inside sanitizeConfig by modifying the block config. Instead, this PR had to bring back tedious logic to handle it everywhere the `field.localized` property is accessed. For backwards-compatibility, we need to keep the existing sanitizeConfig logic. In 4.0, we should remove it to benefit from better test coverage of runtime field.localized handling - for now, this is done for our test suite using the `PAYLOAD_DO_NOT_SANITIZE_LOCALIZED_PROPERTY` flag.
105 lines
2.2 KiB
JavaScript
105 lines
2.2 KiB
JavaScript
import payloadEsLintConfig from '@payloadcms/eslint-config'
|
|
import payloadPlugin from '@payloadcms/eslint-plugin'
|
|
|
|
export const defaultESLintIgnores = [
|
|
'**/.temp',
|
|
'**/.*', // ignore all dotfiles
|
|
'**/.git',
|
|
'**/.hg',
|
|
'**/.pnp.*',
|
|
'**/.svn',
|
|
'**/playwright.config.ts',
|
|
'**/jest.config.js',
|
|
'**/tsconfig.tsbuildinfo',
|
|
'**/README.md',
|
|
'**/eslint.config.js',
|
|
'**/payload-types.ts',
|
|
'**/dist/',
|
|
'**/.yarn/',
|
|
'**/build/',
|
|
'**/node_modules/',
|
|
'**/temp/',
|
|
'packages/**/*.spec.ts',
|
|
'next-env.d.ts',
|
|
'**/app',
|
|
'src/**/*.spec.ts',
|
|
'**/jest.setup.js',
|
|
]
|
|
|
|
/** @typedef {import('eslint').Linter.Config} Config */
|
|
|
|
export const rootParserOptions = {
|
|
sourceType: 'module',
|
|
ecmaVersion: 'latest',
|
|
projectService: true,
|
|
}
|
|
|
|
/** @type {Config[]} */
|
|
export const rootEslintConfig = [
|
|
...payloadEsLintConfig,
|
|
{
|
|
ignores: [
|
|
...defaultESLintIgnores,
|
|
'packages/eslint-*/**',
|
|
'test/live-preview/next-app',
|
|
'packages/**/*.spec.ts',
|
|
'templates/**',
|
|
'examples/**',
|
|
],
|
|
},
|
|
{
|
|
plugins: {
|
|
payload: payloadPlugin,
|
|
},
|
|
rules: {
|
|
'payload/no-jsx-import-statements': 'warn',
|
|
'payload/no-relative-monorepo-imports': 'error',
|
|
'payload/no-imports-from-exports-dir': 'error',
|
|
'payload/no-imports-from-self': 'error',
|
|
'payload/proper-payload-logger-usage': 'error',
|
|
},
|
|
},
|
|
{
|
|
files: ['scripts/**/*.ts'],
|
|
rules: {
|
|
'@typescript-eslint/no-unused-vars': 'off',
|
|
'no-console': 'off',
|
|
'perfectionist/sort-object-types': 'off',
|
|
'perfectionist/sort-objects': 'off',
|
|
},
|
|
},
|
|
{
|
|
files: ['tools/**/*.ts'],
|
|
rules: {
|
|
'no-console': 'off',
|
|
'perfectionist/sort-object-types': 'off',
|
|
'perfectionist/sort-objects': 'off',
|
|
},
|
|
},
|
|
]
|
|
|
|
export default [
|
|
...rootEslintConfig,
|
|
{
|
|
languageOptions: {
|
|
parserOptions: {
|
|
...rootParserOptions,
|
|
projectService: true,
|
|
tsconfigRootDir: import.meta.dirname,
|
|
},
|
|
},
|
|
},
|
|
{
|
|
files: ['packages/eslint-config/**/*.ts'],
|
|
rules: {
|
|
'perfectionist/sort-objects': 'off',
|
|
},
|
|
},
|
|
{
|
|
files: ['templates/vercel-postgres/**'],
|
|
rules: {
|
|
'no-restricted-exports': 'off',
|
|
},
|
|
},
|
|
]
|