From 93f00683dd7a1713379220f5527d47897613c6dc Mon Sep 17 00:00:00 2001 From: Lukasz Ostrowski Date: Sat, 30 Nov 2024 10:06:24 +0100 Subject: [PATCH] Install Vitest eslint plugin (#1655) --- .../modules/avatax/address-factory.test.ts | 2 +- packages/eslint-config-saleor/index.js | 21 +++++- packages/eslint-config-saleor/package.json | 3 +- pnpm-lock.yaml | 69 ++++++++++++++----- 4 files changed, 74 insertions(+), 21 deletions(-) diff --git a/apps/avatax/src/modules/avatax/address-factory.test.ts b/apps/avatax/src/modules/avatax/address-factory.test.ts index 07f3d1a572..643033f3ca 100644 --- a/apps/avatax/src/modules/avatax/address-factory.test.ts +++ b/apps/avatax/src/modules/avatax/address-factory.test.ts @@ -1,4 +1,4 @@ -import { describe, expect, it } from "vitest"; +import { describe, expect, it, Mock, vi } from "vitest"; import { avataxAddressFactory } from "./address-factory"; diff --git a/packages/eslint-config-saleor/index.js b/packages/eslint-config-saleor/index.js index 78e6e8b75b..8e81f23ec1 100644 --- a/packages/eslint-config-saleor/index.js +++ b/packages/eslint-config-saleor/index.js @@ -1,7 +1,22 @@ module.exports = { - extends: ["next", "turbo", "prettier", "plugin:@saleor/saleor-app/recommended"], + extends: [ + "next", + "turbo", + "prettier", + "plugin:@saleor/saleor-app/recommended", + /* + * After upgrade to eslint 9 config should be updated + * https://github.com/vitest-dev/eslint-plugin-vitest/tree/main?tab=readme-ov-file#usage + * + * This is disabled, because it seems not to work, despite being set up just like in docs + * Some rules are applied manually in "rules" section - they work. + * + * TODO: Once we upgrade Vitest and ESLint, try to set up everything again with non-legacy approach + */ + // "plugin:@vitest/legacy-recommended", + ], parser: "@typescript-eslint/parser", - plugins: ["simple-import-sort"], + plugins: ["simple-import-sort", "@vitest"], rules: { "import/order": "off", // to avoid conflicts with simple-import-sort "import/first": "warn", @@ -13,6 +28,8 @@ module.exports = { "@next/next/no-html-link-for-pages": "off", "react/jsx-key": "off", "newline-after-var": "warn", + "@vitest/prefer-strict-equal": "warn", + "@vitest/prefer-vi-mocked": "warn", "multiline-comment-style": ["warn", "starred-block"], "no-restricted-imports": [ "error", diff --git a/packages/eslint-config-saleor/package.json b/packages/eslint-config-saleor/package.json index 7ac99b8c3a..3bad542441 100644 --- a/packages/eslint-config-saleor/package.json +++ b/packages/eslint-config-saleor/package.json @@ -12,7 +12,8 @@ "eslint-plugin-react": "7.34.3", "eslint-plugin-simple-import-sort": "12.1.1", "next": "14.2.3", - "typescript": "5.5.4" + "typescript": "5.5.4", + "@vitest/eslint-plugin": "1.1.12" }, "license": "MIT", "main": "index.js", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 54a2e2ddce..8a7e476a43 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -210,7 +210,7 @@ importers: version: 10.43.1(@trpc/server@10.43.1) '@trpc/next': specifier: 10.43.1 - version: 10.43.1(@tanstack/react-query@4.29.19(react-dom@18.2.0(react@18.2.0))(react@18.2.0))(@trpc/client@10.43.1(@trpc/server@10.43.1))(@trpc/react-query@10.43.1(@tanstack/react-query@4.29.19(react-dom@18.2.0(react@18.2.0))(react@18.2.0))(@trpc/client@10.43.1(@trpc/server@10.43.1))(@trpc/server@10.43.1)(react-dom@18.2.0(react@18.2.0))(react@18.2.0))(@trpc/server@10.43.1)(next@14.2.3(@babel/core@7.24.7)(@opentelemetry/api@1.9.0)(react-dom@18.2.0(react@18.2.0))(react@18.2.0))(react-dom@18.2.0(react@18.2.0))(react@18.2.0) + version: 10.43.1(@tanstack/react-query@4.29.19(react-dom@18.2.0(react@18.2.0))(react@18.2.0))(@trpc/client@10.43.1(@trpc/server@10.43.1))(@trpc/react-query@10.43.1(@tanstack/react-query@4.29.19(react-dom@18.2.0(react@18.2.0))(react@18.2.0))(@trpc/client@10.43.1(@trpc/server@10.43.1))(@trpc/server@10.43.1)(react-dom@18.2.0(react@18.2.0))(react@18.2.0))(@trpc/server@10.43.1)(next@14.2.3(@opentelemetry/api@1.9.0)(react-dom@18.2.0(react@18.2.0))(react@18.2.0))(react-dom@18.2.0(react@18.2.0))(react@18.2.0) '@trpc/server': specifier: 10.43.1 version: 10.43.1 @@ -252,7 +252,7 @@ importers: version: 6.2.1 next: specifier: 14.2.3 - version: 14.2.3(@babel/core@7.24.7)(@opentelemetry/api@1.9.0)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) + version: 14.2.3(@opentelemetry/api@1.9.0)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) react: specifier: 18.2.0 version: 18.2.0 @@ -445,7 +445,7 @@ importers: version: 10.43.1(@trpc/server@10.43.1) '@trpc/next': specifier: 10.43.1 - version: 10.43.1(@tanstack/react-query@4.29.19(react-dom@18.2.0(react@18.2.0))(react@18.2.0))(@trpc/client@10.43.1(@trpc/server@10.43.1))(@trpc/react-query@10.43.1(@tanstack/react-query@4.29.19(react-dom@18.2.0(react@18.2.0))(react@18.2.0))(@trpc/client@10.43.1(@trpc/server@10.43.1))(@trpc/server@10.43.1)(react-dom@18.2.0(react@18.2.0))(react@18.2.0))(@trpc/server@10.43.1)(next@14.2.3(@opentelemetry/api@node_modules+@opentelemetry+api)(react-dom@18.2.0(react@18.2.0))(react@18.2.0))(react-dom@18.2.0(react@18.2.0))(react@18.2.0) + version: 10.43.1(@tanstack/react-query@4.29.19(react-dom@18.2.0(react@18.2.0))(react@18.2.0))(@trpc/client@10.43.1(@trpc/server@10.43.1))(@trpc/react-query@10.43.1(@tanstack/react-query@4.29.19(react-dom@18.2.0(react@18.2.0))(react@18.2.0))(@trpc/client@10.43.1(@trpc/server@10.43.1))(@trpc/server@10.43.1)(react-dom@18.2.0(react@18.2.0))(react@18.2.0))(@trpc/server@10.43.1)(next@14.2.3(@babel/core@7.24.7)(@opentelemetry/api@node_modules+@opentelemetry+api)(react-dom@18.2.0(react@18.2.0))(react@18.2.0))(react-dom@18.2.0(react@18.2.0))(react@18.2.0) '@trpc/react-query': specifier: 10.43.1 version: 10.43.1(@tanstack/react-query@4.29.19(react-dom@18.2.0(react@18.2.0))(react@18.2.0))(@trpc/client@10.43.1(@trpc/server@10.43.1))(@trpc/server@10.43.1)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) @@ -475,7 +475,7 @@ importers: version: 20.0.3 next: specifier: 14.2.3 - version: 14.2.3(@opentelemetry/api@node_modules+@opentelemetry+api)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) + version: 14.2.3(@babel/core@7.24.7)(@opentelemetry/api@node_modules+@opentelemetry+api)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) p-ratelimit: specifier: 1.0.1 version: 1.0.1 @@ -647,7 +647,7 @@ importers: version: 2.12.6(graphql@16.7.1) next: specifier: 14.2.3 - version: 14.2.3(@opentelemetry/api@node_modules+@opentelemetry+api)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) + version: 14.2.3(@babel/core@7.24.7)(@opentelemetry/api@node_modules+@opentelemetry+api)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) node-fetch: specifier: ^3.2.6 version: 3.2.6 @@ -849,7 +849,7 @@ importers: version: 20.0.3 next: specifier: 14.2.3 - version: 14.2.3(@opentelemetry/api@node_modules+@opentelemetry+api)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) + version: 14.2.3(@babel/core@7.24.7)(@opentelemetry/api@node_modules+@opentelemetry+api)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) react: specifier: 18.2.0 version: 18.2.0 @@ -1042,7 +1042,7 @@ importers: version: 2.12.6(graphql@16.7.1) next: specifier: 14.2.3 - version: 14.2.3(@opentelemetry/api@node_modules+@opentelemetry+api)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) + version: 14.2.3(@babel/core@7.24.7)(@opentelemetry/api@node_modules+@opentelemetry+api)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) react: specifier: 18.2.0 version: 18.2.0 @@ -1256,7 +1256,7 @@ importers: version: 6.2.1 next: specifier: 14.2.3 - version: 14.2.3(@opentelemetry/api@node_modules+@opentelemetry+api)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) + version: 14.2.3(@babel/core@7.24.7)(@opentelemetry/api@node_modules+@opentelemetry+api)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) nodemailer: specifier: ^6.9.1 version: 6.9.1 @@ -1381,6 +1381,9 @@ importers: '@typescript-eslint/parser': specifier: 7.15.0 version: 7.15.0(eslint@node_modules+eslint)(typescript@5.5.4) + '@vitest/eslint-plugin': + specifier: 1.1.12 + version: 1.1.12(@typescript-eslint/utils@5.62.0(eslint@node_modules+eslint)(typescript@5.5.4))(eslint@node_modules+eslint)(typescript@5.5.4)(vitest@1.6.0(@types/node@20.12.3)(jsdom@20.0.3)(terser@5.18.0)) eslint: specifier: ../../node_modules/eslint version: link:../../node_modules/eslint @@ -1404,7 +1407,7 @@ importers: version: 12.1.1(eslint@node_modules+eslint) next: specifier: 14.2.3 - version: 14.2.3(@babel/core@7.24.7)(@opentelemetry/api@1.9.0)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) + version: 14.2.3(@opentelemetry/api@1.9.0)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) typescript: specifier: 5.5.4 version: 5.5.4 @@ -1612,7 +1615,7 @@ importers: version: link:../eslint-config-saleor next: specifier: 14.2.3 - version: 14.2.3(@babel/core@7.24.7)(@opentelemetry/api@1.9.0)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) + version: 14.2.3(@opentelemetry/api@1.9.0)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) react: specifier: 18.2.0 version: 18.2.0 @@ -1673,7 +1676,7 @@ importers: version: link:../eslint-config-saleor next: specifier: 14.2.3 - version: 14.2.3(@babel/core@7.24.7)(@opentelemetry/api@1.9.0)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) + version: 14.2.3(@opentelemetry/api@1.9.0)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) typescript: specifier: 5.5.4 version: 5.5.4 @@ -1704,7 +1707,7 @@ importers: version: link:../eslint-config-saleor next: specifier: 14.2.3 - version: 14.2.3(@babel/core@7.24.7)(@opentelemetry/api@1.9.0)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) + version: 14.2.3(@opentelemetry/api@1.9.0)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) react: specifier: 18.2.0 version: 18.2.0 @@ -1737,7 +1740,7 @@ importers: version: 6.1.0(modern-errors@7.0.1) next: specifier: 14.2.3 - version: 14.2.3(@babel/core@7.24.7)(@opentelemetry/api@1.9.0)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) + version: 14.2.3(@opentelemetry/api@1.9.0)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) semver: specifier: 7.5.1 version: 7.5.1 @@ -6945,6 +6948,19 @@ packages: peerDependencies: vite: ^4.2.0 || ^5.0.0 + '@vitest/eslint-plugin@1.1.12': + resolution: {integrity: sha512-iv9K9fz9qRxBo9J/PGSMcLdOFIKqtFZ6THqSVG/jW8CJZFkIWLxPduCTXkbyG6FNKgL49fkv348nSgmfqCU6FA==} + peerDependencies: + '@typescript-eslint/utils': '>= 8.0' + eslint: '>= 8.57.0' + typescript: '>= 5.0.0' + vitest: '*' + peerDependenciesMeta: + typescript: + optional: true + vitest: + optional: true + '@vitest/expect@1.6.0': resolution: {integrity: sha512-ixEvFVQjycy/oNgHjqsL6AZCDduC+tflRluaHIzKIsdbzkLn2U/iBnVeJwB6HsIjQBdfMR8Z0tRxKUsvFJEeWQ==} @@ -20295,13 +20311,24 @@ snapshots: react-dom: 18.2.0(react@18.2.0) react-ssr-prepass: 1.5.0(react@18.2.0) - '@trpc/next@10.43.1(@tanstack/react-query@4.29.19(react-dom@18.2.0(react@18.2.0))(react@18.2.0))(@trpc/client@10.43.1(@trpc/server@10.43.1))(@trpc/react-query@10.43.1(@tanstack/react-query@4.29.19(react-dom@18.2.0(react@18.2.0))(react@18.2.0))(@trpc/client@10.43.1(@trpc/server@10.43.1))(@trpc/server@10.43.1)(react-dom@18.2.0(react@18.2.0))(react@18.2.0))(@trpc/server@10.43.1)(next@14.2.3(@babel/core@7.24.7)(@opentelemetry/api@1.9.0)(react-dom@18.2.0(react@18.2.0))(react@18.2.0))(react-dom@18.2.0(react@18.2.0))(react@18.2.0)': + '@trpc/next@10.43.1(@tanstack/react-query@4.29.19(react-dom@18.2.0(react@18.2.0))(react@18.2.0))(@trpc/client@10.43.1(@trpc/server@10.43.1))(@trpc/react-query@10.43.1(@tanstack/react-query@4.29.19(react-dom@18.2.0(react@18.2.0))(react@18.2.0))(@trpc/client@10.43.1(@trpc/server@10.43.1))(@trpc/server@10.43.1)(react-dom@18.2.0(react@18.2.0))(react@18.2.0))(@trpc/server@10.43.1)(next@14.2.3(@babel/core@7.24.7)(@opentelemetry/api@node_modules+@opentelemetry+api)(react-dom@18.2.0(react@18.2.0))(react@18.2.0))(react-dom@18.2.0(react@18.2.0))(react@18.2.0)': + dependencies: + '@tanstack/react-query': 4.29.19(react-dom@18.2.0(react@18.2.0))(react@18.2.0) + '@trpc/client': 10.43.1(@trpc/server@10.43.1) + '@trpc/react-query': 10.43.1(@tanstack/react-query@4.29.19(react-dom@18.2.0(react@18.2.0))(react@18.2.0))(@trpc/client@10.43.1(@trpc/server@10.43.1))(@trpc/server@10.43.1)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) + '@trpc/server': 10.43.1 + next: 14.2.3(@babel/core@7.24.7)(@opentelemetry/api@node_modules+@opentelemetry+api)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) + react: 18.2.0 + react-dom: 18.2.0(react@18.2.0) + react-ssr-prepass: 1.5.0(react@18.2.0) + + '@trpc/next@10.43.1(@tanstack/react-query@4.29.19(react-dom@18.2.0(react@18.2.0))(react@18.2.0))(@trpc/client@10.43.1(@trpc/server@10.43.1))(@trpc/react-query@10.43.1(@tanstack/react-query@4.29.19(react-dom@18.2.0(react@18.2.0))(react@18.2.0))(@trpc/client@10.43.1(@trpc/server@10.43.1))(@trpc/server@10.43.1)(react-dom@18.2.0(react@18.2.0))(react@18.2.0))(@trpc/server@10.43.1)(next@14.2.3(@opentelemetry/api@1.9.0)(react-dom@18.2.0(react@18.2.0))(react@18.2.0))(react-dom@18.2.0(react@18.2.0))(react@18.2.0)': dependencies: '@tanstack/react-query': 4.29.19(react-dom@18.2.0(react@18.2.0))(react@18.2.0) '@trpc/client': 10.43.1(@trpc/server@10.43.1) '@trpc/react-query': 10.43.1(@tanstack/react-query@4.29.19(react-dom@18.2.0(react@18.2.0))(react@18.2.0))(@trpc/client@10.43.1(@trpc/server@10.43.1))(@trpc/server@10.43.1)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) '@trpc/server': 10.43.1 - next: 14.2.3(@babel/core@7.24.7)(@opentelemetry/api@1.9.0)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) + next: 14.2.3(@opentelemetry/api@1.9.0)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) react: 18.2.0 react-dom: 18.2.0(react@18.2.0) react-ssr-prepass: 1.5.0(react@18.2.0) @@ -20847,6 +20874,14 @@ snapshots: transitivePeerDependencies: - supports-color + '@vitest/eslint-plugin@1.1.12(@typescript-eslint/utils@5.62.0(eslint@node_modules+eslint)(typescript@5.5.4))(eslint@node_modules+eslint)(typescript@5.5.4)(vitest@1.6.0(@types/node@20.12.3)(jsdom@20.0.3)(terser@5.18.0))': + dependencies: + '@typescript-eslint/utils': 5.62.0(eslint@node_modules+eslint)(typescript@5.5.4) + eslint: link:node_modules/eslint + optionalDependencies: + typescript: 5.5.4 + vitest: 1.6.0(@types/node@20.12.3)(jsdom@20.0.3)(terser@5.18.0) + '@vitest/expect@1.6.0': dependencies: '@vitest/spy': 1.6.0 @@ -25681,7 +25716,7 @@ snapshots: neverthrow@6.2.1: {} - next@14.2.3(@babel/core@7.24.7)(@opentelemetry/api@1.9.0)(react-dom@18.2.0(react@18.2.0))(react@18.2.0): + next@14.2.3(@babel/core@7.24.7)(@opentelemetry/api@node_modules+@opentelemetry+api)(react-dom@18.2.0(react@18.2.0))(react@18.2.0): dependencies: '@next/env': 14.2.3 '@swc/helpers': 0.5.5 @@ -25702,7 +25737,7 @@ snapshots: '@next/swc-win32-arm64-msvc': 14.2.3 '@next/swc-win32-ia32-msvc': 14.2.3 '@next/swc-win32-x64-msvc': 14.2.3 - '@opentelemetry/api': 1.9.0 + '@opentelemetry/api': link:node_modules/@opentelemetry/api transitivePeerDependencies: - '@babel/core' - babel-plugin-macros