Skip to content

Commit

Permalink
Fixed eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
pkolt committed Dec 6, 2024
1 parent 11e12d3 commit a8db51a
Show file tree
Hide file tree
Showing 7 changed files with 481 additions and 547 deletions.
61 changes: 21 additions & 40 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,58 +1,39 @@
import path from 'node:path';
import { fileURLToPath } from 'node:url';

import { fixupConfigRules, fixupPluginRules } from '@eslint/compat';
import globals from 'globals';
import pluginJs from '@eslint/js';
import tseslint from 'typescript-eslint';
import pluginReact from 'eslint-plugin-react';
import reactRefresh from 'eslint-plugin-react-refresh';
import typescriptEslint from '@typescript-eslint/eslint-plugin';
import tsParser from '@typescript-eslint/parser';
import js from '@eslint/js';
import { FlatCompat } from '@eslint/eslintrc';

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,
});
import pluginReactHooks from 'eslint-plugin-react-hooks';

/** @type {import('eslint').Linter.Config[]} */
export default [
{
ignores: ['**/dist', '**/eslint.config.js'],
},
...fixupConfigRules(
compat.extends(
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react-hooks/recommended',
'plugin:react/recommended',
),
),
pluginJs.configs.recommended,
...tseslint.configs.recommended,
pluginReact.configs.flat.recommended,
reactRefresh.configs.recommended,

// https://github.com/facebook/react/issues/28313
{
plugins: {
'react-refresh': reactRefresh,
'@typescript-eslint': fixupPluginRules(typescriptEslint),
},

languageOptions: {
parser: tsParser,
'react-hooks': pluginReactHooks,
rules: pluginReactHooks.configs.recommended.rules,
},
},

settings: {
react: {
version: 'detect',
},
},
// It's mad: https://github.com/eslint/eslint/issues/19093
// { ignores: ['dist', 'node_modules', 'coverage'] },

{ files: ['**/*.{ts,tsx}'] },
{ settings: { react: { version: 'detect' } } },
{ languageOptions: { globals: globals.browser } },
{
rules: {
'react-refresh/only-export-components': [
'error',
{
allowConstantExport: true,
},
],

'no-console': ['error', { allow: ['warn', 'error'] }],
'react/react-in-jsx-scope': ['off'],
'react/prop-types': ['off'],
Expand Down
Loading

0 comments on commit a8db51a

Please sign in to comment.