From 32ad97e10893809f57c02a01519acf87c6f0abb9 Mon Sep 17 00:00:00 2001 From: araddcc002 Date: Tue, 28 Jan 2025 17:52:00 +0000 Subject: [PATCH] migrated to use new linting config for frontend --- frontend/.eslintrc.json | 29 -------- frontend/eslint.config.mjs | 72 +++++++++++++++++++ frontend/package-lock.json | 25 +++++++ frontend/package.json | 3 + frontend/src/Form/JsonSchemaForm.tsx | 1 - .../entry/overview/ExportEntryCardDialog.tsx | 1 - frontend/src/errors/MultipleErrorWrapper.tsx | 1 - 7 files changed, 100 insertions(+), 32 deletions(-) delete mode 100644 frontend/.eslintrc.json create mode 100644 frontend/eslint.config.mjs diff --git a/frontend/.eslintrc.json b/frontend/.eslintrc.json deleted file mode 100644 index f408f60f6..000000000 --- a/frontend/.eslintrc.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "root": true, - "parser": "@typescript-eslint/parser", - "plugins": ["@typescript-eslint", "prettier", "simple-import-sort", "cypress"], - "extends": [ - "eslint:recommended", - "plugin:@typescript-eslint/eslint-recommended", - "plugin:@typescript-eslint/recommended", - "plugin:react/recommended", - "plugin:react/jsx-runtime", - "plugin:react-hooks/recommended", - "next/core-web-vitals" - ], - "rules": { - "@typescript-eslint/no-unused-vars": [ - "warn", - { "argsIgnorePattern": "^_", "varsIgnorePattern": "^_", "caughtErrorsIgnorePattern": "^_" } - ], - "@typescript-eslint/no-extra-semi": "off", - "@typescript-eslint/no-explicit-any": "off", - "@typescript-eslint/no-require-imports": "off", - "@typescript-eslint/no-unused-expressions": "off", - "react/jsx-newline": [1, { "prevent": true }], - "cypress/no-async-tests": "ofF", - "simple-import-sort/imports": "warn", - "simple-import-sort/exports": "warn", - "no-console": "warn" - } -} diff --git a/frontend/eslint.config.mjs b/frontend/eslint.config.mjs new file mode 100644 index 000000000..1e2ceddb2 --- /dev/null +++ b/frontend/eslint.config.mjs @@ -0,0 +1,72 @@ +import { fixupConfigRules, fixupPluginRules } from '@eslint/compat' +import typescriptEslint from '@typescript-eslint/eslint-plugin' +import prettier from 'eslint-plugin-prettier' +import simpleImportSort from 'eslint-plugin-simple-import-sort' +import cypress from 'eslint-plugin-cypress' +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 [ + ...fixupConfigRules( + compat.extends( + 'eslint:recommended', + 'plugin:@typescript-eslint/eslint-recommended', + 'plugin:@typescript-eslint/recommended', + 'plugin:react/recommended', + 'plugin:react/jsx-runtime', + 'plugin:react-hooks/recommended', + 'next/core-web-vitals', + ), + ), + { + plugins: { + '@typescript-eslint': fixupPluginRules(typescriptEslint), + prettier, + 'simple-import-sort': simpleImportSort, + cypress, + }, + + languageOptions: { + parser: tsParser, + }, + + rules: { + '@typescript-eslint/no-unused-vars': [ + 'warn', + { + argsIgnorePattern: '^_', + varsIgnorePattern: '^_', + caughtErrorsIgnorePattern: '^_', + }, + ], + + '@typescript-eslint/no-extra-semi': 'off', + '@typescript-eslint/no-explicit-any': 'off', + '@typescript-eslint/no-require-imports': 'off', + '@typescript-eslint/no-unused-expressions': 'off', + + 'react/jsx-newline': [ + 1, + { + prevent: true, + }, + ], + + 'cypress/no-async-tests': 'off', + 'simple-import-sort/imports': 'warn', + 'simple-import-sort/exports': 'warn', + 'no-console': 'warn', + }, + }, +] diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 0ad5fc0e3..764aced39 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -53,6 +53,9 @@ "uuid": "^10.0.0" }, "devDependencies": { + "@eslint/compat": "^1.2.5", + "@eslint/eslintrc": "^3.2.0", + "@eslint/js": "^9.19.0", "@next/bundle-analyzer": "^14.2.4", "@testing-library/react": "^16.1.0", "@testing-library/user-event": "^14.5.2", @@ -724,6 +727,24 @@ "node": "^12.0.0 || ^14.0.0 || >=16.0.0" } }, + "node_modules/@eslint/compat": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/@eslint/compat/-/compat-1.2.5.tgz", + "integrity": "sha512-5iuG/StT+7OfvhoBHPlmxkPA9om6aDUFgmD4+mWKAGsYt4vCe8rypneG03AuseyRHBmcCLXQtIH5S26tIoggLg==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "peerDependencies": { + "eslint": "^9.10.0" + }, + "peerDependenciesMeta": { + "eslint": { + "optional": true + } + } + }, "node_modules/@eslint/config-array": { "version": "0.19.1", "dev": true, @@ -770,6 +791,8 @@ }, "node_modules/@eslint/eslintrc": { "version": "3.2.0", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-3.2.0.tgz", + "integrity": "sha512-grOjVNN8P3hjJn/eIETF1wwd12DdnwFDoyceUJLYYdkpbwq3nLi+4fqrTAONx7XDALqlL220wC/RHSC/QTI/0w==", "dev": true, "license": "MIT", "dependencies": { @@ -843,6 +866,8 @@ }, "node_modules/@eslint/js": { "version": "9.19.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.19.0.tgz", + "integrity": "sha512-rbq9/g38qjfqFLOVPvwjIvFFdNziEC5S65jmjPw5r6A//QH+W91akh9irMwjDN8zKUTak6W9EsAv4m/7Wnw0UQ==", "dev": true, "license": "MIT", "engines": { diff --git a/frontend/package.json b/frontend/package.json index ac4135dfa..4ff995d69 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -60,6 +60,9 @@ "uuid": "^10.0.0" }, "devDependencies": { + "@eslint/compat": "^1.2.5", + "@eslint/eslintrc": "^3.2.0", + "@eslint/js": "^9.19.0", "@next/bundle-analyzer": "^14.2.4", "@testing-library/react": "^16.1.0", "@testing-library/user-event": "^14.5.2", diff --git a/frontend/src/Form/JsonSchemaForm.tsx b/frontend/src/Form/JsonSchemaForm.tsx index 7e56fa322..82eaf1f1b 100644 --- a/frontend/src/Form/JsonSchemaForm.tsx +++ b/frontend/src/Form/JsonSchemaForm.tsx @@ -106,7 +106,6 @@ export default function JsonSchemaForm({ } } > - {/* eslint-disable-next-line react/jsx-no-useless-fragment */} <> diff --git a/frontend/src/entry/overview/ExportEntryCardDialog.tsx b/frontend/src/entry/overview/ExportEntryCardDialog.tsx index c8179d497..ce8d246f0 100644 --- a/frontend/src/entry/overview/ExportEntryCardDialog.tsx +++ b/frontend/src/entry/overview/ExportEntryCardDialog.tsx @@ -54,7 +54,6 @@ export default function ExportEntryCardDialog({ entry, splitSchema, open, setOpe ObjectFieldTemplate, }} > - {/* eslint-disable-next-line react/jsx-no-useless-fragment */} <> )) diff --git a/frontend/src/errors/MultipleErrorWrapper.tsx b/frontend/src/errors/MultipleErrorWrapper.tsx index 97d2fc6ab..725a3fed0 100644 --- a/frontend/src/errors/MultipleErrorWrapper.tsx +++ b/frontend/src/errors/MultipleErrorWrapper.tsx @@ -5,7 +5,6 @@ import DefaultErrorWrapper from './ErrorWrapper' export default function MultipleErrorWrapper(generic: string, errors: any, ErrorWrapper: any = DefaultErrorWrapper) { for (const key of Object.keys(errors)) { - // eslint-disable-next-line react/destructuring-assignment const error = errors[key] if (error) {