From f0fc7f022a9511ce5dc741b145391867c4cd8d22 Mon Sep 17 00:00:00 2001 From: SpacingBat3 Date: Mon, 25 Jul 2022 01:18:03 +0200 Subject: [PATCH] "Remove" unused exports. Add ESLint rule to trow an Error when linting and detecting an unused export and update a code accordingly to that rule. --- .eslintrc.json | 4 +++- sources/code/common/modules/package.ts | 6 +++--- sources/code/main/modules/config.ts | 2 +- sources/code/main/modules/csp.ts | 2 +- sources/code/renderer/modules/api.ts | 1 + 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 90db6ea8..679b6b56 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -6,7 +6,6 @@ }, "extends": [ "eslint:recommended", - "plugin:@typescript-eslint/eslint-recommended", "plugin:@typescript-eslint/recommended", "plugin:@typescript-eslint/recommended-requiring-type-checking", "plugin:import/recommended", @@ -57,6 +56,9 @@ "no-restricted-imports": ["error", { "name": "electron", "message": "This module does not provide the information about the process type. Please use 'electron/common', 'electron/main' or 'electron/renderer' instead." + }], + "import/no-unused-modules": ["error", { + "unusedExports": true }] } } diff --git a/sources/code/common/modules/package.ts b/sources/code/common/modules/package.ts index c1d4fda4..923d58a5 100644 --- a/sources/code/common/modules/package.ts +++ b/sources/code/common/modules/package.ts @@ -13,10 +13,10 @@ interface PersonObject { url?: string; } -export type PersonAny = string & PersonObject -export type PersonLike = string | PersonObject +type PersonAny = string & PersonObject +type PersonLike = string | PersonObject -export interface PackageJsonProperties { +interface PackageJsonProperties { /** Node.js-friendly application name. */ name: string, /** Node package description. */ diff --git a/sources/code/main/modules/config.ts b/sources/code/main/modules/config.ts index e6a476f2..c40fc191 100644 --- a/sources/code/main/modules/config.ts +++ b/sources/code/main/modules/config.ts @@ -30,7 +30,7 @@ const test = {} as unknown as ConfigElement; if("radio" in test) test.radio; -export interface AppConfigBase { +interface AppConfigBase { settings: Record>, update: Record } diff --git a/sources/code/main/modules/csp.ts b/sources/code/main/modules/csp.ts index 3254dd1a..354d69e5 100644 --- a/sources/code/main/modules/csp.ts +++ b/sources/code/main/modules/csp.ts @@ -17,7 +17,7 @@ const cspKeysRegExp = new RegExp("(?<="+cspKeys.join("|")+")\\s+"); type cspObject = Partial>; -export default class CSP { +class CSP { private values: { object: cspObject, string: string diff --git a/sources/code/renderer/modules/api.ts b/sources/code/renderer/modules/api.ts index 3ef7c076..07836838 100644 --- a/sources/code/renderer/modules/api.ts +++ b/sources/code/renderer/modules/api.ts @@ -1,3 +1,4 @@ +/* eslint-disable import/no-unused-modules */ /* * A place to move useful WebCord's function that could be exposed to * third-party addons in the future as part of planned "API".