From dc4dc0557b8f1379ac176abf179d9f1a4cc39743 Mon Sep 17 00:00:00 2001 From: Huey Date: Sun, 23 Jan 2022 15:22:22 +0800 Subject: [PATCH] fix(linting): resolve linting issues --- .eslintrc.js | 4 +++- package.json | 4 ++-- scripts/getVersion.ts | 2 +- src/Popup/Popup.tsx | 1 + src/utils/Constants.ts | 9 +++------ src/utils/Helpers.ts | 2 +- src/utils/scraper/ECHR/index.ts | 5 +++-- src/utils/scraper/EU/index.ts | 5 +++-- src/utils/scraper/HK/index.ts | 5 +++-- src/utils/scraper/SG/index.ts | 5 +++-- src/utils/scraper/UK/index.ts | 5 +++-- src/utils/scraper/UN/index.ts | 5 +++-- src/utils/scraper/custom/Custom.ts | 6 ++---- src/utils/scraper/index.ts | 5 +++-- tsconfig.json | 5 ++++- 15 files changed, 38 insertions(+), 30 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 3868379..8cd078a 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -64,6 +64,7 @@ module.exports = { `warn`, `never`, ], + "sonarjs/no-nested-template-literals": `warn`, "sort-keys-fix/sort-keys-fix": `warn`, "unicorn/consistent-function-scoping": `off`, "unicorn/filename-case": [ @@ -79,9 +80,10 @@ module.exports = { ], }, ], - "unicorn/no-array-reduce": `off`, + "unicorn/no-array-reduce": `warn`, "unicorn/no-await-expression-member": `off`, "unicorn/no-null": 0, + "unicorn/prefer-code-point": `warn`, "unicorn/prefer-module": `off`, "unicorn/prefer-node-protocol": `off`, "unicorn/prevent-abbreviations": [ diff --git a/package.json b/package.json index 1639c43..eb6d183 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "clerkent", - "version": "2.8.4", + "version": "2.8.5", "private": true, "description": "quick search for international caselaw and legislation", "repository": "https://github.com/lacuna-technologies/clerkent.git", @@ -33,7 +33,7 @@ }, "lint-staged": { "*.{ts,tsx,d.ts}": [ - "tsc-files --noEmit" + "tsc-files --noEmit src/types/Filetypes.d.ts" ], "*.{ts,tsx,js,jsx,json}": [ "eslint --cache --fix" diff --git a/scripts/getVersion.ts b/scripts/getVersion.ts index 84b9653..8e4f921 100644 --- a/scripts/getVersion.ts +++ b/scripts/getVersion.ts @@ -1,5 +1,5 @@ import fs from 'fs' -const packageJson = JSON.parse(fs.readFileSync(`package.json`, `utf-8`)) +const packageJson = JSON.parse(fs.readFileSync(`package.json`).toString()) console.log(packageJson.version) diff --git a/src/Popup/Popup.tsx b/src/Popup/Popup.tsx index 73d6fa4..c2d7c81 100644 --- a/src/Popup/Popup.tsx +++ b/src/Popup/Popup.tsx @@ -142,6 +142,7 @@ const Popup: React.FC = () => { port.current.onMessage.addListener(onMessage) }, [onMessage, sendMessage]) + // eslint-disable-next-line sonarjs/cognitive-complexity useEffect(() => { (async () => { let shouldDoSearch = false diff --git a/src/utils/Constants.ts b/src/utils/Constants.ts index 3378450..0a54ce7 100644 --- a/src/utils/Constants.ts +++ b/src/utils/Constants.ts @@ -230,14 +230,11 @@ const INSTITUTIONAL_LOGINS = { } const dedupeObjects = (inputObject: Record>, jurisdictionCode: Law.JursidictionCode) => - Object.entries(inputObject) - .reduce((accumulator, [id, object]: [string, Record]) => ({ - ...accumulator, - [`${jurisdictionCode}_${id}`]: { + Object.fromEntries(Object.entries(inputObject) + .map(( [id, object]: [string, Record]) => [`${jurisdictionCode}_${id}`, { id: `${jurisdictionCode}_${id}`, ...object, - }, - }), {}) + }])) const DATABASES: Record = { ...dedupeObjects(SG_DATABASES, `SG`), diff --git a/src/utils/Helpers.ts b/src/utils/Helpers.ts index 1cfa6db..4278f92 100644 --- a/src/utils/Helpers.ts +++ b/src/utils/Helpers.ts @@ -12,7 +12,7 @@ const debounce = (function_: (...arguments_: any[]) => unknown, timeout = 500) = } } -const classnames = (...arguments_: string[]) => [...new Set([...arguments_])].filter(item => item && item.length > 0).join(` `) +const classnames = (...arguments_: string[]) => [...new Set(arguments_)].filter(item => item && item.length > 0).join(` `) const escapeRegExp = (string: string) => string.replace(/[$()*+.?[\\\]^{|}]/g, `\\$&`) diff --git a/src/utils/scraper/ECHR/index.ts b/src/utils/scraper/ECHR/index.ts index 44946b4..8e6975f 100644 --- a/src/utils/scraper/ECHR/index.ts +++ b/src/utils/scraper/ECHR/index.ts @@ -1,2 +1,3 @@ -import ECHR from './ECHR' -export default ECHR \ No newline at end of file + + +export {default} from './ECHR' \ No newline at end of file diff --git a/src/utils/scraper/EU/index.ts b/src/utils/scraper/EU/index.ts index 20f5be3..2f3928a 100644 --- a/src/utils/scraper/EU/index.ts +++ b/src/utils/scraper/EU/index.ts @@ -1,2 +1,3 @@ -import EU from './EU' -export default EU \ No newline at end of file + + +export {default} from './EU' \ No newline at end of file diff --git a/src/utils/scraper/HK/index.ts b/src/utils/scraper/HK/index.ts index b058c87..570a129 100644 --- a/src/utils/scraper/HK/index.ts +++ b/src/utils/scraper/HK/index.ts @@ -1,2 +1,3 @@ -import HK from './HK' -export default HK \ No newline at end of file + + +export {default} from './HK' \ No newline at end of file diff --git a/src/utils/scraper/SG/index.ts b/src/utils/scraper/SG/index.ts index f9a7f70..6ad410d 100644 --- a/src/utils/scraper/SG/index.ts +++ b/src/utils/scraper/SG/index.ts @@ -1,2 +1,3 @@ -import SG from './SG' -export default SG \ No newline at end of file + + +export {default} from './SG' \ No newline at end of file diff --git a/src/utils/scraper/UK/index.ts b/src/utils/scraper/UK/index.ts index eaff5c0..3ad043b 100644 --- a/src/utils/scraper/UK/index.ts +++ b/src/utils/scraper/UK/index.ts @@ -1,2 +1,3 @@ -import UK from './UK' -export default UK \ No newline at end of file + + +export {default} from './UK' \ No newline at end of file diff --git a/src/utils/scraper/UN/index.ts b/src/utils/scraper/UN/index.ts index 36d2b8d..566c2fc 100644 --- a/src/utils/scraper/UN/index.ts +++ b/src/utils/scraper/UN/index.ts @@ -1,2 +1,3 @@ -import UN from './UN' -export default UN \ No newline at end of file + + +export {default} from './UN' \ No newline at end of file diff --git a/src/utils/scraper/custom/Custom.ts b/src/utils/scraper/custom/Custom.ts index f68a2be..f4023ce 100644 --- a/src/utils/scraper/custom/Custom.ts +++ b/src/utils/scraper/custom/Custom.ts @@ -18,16 +18,14 @@ const getCaseByName = async (caseName: string): Promise => { .map(rawCase => toLawCase(rawCase)) } -const getCaseByCitation = async (citation: string, court: string): Promise => Promise.resolve( - CustomCases +const getCaseByCitation = async (citation: string, court: string): Promise => CustomCases .filter(({ citations }) => citations.some((cit) => (new RegExp(`${citation}`, `i`)).test(cit)), ) .map(({ citations, ...others }) => ({ ...others, citation: citations[0], - })), -) + })) const Custom = { getCaseByCitation, diff --git a/src/utils/scraper/index.ts b/src/utils/scraper/index.ts index d205ff5..0d21308 100644 --- a/src/utils/scraper/index.ts +++ b/src/utils/scraper/index.ts @@ -1,2 +1,3 @@ -import Scraper from './Scraper' -export default Scraper \ No newline at end of file + + +export {default} from './Scraper' \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index a9a10c2..8cd6a26 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -26,5 +26,8 @@ "jest.config.ts.ts", "src/types/Filetypes.d.ts" ], - "exclude": ["**/node_modules", "**/.*/"] + "exclude": [ + "**/node_modules", + "**/.*/" + ] } \ No newline at end of file