Skip to content

Commit

Permalink
chore: report/remove unused eslint disable directives
Browse files Browse the repository at this point in the history
  • Loading branch information
raymondfeng committed Jun 3, 2019
1 parent 8dcbc3e commit 739ee16
Show file tree
Hide file tree
Showing 48 changed files with 15 additions and 89 deletions.
9 changes: 4 additions & 5 deletions examples/log-extension/src/providers/log-action.provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

import {inject, Provider, Constructor, Getter} from '@loopback/context';
import {Constructor, Getter, inject, Provider} from '@loopback/context';
import {CoreBindings} from '@loopback/core';
import {OperationArgs, Request} from '@loopback/rest';
import chalk from 'chalk';
import {getLogMetadata} from '../decorators';
import {EXAMPLE_LOG_BINDINGS, LOG_LEVEL} from '../keys';
import {
LogFn,
TimerFn,
HighResTime,
LevelMetadata,
LogFn,
LogWriterFn,
TimerFn,
} from '../types';
import chalk from 'chalk';

export class LogActionProvider implements Provider<LogFn> {
// LogWriteFn is an optional dependency and it falls back to `logToConsole`
Expand Down Expand Up @@ -80,7 +80,6 @@ export class LogActionProvider implements Provider<LogFn> {
if (start) {
const timeDiff: HighResTime = this.timer(start);
const time: number =
// eslint-disable-next-line no-mixed-operators
timeDiff[0] * 1000 + Math.round(timeDiff[1] * 1e-4) / 100;
msg = `${time}ms: ${msg}`;
}
Expand Down
1 change: 0 additions & 1 deletion examples/todo/src/__tests__/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ export const aLocation = {
address: '1 New Orchard Road, Armonk, 10504',
geopoint: <GeoPoint>{y: 41.109653, x: -73.72467},
get geostring() {
// eslint-disable-next-line no-invalid-this
return `${this.geopoint.y},${this.geopoint.x}`;
},
};
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
"coverage": "open coverage/index.html",
"lint": "npm run prettier:check && npm run eslint && node bin/check-package-locks",
"lint:fix": "npm run eslint:fix && npm run prettier:fix",
"eslint": "node packages/build/bin/run-eslint --cache .",
"eslint:fix": "npm run eslint -- --cache --fix",
"eslint": "node packages/build/bin/run-eslint --report-unused-disable-directives --cache .",
"eslint:fix": "npm run eslint -- --fix",
"prettier:cli": "node packages/build/bin/run-prettier \"**/*.ts\" \"**/*.js\" \"**/*.md\"",
"prettier:check": "npm run prettier:cli -- -l",
"prettier:fix": "npm run prettier:cli -- --write",
Expand Down
1 change: 0 additions & 1 deletion packages/boot/src/booters/datasource.booter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ export class DataSourceBooter extends BaseArtifactBooter {
);
} else {
this.classes.forEach(cls => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
this.app.dataSource(cls as Class<juggler.DataSource>);
});
}
Expand Down
1 change: 0 additions & 1 deletion packages/boot/src/booters/repository.booter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ export class RepositoryBooter extends BaseArtifactBooter {
);
} else {
this.classes.forEach(cls => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
this.app.repository(cls);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ describe('Context bindings - Injecting dependencies of classes', () => {
expect(instance).to.have.property('isAuthenticated', false);
});

// eslint-disable-next-line max-len
it('creates instance synchronously when all dependencies are sync too', () => {
ctx.bind('appName').to('CodeHub');
class InfoController {
Expand Down Expand Up @@ -128,7 +127,6 @@ describe('Context bindings - Injecting dependencies of classes', () => {
expect(instance).to.have.property('isAuthenticated', false);
});

// eslint-disable-next-line max-len
it('creates instance synchronously when property/constructor dependencies are sync too', () => {
ctx.bind('appName').to('CodeHub');
ctx.bind('authenticated').to(false);
Expand Down
1 change: 0 additions & 1 deletion packages/context/src/__tests__/unit/inject.unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ describe('function argument injection', () => {
});

it('can retrieve information about injected method arguments', () => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
class TestClass {
test(@inject('foo') foo: string) {}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {Binding, inject, Injection, ResolutionSession} from '../..';

describe('ResolutionSession', () => {
class MyController {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
constructor(@inject('b') private b: string) {}
}
function givenInjection(): Injection {
Expand Down
4 changes: 0 additions & 4 deletions packages/context/src/__tests__/unit/resolver.unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ describe('constructor injection', () => {
expect(t.fooBar).to.eql('FOO:BAR');
});

// eslint-disable-next-line max-len
it('resolves constructor arguments with custom resolve function and no binding key', () => {
class TestClass {
constructor(
Expand Down Expand Up @@ -201,7 +200,6 @@ describe('constructor injection', () => {
);
});

// eslint-disable-next-line max-len
it('will not report circular dependencies if a binding is injected twice', () => {
const context = new Context();
class XClass {}
Expand Down Expand Up @@ -350,7 +348,6 @@ describe('async constructor injection', () => {
expect(t.foo).to.eql('FOO');
});

// eslint-disable-next-line max-len
it('resolves constructor arguments with custom async decorator', async () => {
class TestClass {
constructor(@customAsyncDecorator({x: 'bar'}) public fooBar: string) {}
Expand Down Expand Up @@ -405,7 +402,6 @@ describe('property injection', () => {
expect(t.fooBar).to.eql('FOO:BAR');
});

// eslint-disable-next-line max-len
it('resolves inject properties with custom resolve function and no binding key', () => {
class TestClass {
@inject('', {x: 'bar'}, (c: Context, injection: Injection) => {
Expand Down
1 change: 0 additions & 1 deletion packages/context/src/binding-filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import {BindingAddress} from './binding-key';
* 2. `(binding: Readonly<Binding<unknown>>) => binding is Readonly<Binding<ValueType>>`
*
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export type BindingFilter<ValueType = unknown> = (
binding: Readonly<Binding<unknown>>,
) => boolean;
Expand Down
1 change: 0 additions & 1 deletion packages/context/src/binding-key.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

export type BindingAddress<T = unknown> = string | BindingKey<T>;

// eslint-disable-next-line @typescript-eslint/no-unused-vars
export class BindingKey<ValueType> {
static readonly PROPERTY_SEPARATOR = '#';

Expand Down
2 changes: 0 additions & 2 deletions packages/context/src/binding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ import {

const debug = debugFactory('loopback:context:binding');

/* eslint-disable @typescript-eslint/ban-types */

/**
* Scope for binding values
*/
Expand Down
2 changes: 0 additions & 2 deletions packages/context/src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ import {iterator, multiple} from 'p-event';

const debug = debugFactory('loopback:context');

/* eslint-disable @typescript-eslint/ban-types */

/**
* Context provides an implementation of Inversion of Control (IoC) container
*/
Expand Down
3 changes: 1 addition & 2 deletions packages/context/src/interception-proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ export type AsValueOrPromise<T> = T extends Promise<unknown>
*/
export type AsInterceptedFunction<T> = T extends (
...args: InvocationArgs
) => // eslint-disable-next-line @typescript-eslint/no-unused-vars (possible tslint bug to treat `R` as unused)
infer R
) => infer R
? (...args: InvocationArgs) => AsValueOrPromise<R>
: T;

Expand Down
1 change: 0 additions & 1 deletion packages/context/src/value-promise.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ export function resolveList<T, V>(
result[index] = val;
};

// eslint-disable-next-line prefer-for-of
for (let ix = 0; ix < list.length; ix++) {
const valueOrPromise = resolver(list[ix], ix, list);
if (isPromiseLike(valueOrPromise)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {HttpCachingProxy, ProxyOptions} from '../../http-caching-proxy';

const CACHE_DIR = path.join(__dirname, '.cache');

/* eslint-disable await-promise */
const rimraf = util.promisify(rimrafCb);

describe('HttpCachingProxy', () => {
Expand Down
5 changes: 2 additions & 3 deletions packages/http-caching-proxy/src/http-caching-proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

import * as debugFactory from 'debug';
import {
createServer,
IncomingMessage,
OutgoingHttpHeaders,
Server as HttpServer,
IncomingMessage,
ServerResponse,
createServer,
} from 'http';
import {AddressInfo} from 'net';
import pEvent from 'p-event';
Expand Down Expand Up @@ -174,7 +174,6 @@ export class HttpCachingProxy {
clientRequest: IncomingMessage,
clientResponse: ServerResponse,
) {
// eslint-disable-next-line await-promise
const backendResponse = await makeRequest({
resolveWithFullResponse: true,
simple: false,
Expand Down
1 change: 0 additions & 1 deletion packages/metadata/src/decorator-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {DecoratorType, MetadataKey, MetadataMap} from './types';
const debug = debugModule('loopback:metadata:decorator');

/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/ban-types */

/**
* Options for a decorator
Expand Down
8 changes: 3 additions & 5 deletions packages/metadata/src/inspector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

import {Reflector, NamespacedReflect} from './reflect';
import {NamespacedReflect, Reflector} from './reflect';
import {
DecoratorType,
DesignTimeMethodMetadata,
MetadataKey,
MetadataMap,
DesignTimeMethodMetadata,
DecoratorType,
} from './types';

/* eslint-disable @typescript-eslint/ban-types */

/**
* TypeScript reflector without a namespace. The TypeScript compiler can be
* configured to add design time metadata.
Expand Down
3 changes: 0 additions & 3 deletions packages/metadata/src/reflect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import 'reflect-metadata';

/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/ban-types */
/* eslint-disable @typescript-eslint/unified-signatures */

/*
Expand Down Expand Up @@ -180,7 +179,6 @@ export class NamespacedReflect {
}
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
metadata(
metadataKey: string,
metadataValue: any,
Expand All @@ -193,5 +191,4 @@ export class NamespacedReflect {
}
}

// eslint-disable-next-line variable-name */
export const Reflector = new NamespacedReflect('loopback');
1 change: 0 additions & 1 deletion packages/metadata/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export type DecoratorType =
* @typeParam T - Type of the metadata value
* @typeParam D - Type of the decorator
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export class MetadataAccessor<T, D extends DecoratorType = DecoratorType> {
private constructor(public readonly key: string) {}

Expand Down
2 changes: 0 additions & 2 deletions packages/openapi-v3/src/controller-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ import {OAI3Keys} from './keys';

const debug = require('debug')('loopback:openapi3:metadata:controller-spec');

/* eslint-disable @typescript-eslint/no-explicit-any */

export interface ControllerSpec {
/**
* The base path on which the Controller API is served.
Expand Down
1 change: 0 additions & 1 deletion packages/repository-json-schema/src/build-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ export function isArrayType(type: string | Function) {
* @param meta
*/
export function metaToJsonProperty(meta: PropertyDefinition): JSONSchema {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const propDef: JSONSchema = {};
let result: JSONSchema;
let propertyType = meta.type as string | Function;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

/* eslint-disable @typescript-eslint/no-unused-vars */

import {EntityCrudRepository, repository} from '../..';
import {Customer} from '../models/customer.model';
/**
Expand All @@ -15,7 +13,6 @@ import {Customer} from '../models/customer.model';
export class CustomerController {
constructor(
// Use constructor dependency injection
// eslint-disable-next-line @typescript-eslint/no-unused-vars
@repository('Customer', 'mongodbDataSource')
private _repository: EntityCrudRepository<Customer, string>,
) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

/* eslint-disable @typescript-eslint/no-unused-vars */

import {EntityCrudRepository, repository} from '../..';
import {Customer} from '../models/customer.model';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ describe('repository class', () => {

before(givenCtx);

// eslint-disable-next-line max-len
it('supports referencing predefined repository by name via constructor', async () => {
const myController = await ctx.get<StringBoundController>(
'controllers.StringBoundController',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ describe('repository class', () => {
ctx.bind('controllers.MyController').toClass(MyController);
});

// eslint-disable-next-line max-len
it('supports referencing predefined repository by name via constructor', async () => {
const myController = await ctx.get<MyController>(
'controllers.MyController',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,13 @@ describe('repository decorator', () => {
ctx.bind('controllers.MyController').toClass(MyController);
});

// eslint-disable-next-line max-len
it('supports referencing predefined repository by name via constructor', async () => {
const myController = await ctx.get<MyController>(
'controllers.MyController',
);
expect(myController.noteRepo).exactly(defaultRepo);
});

// eslint-disable-next-line max-len
it('supports referencing predefined repository by name via property', async () => {
const myController = await ctx.get<MyController>(
'controllers.MyController',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,11 @@ describe('legacy loopback-datasource-juggler', () => {
});

it('creates models', () => {
// eslint-disable-next-line variable-name */
const Note = ds.createModel<juggler.PersistedModelClass>(
'note',
{title: 'string', content: 'string', id: {type: 'number', id: true}},
{},
);
// eslint-disable-next-line variable-name */
const Note2 = bindModel(Note, ds);
expect(Note2.modelName).to.eql('note');
expect(Note2.definition).to.eql(Note.definition);
Expand Down Expand Up @@ -157,7 +155,6 @@ describe('DefaultCrudRepository', () => {

expect(ds.getModel('User')).undefined();

// eslint-disable-next-line no-unused-expression
new DefaultCrudRepository(User, ds);

const JugglerUser = ds.getModel('User')!;
Expand Down
1 change: 0 additions & 1 deletion packages/repository/src/common-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ export type NamedParameters = AnyObject;
/**
* Positional parameters, such as [1, 'a']
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export type PositionalParameters = any[];

/**
Expand Down
Loading

0 comments on commit 739ee16

Please sign in to comment.