import { allExtensionsStr } from '../constants/index.mjs'; import { withDefaultOption, type EslintImportsRules } from '../types/index.mjs'; export const eslintImportsRules = { // Not needed when using TypeScript. 'import-x/no-unresolved': 'off', // The following import-x resolution rules are redundant when using TypeScript: // the type-checker already reports missing named / default imports and invalid // namespace member access (TS2339). They also build large ExportMaps that are // slow and memory-heavy (a known cause of ESLint OOM on large codebases), so // keep them off for TypeScript. 'import-x/named': 'off', 'import-x/default': 'off', 'import-x/namespace': 'off', 'import-x/no-restricted-paths': 'off', // TODO 'import-x/no-absolute-path': withDefaultOption('error'), 'import-x/no-dynamic-require': withDefaultOption('error'), 'import-x/no-internal-modules': [ 'error', { allow: [ `*/index.{${allExtensionsStr}}`, `./index.{${allExtensionsStr}}`, 'rxjs/operators', 'solid-js/web', '@testing-library/jest-dom/**', 'react-dom/client', 'preact/**', 'immer/**', 'firebase/*', 'firebase-functions/**', '@blueprintjs/*', '@material-ui/**', '@mui/material', '@fontsource/**', 'resize-observer/lib/ResizeObserverEntry', 'vitest/config', 'zx/globals', ], }, ], 'import-x/no-webpack-loader-syntax': 'error', 'import-x/no-self-import': 'error', 'import-x/no-cycle': withDefaultOption('error'), 'import-x/no-useless-path-segments': withDefaultOption('error'), 'import-x/no-relative-parent-imports': 'off', // relates to @typescript-eslint/consistent-type-imports rule 'import-x/consistent-type-specifier-style': ['error', 'prefer-inline'], 'import-x/no-relative-packages': withDefaultOption('error'), // helpfulWarnings // Redundant with TypeScript: duplicate / conflicting exports are reported as // TS2323 / TS2528. 'import-x/export': 'off', 'import-x/no-named-as-default': 'error', // Redundant with TypeScript: accessing a named export through the default // import is already a type error. 'import-x/no-named-as-default-member': 'off', // prefer @typescript-eslint/no-deprecated (raised in import-js/eslint-plugin-import#1532) 'import-x/no-deprecated': 'off', 'import-x/no-extraneous-dependencies': 'off', 'import-x/no-mutable-exports': 'error', // TODO: https://github.com/noshiro-pf/mono/issues/98 // 'import-x/no-unused-modules': ['error', { unusedExports: true }], 'import-x/no-unused-modules': 'off', // moduleSystems 'import-x/unambiguous': 'error', 'import-x/no-commonjs': 'off', 'import-x/no-amd': 'error', 'import-x/no-nodejs-modules': 'off', 'import-x/no-import-module-exports': 'off', // styleGuide 'import-x/first': ['error', 'absolute-first'], 'import-x/exports-last': 'off', 'import-x/no-duplicates': withDefaultOption('error'), 'import-x/no-namespace': 'off', 'import-x/extensions': [ 'error', 'never', { pattern: { json: 'always', mjs: 'always' }, }, ], 'import-x/order': 'off', // Covered by prettier-plugin-organize-imports // 'import-x/order': [ // 'error', // { // groups: [], // 'newlines-between': 'never', // }, // ], 'import-x/newline-after-import': [ 'error', { considerComments: false, // Must be false for consistency with the @stylistic/padding-line-between-statements rule count: 1, }, ], 'import-x/max-dependencies': 'off', 'import-x/no-unassigned-import': [ 'error', { allow: [ '**/*.css', '@testing-library/jest-dom/**', 'solid-js', 'zx/globals', ], }, ], 'import-x/no-named-default': 'off', /** * Prohibit default exports as renaming on the definition side is not * reflected on the import side */ 'import-x/no-default-export': 'error', 'import-x/prefer-default-export': 'off', 'import-x/no-named-export': 'off', 'import-x/no-anonymous-default-export': withDefaultOption('error'), 'import-x/group-exports': 'off', 'import-x/dynamic-import-chunkname': 'off', 'import-x/no-empty-named-blocks': 'error', // Covered by unicorn/prefer-node-protocol // 'import/enforce-node-protocol-usage': ['error', 'always'], 'import-x/no-rename-default': withDefaultOption('error'), // Covered by react-coding-style/import-style 'import-x/prefer-namespace-import': 'off', // 'import-x/prefer-namespace-import': ['error', { patterns: ['react'] }], // deprecated rules 'import-x/imports-first': 0, } as const satisfies EslintImportsRules;