Browse Source

Update `eslint` configuration

Signed-off-by: Mihaela Balutoiu <mbalutoiu@cloudbasesolutions.com>
Mihaela Balutoiu 1 year ago
parent
commit
87bb2a4168
2 changed files with 72 additions and 38 deletions
  1. 0 38
      .eslintrc.js
  2. 72 0
      eslint.config.mjs

+ 0 - 38
.eslintrc.js

@@ -1,38 +0,0 @@
-module.exports = {
-  env: {
-    browser: true,
-    es2021: true,
-    jest: true,
-    node: true,
-  },
-  extends: [
-    "eslint:recommended",
-    "plugin:react/recommended",
-    "plugin:@typescript-eslint/recommended",
-    "prettier",
-  ],
-  overrides: [],
-  parser: "@typescript-eslint/parser",
-  parserOptions: {
-    ecmaVersion: "latest",
-    sourceType: "module",
-  },
-  plugins: ["react", "@typescript-eslint", "prettier", "coriolis-web"],
-  settings: {
-    "import/resolver": {
-      typescript: {},
-    },
-    react: {
-      version: "detect",
-    },
-  },
-  ignorePatterns: ["*.svg", "*.png", "*.jpg", "*.jpeg", "*.woff"],
-  rules: {
-    "coriolis-web/import-no-duplicate-name": "error",
-    "@typescript-eslint/ban-ts-comment": "off",
-    "@typescript-eslint/no-explicit-any": "off",
-    "@typescript-eslint/no-non-null-assertion": "off",
-    "@typescript-eslint/no-empty-function": "off",
-    "@typescript-eslint/no-non-null-asserted-optional-chain": "off",
-  },
-};

+ 72 - 0
eslint.config.mjs

@@ -0,0 +1,72 @@
+import { defineConfig, globalIgnores } from "eslint/config";
+import react from "eslint-plugin-react";
+import typescriptEslint from "@typescript-eslint/eslint-plugin";
+import prettier from "eslint-plugin-prettier";
+import coriolisWeb from "eslint-plugin-coriolis-web";
+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 defineConfig([
+    globalIgnores(["**/*.svg", "**/*.png", "**/*.jpg", "**/*.jpeg", "**/*.woff"]),
+    {
+        extends: compat.extends(
+            "eslint:recommended",
+            "plugin:react/recommended",
+            "plugin:@typescript-eslint/recommended",
+            "prettier",
+        ),
+
+        plugins: {
+            react,
+            "@typescript-eslint": typescriptEslint,
+            prettier,
+            "coriolis-web": coriolisWeb,
+        },
+
+        languageOptions: {
+            globals: {
+                ...globals.browser,
+                ...globals.jest,
+                ...globals.node,
+            },
+
+            parser: tsParser,
+            ecmaVersion: "latest",
+            sourceType: "module",
+        },
+
+        settings: {
+            "import/resolver": {
+                typescript: {},
+            },
+
+            react: {
+                version: "detect",
+            },
+        },
+
+        rules: {
+            "coriolis-web/import-no-duplicate-name": "error",
+            "@typescript-eslint/ban-ts-comment": "off",
+            "@typescript-eslint/no-explicit-any": "off",
+            "@typescript-eslint/no-non-null-assertion": "off",
+            "@typescript-eslint/no-empty-function": "off",
+            "@typescript-eslint/no-non-null-asserted-optional-chain": "off",
+            "@typescript-eslint/no-unused-vars": "off",
+            "@typescript-eslint/no-unused-expressions": "off",
+            "@typescript-eslint/no-require-imports": "off",
+        },
+    },
+]);