From bd041979c434086039d125b72b7af574f84a3e78 Mon Sep 17 00:00:00 2001 From: Freya Gustavsson Date: Mon, 10 Jun 2024 15:40:24 +0200 Subject: [PATCH] chore: upgrade ESLint to use new flat config With ESLint 9 being out and plugins slowly migrating, this takes care of the migration of ESLint config from package.json to its own eslint.config.mjs. This is needed as package.json and .eslintrc is deprecated --- frontend/eslint.config.mjs | 51 ++++++++++++++++++++++++ frontend/package.json | 50 +---------------------- frontend/src/app/AppLayout/AppLayout.tsx | 1 - frontend/yarn.lock | 33 ++------------- 4 files changed, 56 insertions(+), 79 deletions(-) create mode 100644 frontend/eslint.config.mjs diff --git a/frontend/eslint.config.mjs b/frontend/eslint.config.mjs new file mode 100644 index 0000000..31aceb7 --- /dev/null +++ b/frontend/eslint.config.mjs @@ -0,0 +1,51 @@ +// Copyright Contributors to the Packit project. +// SPDX-License-Identifier: MIT + +import eslint from "@eslint/js"; +import * as react from "eslint-plugin-react"; +import tseslint from "typescript-eslint"; + +export default tseslint.config( + eslint.configs.recommended, + ...tseslint.configs.recommended, + { + settings: { + react: { + version: "detect", + }, + }, + plugins: { + react, + "@typescript-eslint": tseslint.plugin, + }, + languageOptions: { + parser: tseslint.parser, + parserOptions: { + project: "./tsconfig.json", + ecmaFeatures: { + jsx: true, + }, + }, + }, + rules: { + "import/no-anonymous-default-export": "off", + "react/no-unescaped-entities": "off", + "react/prop-types": "off", + "@typescript-eslint/no-unused-vars": [ + "error", + { + args: "all", + argsIgnorePattern: "^_", + caughtErrors: "all", + caughtErrorsIgnorePattern: "^_", + destructuredArrayIgnorePattern: "^_", + varsIgnorePattern: "^_", + ignoreRestSiblings: true, + }, + ], + }, + }, + { + files: ["**/*.{js,jsx,mjs,cjs,ts,tsx}", "**/*.stories.*"], + }, +); diff --git a/frontend/package.json b/frontend/package.json index f0aed46..b75bd2f 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -23,7 +23,6 @@ "@types/react": "^18.0.29", "@types/react-dom": "^18.0.11", "@vitejs/plugin-react": "^4.0.1", - "eslint": "^8.43.0", "msw": "^1.2.1", "prettier": "^2.8.3", "react": "^18.2.0", @@ -47,54 +46,6 @@ "storybook": "storybook dev -p 6006", "build-storybook": "storybook build" }, - "eslintConfig": { - "ignorePatterns": [ - "dist/*", - "public/*", - "frontend/*" - ], - "settings": { - "react": { - "version": "detect" - } - }, - "parser": "@typescript-eslint/parser", - "parserOptions": { - "project": "./tsconfig.json" - }, - "extends": [ - "eslint:recommended", - "plugin:@typescript-eslint/recommended-type-checked", - "plugin:react/recommended", - "plugin:react/jsx-runtime", - "plugin:storybook/recommended", - "prettier" - ], - "rules": { - "import/no-anonymous-default-export": "off", - "react/no-unescaped-entities": "off", - "react/prop-types": "off", - "@typescript-eslint/no-unused-vars": [ - "error", - { - "args": "all", - "argsIgnorePattern": "^_", - "caughtErrors": "all", - "caughtErrorsIgnorePattern": "^_", - "destructuredArrayIgnorePattern": "^_", - "varsIgnorePattern": "^_", - "ignoreRestSiblings": true - } - ] - }, - "overrides": [ - { - "files": [ - "**/*.stories.*" - ] - } - ] - }, "prettier": { "overrides": [ { @@ -139,6 +90,7 @@ "@storybook/theming": "^7.4.0", "@storybook/types": "^7.4.0", "babel-plugin-named-exports-order": "^0.0.2", + "eslint": "^8.57.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-react": "^7.34.1", "eslint-plugin-storybook": "^0.6.12", diff --git a/frontend/src/app/AppLayout/AppLayout.tsx b/frontend/src/app/AppLayout/AppLayout.tsx index 83bc89e..87cdce5 100644 --- a/frontend/src/app/AppLayout/AppLayout.tsx +++ b/frontend/src/app/AppLayout/AppLayout.tsx @@ -71,7 +71,6 @@ const AppLayout = () => { }; // eslint-disable-next-line @typescript-eslint/no-explicit-any const onPageResize = (props: any) => { - // eslint-disable-next-line react/prop-types if (Object.hasOwn(props, "mobileView")) setIsMobileView(props.mobileView); }; diff --git a/frontend/yarn.lock b/frontend/yarn.lock index 59072e2..f42a23a 100644 --- a/frontend/yarn.lock +++ b/frontend/yarn.lock @@ -5330,7 +5330,7 @@ eslint-visitor-keys@^3.3.0, eslint-visitor-keys@^3.4.1, eslint-visitor-keys@^3.4 resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz#0cd72fe8550e3c2eae156a96a4dddcd1c8ac5800" integrity sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag== -eslint@^8.43.0: +eslint@^8.57.0: version "8.57.0" resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.57.0.tgz#c786a6fd0e0b68941aaf624596fb987089195668" integrity sha512-dZ6+mexnaTIbSBZWgou51U6OmzIhYM2VcNdtiTtI7qPNZm35Akpr0f6vtw3w1Kmn5PYo+tZVfh13WrhpS6oLqQ== @@ -8622,16 +8622,7 @@ strict-event-emitter@^0.4.3: resolved "https://registry.yarnpkg.com/strict-event-emitter/-/strict-event-emitter-0.4.6.tgz#ff347c8162b3e931e3ff5f02cfce6772c3b07eb3" integrity sha512-12KWeb+wixJohmnwNFerbyiBrAlq5qJLwIt38etRtKtmmHyDSoGlIqFE9wx+4IwG0aDjI7GV8tc8ZccjWZZtTg== -"string-width-cjs@npm:string-width@^4.2.0": - version "4.2.3" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" - integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== - dependencies: - emoji-regex "^8.0.0" - is-fullwidth-code-point "^3.0.0" - strip-ansi "^6.0.1" - -string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: +"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: version "4.2.3" resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== @@ -8709,14 +8700,7 @@ string_decoder@~1.1.1: dependencies: safe-buffer "~5.1.0" -"strip-ansi-cjs@npm:strip-ansi@^6.0.1": - version "6.0.1" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" - integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== - dependencies: - ansi-regex "^5.0.1" - -strip-ansi@^6.0.0, strip-ansi@^6.0.1: +"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1: version "6.0.1" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== @@ -9659,7 +9643,7 @@ wordwrap@^1.0.0: resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb" integrity sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q== -"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0": +"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0: version "7.0.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== @@ -9677,15 +9661,6 @@ wrap-ansi@^6.0.1: string-width "^4.1.0" strip-ansi "^6.0.0" -wrap-ansi@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" - integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== - dependencies: - ansi-styles "^4.0.0" - string-width "^4.1.0" - strip-ansi "^6.0.0" - wrap-ansi@^8.1.0: version "8.1.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214"