diff --git a/.eslintrc.js b/.eslintrc.js index a91ef4dcd7..ef1ede40e0 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -21,18 +21,18 @@ module.exports = { }, parser: '@typescript-eslint/parser', parserOptions: { - project: ['./tsconfig.json', './scripts/tsconfig.json'], + project: ['./tsconfig.json', './check-translations/tsconfig.json'], tsconfigRootDir: './', }, settings: { 'import/resolver': { node: { extensions: ['.js', '.jsx', '.ts', '.tsx'], - moduleDirectory: ["node_modules"], + moduleDirectory: ['node_modules'], }, - "typescript": { + typescript: { alwaysTryTypes: true, - } + }, }, 'import/parsers': { '@typescript-eslint/parser': ['.ts', '.tsx'], @@ -61,19 +61,17 @@ module.exports = { 'no-nested-ternary': 'off', 'import/no-unresolved': 'off', 'import/extensions': ['error', 'never'], - 'import/order': ["error", { - "groups": [ - "external", - ["sibling","parent","internal"], - "builtin", - "unknown", - ], - "newlines-between": "always", - "alphabetize": { - "order": 'asc', - "caseInsensitive": true, + 'import/order': [ + 'error', + { + groups: ['external', ['sibling', 'parent', 'internal'], 'builtin', 'unknown'], + 'newlines-between': 'always', + alphabetize: { + order: 'asc', + caseInsensitive: true, + }, }, - }], + ], curly: ['error', 'all'], }, } diff --git a/scripts/.eslintrc.js b/check-translations/.eslintrc.js similarity index 100% rename from scripts/.eslintrc.js rename to check-translations/.eslintrc.js diff --git a/scripts/checkMissingTranslations.ts b/check-translations/index.ts similarity index 100% rename from scripts/checkMissingTranslations.ts rename to check-translations/index.ts diff --git a/scripts/tsconfig.json b/check-translations/tsconfig.json similarity index 60% rename from scripts/tsconfig.json rename to check-translations/tsconfig.json index c93f174398..aa1518f5d2 100644 --- a/scripts/tsconfig.json +++ b/check-translations/tsconfig.json @@ -1,12 +1,13 @@ { "extends": "../tsconfig.json", "include": [ - "./checkMissingTranslations.ts" + "./index.ts" ], "compilerOptions": { "module": "commonjs", - "outDir": "../bin", + "outDir": "compiled", "target": "es5", - "sourceMap": false + "sourceMap": false, + "noEmit": false } } diff --git a/package.json b/package.json index da12935cb6..5882dc6a71 100644 --- a/package.json +++ b/package.json @@ -27,13 +27,13 @@ "react-dom": "~16.13.0", "react-i18next": "~11.5.0", "react-redux": "~7.2.0", - "react-router": "~5.1.2", - "react-router-dom": "~5.1.2", + "react-router": "~5.2.0", + "react-router-dom": "~5.2.0", "react-scripts": "~3.4.0", "redux": "~4.0.5", "redux-thunk": "~2.3.0", "shortid": "^2.2.15", - "typescript": "~3.8.2", + "typescript": "~3.8.3", "uuid": "^8.0.0", "validator": "^13.0.0" }, @@ -57,7 +57,7 @@ "@commitlint/config-conventional": "~8.3.4", "@commitlint/core": "~8.3.5", "@commitlint/prompt": "~8.3.5", - "@testing-library/react": "~10.1.0", + "@testing-library/react": "~10.2.1", "@testing-library/react-hooks": "~3.3.0", "@types/enzyme": "^3.10.5", "@types/jest": "~26.0.0", @@ -73,8 +73,8 @@ "@types/shortid": "^0.0.29", "@types/uuid": "^8.0.0", "@types/validator": "~13.0.0", - "@typescript-eslint/eslint-plugin": "~2.34.0", - "@typescript-eslint/parser": "~2.34.0", + "@typescript-eslint/eslint-plugin": "~3.3.0", + "@typescript-eslint/parser": "~3.3.0", "chalk": "^4.0.0", "commitizen": "~4.1.2", "commitlint-config-cz": "~0.13.0", @@ -92,7 +92,7 @@ "eslint-plugin-jsx-a11y": "~6.2.3", "eslint-plugin-prettier": "~3.1.2", "eslint-plugin-react": "~7.20.0", - "eslint-plugin-react-hooks": "~2.5.0", + "eslint-plugin-react-hooks": "~4.0.4", "history": "~4.10.1", "husky": "~4.2.1", "jest": "~24.9.0", @@ -100,24 +100,29 @@ "memdown": "~5.1.0", "prettier": "~2.0.4", "redux-mock-store": "~1.5.4", + "rimraf": "~3.0.2", "source-map-explorer": "^2.2.2", "standard-version": "~8.0.0", - "ts-jest": "~24.3.0" + "ts-jest": "~26.1.0" }, "scripts": { "analyze": "source-map-explorer 'build/static/js/*.js'", "commit": "npx git-cz", - "start": "yarn translation:check && react-scripts start", + "start": "npm run translation:check && react-scripts start", "build": "react-scripts build", + "update": "npx npm-check -u", "prepublishOnly": "npm run build", - "test": "yarn translation:check && react-scripts test --detectOpenHandles", + "test": "npm run translation:check && react-scripts test --detectOpenHandles", "test:ci": "cross-env CI=true react-scripts test --passWithNoTests", - "lint": "eslint \"src/**/*.{js,jsx,ts,tsx}\" \"scripts/**/*.{js,ts}\"", - "lint:fix": "eslint \"src/**/*.{js,jsx,ts,tsx}\" \"scripts/**/*.{js,ts}\" --fix", + "lint": "eslint \"src/**/*.{js,jsx,ts,tsx}\" \"check-translations/**/*.{js,ts}\"", + "lint:fix": "eslint \"src/**/*.{js,jsx,ts,tsx}\" \"check-translations/**/*.{js,ts}\" --fix", "lint-staged": "lint-staged", "commitlint": "commitlint", "coveralls": "npm run test:ci -- --coverage --watchAll=false && cat ./coverage/lcov.info", - "translation:check": "cd scripts && tsc && node ../bin/scripts/checkMissingTranslations.js" + "remove-compiled-translations": "rimraf ./check-translations/compiled", + "pretranslation:check": "npm run remove-compiled-translations", + "translation:check": "tsc -p ./check-translations/tsconfig.json && node ./check-translations/compiled/check-translations/index.js", + "posttranslation:check": "npm run remove-compiled-translations" }, "browserslist": { "production": [ diff --git a/src/__tests__/clients/db/LabRepository.test.ts b/src/__tests__/clients/db/LabRepository.test.ts index cbbc7238a0..83589483a0 100644 --- a/src/__tests__/clients/db/LabRepository.test.ts +++ b/src/__tests__/clients/db/LabRepository.test.ts @@ -1,5 +1,3 @@ -/* eslint "@typescript-eslint/camelcase": "off" */ - import shortid from 'shortid' import LabRepository from '../../../clients/db/LabRepository' diff --git a/src/clients/db/Repository.ts b/src/clients/db/Repository.ts index 7a82d2631b..7ced8d0086 100644 --- a/src/clients/db/Repository.ts +++ b/src/clients/db/Repository.ts @@ -1,4 +1,3 @@ -/* eslint "@typescript-eslint/camelcase": "off" */ import { v4 as uuidv4 } from 'uuid' import AbstractDBModel from '../../model/AbstractDBModel' diff --git a/src/components/network-status/NetworkStatusMessage.tsx b/src/components/network-status/NetworkStatusMessage.tsx index c8269d22d6..c9e1b35227 100644 --- a/src/components/network-status/NetworkStatusMessage.tsx +++ b/src/components/network-status/NetworkStatusMessage.tsx @@ -8,7 +8,7 @@ const OFFLINE_COLOR = 'rgba(255, 0, 0, 0.65)' const OPACITY_TRANSITION_TIME = 4000 const BASE_STYLE = { height: '50px', - pointerEvents: 'none' as 'none', + pointerEvents: 'none' as const, transition: `opacity ${OPACITY_TRANSITION_TIME}ms ease-in`, } diff --git a/src/custom-pouchdb.d.ts b/src/custom-pouchdb.d.ts index 2910c943e6..a3211e3398 100644 --- a/src/custom-pouchdb.d.ts +++ b/src/custom-pouchdb.d.ts @@ -1,3 +1,4 @@ +/* eslint-disable camelcase */ declare namespace PouchDB { interface SearchQuery { // Search string @@ -16,8 +17,8 @@ declare namespace PouchDB { filter?: (content: Content) => boolean - include_docs?: boolean highlighting?: boolean + include_docs?: boolean highlighting_pre?: string highlighting_post?: string @@ -36,10 +37,11 @@ declare namespace PouchDB { interface SearchResponse { rows: Array> + total_rows: number } - interface Database { + interface Database = Record> { search(query: SearchQuery): SearchResponse } } diff --git a/src/hooks/useUpdateEffect.ts b/src/hooks/useUpdateEffect.ts index 7b2e4c7908..12f93ca4fa 100644 --- a/src/hooks/useUpdateEffect.ts +++ b/src/hooks/useUpdateEffect.ts @@ -1,6 +1,6 @@ -import { useRef, useEffect } from 'react' +import { useRef, useEffect, EffectCallback } from 'react' -export default function (effect: Function, dependencies: any[]) { +export default function (effect: EffectCallback, dependencies: any[]): void { const isInitialMount = useRef(true) useEffect(() => {