Skip to content

Commit

Permalink
all: migrate to ESLint v9
Browse files Browse the repository at this point in the history
Migrating to the new config file format is required:
https://eslint.org/docs/latest/use/configure/migration-guide

The new config file has been automatically generated with
@eslint/migrate-config.

Signed-off-by: Simon Ser <[email protected]>
  • Loading branch information
emersion committed Nov 4, 2024
1 parent b1a9cc9 commit 954ab22
Show file tree
Hide file tree
Showing 4 changed files with 686 additions and 234 deletions.
127 changes: 0 additions & 127 deletions .eslintrc

This file was deleted.

152 changes: 152 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
import { fixupConfigRules, fixupPluginRules } from "@eslint/compat";
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 { fileURLToPath } from "node:url";
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
});

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",
)), {
plugins: {
"@typescript-eslint": fixupPluginRules(typescriptEslint),
import: fixupPluginRules(_import),
"only-warn": onlyWarn,
prettier: fixupPluginRules(prettier),
react: fixupPluginRules(react),
"react-hooks": fixupPluginRules(reactHooks),
},

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

parser: tsParser,
},

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

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

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

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

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/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",
},
}];
Loading

0 comments on commit 954ab22

Please sign in to comment.