Skip to content

Commit 99a001d

Browse files
authored
Merge pull request #48 from sectsect/update-dependencies
chore: migrate ESLint config to flat config
2 parents 5b7ae9e + fea792a commit 99a001d

4 files changed

Lines changed: 3943 additions & 2890 deletions

File tree

.eslintrc

Lines changed: 0 additions & 137 deletions
This file was deleted.

eslint.config.mjs

Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
/* eslint-disable import/no-extraneous-dependencies */
2+
/* eslint-disable no-underscore-dangle */
3+
/* eslint-disable import/no-anonymous-default-export */
4+
5+
// ESLint core and compatibility utilities
6+
import js from '@eslint/js';
7+
import { FlatCompat } from '@eslint/eslintrc';
8+
// import { fixupPluginRules } from '@eslint/compat';
9+
import globals from 'globals';
10+
11+
// ESLint plugins for various technologies and best practices
12+
import react from 'eslint-plugin-react';
13+
import reactHooks from 'eslint-plugin-react-hooks';
14+
import jsxA11Y from 'eslint-plugin-jsx-a11y';
15+
import typescriptEslint from '@typescript-eslint/eslint-plugin';
16+
// import tseslint from 'typescript-eslint';
17+
import unusedImports from 'eslint-plugin-unused-imports';
18+
import tailwindcss from 'eslint-plugin-tailwindcss';
19+
import tsdoc from 'eslint-plugin-tsdoc';
20+
import _import from 'eslint-plugin-import';
21+
import prettier from 'eslint-plugin-prettier';
22+
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
23+
import testingLibrary from 'eslint-plugin-testing-library';
24+
import vitest from '@vitest/eslint-plugin';
25+
import deprecation from 'eslint-plugin-deprecation';
26+
// import nextPlugin from '@next/eslint-plugin-next';
27+
import pluginQuery from '@tanstack/eslint-plugin-query';
28+
29+
const compat = new FlatCompat({
30+
baseDirectory: import.meta.dirname, // Added in: v21.2.0, v20.11.0 @ https://nodejs.org/api/esm.html#importmetadirname
31+
recommendedConfig: js.configs.recommended,
32+
allConfig: js.configs.all,
33+
});
34+
35+
export default [
36+
// Ignore specific files and directories
37+
{
38+
ignores: [
39+
'**/dist/**',
40+
'**/out/**',
41+
'**/build/**',
42+
'**/node_modules/**',
43+
'**/playwright-report/**',
44+
'**/coverage/**',
45+
'**/.next/**',
46+
'**/.storybook/**',
47+
'**/*.config.{js,cjs,mjs}',
48+
'**/vendor/**',
49+
],
50+
},
51+
52+
// Base configuration extensions
53+
...compat.extends('airbnb', 'airbnb-typescript'),
54+
55+
// Detailed settings for TypeScript and React files
56+
{
57+
files: ['**/*.{ts,tsx}', '**/*.{test,spec}.{ts,tsx}'],
58+
59+
plugins: {
60+
react,
61+
'react-hooks': reactHooks,
62+
'jsx-a11y': jsxA11Y,
63+
'@typescript-eslint': typescriptEslint,
64+
// '@typescript-eslint': tseslint.plugin, // Commented out. This is because the @typescript-eslint plugin is already loaded by ...compat.extends('airbnb-typescript').
65+
// '@next/next': nextPlugin,
66+
'unused-imports': unusedImports,
67+
'@tanstack/query': pluginQuery,
68+
// deprecation: fixupPluginRules(deprecationPlugin),
69+
deprecation,
70+
tailwindcss,
71+
tsdoc,
72+
import: _import,
73+
prettier,
74+
'testing-library': testingLibrary,
75+
vitest,
76+
},
77+
78+
languageOptions: {
79+
ecmaVersion: 'latest',
80+
sourceType: 'module',
81+
// parser: tseslint.parser,
82+
parserOptions: {
83+
project: './tsconfig.json',
84+
},
85+
globals: {
86+
...globals.browser,
87+
...globals.node,
88+
...globals.jquery,
89+
window: true,
90+
lazySizes: true,
91+
},
92+
},
93+
94+
settings: {
95+
react: {
96+
version: '19.0.0',
97+
},
98+
},
99+
100+
rules: {
101+
// Prettier rules
102+
'prettier/prettier': 'error',
103+
104+
// React rules
105+
'react/require-default-props': 'off',
106+
'react/jsx-props-no-spreading': 'off',
107+
'react/no-danger': 'off',
108+
'react/function-component-definition': [
109+
2,
110+
{
111+
namedComponents: 'arrow-function',
112+
unnamedComponents: 'arrow-function',
113+
},
114+
],
115+
// Performance and optimization rules
116+
'react/jsx-no-useless-fragment': 'error',
117+
118+
// Accessibility rules
119+
'jsx-a11y/anchor-is-valid': 'off',
120+
'jsx-a11y/label-has-associated-control': [
121+
2,
122+
{
123+
assert: 'either',
124+
},
125+
],
126+
'jsx-a11y/control-has-associated-label': 'off',
127+
128+
// Next.js rules
129+
// '@next/next/no-img-element': 'off',
130+
131+
// Import rules
132+
'import/order': [
133+
'error',
134+
{
135+
groups: ['builtin', 'external', 'internal'],
136+
pathGroups: [
137+
{
138+
pattern: 'react',
139+
group: 'external',
140+
position: 'before',
141+
},
142+
],
143+
pathGroupsExcludedImportTypes: ['react'],
144+
'newlines-between': 'always',
145+
alphabetize: {
146+
order: 'asc',
147+
caseInsensitive: true,
148+
},
149+
},
150+
],
151+
'import/prefer-default-export': 'off',
152+
'import/no-duplicates': 'error',
153+
154+
// TypeScript rules
155+
'@typescript-eslint/comma-dangle': 'off',
156+
'@typescript-eslint/consistent-type-imports': 'error',
157+
'@typescript-eslint/no-unnecessary-condition': 'error',
158+
// '@typescript-eslint/strict-boolean-expressions': 'error',
159+
'@typescript-eslint/no-explicit-any': 'error',
160+
'@typescript-eslint/no-unused-vars': 'off',
161+
'@typescript-eslint/prefer-optional-chain': 'error',
162+
163+
// Unused imports/variables rules
164+
'unused-imports/no-unused-imports': 'error',
165+
'unused-imports/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
166+
167+
// Other miscellaneous rules
168+
'no-underscore-dangle': 'off',
169+
'tailwindcss/no-custom-classname': 'off',
170+
'tsdoc/syntax': 'warn',
171+
'no-console': ['warn', { allow: ['warn', 'error'] }],
172+
},
173+
},
174+
175+
// Additional rules for test files
176+
{
177+
files: ['**/*.{test,spec}.{ts,tsx}'],
178+
rules: {
179+
'vitest/consistent-test-it': ['error', { fn: 'test' }],
180+
'vitest/require-top-level-describe': [
181+
'error',
182+
{ maxNumberOfTopLevelDescribes: 2 },
183+
],
184+
},
185+
},
186+
187+
// Keep Prettier configuration last to avoid conflicts
188+
eslintPluginPrettierRecommended,
189+
];

0 commit comments

Comments
 (0)