From 15c694156ae41ae5591c1b91456b6a6aacd447d2 Mon Sep 17 00:00:00 2001 From: Juan Picado Date: Sat, 12 Jun 2021 09:25:53 +0200 Subject: [PATCH] fix eslint warnings (#2265) * chore: reduce warnings * chore: fix eslint warnings * fix warning --- package.json | 2 +- packages/api/src/index.ts | 10 ++-------- packages/cli/src/commands/version.ts | 1 + packages/config/test/config.spec.ts | 1 - packages/core/htpasswd/tests/__mocks__/Config.js | 1 + packages/core/local-storage/tests/token.test.ts | 9 +-------- packages/core/url/src/index.ts | 3 --- packages/hooks/src/notify.ts | 1 - .../test/__snapshots__/index.spec.ts.snap | 2 +- packages/logger-prettify/test/index.spec.ts | 2 +- packages/logger/test/logger.spec.ts | 4 ++-- packages/middleware/src/middleware.ts | 2 ++ packages/mock/src/mock-api.ts | 1 - packages/mock/src/types/index.ts | 5 ----- .../plugins/google-cloud-storage/src/storage.ts | 3 ++- packages/plugins/memory/src/local-memory.ts | 14 +++----------- .../src/App/Header/RegistryInfoDialog/styles.ts | 6 +++--- .../src/App/Header/Search/SearchAdornment.tsx | 2 +- packages/plugins/ui-theme/src/App/Header/styles.ts | 6 +++--- .../ui-theme/src/components/Author/styles.ts | 2 +- .../src/components/AutoComplete/styles.tsx | 4 ++-- .../ui-theme/src/design-tokens/ResetStyles.tsx | 6 +++--- .../DetailContainer/Dependencies/Dependencies.tsx | 2 +- .../Version/DetailContainer/DetailContainer.tsx | 8 +++++++- .../DetailContainer/DetailContainerContent.tsx | 8 +++++++- .../Version/DetailContainer/UpLinks/styles.ts | 2 +- .../Version/DetailContainer/Versions/styles.ts | 2 +- .../src/pages/Version/DetailContainer/tabs.ts | 6 ------ .../pages/Version/DetailSidebar/DetailSidebar.tsx | 3 ++- .../DetailSidebar/Developers/Developers.test.tsx | 2 +- .../DetailSidebar/Developers/Developers.tsx | 6 +++++- .../DetailSidebar/Developers/DevelopersTitle.tsx | 5 ++++- .../Version/DetailSidebar/Developers/index.ts | 1 - .../Version/DetailSidebar/Developers/styles.ts | 6 +++--- .../Version/DetailSidebar/Developers/types.ts | 4 ---- .../pages/Version/DetailSidebar/Engines/styles.ts | 2 +- .../DetailSidebar/Repository/Repository.tsx | 2 +- packages/proxy/src/up-storage.ts | 4 ++-- packages/proxy/test/proxy.spec.ts | 8 +------- packages/standalone/scripts/web.ts | 2 +- packages/store/src/local-storage.ts | 4 ++-- packages/store/src/storage-utils.ts | 5 +++-- packages/store/src/storage.ts | 2 +- packages/tools/eslint/src/rules/base.js | 5 +++-- .../verdaccio/test/functional/readme/readme.ts | 4 ++-- test/e2e-ui/server.ts | 2 +- 46 files changed, 80 insertions(+), 102 deletions(-) delete mode 100644 packages/plugins/ui-theme/src/pages/Version/DetailContainer/tabs.ts delete mode 100644 packages/plugins/ui-theme/src/pages/Version/DetailSidebar/Developers/types.ts diff --git a/package.json b/package.json index d79b2bec0..f6228122f 100644 --- a/package.json +++ b/package.json @@ -133,7 +133,7 @@ "docker": "docker build -t verdaccio/verdaccio:local . --no-cache", "format": "prettier --write \"**/*.{js,jsx,ts,tsx,json,yml,yaml,md}\"", "format:check": "prettier --check \"**/*.{js,jsx,ts,tsx,json,yml,yaml,md}\"", - "lint": "eslint --max-warnings 165 \"**/*.{js,jsx,ts,tsx}\"", + "lint": "eslint --max-warnings 48 \"**/*.{js,jsx,ts,tsx}\"", "test": "pnpm recursive test --filter ./packages", "test:e2e:cli": "pnpm test --filter ...@verdaccio/e2e-cli", "test:e2e:ui": "pnpm test --filter ...@verdaccio/e2e-ui", diff --git a/packages/api/src/index.ts b/packages/api/src/index.ts index 993b138d4..7e94f0e10 100644 --- a/packages/api/src/index.ts +++ b/packages/api/src/index.ts @@ -1,6 +1,4 @@ -import _ from 'lodash'; -import express, { Express } from 'express'; - +import express, { Router } from 'express'; import { match, validateName, @@ -25,11 +23,7 @@ import profile from './v1/profile'; import token from './v1/token'; import v1Search from './v1/search'; -export default function ( - config: Config, - auth: IAuth, - storage: IStorageHandler -): Express.Application { +export default function (config: Config, auth: IAuth, storage: IStorageHandler): Router { /* eslint new-cap:off */ const app = express.Router(); /* eslint new-cap:off */ diff --git a/packages/cli/src/commands/version.ts b/packages/cli/src/commands/version.ts index 0b6800084..b7272fbf3 100644 --- a/packages/cli/src/commands/version.ts +++ b/packages/cli/src/commands/version.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/explicit-member-accessibility */ import { Command } from 'clipanion'; export class VersionCommand extends Command { diff --git a/packages/config/test/config.spec.ts b/packages/config/test/config.spec.ts index eb0f15122..7698ab6fb 100644 --- a/packages/config/test/config.spec.ts +++ b/packages/config/test/config.spec.ts @@ -9,7 +9,6 @@ import { parseConfigFile, ROLES, WEB_TITLE, - getMatchedPackagesSpec, } from '../src'; import { parseConfigurationFile } from './utils'; diff --git a/packages/core/htpasswd/tests/__mocks__/Config.js b/packages/core/htpasswd/tests/__mocks__/Config.js index 3dfc3a124..d514e2650 100644 --- a/packages/core/htpasswd/tests/__mocks__/Config.js +++ b/packages/core/htpasswd/tests/__mocks__/Config.js @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/explicit-member-accessibility */ export default class Config { constructor() { this.storage = './test-storage'; diff --git a/packages/core/local-storage/tests/token.test.ts b/packages/core/local-storage/tests/token.test.ts index 717e561f6..baaf2a539 100644 --- a/packages/core/local-storage/tests/token.test.ts +++ b/packages/core/local-storage/tests/token.test.ts @@ -1,12 +1,8 @@ /* eslint-disable jest/no-mocks-import */ import fs from 'fs'; -import path from 'path'; - -import { assign } from 'lodash'; import { ILocalData, PluginOptions, Token } from '@verdaccio/types'; import LocalDatabase from '../src/local-database'; -import { ILocalFSPackageManager } from '../src/local-fs'; import * as pkgUtils from '../src/pkg-utils'; // FIXME: remove this mocks imports @@ -19,14 +15,11 @@ const optionsPlugin: PluginOptions<{}> = { }; let locaDatabase: ILocalData<{}>; -let loadPrivatePackages; describe('Local Database', () => { beforeEach(() => { const writeMock = jest.spyOn(fs, 'writeFileSync').mockImplementation(); - loadPrivatePackages = jest - .spyOn(pkgUtils, 'loadPrivatePackages') - .mockReturnValue({ list: [], secret: '' }); + jest.spyOn(pkgUtils, 'loadPrivatePackages').mockReturnValue({ list: [], secret: '' }); locaDatabase = new LocalDatabase(optionsPlugin.config, optionsPlugin.logger); (locaDatabase as LocalDatabase).clean(); writeMock.mockClear(); diff --git a/packages/core/url/src/index.ts b/packages/core/url/src/index.ts index 25fb34816..99b4ec7cc 100644 --- a/packages/core/url/src/index.ts +++ b/packages/core/url/src/index.ts @@ -1,9 +1,6 @@ import { URL } from 'url'; -import _ from 'lodash'; import buildDebug from 'debug'; import isURLValidator from 'validator/lib/isURL'; - -import { ConfigYaml } from '@verdaccio/types'; import { HEADERS } from '@verdaccio/commons-api'; const debug = buildDebug('verdaccio:core:url'); diff --git a/packages/hooks/src/notify.ts b/packages/hooks/src/notify.ts index a26e5c978..3c861f3e0 100644 --- a/packages/hooks/src/notify.ts +++ b/packages/hooks/src/notify.ts @@ -8,7 +8,6 @@ import { logger } from '@verdaccio/logger'; import { notifyRequest, NotifyRequestOptions } from './notify-request'; const debug = buildDebug('verdaccio:hooks'); -type TemplateMetadata = Package & { publishedPackage: string }; export function compileTemplate(content, metadata) { // FUTURE: multiple handlers diff --git a/packages/logger-prettify/test/__snapshots__/index.spec.ts.snap b/packages/logger-prettify/test/__snapshots__/index.spec.ts.snap index 94d4f6be5..8ef4256c0 100644 --- a/packages/logger-prettify/test/__snapshots__/index.spec.ts.snap +++ b/packages/logger-prettify/test/__snapshots__/index.spec.ts.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`prettyFactory should return a function 1`] = ` +exports[`prettyFactory should return a function with options 1`] = ` " trace--- [trace] - foo " `; diff --git a/packages/logger-prettify/test/index.spec.ts b/packages/logger-prettify/test/index.spec.ts index 8d9be8180..3f7c388f1 100644 --- a/packages/logger-prettify/test/index.spec.ts +++ b/packages/logger-prettify/test/index.spec.ts @@ -6,7 +6,7 @@ describe('prettyFactory', () => { expect(typeof factory['default']({})).toEqual('function'); }); - test('should return a function', () => { + test('should return a function with options', () => { const log = { level: 10, foo: 'foo', diff --git a/packages/logger/test/logger.spec.ts b/packages/logger/test/logger.spec.ts index 4300a0fdc..ab9a05877 100644 --- a/packages/logger/test/logger.spec.ts +++ b/packages/logger/test/logger.spec.ts @@ -2,7 +2,7 @@ import { logger, setup } from '../src'; describe('logger', () => { test('dsadasd', () => { - const spyOn = jest.spyOn(process.stdout, 'write'); + jest.spyOn(process.stdout, 'write'); setup([ { level: 'info', @@ -10,7 +10,7 @@ describe('logger', () => { ]); logger.info({ packageName: 'test' }, `publishing or updating a new version for @{packageName}`); - + // FIXME: check expect // expect(spyOn).toHaveBeenCalledTimes(2); }); }); diff --git a/packages/middleware/src/middleware.ts b/packages/middleware/src/middleware.ts index 7fa95e016..4d91c3419 100644 --- a/packages/middleware/src/middleware.ts +++ b/packages/middleware/src/middleware.ts @@ -207,6 +207,8 @@ export function final( body: FinalBody, req: $RequestExtend, res: $ResponseExtend, + // if we remove `next` breaks test + // eslint-disable-next-line @typescript-eslint/no-unused-vars next: $NextFunctionVer ): void { if (res.statusCode === HTTP_STATUS.UNAUTHORIZED && !res.getHeader(HEADERS.WWW_AUTH)) { diff --git a/packages/mock/src/mock-api.ts b/packages/mock/src/mock-api.ts index 78aedc51d..a6df3b670 100644 --- a/packages/mock/src/mock-api.ts +++ b/packages/mock/src/mock-api.ts @@ -13,7 +13,6 @@ import { import { buildToken } from '@verdaccio/utils'; import { generateRandomHexString } from '@verdaccio/utils'; import { Package } from '@verdaccio/types'; -import { response } from 'express'; const debug = buildDebug('verdaccio:mock:api'); diff --git a/packages/mock/src/types/index.ts b/packages/mock/src/types/index.ts index ae65b7be1..cea64094c 100644 --- a/packages/mock/src/types/index.ts +++ b/packages/mock/src/types/index.ts @@ -9,8 +9,3 @@ export interface IServerProcess { init(binPath: string): Promise; stop(): void; } - -// eslint-disable-next-line no-unused-vars -declare class PromiseAssert extends Promise { - public constructor(options: any); -} diff --git a/packages/plugins/google-cloud-storage/src/storage.ts b/packages/plugins/google-cloud-storage/src/storage.ts index b3b4000c5..a008c1f63 100644 --- a/packages/plugins/google-cloud-storage/src/storage.ts +++ b/packages/plugins/google-cloud-storage/src/storage.ts @@ -104,11 +104,12 @@ class GoogleCloudStorageHandler implements IPackageStorageManager { const file = this.helper.buildFilePath(this.name, fileName); this.logger.debug({ name: file.name }, 'gcloud: deleting @{name} from storage'); try { - // @ts-ignore file + // @ts-ignore .delete() // FIXME: after upgrade this is broken // @ts-ignore + // eslint-disable-next-line @typescript-eslint/no-unused-vars .then((_data: [Response]): void => { this.logger.debug( { name: file.name }, diff --git a/packages/plugins/memory/src/local-memory.ts b/packages/plugins/memory/src/local-memory.ts index 3f670c1be..bddb4d7d9 100644 --- a/packages/plugins/memory/src/local-memory.ts +++ b/packages/plugins/memory/src/local-memory.ts @@ -1,13 +1,5 @@ import { getServiceUnavailable } from '@verdaccio/commons-api'; -import { - Logger, - Callback, - Config, - IPluginStorage, - Token, - TokenFilter, - PluginOptions, -} from '@verdaccio/types'; +import { Logger, Callback, Config, IPluginStorage, Token, PluginOptions } from '@verdaccio/types'; import buildDebug from 'debug'; import MemoryHandler, { DataHandler } from './memory-handler'; @@ -108,7 +100,7 @@ class LocalMemory implements IPluginStorage { return emptyDatabase; } - public saveToken(token: Token): Promise { + public saveToken(): Promise { this.logger.warn('[verdaccio/memory][saveToken] save token has not been implemented yet'); return Promise.reject(getServiceUnavailable('method not implemented')); @@ -123,7 +115,7 @@ class LocalMemory implements IPluginStorage { return Promise.reject(getServiceUnavailable('method not implemented')); } - public readTokens(filter: TokenFilter): Promise { + public readTokens(): Promise { this.logger.warn('[verdaccio/memory][readTokens] read tokens has not been implemented yet '); return Promise.reject(getServiceUnavailable('method not implemented')); diff --git a/packages/plugins/ui-theme/src/App/Header/RegistryInfoDialog/styles.ts b/packages/plugins/ui-theme/src/App/Header/RegistryInfoDialog/styles.ts index df745d5f7..917a9991e 100644 --- a/packages/plugins/ui-theme/src/App/Header/RegistryInfoDialog/styles.ts +++ b/packages/plugins/ui-theme/src/App/Header/RegistryInfoDialog/styles.ts @@ -5,9 +5,9 @@ import DialogTitle from 'verdaccio-ui/components/DialogTitle'; import { Theme } from 'verdaccio-ui/design-tokens/theme'; export const Title = styled(DialogTitle)<{ theme?: Theme }>((props) => ({ - backgroundColor: props.theme && props.theme.palette.primary.main, - color: props.theme && props.theme.palette.white, - fontSize: props.theme && props.theme.fontSize.lg, + backgroundColor: props.theme?.palette.primary.main, + color: props.theme?.palette.white, + fontSize: props.theme?.fontSize.lg, })); export const Content = styled(DialogContent)<{ theme?: Theme }>(({ theme }) => ({ diff --git a/packages/plugins/ui-theme/src/App/Header/Search/SearchAdornment.tsx b/packages/plugins/ui-theme/src/App/Header/Search/SearchAdornment.tsx index c3907921a..9547f22ee 100644 --- a/packages/plugins/ui-theme/src/App/Header/Search/SearchAdornment.tsx +++ b/packages/plugins/ui-theme/src/App/Header/Search/SearchAdornment.tsx @@ -6,7 +6,7 @@ import InputAdornment from 'verdaccio-ui/components/InputAdornment'; import { Theme } from 'verdaccio-ui/design-tokens/theme'; const StyledInputAdornment = styled(InputAdornment)<{ theme?: Theme }>((props) => ({ - color: props.theme && props.theme.palette.white, + color: props.theme?.palette.white, })); const SearchAdornment: React.FC = () => ( diff --git a/packages/plugins/ui-theme/src/App/Header/styles.ts b/packages/plugins/ui-theme/src/App/Header/styles.ts index 534507ef8..517942faf 100644 --- a/packages/plugins/ui-theme/src/App/Header/styles.ts +++ b/packages/plugins/ui-theme/src/App/Header/styles.ts @@ -29,15 +29,15 @@ export const LeftSide = styled(RightSide)({ export const MobileNavBar = styled('div')<{ theme?: Theme }>((props) => ({ alignItems: 'center', display: 'flex', - borderBottom: `1px solid ${props.theme && props.theme.palette.greyLight}`, + borderBottom: `1px solid ${props.theme?.palette.greyLight}`, padding: '8px', position: 'relative', })); export const InnerMobileNavBar = styled('div')<{ theme?: Theme }>((props) => ({ borderRadius: '4px', - backgroundColor: props.theme && props.theme.palette.greyLight, - color: props.theme && props.theme.palette.white, + backgroundColor: props.theme?.palette.greyLight, + color: props.theme?.palette.white, width: '100%', padding: '0 5px', margin: '0 10px 0 0', diff --git a/packages/plugins/ui-theme/src/components/Author/styles.ts b/packages/plugins/ui-theme/src/components/Author/styles.ts index 5b80aa621..0c8f0a332 100644 --- a/packages/plugins/ui-theme/src/components/Author/styles.ts +++ b/packages/plugins/ui-theme/src/components/Author/styles.ts @@ -7,7 +7,7 @@ import ListItemText from '../ListItemText'; import Text from '../Text'; export const StyledText = styled(Text)<{ theme?: Theme }>((props) => ({ - fontWeight: props.theme && props.theme.fontWeight.bold, + fontWeight: props.theme?.fontWeight.bold, })); export const AuthorListItem = styled(ListItem)({ diff --git a/packages/plugins/ui-theme/src/components/AutoComplete/styles.tsx b/packages/plugins/ui-theme/src/components/AutoComplete/styles.tsx index 9ef1b2be3..9f742aa63 100644 --- a/packages/plugins/ui-theme/src/components/AutoComplete/styles.tsx +++ b/packages/plugins/ui-theme/src/components/AutoComplete/styles.tsx @@ -24,7 +24,7 @@ export const StyledTextField = styled(TextField)<{ theme?: Theme }>((props) => ( border: 'none', }, ':after': { - borderColor: props.theme && props.theme.palette.white, + borderColor: props.theme?.palette.white, }, ':hover:before': { content: 'none', @@ -41,7 +41,7 @@ export const StyledTextField = styled(TextField)<{ theme?: Theme }>((props) => ( }, '& .MuiInputBase-input': { [`@media screen and (min-width: ${props.theme?.breakPoints.medium}px)`]: { - color: props.theme && props.theme.palette.white, + color: props.theme?.palette.white, }, }, })); diff --git a/packages/plugins/ui-theme/src/design-tokens/ResetStyles.tsx b/packages/plugins/ui-theme/src/design-tokens/ResetStyles.tsx index 5981bb118..bb793cddf 100644 --- a/packages/plugins/ui-theme/src/design-tokens/ResetStyles.tsx +++ b/packages/plugins/ui-theme/src/design-tokens/ResetStyles.tsx @@ -11,7 +11,7 @@ const resetStyles = makeStyles(({ theme }: { theme?: Theme }) => ({ fontFamily: '"Roboto", Helvetica Neue, Arial, sans-serif', }, strong: { - fontWeight: theme && theme.fontWeight.semiBold, + fontWeight: theme?.fontWeight.semiBold, }, 'html, body, #root': { height: '100%', @@ -26,8 +26,8 @@ const resetStyles = makeStyles(({ theme }: { theme?: Theme }) => ({ flex: 1, height: '100%', - [`@media screen and (min-width: ${theme && theme.breakPoints.container}px)`]: { - maxWidth: theme && theme.breakPoints.container, + [`@media screen and (min-width: ${theme?.breakPoints.container}px)`]: { + maxWidth: theme?.breakPoints.container, width: '100%', marginLeft: 'auto', marginRight: 'auto', diff --git a/packages/plugins/ui-theme/src/pages/Version/DetailContainer/Dependencies/Dependencies.tsx b/packages/plugins/ui-theme/src/pages/Version/DetailContainer/Dependencies/Dependencies.tsx index d0dffcf2f..a9e4a77d7 100644 --- a/packages/plugins/ui-theme/src/pages/Version/DetailContainer/Dependencies/Dependencies.tsx +++ b/packages/plugins/ui-theme/src/pages/Version/DetailContainer/Dependencies/Dependencies.tsx @@ -23,7 +23,7 @@ const DependencyBlock: React.FC = ({ title, dependencies } const deps = Object.entries(dependencies); function handleClick(name: string): void { - enableLoading && enableLoading(); + enableLoading?.(); history.push(`/-/web/detail/${name}`); } diff --git a/packages/plugins/ui-theme/src/pages/Version/DetailContainer/DetailContainer.tsx b/packages/plugins/ui-theme/src/pages/Version/DetailContainer/DetailContainer.tsx index 399b5f087..516e62a72 100644 --- a/packages/plugins/ui-theme/src/pages/Version/DetailContainer/DetailContainer.tsx +++ b/packages/plugins/ui-theme/src/pages/Version/DetailContainer/DetailContainer.tsx @@ -7,7 +7,13 @@ import { DetailContext } from '../context'; import Deprecated from './Deprecated'; import DetailContainerContent from './DetailContainerContent'; import DetailContainerTabs from './DetailContainerTabs'; -import { TabPosition } from './tabs'; + +export enum TabPosition { + README = 'readme', + DEPENDENCIES = 'dependencies', + VERSIONS = 'versions', + UPLINKS = 'uplinks', +} const DetailContainer: React.FC = () => { const tabs = Object.values(TabPosition); diff --git a/packages/plugins/ui-theme/src/pages/Version/DetailContainer/DetailContainerContent.tsx b/packages/plugins/ui-theme/src/pages/Version/DetailContainer/DetailContainerContent.tsx index a37a8f33b..72a3019a5 100644 --- a/packages/plugins/ui-theme/src/pages/Version/DetailContainer/DetailContainerContent.tsx +++ b/packages/plugins/ui-theme/src/pages/Version/DetailContainer/DetailContainerContent.tsx @@ -3,7 +3,13 @@ import React from 'react'; import loadable from '../../../App/utils/loadable'; import DetailContainerContentReadme from './DetailContainerContentReadme'; -import { TabPosition } from './tabs'; + +export enum TabPosition { + README = 'readme', + DEPENDENCIES = 'dependencies', + VERSIONS = 'versions', + UPLINKS = 'uplinks', +} const Versions = loadable(() => import(/* webpackChunkName: "Versions" */ './Versions')); const UpLinks = loadable(() => import(/* webpackChunkName: "UpLinks" */ './UpLinks')); diff --git a/packages/plugins/ui-theme/src/pages/Version/DetailContainer/UpLinks/styles.ts b/packages/plugins/ui-theme/src/pages/Version/DetailContainer/UpLinks/styles.ts index 9069b63ce..265cc8b21 100644 --- a/packages/plugins/ui-theme/src/pages/Version/DetailContainer/UpLinks/styles.ts +++ b/packages/plugins/ui-theme/src/pages/Version/DetailContainer/UpLinks/styles.ts @@ -5,7 +5,7 @@ import Text from 'verdaccio-ui/components/Text'; import { Theme } from 'verdaccio-ui/design-tokens/theme'; export const StyledText = styled(Text)<{ theme?: Theme }>((props) => ({ - fontWeight: props.theme && props.theme.fontWeight.bold, + fontWeight: props.theme?.fontWeight.bold, })); export const Spacer = styled('div')<{ theme?: Theme }>(({ theme }) => ({ diff --git a/packages/plugins/ui-theme/src/pages/Version/DetailContainer/Versions/styles.ts b/packages/plugins/ui-theme/src/pages/Version/DetailContainer/Versions/styles.ts index ecfa23a0a..a5cef0fdd 100644 --- a/packages/plugins/ui-theme/src/pages/Version/DetailContainer/Versions/styles.ts +++ b/packages/plugins/ui-theme/src/pages/Version/DetailContainer/Versions/styles.ts @@ -6,7 +6,7 @@ import Text from 'verdaccio-ui/components/Text'; import { Theme } from 'verdaccio-ui/design-tokens/theme'; export const StyledText = styled(Text)<{ theme?: Theme }>((props) => ({ - fontWeight: props.theme && props.theme.fontWeight.bold, + fontWeight: props.theme?.fontWeight.bold, })); export const Spacer = styled('div')<{ theme?: Theme }>(({ theme }) => ({ diff --git a/packages/plugins/ui-theme/src/pages/Version/DetailContainer/tabs.ts b/packages/plugins/ui-theme/src/pages/Version/DetailContainer/tabs.ts deleted file mode 100644 index 565f1c698..000000000 --- a/packages/plugins/ui-theme/src/pages/Version/DetailContainer/tabs.ts +++ /dev/null @@ -1,6 +0,0 @@ -export enum TabPosition { - README = 'readme', - DEPENDENCIES = 'dependencies', - VERSIONS = 'versions', - UPLINKS = 'uplinks', -} diff --git a/packages/plugins/ui-theme/src/pages/Version/DetailSidebar/DetailSidebar.tsx b/packages/plugins/ui-theme/src/pages/Version/DetailSidebar/DetailSidebar.tsx index cb08eab0b..4c49d0fd8 100644 --- a/packages/plugins/ui-theme/src/pages/Version/DetailSidebar/DetailSidebar.tsx +++ b/packages/plugins/ui-theme/src/pages/Version/DetailSidebar/DetailSidebar.tsx @@ -11,7 +11,8 @@ import loadable from '../../../App/utils/loadable'; import DetailSidebarFundButton from './DetailSidebarFundButton'; import DetailSidebarTitle from './DetailSidebarTitle'; -import Developers, { DeveloperType } from './Developers'; +import Developers from './Developers'; +import { DeveloperType } from './Developers/DevelopersTitle'; const Engines = loadable(() => import(/* webpackChunkName: "Engines" */ './Engines')); const Dist = loadable(() => import(/* webpackChunkName: "Dist" */ './Dist')); diff --git a/packages/plugins/ui-theme/src/pages/Version/DetailSidebar/Developers/Developers.test.tsx b/packages/plugins/ui-theme/src/pages/Version/DetailSidebar/Developers/Developers.test.tsx index 3e97fba61..f745c2b61 100644 --- a/packages/plugins/ui-theme/src/pages/Version/DetailSidebar/Developers/Developers.test.tsx +++ b/packages/plugins/ui-theme/src/pages/Version/DetailSidebar/Developers/Developers.test.tsx @@ -5,7 +5,7 @@ import { render, cleanup, fireEvent } from 'verdaccio-ui/utils/test-react-testin import { DetailContextProvider } from '../../context'; import Developers from './Developers'; -import { DeveloperType } from './types'; +import { DeveloperType } from './DevelopersTitle'; describe('test Developers', () => { afterEach(() => { diff --git a/packages/plugins/ui-theme/src/pages/Version/DetailSidebar/Developers/Developers.tsx b/packages/plugins/ui-theme/src/pages/Version/DetailSidebar/Developers/Developers.tsx index bbdc5d48c..69ab3b737 100644 --- a/packages/plugins/ui-theme/src/pages/Version/DetailSidebar/Developers/Developers.tsx +++ b/packages/plugins/ui-theme/src/pages/Version/DetailSidebar/Developers/Developers.tsx @@ -13,7 +13,11 @@ import { DetailContext } from '../..'; import DevelopersTitle from './DevelopersTitle'; import getUniqueDeveloperValues from './get-unique-developer-values'; -import { DeveloperType } from './types'; + +export enum DeveloperType { + CONTRIBUTORS = 'contributors', + MAINTAINERS = 'maintainers', +} export const Fab = styled(FloatingActionButton)<{ theme?: Theme }>((props) => ({ backgroundColor: props.theme?.palette.primary.main, diff --git a/packages/plugins/ui-theme/src/pages/Version/DetailSidebar/Developers/DevelopersTitle.tsx b/packages/plugins/ui-theme/src/pages/Version/DetailSidebar/Developers/DevelopersTitle.tsx index 9ac371b5f..8b0d34f09 100644 --- a/packages/plugins/ui-theme/src/pages/Version/DetailSidebar/Developers/DevelopersTitle.tsx +++ b/packages/plugins/ui-theme/src/pages/Version/DetailSidebar/Developers/DevelopersTitle.tsx @@ -5,7 +5,10 @@ import { useTranslation } from 'react-i18next'; import Text from 'verdaccio-ui/components/Text'; import { Theme } from 'verdaccio-ui/design-tokens/theme'; -import { DeveloperType } from './types'; +export enum DeveloperType { + CONTRIBUTORS = 'contributors', + MAINTAINERS = 'maintainers', +} interface Props { type: DeveloperType; diff --git a/packages/plugins/ui-theme/src/pages/Version/DetailSidebar/Developers/index.ts b/packages/plugins/ui-theme/src/pages/Version/DetailSidebar/Developers/index.ts index 61dcb4878..fb3ef86a6 100644 --- a/packages/plugins/ui-theme/src/pages/Version/DetailSidebar/Developers/index.ts +++ b/packages/plugins/ui-theme/src/pages/Version/DetailSidebar/Developers/index.ts @@ -1,2 +1 @@ export { default } from './Developers'; -export { DeveloperType } from './types'; diff --git a/packages/plugins/ui-theme/src/pages/Version/DetailSidebar/Developers/styles.ts b/packages/plugins/ui-theme/src/pages/Version/DetailSidebar/Developers/styles.ts index 63eb36f5e..b05662c1e 100644 --- a/packages/plugins/ui-theme/src/pages/Version/DetailSidebar/Developers/styles.ts +++ b/packages/plugins/ui-theme/src/pages/Version/DetailSidebar/Developers/styles.ts @@ -20,12 +20,12 @@ export const Content = styled('div')({ }); export const StyledText = styled(Text)<{ theme?: Theme }>((props) => ({ - fontWeight: props.theme && props.theme.fontWeight.bold, + fontWeight: props.theme?.fontWeight.bold, marginBottom: '10px', textTransform: 'capitalize', })); export const Fab = styled(FloatingActionButton)<{ theme?: Theme }>((props) => ({ - backgroundColor: props.theme && props.theme.palette.primary.main, - color: props.theme && props.theme.palette.white, + backgroundColor: props.theme?.palette.primary.main, + color: props.theme?.palette.white, })); diff --git a/packages/plugins/ui-theme/src/pages/Version/DetailSidebar/Developers/types.ts b/packages/plugins/ui-theme/src/pages/Version/DetailSidebar/Developers/types.ts deleted file mode 100644 index 1ae0f6165..000000000 --- a/packages/plugins/ui-theme/src/pages/Version/DetailSidebar/Developers/types.ts +++ /dev/null @@ -1,4 +0,0 @@ -export enum DeveloperType { - CONTRIBUTORS = 'contributors', - MAINTAINERS = 'maintainers', -} diff --git a/packages/plugins/ui-theme/src/pages/Version/DetailSidebar/Engines/styles.ts b/packages/plugins/ui-theme/src/pages/Version/DetailSidebar/Engines/styles.ts index f321c925c..a4bf21cfa 100644 --- a/packages/plugins/ui-theme/src/pages/Version/DetailSidebar/Engines/styles.ts +++ b/packages/plugins/ui-theme/src/pages/Version/DetailSidebar/Engines/styles.ts @@ -5,7 +5,7 @@ import Text from 'verdaccio-ui/components/Text'; import { Theme } from 'verdaccio-ui/design-tokens/theme'; export const StyledText = styled(Text)<{ theme?: Theme }>((props) => ({ - fontWeight: props.theme && props.theme.fontWeight.bold, + fontWeight: props.theme?.fontWeight.bold, textTransform: 'capitalize', })); diff --git a/packages/plugins/ui-theme/src/pages/Version/DetailSidebar/Repository/Repository.tsx b/packages/plugins/ui-theme/src/pages/Version/DetailSidebar/Repository/Repository.tsx index 04e11d353..0e723cede 100644 --- a/packages/plugins/ui-theme/src/pages/Version/DetailSidebar/Repository/Repository.tsx +++ b/packages/plugins/ui-theme/src/pages/Version/DetailSidebar/Repository/Repository.tsx @@ -17,7 +17,7 @@ import { DetailContext } from '../../context'; import git from './img/git.png'; const StyledText = styled(Text)<{ theme?: Theme }>((props) => ({ - fontWeight: props.theme && props.theme.fontWeight.bold, + fontWeight: props.theme?.fontWeight.bold, textTransform: 'capitalize', })); diff --git a/packages/proxy/src/up-storage.ts b/packages/proxy/src/up-storage.ts index f54dae780..290245449 100644 --- a/packages/proxy/src/up-storage.ts +++ b/packages/proxy/src/up-storage.ts @@ -1,6 +1,6 @@ import zlib from 'zlib'; import Stream from 'stream'; -import URL, { UrlWithStringQuery } from 'url'; +import URL from 'url'; import JSONStream from 'JSONStream'; import _ from 'lodash'; import request from 'request'; @@ -480,7 +480,7 @@ class ProxyStorage implements IProxy { * @param {String} url * @return {Stream} */ - fetchTarball(url: string) { + public fetchTarball(url: string) { const stream = new ReadTarball({}); let current_length = 0; let expected_length; diff --git a/packages/proxy/test/proxy.spec.ts b/packages/proxy/test/proxy.spec.ts index 42974a807..1ae5cf0b0 100644 --- a/packages/proxy/test/proxy.spec.ts +++ b/packages/proxy/test/proxy.spec.ts @@ -3,13 +3,7 @@ import nock from 'nock'; import * as httpMocks from 'node-mocks-http'; import { Config, parseConfigFile } from '@verdaccio/config'; import { ErrorCode } from '@verdaccio/utils'; -import { - API_ERROR, - HEADERS, - HEADER_TYPE, - HTTP_STATUS, - VerdaccioError, -} from '@verdaccio/commons-api'; +import { API_ERROR, HEADER_TYPE, HTTP_STATUS, VerdaccioError } from '@verdaccio/commons-api'; import { ProxyStorage } from '../src/up-storage'; const getConf = (name) => path.join(__dirname, '/conf', name); diff --git a/packages/standalone/scripts/web.ts b/packages/standalone/scripts/web.ts index 1cf4b3d47..82a79e724 100644 --- a/packages/standalone/scripts/web.ts +++ b/packages/standalone/scripts/web.ts @@ -1,6 +1,6 @@ const path = require('path'); const fse = require('fs-extra'); -const { staticPath, manifest, manifestFiles } = require('@verdaccio/ui-theme')(); +const { staticPath } = require('@verdaccio/ui-theme')(); fse.copySync(staticPath, path.join(__dirname, '../dist/static')); // eslint-disable-next-line no-console console.log('theme files copied'); diff --git a/packages/store/src/local-storage.ts b/packages/store/src/local-storage.ts index 76941afdc..2633f8144 100644 --- a/packages/store/src/local-storage.ts +++ b/packages/store/src/local-storage.ts @@ -538,7 +538,7 @@ class LocalStorage implements IStorage { // @ts-ignore } else if (err.code === STORAGE.NO_SUCH_FILE_ERROR || err.code === HTTP_STATUS.NOT_FOUND) { // check if package exists to throw an appropriate message - this.getPackageMetadata(name, function (_err: VerdaccioError, _res: Package): void { + this.getPackageMetadata(name, function (_err: VerdaccioError): void { if (_err) { uploadStream.emit('error', _err); } else { @@ -686,7 +686,7 @@ class LocalStorage implements IStorage { * @param {*} options * @return {Function} */ - public search(startKey: string, options: any): IReadTarball { + public search(startKey: string): IReadTarball { const stream = new ReadTarball({ objectMode: true }); debug('search by %o', startKey); this._searchEachPackage( diff --git a/packages/store/src/storage-utils.ts b/packages/store/src/storage-utils.ts index d59ed71f6..7871c1362 100644 --- a/packages/store/src/storage-utils.ts +++ b/packages/store/src/storage-utils.ts @@ -227,8 +227,9 @@ export function mergeUplinkTimeIntoLocal(localMetadata: Package, remoteMetadata: export function prepareSearchPackage(data: Package, time: unknown): any { const listVersions: string[] = Object.keys(data.versions); const versions: string[] = semverSort(listVersions); - const latest: string | undefined = - data[DIST_TAGS] && data[DIST_TAGS].latest ? data[DIST_TAGS].latest : versions.pop(); + const latest: string | undefined = data[DIST_TAGS]?.latest + ? data[DIST_TAGS].latest + : versions.pop(); if (latest && data.versions[latest]) { const version: Version = data.versions[latest]; diff --git a/packages/store/src/storage.ts b/packages/store/src/storage.ts index 7269810ee..b13e71582 100644 --- a/packages/store/src/storage.ts +++ b/packages/store/src/storage.ts @@ -2,7 +2,7 @@ import assert from 'assert'; import Stream from 'stream'; import async, { AsyncResultArrayCallback } from 'async'; import _ from 'lodash'; -import e, { Request } from 'express'; +import { Request } from 'express'; import buildDebug from 'debug'; import { ProxyStorage } from '@verdaccio/proxy'; diff --git a/packages/tools/eslint/src/rules/base.js b/packages/tools/eslint/src/rules/base.js index 1e5d294b1..6a68b381d 100644 --- a/packages/tools/eslint/src/rules/base.js +++ b/packages/tools/eslint/src/rules/base.js @@ -23,6 +23,8 @@ module.exports = { camelcase: 'off', 'guard-for-in': 'error', 'new-cap': 'error', + // disabled in favor of @typescript-eslint/no-unused-vars + 'no-unused-vars': 'off', 'max-len': ['error', 100], 'no-console': ['error', { allow: ['warn'] }], 'no-constant-condition': 'error', @@ -54,11 +56,10 @@ module.exports = { '@typescript-eslint/ban-types': 0, '@typescript-eslint/explicit-module-boundary-types': 0, // rules to fix - 'no-unused-vars': ['warn', { vars: 'all', args: 'none' }], 'prefer-promise-reject-errors': ['warn'], '@typescript-eslint/prefer-optional-chain': ['warn'], '@typescript-eslint/explicit-member-accessibility': ['warn'], - '@typescript-eslint/no-unused-vars': ['warn'], + '@typescript-eslint/no-unused-vars': ['error'], }, }; diff --git a/packages/verdaccio/test/functional/readme/readme.ts b/packages/verdaccio/test/functional/readme/readme.ts index 7743c9385..c485ff2b0 100644 --- a/packages/verdaccio/test/functional/readme/readme.ts +++ b/packages/verdaccio/test/functional/readme/readme.ts @@ -37,11 +37,11 @@ export default function (server, server2) { return matchReadme(server2, README_PKG1, README_MESSAGE); }); - test.skip('should fetch not found readme server2 over uplink server1', () => { + test('should fetch not found readme server2 over uplink server1', () => { return matchReadme(server, README_PKG2, DEFAULT_NO_README); }); - test.skip('should fetch not found readme package on local server1', () => { + test('should fetch not found readme package on local server1', () => { return matchReadme(server2, README_PKG2, DEFAULT_NO_README); }); }); diff --git a/test/e2e-ui/server.ts b/test/e2e-ui/server.ts index 4878995e9..211671fcc 100644 --- a/test/e2e-ui/server.ts +++ b/test/e2e-ui/server.ts @@ -6,7 +6,7 @@ import _ from 'lodash'; import { CREDENTIALS } from './registry-launcher'; import smartRequest, { RequestPromise } from './request'; -declare class PromiseAssert extends Promise { +declare class PromiseAssert extends Promise { public constructor(options: any); }