Skip to content

Commit

Permalink
fix: rework tslint comments disabling "no-unused-variable" rule
Browse files Browse the repository at this point in the history
  • Loading branch information
bajtos committed Jan 7, 2019
1 parent 78c9d36 commit a18a3d7
Show file tree
Hide file tree
Showing 26 changed files with 48 additions and 52 deletions.
2 changes: 1 addition & 1 deletion packages/boot/test/fixtures/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {ServiceMixin} from '@loopback/service-proxy';
import {BootMixin} from '../..';

// Force package.json to be copied to `dist` by `tsc`
//tslint:disable-next-line:no-unused-variable
//tslint:disable-next-line:no-unused
import * as pkg from './package.json';

export class BooterApp extends BootMixin(
Expand Down
2 changes: 1 addition & 1 deletion packages/context/src/binding-key.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

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

// tslint:disable-next-line:no-unused-variable
// tslint:disable-next-line:no-unused
export class BindingKey<ValueType> {
static readonly PROPERTY_SEPARATOR = '#';

Expand Down
2 changes: 1 addition & 1 deletion packages/context/src/resolution-session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const debugSession = debugModule('loopback:context:resolver:session');
const getTargetName = DecoratorFactory.getTargetName;

// NOTE(bajtos) The following import is required to satisfy TypeScript compiler
// tslint:disable-next-line:no-unused-variable
// tslint:disable-next-line:no-unused
import {BindingKey} from './binding-key';

/**
Expand Down
10 changes: 5 additions & 5 deletions packages/context/test/unit/inject.unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {

describe('function argument injection', () => {
it('can decorate class constructor arguments', () => {
// tslint:disable-next-line:no-unused-variable
// tslint:disable-next-line:no-unused
class TestClass {
constructor(@inject('foo') foo: string) {}
}
Expand All @@ -29,7 +29,7 @@ describe('function argument injection', () => {
});

it('can retrieve information about injected method arguments', () => {
// tslint:disable-next-line:no-unused-variable
// tslint:disable-next-line:no-unused
class TestClass {
test(@inject('foo') foo: string) {}
}
Expand Down Expand Up @@ -97,7 +97,7 @@ describe('function argument injection', () => {

describe('property injection', () => {
it('can decorate properties', () => {
// tslint:disable-next-line:no-unused-variable
// tslint:disable-next-line:no-unused
class TestClass {
@inject('foo')
foo: string;
Expand Down Expand Up @@ -126,7 +126,7 @@ describe('property injection', () => {

it('cannot decorate static properties', () => {
expect(() => {
// tslint:disable-next-line:no-unused-variable
// tslint:disable-next-line:no-unused
class TestClass {
@inject('foo')
static foo: string;
Expand All @@ -136,7 +136,7 @@ describe('property injection', () => {

it('cannot decorate a method', () => {
expect(() => {
// tslint:disable-next-line:no-unused-variable
// tslint:disable-next-line:no-unused
class TestClass {
@inject('bar')
foo() {}
Expand Down
2 changes: 1 addition & 1 deletion packages/context/test/unit/resolution-session.unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {ResolutionSession, Binding, Injection, inject} from '../..';

describe('ResolutionSession', () => {
class MyController {
// tslint:disable-next-line:no-unused-variable
// tslint:disable-next-line:no-unused
constructor(@inject('b') private b: string) {}
}
function givenInjection(): Injection {
Expand Down
1 change: 1 addition & 0 deletions packages/metadata/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export type DecoratorType =
* @typeparam T Type of the metadata value
* @typeparam D Type of the decorator
*/
// tslint:disable-next-line:no-unused
export class MetadataAccessor<T, D extends DecoratorType = DecoratorType> {
private constructor(public readonly key: string) {}

Expand Down
16 changes: 8 additions & 8 deletions packages/metadata/test/unit/decorator-factory.unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ describe('ClassDecoratorFactory', () => {
expect(() => {
@classDecorator({x: 1})
@classDecorator({y: 2})
// tslint:disable-next-line:no-unused-variable
// tslint:disable-next-line:no-unused
class MyController {}
}).to.throw(
/Decorator cannot be applied more than once on class MyController/,
Expand Down Expand Up @@ -352,7 +352,7 @@ describe('PropertyDecoratorFactory', () => {

it('throws if applied more than once on the same property', () => {
expect(() => {
// tslint:disable-next-line:no-unused-variable
// tslint:disable-next-line:no-unused
class MyController {
@propertyDecorator({x: 1})
@propertyDecorator({y: 2})
Expand Down Expand Up @@ -400,7 +400,7 @@ describe('PropertyDecoratorFactory for static properties', () => {

it('throws if applied more than once on the same static property', () => {
expect(() => {
// tslint:disable-next-line:no-unused-variable
// tslint:disable-next-line:no-unused
class MyController {
@propertyDecorator({x: 1})
@propertyDecorator({y: 2})
Expand Down Expand Up @@ -448,7 +448,7 @@ describe('MethodDecoratorFactory', () => {

it('throws if applied more than once on the same method', () => {
expect(() => {
// tslint:disable-next-line:no-unused-variable
// tslint:disable-next-line:no-unused
class MyController {
@methodDecorator({x: 1})
@methodDecorator({y: 2})
Expand Down Expand Up @@ -496,7 +496,7 @@ describe('MethodDecoratorFactory for static methods', () => {

it('throws if applied more than once on the same static method', () => {
expect(() => {
// tslint:disable-next-line:no-unused-variable
// tslint:disable-next-line:no-unused
class MyController {
@methodDecorator({x: 1})
@methodDecorator({y: 2})
Expand Down Expand Up @@ -545,7 +545,7 @@ describe('ParameterDecoratorFactory', () => {

it('throws if applied more than once on the same parameter', () => {
expect(() => {
// tslint:disable-next-line:no-unused-variable
// tslint:disable-next-line:no-unused
class MyController {
myMethod(
@parameterDecorator({x: 1})
Expand Down Expand Up @@ -634,7 +634,7 @@ describe('ParameterDecoratorFactory for a static method', () => {

it('throws if applied more than once on the same parameter', () => {
expect(() => {
// tslint:disable-next-line:no-unused-variable
// tslint:disable-next-line:no-unused
class MyController {
static myMethod(
@parameterDecorator({x: 1})
Expand Down Expand Up @@ -695,7 +695,7 @@ describe('MethodParameterDecoratorFactory with invalid decorations', () => {

it('reports error if the # of decorations exceeeds the # of params', () => {
expect(() => {
// tslint:disable-next-line:no-unused-variable
// tslint:disable-next-line:no-unused
class MyController {
@methodParameterDecorator({x: 1}) // Causing error
@methodParameterDecorator({x: 2}) // For a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe('openapi-v3-types unit tests', () => {
* original OAS 3 definition. (Though some interfaces allow for extensibility).
*/

// tslint:disable-next-line:no-unused-variable
// tslint:disable-next-line:no-unused
class TestObject implements ExampleObject {
summary: 'test object';
description: 'test object';
Expand All @@ -66,20 +66,20 @@ describe('openapi-v3-types unit tests', () => {
randomProperty: 'extension value';
}

// tslint:disable-next-line:no-unused-variable
// tslint:disable-next-line:no-unused
class ReferenceTestObject implements ReferenceObject {
$ref: '#def/reference-object';
}

// tslint:disable-next-line:no-unused-variable
// tslint:disable-next-line:no-unused
class DiscriminatorTestObject implements DiscriminatorObject {
propertyName: 'test';
mapping: {
hello: 'world';
};
}

// tslint:disable-next-line:no-unused-variable
// tslint:disable-next-line:no-unused
class XMLTestObject implements XmlObject {
name: 'test';
namespace: 'test';
Expand All @@ -88,13 +88,13 @@ describe('openapi-v3-types unit tests', () => {
wrapped: false;
}

// tslint:disable-next-line:no-unused-variable
// tslint:disable-next-line:no-unused
class TestExternalDocumentationObject
implements ExternalDocumentationObject {
url: 'https://test.com/test.html';
}

// tslint:disable-next-line:no-unused-variable
// tslint:disable-next-line:no-unused
class TestISpecificationExtension implements ISpecificationExtension {
test: 'test';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ describe('Routing metadata for parameters', () => {
it('reports error if an array parameter type is not Array', () => {
expect.throws(
() => {
// tslint:disable-next-line:no-unused-variable
// tslint:disable-next-line:no-unused
class MyController {
@get('/greet')
greet(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('JSON Schema type', () => {
* Inspired by https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/json-schema/json-schema-tests.ts
*/

// tslint:disable-next-line:no-unused-variable
// tslint:disable-next-line:no-unused
const testSchema: JsonSchema = {
$id: 'test',
$ref: 'test/sub',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

// tslint:disable:no-unused-variable
// tslint:disable:no-unused

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

// tslint:disable:no-unused-variable
// tslint:disable:no-unused

import {EntityCrudRepository, repository} from '../..';
import {Customer} from '../models/customer.model';
Expand Down
2 changes: 1 addition & 1 deletion packages/repository/examples/models/order.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import {belongsTo, Entity, model, property} from '../..';
import {Customer} from './customer.model';

// tslint:disable:no-unused-variable
// tslint:disable:no-unused

@model()
class Order extends Entity {
Expand Down
4 changes: 2 additions & 2 deletions packages/repository/src/repositories/repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {CrudConnector} from '../connectors';
import {Filter, Where} from '../query';
import {EntityNotFoundError} from '../errors';

// tslint:disable:no-unused-variable
// tslint:disable:no-unused

export interface Repository<T extends Model> {}

Expand Down Expand Up @@ -333,7 +333,7 @@ export class CrudRepositoryImpl<T extends Entity, ID>
);
} else {
// FIXME: populate inst with all properties
// tslint:disable-next-line:no-unused-variable
// tslint:disable-next-line:no-unused
const inst = data;
const where = this.entityClass.buildWhereForId(id);
const result = await this.updateAll(data, where, options);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import {Application} from '@loopback/core';
import {expect, toJSON} from '@loopback/testlab';
import * as _ from 'lodash';
import {
ApplicationWithRepositories,
juggler,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ describe('model decorator', () => {
it('throws when @property.array is used on a non-array property', () => {
expect.throws(
() => {
// tslint:disable-next-line:no-unused-variable
// tslint:disable-next-line:no-unused
class Oops {
@property.array(Product)
product: Product;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ describe('relation decorator', () => {
province: string;
}

// tslint:disable-next-line:no-unused-variable
// tslint:disable-next-line:no-unused
class AddressBook extends Entity {
id: number;
@property.array(Entity)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ describe('repository decorator', () => {
it('throws not implemented for class-level @repository', () => {
expect(() => {
@repository('noteRepo')
// tslint:disable-next-line:no-unused-variable
// tslint:disable-next-line:no-unused
class Controller1 {}
}).to.throw(/not implemented/);
});
Expand Down
2 changes: 1 addition & 1 deletion packages/repository/test/unit/model/model.unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ describe('model', () => {
}
}

// tslint:disable-next-line:no-unused-variable
// tslint:disable-next-line:no-unused
class User extends Entity {
static definition = userDef;
id: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
DefaultCrudRepository,
DefaultHasManyRepository,
Entity,
EntityCrudRepository,
Filter,
HasManyRepository,
juggler,
Expand All @@ -36,12 +35,9 @@ describe('relation repository', () => {
* interface. The TS Compiler will complain if the interface changes.
*/

// tslint:disable-next-line:no-unused-variable
class testHasManyEntityCrudRepository<
T extends Entity,
ID,
TargetRepository extends EntityCrudRepository<T, ID>
> implements HasManyRepository<T> {
// tslint:disable-next-line:no-unused
class testHasManyEntityCrudRepository<T extends Entity>
implements HasManyRepository<T> {
create(
targetModelData: DataObject<T>,
options?: AnyObject | undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ async function startServerCheck(app: Application) {
}

function sequenceHandler(
{request, response}: RequestContext,
{response}: RequestContext,
sequence: DefaultSequence,
) {
sequence.send(response, 'hello world');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ describe('Routing', () => {

it('provides httpHandler compatible with HTTP server API', async () => {
const app = new RestApplication();
app.handler(({request, response}, sequence) => response.end('hello'));
app.handler(({response}, sequence) => response.end('hello'));

await createClientForHandler(app.requestHandler)
.get('/')
Expand Down
4 changes: 2 additions & 2 deletions packages/rest/test/acceptance/sequence/sequence.acceptance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe('Sequence', () => {
});

it('allows users to define a custom sequence as a function', () => {
server.handler(({request, response}, sequence) => {
server.handler(({response}, sequence) => {
sequence.send(response, 'hello world');
});
return whenIRequest()
Expand Down Expand Up @@ -98,7 +98,7 @@ describe('Sequence', () => {
class MySequence implements SequenceHandler {
constructor(@inject(SequenceActions.SEND) protected send: Send) {}

async handle({request, response}: RequestContext) {
async handle({response}: RequestContext) {
this.send(response, 'MySequence was invoked.');
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/rest/test/unit/re-export.unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {get} from '../..';

describe('re-export controller decorators', () => {
it('exports functions from @loopback/openapi-v3', async () => {
/* tslint:disable-next-line:no-unused-variable */
/* tslint:disable-next-line:no-unused */
class Test {
// Make sure the decorators are exported
@get('/test')
Expand Down
Loading

0 comments on commit a18a3d7

Please sign in to comment.