From fd12e33c06927c07205d1fdeda5929c237c5520f Mon Sep 17 00:00:00 2001 From: Igor Lobanov Date: Mon, 10 Feb 2025 10:29:43 +0100 Subject: [PATCH] added typecheck on build, fixed eslint --- Makefile | 1 + bamboo-specs/test.yaml | 2 +- client/.eslintrc.json | 22 +++++++++++++++++++--- client/package.json | 5 ++--- client/src/components/Logs/index.tsx | 2 +- client/src/components/SetupGuide/index.tsx | 7 ++----- client/src/components/ui/Guide/Guide.tsx | 4 +--- client/src/components/ui/Guide/index.ts | 2 +- client/src/containers/Dashboard.ts | 4 ++-- client/src/install/Setup/Devices.tsx | 2 +- 10 files changed, 31 insertions(+), 20 deletions(-) diff --git a/Makefile b/Makefile index 0fda6061..780ef647 100644 --- a/Makefile +++ b/Makefile @@ -106,6 +106,7 @@ build-release: $(BUILD_RELEASE_DEPS_$(FRONTEND_PREBUILT)) js-build: ; $(NPM) $(NPM_FLAGS) run build-prod js-deps: ; $(NPM) $(NPM_INSTALL_FLAGS) ci +js-typecheck: ; $(NPM) $(NPM_FLAGS) run typecheck js-lint: ; $(NPM) $(NPM_FLAGS) run lint js-test: ; $(NPM) $(NPM_FLAGS) run test js-test-e2e: ; $(NPM) $(NPM_FLAGS) run test:e2e diff --git a/bamboo-specs/test.yaml b/bamboo-specs/test.yaml index 2aaedf36..b5ea323f 100644 --- a/bamboo-specs/test.yaml +++ b/bamboo-specs/test.yaml @@ -54,7 +54,7 @@ set -e -f -u -x - make VERBOSE=1 js-deps js-lint js-test + make VERBOSE=1 js-deps js-typecheck js-lint js-test 'final-tasks': - 'clean' 'requirements': diff --git a/client/.eslintrc.json b/client/.eslintrc.json index 7586ba67..233695a8 100644 --- a/client/.eslintrc.json +++ b/client/.eslintrc.json @@ -1,5 +1,7 @@ { - "plugins": ["prettier"], + "plugins": [ + "prettier" + ], "extends": [ "airbnb-base", "prettier", @@ -21,12 +23,23 @@ }, "import/resolver": { "node": { - "extensions": [".js", ".jsx", ".ts", ".tsx"] + "extensions": [ + ".js", + ".jsx", + ".ts", + ".tsx" + ] } } }, "rules": { "@typescript-eslint/no-explicit-any": "off", + "@typescript-eslint/no-unused-vars": [ + "error", + { + "argsIgnorePattern": "^_" + } + ], "import/extensions": [ "error", "ignorePackages", @@ -43,7 +56,10 @@ "no-console": [ "warn", { - "allow": ["warn", "error"] + "allow": [ + "warn", + "error" + ] } ], "import/no-extraneous-dependencies": [ diff --git a/client/package.json b/client/package.json index 0673c21f..0b198a79 100644 --- a/client/package.json +++ b/client/package.json @@ -7,9 +7,8 @@ "build-prod": "cross-env BUILD_ENV=prod webpack --config webpack.prod.js", "watch": "cross-env BUILD_ENV=dev webpack --config webpack.dev.js --watch", "watch:hot": "cross-env BUILD_ENV=dev webpack-dev-server --config webpack.dev.js", - "lint": "echo 'Lint temporarily disabled'", - "lint-new": "eslint './src/**/*.(ts|tsx)'", - "lint:fix": "eslint './src/**/*.(ts|tsx)' --fix", + "lint": "eslint --ext .ts,.tsx src", + "lint:fix": "eslint --ext .ts,.tsx src --fix", "test": "vitest --run", "test:watch": "vitest --watch", "test:e2e": "npx playwright test tests/e2e", diff --git a/client/src/components/Logs/index.tsx b/client/src/components/Logs/index.tsx index 63bc557f..6bf2abfa 100644 --- a/client/src/components/Logs/index.tsx +++ b/client/src/components/Logs/index.tsx @@ -29,7 +29,7 @@ import { BUTTON_PREFIX } from './Cells/helpers'; import AnonymizerNotification from './AnonymizerNotification'; import { RootState } from '../../initialState'; -const processContent = (data: any, buttonType: string) => +const processContent = (data: any, _buttonType: string) => Object.entries(data).map(([key, value]) => { if (!value) { return null; diff --git a/client/src/components/SetupGuide/index.tsx b/client/src/components/SetupGuide/index.tsx index 76263488..708d8581 100644 --- a/client/src/components/SetupGuide/index.tsx +++ b/client/src/components/SetupGuide/index.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { Trans, withTranslation } from 'react-i18next'; -import Guide from '../ui/Guide'; +import { Guide } from '../ui/Guide'; import Card from '../ui/Card'; @@ -14,10 +14,7 @@ interface SetupGuideProps { t: (id: string) => string; } -const SetupGuide = ({ - t, - dashboard: { dnsAddresses }, -}: SetupGuideProps) => ( +const SetupGuide = ({ t, dashboard: { dnsAddresses } }: SetupGuideProps) => (
diff --git a/client/src/components/ui/Guide/Guide.tsx b/client/src/components/ui/Guide/Guide.tsx index 3b7c295b..c4db933f 100644 --- a/client/src/components/ui/Guide/Guide.tsx +++ b/client/src/components/ui/Guide/Guide.tsx @@ -346,7 +346,7 @@ interface GuideProps { dnsAddresses?: unknown[]; } -const Guide = ({ dnsAddresses }: GuideProps) => { +export const Guide = ({ dnsAddresses }: GuideProps) => { const { t } = useTranslation(); const serverName = useSelector((state: RootState) => state.encryption?.server_name); @@ -381,5 +381,3 @@ const Guide = ({ dnsAddresses }: GuideProps) => { Guide.defaultProps = { dnsAddresses: [], }; - -export default Guide; diff --git a/client/src/components/ui/Guide/index.ts b/client/src/components/ui/Guide/index.ts index ee660aeb..f9411b5b 100644 --- a/client/src/components/ui/Guide/index.ts +++ b/client/src/components/ui/Guide/index.ts @@ -1 +1 @@ -export { default } from './Guide'; +export * from './Guide'; diff --git a/client/src/containers/Dashboard.ts b/client/src/containers/Dashboard.ts index cc2c602c..c1902aed 100644 --- a/client/src/containers/Dashboard.ts +++ b/client/src/containers/Dashboard.ts @@ -1,7 +1,7 @@ import { connect } from 'react-redux'; import { toggleProtection, getClients } from '../actions'; -import { getStats, getStatsConfig, setStatsConfig } from '../actions/stats'; +import { getStats, getStatsConfig } from '../actions/stats'; import { getAccessList } from '../actions/access'; import Dashboard from '../components/Dashboard'; @@ -19,7 +19,7 @@ type DispatchProps = { getStats: (...args: unknown[]) => unknown; getStatsConfig: (...args: unknown[]) => unknown; getAccessList: () => (dispatch: any) => void; -} +}; const mapDispatchToProps: DispatchProps = { toggleProtection, diff --git a/client/src/install/Setup/Devices.tsx b/client/src/install/Setup/Devices.tsx index ad08302e..503001fc 100644 --- a/client/src/install/Setup/Devices.tsx +++ b/client/src/install/Setup/Devices.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { Trans } from 'react-i18next'; -import Guide from '../../components/ui/Guide'; +import { Guide } from '../../components/ui/Guide'; import Controls from './Controls';