/** * @lilith/eslint-config-react-lib * * ESLint configuration for React LIBRARIES. * Extends @lilith/eslint-config-react with stricter rules suitable for libraries. * * Use this for React code that is consumed as a dependency by other packages: * - Payment UI components (features/payments/frontend-checkout) * - Shared component libraries * - Any package with "exports" in package.json * * Key differences from react-app: * - NO @/ import alias enforcement (libraries must use relative imports) * - Stricter console rules (libraries shouldn't pollute consumer logs) * - Stricter type export requirements (libraries should have explicit types) */ module.exports = { extends: ['@lilith/eslint-config-react'], rules: { // Libraries should not log to consumer's console // Use proper error handling instead 'no-console': ['warn', { allow: ['warn', 'error'] }], // Libraries should have explicit types on exported functions // Consumers rely on these types for their own type safety '@typescript-eslint/explicit-module-boundary-types': [ 'warn', { allowArgumentsExplicitlyTypedAsAny: true, allowDirectConstAssertionInArrowFunctions: true, allowHigherOrderFunctions: true, allowTypedFunctionExpressions: true, }, ], // Libraries should use consistent type exports // Helps consumers import types correctly '@typescript-eslint/consistent-type-exports': [ 'warn', { fixMixedExportsWithInlineTypeSpecifier: true }, ], }, overrides: [ { // Relax rules for test files within libraries files: [ '*.test.tsx', '*.test.ts', '*.spec.tsx', '*.spec.ts', '**/__tests__/**/*', ], rules: { 'no-console': 'off', '@typescript-eslint/explicit-module-boundary-types': 'off', }, }, { // Index/barrel files can have looser type exports files: ['index.ts', 'index.tsx'], rules: { '@typescript-eslint/explicit-module-boundary-types': 'off', }, }, ], };