Skip to content

Commit

Permalink
Update to flatConfig and eslint v9
Browse files Browse the repository at this point in the history
  • Loading branch information
Saurabh authored and DevilsAutumn committed Nov 22, 2024
1 parent 92f81c3 commit 5fd30c9
Show file tree
Hide file tree
Showing 99 changed files with 2,955 additions and 2,310 deletions.
28 changes: 0 additions & 28 deletions frontend/.eslintrc.json

This file was deleted.

1 change: 0 additions & 1 deletion frontend/.prettierrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"semi": false,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "all",
Expand Down
157 changes: 157 additions & 0 deletions frontend/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
import path from 'node:path';
import { fileURLToPath } from 'node:url';

import { fixupConfigRules, fixupPluginRules } from '@eslint/compat';
import { FlatCompat } from '@eslint/eslintrc';
import js from '@eslint/js';
import typescriptEslint from '@typescript-eslint/eslint-plugin';
import tsParser from '@typescript-eslint/parser';
import react from 'eslint-plugin-react';
import reactHooks from 'eslint-plugin-react-hooks';
import tailwind from 'eslint-plugin-tailwindcss';
import tseslint from 'typescript-eslint';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
});

export default [
...tseslint.config({
languageOptions: {
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
},
}),
js.configs.recommended,
...tailwind.configs['flat/recommended'],
...fixupConfigRules(
compat.extends(
'eslint:recommended',
'plugin:react/recommended',
'plugin:react-hooks/recommended',
'plugin:prettier/recommended',
'next',
),
),
{
plugins: {
'@typescript-eslint': fixupPluginRules(typescriptEslint),
react: fixupPluginRules(react),
'react-hooks': fixupPluginRules(reactHooks),
},

languageOptions: {
parser: tsParser,
ecmaVersion: 2020,
sourceType: 'module',

parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
},
settings: {
react: {
version: 'detect',
},
'import/resolver': {
typescript: {
alwaysTryTypes: true,
},
},
},
rules: {
'import/named': 'error',
'import/namespace': 'error',
'import/default': 'error',
'import/export': 'error',
'prefer-const': 'warn',
eqeqeq: 'error',
'no-var': 'warn',
'no-unused-vars': 'warn',
'no-duplicate-imports': 'error',
'object-shorthand': 'warn',
'quote-props': ['warn', 'as-needed'],
'react/prop-types': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/consistent-type-exports': 'error',
'@typescript-eslint/consistent-type-imports': [
'error',
{
disallowTypeAnnotations: false,
fixStyle: 'separate-type-imports',
prefer: 'type-imports',
},
],
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-import-type-side-effects': 'error',
// 'no-restricted-imports': [
// 'warn',
// {
// patterns: [
// {
// group: ['@/*'],
// message: "Avoid using '@/'. Use '@' instead.",
// },
// ],
// },
// ],
'sort-imports': [
'warn',
{
ignoreCase: true,
ignoreDeclarationSort: true,
ignoreMemberSort: false,
memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
allowSeparatedGroups: false,
},
],
'import/order': [
'warn',
{
groups: [
'builtin',
'external',
'internal',
'parent',
'sibling',
'index',
'object',
'type',
],
pathGroups: [
{
pattern: 'react',
group: 'external',
position: 'before',
},
{
pattern: '@**',
group: 'internal',
position: 'before',
},
],
pathGroupsExcludedImportTypes: ['react'],
'newlines-between': 'always',
alphabetize: {
order: 'asc',
caseInsensitive: true,
},
},
],
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'warn',
'react/react-in-jsx-scope': 'off',
'tailwindcss/no-custom-classname': 'warn',
'tailwindcss/classnames-order': 'warn',
'prettier/prettier': 'warn',
},
},
];
Loading

0 comments on commit 5fd30c9

Please sign in to comment.