-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.js
More file actions
105 lines (97 loc) · 2.88 KB
/
eslint.config.js
File metadata and controls
105 lines (97 loc) · 2.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
// eslint.config.js (Flat config)
import { dirname } from 'path';
import { fileURLToPath } from 'url';
import { FlatCompat } from '@eslint/eslintrc';
import js from '@eslint/js';
import tseslint from 'typescript-eslint';
import prettier from 'eslint-config-prettier';
import functional from 'eslint-plugin-functional';
import importPlugin from 'eslint-plugin-import';
import unusedImports from 'eslint-plugin-unused-imports';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
});
export default [
{
ignores: [
'node_modules/**',
'.next/**',
'out/**',
'build/**',
'next-env.d.ts',
'**/*.config.js',
'**/*.config.mjs',
'**/*.config.ts',
],
},
// Base JS / TS support
js.configs.recommended,
...tseslint.configs.recommended, // Use recommended instead of recommendedTypeChecked for less strictness
// Next.js rules (using compat for legacy config)
...compat.extends('next/core-web-vitals', 'next/typescript'),
// Plugins
{
plugins: {
functional,
import: importPlugin,
'unused-imports': unusedImports,
},
languageOptions: {
parserOptions: {
project: ['./tsconfig.json'],
tsconfigRootDir: process.cwd(),
},
},
settings: {
'import/resolver': {
typescript: true,
node: true,
},
},
rules: {
// Functional style (relaxed for practicality)
'functional/immutable-data': 'off', // Too strict for typical Next.js apps
'functional/no-let': 'off', // Allow let for practical use
'functional/prefer-readonly-type': 'off',
'functional/no-classes': 'off', // Classes are common in services/DI
'functional/no-try-statement': 'off',
// TS best practices
'@typescript-eslint/consistent-type-imports': ['error', { prefer: 'type-imports' }],
'@typescript-eslint/no-unused-vars': 'off', // replaced by unused-imports
'unused-imports/no-unused-imports': 'error',
'unused-imports/no-unused-vars': [
'warn',
{ args: 'after-used', argsIgnorePattern: '^_', varsIgnorePattern: '^_' },
],
// Imports hygiene
'import/order': [
'warn',
{
groups: ['builtin', 'external', 'internal', ['parent', 'sibling', 'index'], 'type'],
'newlines-between': 'always',
alphabetize: { order: 'asc', caseInsensitive: true },
},
],
// React / Next niceties
'react/jsx-boolean-value': ['warn', 'never'],
'react/self-closing-comp': 'warn',
'@next/next/no-html-link-for-pages': 'off', // if using app router only
},
},
// Make Prettier the source of truth for formatting
{
name: 'prettier-compat',
ignores: ['**/*.yml', '**/*.yaml'], // Prettier override handles spaces there
...prettier,
},
// Test & config file overrides
{
files: ['**/*.test.*', '**/*.spec.*', 'vitest.config.*', 'jest.config.*'],
rules: {
'functional/no-try-statement': 'off',
'functional/no-let': 'off',
},
},
];