Skip to content

Commit

Permalink
Upgrade eslint to v9
Browse files Browse the repository at this point in the history
  • Loading branch information
anajavi committed Dec 5, 2024
1 parent 977c3d7 commit 85199b5
Show file tree
Hide file tree
Showing 17 changed files with 296 additions and 442 deletions.
38 changes: 0 additions & 38 deletions .eslintrc

This file was deleted.

1 change: 0 additions & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-env node */
const ENV = process.env.BABEL_ENV || process.env.NODE_ENV || 'development';

let config = {
Expand Down
81 changes: 81 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import eslint from '@eslint/js';
import { includeIgnoreFile } from '@eslint/compat';
import path from 'node:path';

import globals from 'globals';
import reactPlugin from 'eslint-plugin-react';
import reactHooksPlugin from 'eslint-plugin-react-hooks';
import reactPerfPlugin from 'eslint-plugin-react-perf';
import importPlugin from 'eslint-plugin-import';
import prettierRecommended from 'eslint-plugin-prettier/recommended';

const gitignorePath = path.resolve(import.meta.dirname, '.gitignore');

/** @type {import('@typescript-eslint/utils').TSESLint.FlatConfig.ConfigFile} */
export default [
includeIgnoreFile(gitignorePath),
{
name: 'global ignore',
// If ignores is used without any other keys in the configuration object,
// then the patterns act as global ignores.
ignores: []
},
eslint.configs.recommended,
reactPlugin.configs.flat.recommended,
importPlugin.flatConfigs.errors,
reactPerfPlugin.configs.flat['recommended'],
{
plugins: { 'react-hooks': reactHooksPlugin },
settings: {
// version config for eslint-plugin-react
react: {
version: 'detect'
}
}
},
prettierRecommended,
{
name: 'src and test rules',
files: ['packages/*/+(src|test)/**/*'],
languageOptions: {
globals: {
...globals.browser,
process: 'readonly'
}
},
rules: {
'no-unused-vars': ['error', { ignoreRestSiblings: true }],
'no-console': 'error',
'react/prop-types': 'off',
'prefer-object-spread': 'warn',
'react-hooks/rules-of-hooks': 'error',
'react/jsx-no-constructed-context-values': 'error'
}
},
{
name: 'jest tests',
files: [`packages/*/test/**`],
languageOptions: {
globals: {
...globals.jest,
...globals.node
}
},
rules: {
'react/prop-types': 'off',
'react/display-name': 'off',
'react-perf/jsx-no-new-object-as-prop': 'off',
'react-perf/jsx-no-new-function-as-prop': 'off',
'react-perf/jsx-no-new-array-as-prop': 'off'
}
},
{
// rules for everybody else
ignores: [`packages/*/+(src|test)/**`],
languageOptions: {
globals: {
...globals.node
}
}
}
];
Loading

0 comments on commit 85199b5

Please sign in to comment.