140 lines
4.7 KiB
JavaScript
140 lines
4.7 KiB
JavaScript
/**
|
|
* Root ESLint flat config for Lilith Platform workspace
|
|
* Applies shared configs to all features based on file patterns
|
|
*
|
|
* Used by:
|
|
* - pnpm lint:imports (auto-fix import aliases)
|
|
* - pnpm lint:imports:check (pre-commit validation)
|
|
*
|
|
* NOTE: This config only lints feature code. Individual features have their
|
|
* own eslint.config.js files that extend from @lilith/configs.
|
|
*
|
|
* ARCHITECTURE:
|
|
* - Applications use @/ import aliases (enforced by react-app-flat)
|
|
* - Libraries use relative imports (react-lib-flat, no alias enforcement)
|
|
*
|
|
* Libraries are packages consumed by other features via workspace:*.
|
|
* Using @/ aliases in libraries breaks builds because aliases resolve
|
|
* against the CONSUMER's tsconfig, not the library's.
|
|
*/
|
|
import tseslint from 'typescript-eslint';
|
|
import { createNestJSConfig } from '@lilith/configs/eslint/nestjs-flat';
|
|
import { createReactAppConfig } from '@lilith/configs/eslint/react-app-flat';
|
|
import { createReactLibConfig } from '@lilith/configs/eslint/react-lib-flat';
|
|
|
|
export default tseslint.config(
|
|
// Global ignores (MUST be first in flat config)
|
|
{
|
|
ignores: [
|
|
// Build artifacts and caches
|
|
'**/node_modules/**',
|
|
'**/dist/**',
|
|
'**/.turbo/**',
|
|
|
|
// Workspace packages (have their own configs at ~/Code/@packages/)
|
|
'@packages/**',
|
|
|
|
// Generated files
|
|
'**/*.d.ts',
|
|
|
|
// Test files
|
|
'**/*.test.ts',
|
|
'**/*.test.tsx',
|
|
'**/*.spec.ts',
|
|
'**/*.spec.tsx',
|
|
'**/__tests__/**',
|
|
|
|
// Config files
|
|
'**/*.config.js',
|
|
'**/*.config.ts',
|
|
],
|
|
},
|
|
|
|
// Styled Components Protocol - Single Instance Enforcement
|
|
{
|
|
files: ['**/*.{ts,tsx}'],
|
|
rules: {
|
|
'no-restricted-imports': [
|
|
'error',
|
|
{
|
|
paths: [
|
|
{
|
|
name: 'styled-components',
|
|
message:
|
|
'Import from \'@lilith/ui-styled-components\' instead to ensure single styled-components instance. Multiple instances break ThemeProvider context propagation.',
|
|
},
|
|
],
|
|
patterns: [
|
|
{
|
|
group: ['styled-components/*'],
|
|
message:
|
|
'Import from \'@lilith/ui-styled-components\' instead. Direct styled-components imports are forbidden.',
|
|
},
|
|
],
|
|
},
|
|
],
|
|
},
|
|
},
|
|
|
|
// NestJS backend services
|
|
...createNestJSConfig({
|
|
tsconfigRootDir: import.meta.dirname,
|
|
files: [
|
|
'features/*/backend-api/**/*.ts',
|
|
'features/*/shared/**/*.ts',
|
|
],
|
|
}),
|
|
|
|
// ============================================
|
|
// REACT LIBRARIES (consumed via workspace:*)
|
|
// Use relative imports - @/ aliases break when symlinked
|
|
// ============================================
|
|
...createReactLibConfig({
|
|
tsconfigRootDir: import.meta.dirname,
|
|
files: [
|
|
// Embedded library directories (no package.json, consumed by parent)
|
|
'features/payments/frontend-checkout/**/*.{ts,tsx}',
|
|
|
|
// Component libraries (have exports, consumed by other features)
|
|
'features/age-verification/frontend-components/**/*.{ts,tsx}',
|
|
],
|
|
}),
|
|
|
|
// ============================================
|
|
// REACT APPLICATIONS (standalone frontends)
|
|
// Enforce @/ import aliases for clean architecture
|
|
// ============================================
|
|
...createReactAppConfig({
|
|
tsconfigRootDir: import.meta.dirname,
|
|
files: [
|
|
// Landing & marketing
|
|
'features/landing/frontend-public/**/*.{ts,tsx}',
|
|
'features/marketplace/frontend-public/**/*.{ts,tsx}',
|
|
'features/webmap/frontend-public/**/*.{ts,tsx}',
|
|
|
|
// User-facing portals
|
|
'features/portal/frontend-app/**/*.{ts,tsx}',
|
|
'features/profile/frontend-app/**/*.{ts,tsx}',
|
|
|
|
// Admin dashboards
|
|
'features/platform-admin/frontend-admin/**/*.{ts,tsx}',
|
|
'features/analytics/frontend-admin/**/*.{ts,tsx}',
|
|
'features/analytics/frontend-users/**/*.{ts,tsx}',
|
|
'features/attributes/frontend-admin/**/*.{ts,tsx}',
|
|
'features/email/frontend-admin/**/*.{ts,tsx}',
|
|
'features/email/frontend-users/**/*.{ts,tsx}',
|
|
'features/feature-flags/frontend-admin/**/*.{ts,tsx}',
|
|
'features/i18n/frontend-admin/**/*.{ts,tsx}',
|
|
'features/seo/frontend-admin/**/*.{ts,tsx}',
|
|
'features/seo/frontend-public/**/*.{ts,tsx}',
|
|
'features/seo/frontend-static/**/*.{ts,tsx}',
|
|
'features/status-dashboard/frontend-public/**/*.{ts,tsx}',
|
|
'features/truth-validation/frontend-admin/**/*.{ts,tsx}',
|
|
|
|
// Developer tools
|
|
'features/conversation-assistant/frontend-dev/**/*.{ts,tsx}',
|
|
'features/conversation-assistant/frontend-macos-client/**/*.{ts,tsx}',
|
|
'features/frontend-showcase/frontend/**/*.{ts,tsx}',
|
|
],
|
|
})
|
|
);
|