Skip to content

Commit

Permalink
chore: eslint config migrated to v9
Browse files Browse the repository at this point in the history
  • Loading branch information
Onizuka-wl committed Sep 30, 2024
1 parent 4b83223 commit 82e679e
Show file tree
Hide file tree
Showing 6 changed files with 3,004 additions and 3,074 deletions.
24 changes: 0 additions & 24 deletions .eslintrc.cjs

This file was deleted.

78 changes: 78 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
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 tsParser from '@typescript-eslint/parser';
import prettierConfig from 'eslint-config-prettier';
import importPlugin from 'eslint-plugin-import';
import prettierPlugin from 'eslint-plugin-prettier';
import reactRefresh from 'eslint-plugin-react-refresh';
import globals from 'globals';

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 [
{
ignores: ['**/dist', '**/eslint.config.mjs'],
},
...fixupConfigRules(
compat.extends(
'prettier',
'eslint:recommended',
'plugin:react/recommended',
'plugin:jsx-a11y/recommended',
'plugin:@typescript-eslint/recommended',
'plugin:import/typescript',
'plugin:react/jsx-runtime',
'plugin:react-hooks/recommended',
'plugin:prettier/recommended',
'plugin:@next/next/recommended',
),
),
{
files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx', '**/*.mjs', '**/*.cjs'],
plugins: {
'react-refresh': reactRefresh,
import: fixupPluginRules(importPlugin),
prettier: fixupPluginRules(prettierPlugin),
},
languageOptions: {
globals: {
...globals.browser,
},
parser: tsParser,
},
rules: {
'import/order': [
'error',
{
// Enforce a specific import order
groups: ['builtin', 'external', 'parent', 'sibling', 'index'],
'newlines-between': 'always',
alphabetize: {
order: 'asc',
caseInsensitive: false,
},
},
],
'import/no-duplicates': 'error',
// Prettier plugin to apply formatting rules
'prettier/prettier': 'error', // This tells ESLint to show Prettier errors as ESLint errors
},
settings: {
// Spread Prettier config to disable conflicting ESLint rules
...prettierConfig,
react: {
version: 'detect',
},
},
},
];
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@
},
"devDependencies": {
"@defi-wonderland/crypto-husky-checks": "1.4.0",
"@eslint/compat": "1.1.1",
"@eslint/eslintrc": "3.1.0",
"@eslint/js": "9.11.1",
"@jest/globals": "29.7.0",
"@testing-library/jest-dom": "6.5.0",
"@testing-library/react": "16.0.1",
Expand All @@ -70,6 +73,7 @@
"eslint-plugin-react": "7.37.0",
"eslint-plugin-react-hooks": "4.6.0",
"eslint-plugin-react-refresh": "0.4.12",
"globals": "15.9.0",
"husky": "9.1.6",
"jest": "29.7.0",
"jest-environment-jsdom": "29.7.0",
Expand Down
Loading

0 comments on commit 82e679e

Please sign in to comment.