Skip to content

Commit

Permalink
fix eslint warnings (verdaccio#2265)
Browse files Browse the repository at this point in the history
* chore: reduce warnings

* chore: fix eslint warnings

* fix warning
  • Loading branch information
juanpicado authored Jun 12, 2021
1 parent 59ac312 commit 15c6941
Show file tree
Hide file tree
Showing 46 changed files with 80 additions and 102 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
10 changes: 2 additions & 8 deletions packages/api/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import _ from 'lodash';
import express, { Express } from 'express';

import express, { Router } from 'express';
import {
match,
validateName,
Expand All @@ -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 */
Expand Down
1 change: 1 addition & 0 deletions packages/cli/src/commands/version.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/explicit-member-accessibility */
import { Command } from 'clipanion';

export class VersionCommand extends Command {
Expand Down
1 change: 0 additions & 1 deletion packages/config/test/config.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
parseConfigFile,
ROLES,
WEB_TITLE,
getMatchedPackagesSpec,
} from '../src';
import { parseConfigurationFile } from './utils';

Expand Down
1 change: 1 addition & 0 deletions packages/core/htpasswd/tests/__mocks__/Config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/explicit-member-accessibility */
export default class Config {
constructor() {
this.storage = './test-storage';
Expand Down
9 changes: 1 addition & 8 deletions packages/core/local-storage/tests/token.test.ts
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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();
Expand Down
3 changes: 0 additions & 3 deletions packages/core/url/src/index.ts
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
1 change: 0 additions & 1 deletion packages/hooks/src/notify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
"
`;
2 changes: 1 addition & 1 deletion packages/logger-prettify/test/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
4 changes: 2 additions & 2 deletions packages/logger/test/logger.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import { logger, setup } from '../src';

describe('logger', () => {
test('dsadasd', () => {
const spyOn = jest.spyOn(process.stdout, 'write');
jest.spyOn(process.stdout, 'write');
setup([
{
level: 'info',
},
]);

logger.info({ packageName: 'test' }, `publishing or updating a new version for @{packageName}`);

// FIXME: check expect
// expect(spyOn).toHaveBeenCalledTimes(2);
});
});
2 changes: 2 additions & 0 deletions packages/middleware/src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
1 change: 0 additions & 1 deletion packages/mock/src/mock-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down
5 changes: 0 additions & 5 deletions packages/mock/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,3 @@ export interface IServerProcess {
init(binPath: string): Promise<any>;
stop(): void;
}

// eslint-disable-next-line no-unused-vars
declare class PromiseAssert<IRequestPromise> extends Promise<any> {
public constructor(options: any);
}
3 changes: 2 additions & 1 deletion packages/plugins/google-cloud-storage/src/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down
14 changes: 3 additions & 11 deletions packages/plugins/memory/src/local-memory.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -108,7 +100,7 @@ class LocalMemory implements IPluginStorage<ConfigMemory> {
return emptyDatabase;
}

public saveToken(token: Token): Promise<void> {
public saveToken(): Promise<void> {
this.logger.warn('[verdaccio/memory][saveToken] save token has not been implemented yet');

return Promise.reject(getServiceUnavailable('method not implemented'));
Expand All @@ -123,7 +115,7 @@ class LocalMemory implements IPluginStorage<ConfigMemory> {
return Promise.reject(getServiceUnavailable('method not implemented'));
}

public readTokens(filter: TokenFilter): Promise<Token[]> {
public readTokens(): Promise<Token[]> {
this.logger.warn('[verdaccio/memory][readTokens] read tokens has not been implemented yet ');

return Promise.reject(getServiceUnavailable('method not implemented'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => (
Expand Down
6 changes: 3 additions & 3 deletions packages/plugins/ui-theme/src/App/Header/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/ui-theme/src/components/Author/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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,
},
},
}));
Expand Down
6 changes: 3 additions & 3 deletions packages/plugins/ui-theme/src/design-tokens/ResetStyles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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%',
Expand All @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const DependencyBlock: React.FC<DependencyBlockProps> = ({ title, dependencies }
const deps = Object.entries(dependencies);

function handleClick(name: string): void {
enableLoading && enableLoading();
enableLoading?.();

history.push(`/-/web/detail/${name}`);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => ({
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading

0 comments on commit 15c6941

Please sign in to comment.