- Upgrades eslint from v8 to v9 - Upgrades all other eslint packages. We will have to do a new full-project lint, as new rules have been added - Upgrades husky from v8 to v9 - Upgrades lint-staged from v14 to v15 - Moves the old .eslintrc.cjs file format to the new eslint.config.js flat file format. Previously, we were very specific regarding which rules are applied to which files. Now that `extends` is no longer a thing, I have to use deepMerge & imports instead. This is rather uncommon and is not a documented pattern - e.g. typescript-eslint docs want us to add the default typescript-eslint rules to the top-level & then disable it in files using the disable-typechecked config. However, I hate this opt-out approach. The way I did it here adds a lot of clarity as to which rules are applied to which files, and is pretty easy to read. Much less black magic ## .eslintignore These files are no longer supported (see https://eslint.org/docs/latest/use/configure/migration-guide#ignoring-files). I moved the entries to the ignores property in the eslint config. => one less file in each package folder!
87 lines
1.9 KiB
JavaScript
87 lines
1.9 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/',
|
|
]
|
|
|
|
/** @typedef {import('eslint').Linter.FlatConfig} */
|
|
let FlatConfig
|
|
|
|
export const rootParserOptions = {
|
|
EXPERIMENTAL_useSourceOfProjectReferenceRedirect: true,
|
|
EXPERIMENTAL_useProjectService: {
|
|
allowDefaultProjectForFiles: ['./src/*.ts', './src/*.tsx'],
|
|
},
|
|
sourceType: 'module',
|
|
ecmaVersion: 'latest',
|
|
}
|
|
|
|
/** @type {FlatConfig[]} */
|
|
export const rootEslintConfig = [
|
|
...payloadEsLintConfig,
|
|
{
|
|
ignores: [...defaultESLintIgnores, 'test/live-preview/next-app', 'packages/**/*.spec.ts'],
|
|
},
|
|
{
|
|
languageOptions: {
|
|
parserOptions: {
|
|
project: './tsconfig.json',
|
|
tsconfigDirName: import.meta.dirname,
|
|
...rootParserOptions,
|
|
},
|
|
},
|
|
},
|
|
{
|
|
plugins: {
|
|
payload: payloadPlugin,
|
|
},
|
|
rules: {
|
|
'payload/no-jsx-import-statements': 'warn',
|
|
'payload/no-relative-monorepo-imports': 'error',
|
|
'payload/no-imports-from-exports-dir': 'error',
|
|
},
|
|
},
|
|
{
|
|
files: ['scripts/**/*.ts'],
|
|
rules: {
|
|
'@typescript-eslint/no-unused-vars': 'off',
|
|
'no-console': 'off',
|
|
'perfectionist/sort-object-types': 'off',
|
|
'perfectionist/sort-objects': 'off',
|
|
},
|
|
},
|
|
]
|
|
|
|
export default [
|
|
...rootEslintConfig,
|
|
{
|
|
files: ['packages/eslint-config/**/*.ts'],
|
|
rules: {
|
|
'perfectionist/sort-objects': 'off',
|
|
},
|
|
},
|
|
{
|
|
files: ['templates/vercel-postgres/**'],
|
|
rules: {
|
|
'no-restricted-exports': 'off',
|
|
},
|
|
},
|
|
]
|