Repository: apollographql/apollo-client

Problem statement:
Linter doesn't lint subdirs



Hints:

Patch:
diff --git a/Gruntfile.js b/Gruntfile.js
new file mode 100644
--- /dev/null
+++ b/Gruntfile.js
@@ -0,0 +1,21 @@
+'use strict';
+
+module.exports = function (grunt) {
+  grunt.initConfig({
+    tslint: {
+      options: {
+        // can be a configuration object or a filepath to tslint.json
+        configuration: grunt.file.readJSON('tslint.json')
+      },
+      files: {
+        src: [
+          'src/**/*.ts',
+          'test/**/*.ts',
+          '!test/fixtures/**/*.ts'
+        ]
+      }
+    }
+  })
+
+  grunt.loadNpmTasks('grunt-tslint');
+}
diff --git a/src/networkInterface.ts b/src/networkInterface.ts
--- a/src/networkInterface.ts
+++ b/src/networkInterface.ts
@@ -12,10 +12,13 @@ export interface Request {
 }
 
 export interface NetworkInterface {
+  query(request: Request): Promise<GraphQLResult>;
+}
+
+export interface HTTPNetworkInterface extends NetworkInterface {
   _uri: string;
   _opts: RequestInit;
   _middlewares: MiddlewareInterface[];
-  query(request: Request): Promise<GraphQLResult>;
   use(middlewares: MiddlewareInterface[]);
 }
 
@@ -24,7 +27,7 @@ export interface RequestAndOptions {
   options: RequestInit;
 }
 
-export function createNetworkInterface(uri: string, opts: RequestInit = {}): NetworkInterface {
+export function createNetworkInterface(uri: string, opts: RequestInit = {}): HTTPNetworkInterface {
   if (!uri) {
     throw new Error('A remote enpdoint is required for a network layer');
   }
diff --git a/src/util/Observable.ts b/src/util/Observable.ts
--- a/src/util/Observable.ts
+++ b/src/util/Observable.ts
@@ -9,7 +9,10 @@ function isSubscription(subscription: Function | Subscription): subscription is
 }
 
 export class Observable<T> {
-  constructor(private subscriberFunction: SubscriberFunction<T>) {
+  private subscriberFunction: SubscriberFunction<T>;
+
+  constructor(subscriberFunction: SubscriberFunction<T>) {
+    this.subscriberFunction = subscriberFunction;
   }
 
   public subscribe(observer: Observer<T>): Subscription {
@@ -19,7 +22,7 @@ export class Observable<T> {
       return subscriptionOrCleanupFunction;
     } else {
       return {
-        unsubscribe: <CleanupFunction>subscriptionOrCleanupFunction,
+        unsubscribe: subscriptionOrCleanupFunction,
       };
     }
   }
@@ -32,5 +35,5 @@ export interface Observer<T> {
 }
 
 export interface Subscription {
-  unsubscribe: CleanupFunction
+  unsubscribe: CleanupFunction;
 }


Test patch:
diff --git a/test/client.ts b/test/client.ts
--- a/test/client.ts
+++ b/test/client.ts
@@ -24,7 +24,7 @@ import {
 
 import {
   createNetworkInterface,
-  NetworkInterface,
+  HTTPNetworkInterface,
 } from '../src/networkInterface';
 
 import mockNetworkInterface from './mocks/mockNetworkInterface';
@@ -67,12 +67,12 @@ describe('client', () => {
 
 
   it('can allow passing in a network interface', () => {
-    const networkInterface: NetworkInterface = createNetworkInterface('swapi');
+    const networkInterface = createNetworkInterface('swapi');
     const client = new ApolloClient({
       networkInterface,
     });
 
-    assert.equal(client.networkInterface._uri, networkInterface._uri);
+    assert.equal((client.networkInterface as HTTPNetworkInterface)._uri, networkInterface._uri);
   });
 
   it('can allow passing in a store', () => {
diff --git a/test/mocks/mockNetworkInterface.ts b/test/mocks/mockNetworkInterface.ts
--- a/test/mocks/mockNetworkInterface.ts
+++ b/test/mocks/mockNetworkInterface.ts
@@ -13,7 +13,9 @@ import {
 // making multiple queries to the server
 export default function mockNetworkInterface(
   ...mockedResponses: MockedResponse[]
-): NetworkInterface { return new MockNetworkInterface(...mockedResponses) as any }
+): NetworkInterface {
+  return new MockNetworkInterface(...mockedResponses);
+}
 
 export interface MockedResponse {
   request: Request;
@@ -22,8 +24,8 @@ export interface MockedResponse {
   delay?: number;
 }
 
-export class MockNetworkInterface {
-  private mockedResponsesByKey: { [key:string]: MockedResponse[] } = {};
+export class MockNetworkInterface implements NetworkInterface {
+  private mockedResponsesByKey: { [key: string]: MockedResponse[] } = {};
 
   constructor(...mockedResponses: MockedResponse[]) {
     mockedResponses.forEach((mockedResponse) => {
diff --git a/test/networkInterface.ts b/test/networkInterface.ts
--- a/test/networkInterface.ts
+++ b/test/networkInterface.ts
@@ -10,7 +10,6 @@ const { assert, expect } = chai;
 
 import {
   createNetworkInterface,
-  NetworkInterface,
 } from '../src/networkInterface';
 
 import {
@@ -68,7 +67,7 @@ describe('network interface', () => {
     });
 
     it('should create an instance with a given uri', () => {
-      const networkInterface: NetworkInterface = createNetworkInterface('/graphql');
+      const networkInterface = createNetworkInterface('/graphql');
       assert.equal(networkInterface._uri, '/graphql');
     });