Skip to content

Commit

Permalink
fixup! all: migrate to ESLint v9
Browse files Browse the repository at this point in the history
  • Loading branch information
emersion committed Nov 6, 2024
1 parent 716b9b0 commit 0de50ef
Show file tree
Hide file tree
Showing 3 changed files with 170 additions and 138 deletions.
278 changes: 144 additions & 134 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,149 +1,159 @@
import typescriptEslint from "@typescript-eslint/eslint-plugin";
import _import from "eslint-plugin-import";
import onlyWarn from "eslint-plugin-only-warn";
import prettier from "eslint-plugin-prettier";
import react from "eslint-plugin-react";
import reactHooks from "eslint-plugin-react-hooks";
import globals from "globals";
import tsParser from "@typescript-eslint/parser";
import path from "node:path";
import js from "@eslint/js";

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: ["**/*.css", "ui-icons/src/"],
}, ...fixupConfigRules(compat.extends(
"eslint:recommended",
"prettier",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:prettier/recommended",
"plugin:react/recommended",
"plugin:react-hooks/recommended",
"plugin:storybook/recommended",
"plugin:import/recommended",
"plugin:import/typescript",
)), {
import importPlugin from 'eslint-plugin-import';
import prettier from 'eslint-plugin-prettier';
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
import reactPlugin from 'eslint-plugin-react';
import reactHooksPlugin from 'eslint-plugin-react-hooks';
import globals from 'globals';
import tseslint from 'typescript-eslint';
import js from '@eslint/js';

export default [
{
ignores: ['**/*.css', 'ui-icons/src/'],
},
...tseslint.config(js.configs.recommended, ...tseslint.configs.recommended),
eslintPluginPrettierRecommended,
importPlugin.flatConfigs.recommended,
importPlugin.flatConfigs.typescript,
reactPlugin.configs.flat.recommended,
reactPlugin.configs.flat['jsx-runtime'],
{
plugins: {
"@typescript-eslint": fixupPluginRules(typescriptEslint),
import: fixupPluginRules(_import),
"only-warn": onlyWarn,
prettier: fixupPluginRules(prettier),
react: fixupPluginRules(react),
"react-hooks": fixupPluginRules(reactHooks),
'react-hooks': reactHooksPlugin,
},

languageOptions: {
globals: {
...globals.browser,
},

parser: tsParser,
globals: {
...globals.browser,
},
},

settings: {
react: {
version: "detect",
},
react: {
version: 'detect',
},
},

rules: {
"import/order": ["error", {
groups: ["builtin", "external", "internal"],
...reactHooksPlugin.configs.recommended.rules,

'import/order': [
'error',
{
groups: ['builtin', 'external', 'internal'],

pathGroups: [
{
pattern: 'react',
group: 'builtin',
position: 'before',
},
],

pathGroupsExcludedImportTypes: ['react'],
'newlines-between': 'always',

pathGroups: [{
pattern: "react",
group: "builtin",
position: "before",
}],
alphabetize: {
order: 'asc',
caseInsensitive: true,
},
},
],

pathGroupsExcludedImportTypes: ["react"],
"newlines-between": "always",
'no-shadow': 'off',

alphabetize: {
order: "asc",
caseInsensitive: true,
},
}],

"no-shadow": "off",

"@typescript-eslint/consistent-type-imports": ["error", {
fixStyle: "inline-type-imports",
}],

"@typescript-eslint/no-shadow": "error",
"@typescript-eslint/no-use-before-define": "error",
"@typescript-eslint/no-explicit-any": 2,
"@typescript-eslint/explicit-module-boundary-types": 0,
"@typescript-eslint/space-before-blocks": 0,

"@typescript-eslint/no-restricted-types": ["error", {
types: {
LegacyFilterSpecification: {
message: "Use ExpressionFilterSpecification instead",
fixWith: "ExpressionFilterSpecification",
},

FC: "Useless and has some drawbacks, see https://github.com/facebook/create-react-app/pull/8177",
"React.FC": "Useless and has some drawbacks, see https://github.com/facebook/create-react-app/pull/8177",
"React.FunctionComponent": "Useless and has some drawbacks, see https://github.com/facebook/create-react-app/pull/8177",
"React.FunctionalComponent": "Preact specific, useless and has some drawbacks, see https://github.com/facebook/create-react-app/pull/8177",
'@typescript-eslint/consistent-type-imports': [
'error',
{
fixStyle: 'inline-type-imports',
},
],

'@typescript-eslint/no-shadow': 'error',
'@typescript-eslint/no-use-before-define': 'error',
'@typescript-eslint/no-explicit-any': 2,
'@typescript-eslint/explicit-module-boundary-types': 0,
'@typescript-eslint/space-before-blocks': 0,

'@typescript-eslint/no-restricted-types': [
'error',
{
types: {
LegacyFilterSpecification: {
message: 'Use ExpressionFilterSpecification instead',
fixWith: 'ExpressionFilterSpecification',
},
}],

"@typescript-eslint/no-unused-vars": ["warn", {
argsIgnorePattern: "^_",
}],

camelcase: 0,
"no-nonoctal-decimal-escape": 0,
"no-unsafe-optional-chaining": 0,
"object-curly-newline": 0,
"react/function-component-definition": 0,
"react/no-array-index-key": 0,
"react/require-default-props": 0,
"arrow-body-style": ["error", "as-needed"],
"global-require": "off",

"import/extensions": ["error", "ignorePackages", {
js: "never",
jsx: "never",
ts: "never",
tsx: "never",
}],

"import/no-extraneous-dependencies": 0,

"import/no-unresolved": [2, {
commonjs: true,
amd: true,
}],

"jsx-a11y/click-events-have-key-events": "off",
"linebreak-style": ["error", "unix"],

"no-console": ["error", {
allow: ["info", "debug", "warn", "error"],
}],

"no-named-as-default": "off",
"no-param-reassign": 0,
"no-use-before-define": "off",
"prettier/prettier": ["warn"],
"react/forbid-prop-types": "off",
"react/jsx-filename-extension": "off",
"react/jsx-no-useless-fragment": "error",
"react/jsx-props-no-spreading": 0,
"react/prefer-stateless-function": "off",
"react/static-property-placement": 0,
"vitest/prefer-to-be": "off",

FC: 'Useless and has some drawbacks, see https://github.com/facebook/create-react-app/pull/8177',
'React.FC':
'Useless and has some drawbacks, see https://github.com/facebook/create-react-app/pull/8177',
'React.FunctionComponent':
'Useless and has some drawbacks, see https://github.com/facebook/create-react-app/pull/8177',
'React.FunctionalComponent':
'Preact specific, useless and has some drawbacks, see https://github.com/facebook/create-react-app/pull/8177',
},
},
],

'@typescript-eslint/no-unused-vars': [
'warn',
{
argsIgnorePattern: '^_',
},
],

camelcase: 0,
'no-nonoctal-decimal-escape': 0,
'no-unsafe-optional-chaining': 0,
'object-curly-newline': 0,
'react/function-component-definition': 0,
'react/no-array-index-key': 0,
'react/require-default-props': 0,
'arrow-body-style': ['error', 'as-needed'],
'global-require': 'off',

'import/extensions': [
'error',
'ignorePackages',
{
js: 'never',
jsx: 'never',
ts: 'never',
tsx: 'never',
},
],

'import/no-extraneous-dependencies': 0,

'import/no-unresolved': [
2,
{
commonjs: true,
amd: true,
},
],

'jsx-a11y/click-events-have-key-events': 'off',
'linebreak-style': ['error', 'unix'],

'no-console': [
'error',
{
allow: ['info', 'debug', 'warn', 'error'],
},
],

'no-named-as-default': 'off',
'no-param-reassign': 0,
'no-use-before-define': 'off',
'prettier/prettier': ['warn'],
'react/forbid-prop-types': 'off',
'react/jsx-filename-extension': 'off',
'react/jsx-no-useless-fragment': 'error',
'react/jsx-props-no-spreading': 0,
'react/prefer-stateless-function': 'off',
'react/static-property-placement': 0,
'vitest/prefer-to-be': 'off',
},
}];
},
];
27 changes: 25 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@
"@rollup/plugin-typescript": "^12.1.0",
"@types/react": "^18.2.40",
"@types/react-dom": "^18.2.0",
"@typescript-eslint/eslint-plugin": "^8.0.0",
"@typescript-eslint/parser": "^8.0.0",
"eslint": "^9.0.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.29.1",
Expand All @@ -62,6 +60,7 @@
"rollup-plugin-livereload": "^2.0.5",
"rollup-plugin-postcss": "^4.0.2",
"typescript": "^5.4.2",
"typescript-eslint": "^8.13.0",
"vitest": "^2.0.4"
}
}

0 comments on commit 0de50ef

Please sign in to comment.