build: enable TSLint on the packages folder (#18459)

porting PRs #18392 and #18441 to 4.x
This commit is contained in:
Victor Berchet
2017-08-02 15:23:33 -07:00
committed by GitHub
parent 24db1ed938
commit baf4ce0dd0
48 changed files with 133 additions and 112 deletions

View File

@ -15,8 +15,11 @@ import {HttpParams} from './params';
* All values are optional and will override default values if provided.
*/
interface HttpRequestInit {
headers?: HttpHeaders, reportProgress?: boolean, params?: HttpParams,
responseType?: 'arraybuffer'|'blob'|'json'|'text', withCredentials?: boolean,
headers?: HttpHeaders;
reportProgress?: boolean;
params?: HttpParams;
responseType?: 'arraybuffer'|'blob'|'json'|'text';
withCredentials?: boolean;
}
/**

View File

@ -120,7 +120,10 @@ export interface HttpUserEvent<T> { type: HttpEventType.User; }
*
* @experimental
*/
export interface HttpJsonParseError { error: Error, text: string, }
export interface HttpJsonParseError {
error: Error;
text: string;
}
/**
* Union type for all possible events on the response stream.
@ -233,7 +236,7 @@ export class HttpHeaderResponse extends HttpResponseBase {
status: update.status !== undefined ? update.status : this.status,
statusText: update.statusText || this.statusText,
url: update.url || this.url || undefined,
})
});
}
}

View File

@ -268,27 +268,26 @@ export class HttpXhrBackend implements HttpBackend {
// The upload progress event handler, which is only registered if
// progress events are enabled.
const onUpProgress =
(event: ProgressEvent) => {
// Upload progress events are simpler. Begin building the progress
// event.
let progress: HttpUploadProgressEvent = {
type: HttpEventType.UploadProgress,
loaded: event.loaded,
};
const onUpProgress = (event: ProgressEvent) => {
// Upload progress events are simpler. Begin building the progress
// event.
let progress: HttpUploadProgressEvent = {
type: HttpEventType.UploadProgress,
loaded: event.loaded,
};
// If the total number of bytes being uploaded is available, include
// it.
if (event.lengthComputable) {
progress.total = event.total;
}
// If the total number of bytes being uploaded is available, include
// it.
if (event.lengthComputable) {
progress.total = event.total;
}
// Send the event.
observer.next(progress);
}
// Send the event.
observer.next(progress);
};
// By default, register for load and error events.
xhr.addEventListener('load', onLoad);
// By default, register for load and error events.
xhr.addEventListener('load', onLoad);
xhr.addEventListener('error', onError);
// Progress events are only enabled if requested.

View File

@ -56,11 +56,11 @@ export function main() {
});
describe('throws an error', () => {
it('when request method is not JSONP',
() => {expect(() => backend.handle(SAMPLE_REQ.clone<never>({method: 'GET'})))
.toThrowError(JSONP_ERR_WRONG_METHOD)});
() => expect(() => backend.handle(SAMPLE_REQ.clone<never>({method: 'GET'})))
.toThrowError(JSONP_ERR_WRONG_METHOD));
it('when response type is not json',
() => {expect(() => backend.handle(SAMPLE_REQ.clone<never>({responseType: 'text'})))
.toThrowError(JSONP_ERR_WRONG_RESPONSE_TYPE)});
() => expect(() => backend.handle(SAMPLE_REQ.clone<never>({responseType: 'text'})))
.toThrowError(JSONP_ERR_WRONG_RESPONSE_TYPE));
it('when callback is never called', (done: DoneFn) => {
backend.handle(SAMPLE_REQ).subscribe(undefined, (err: HttpErrorResponse) => {
expect(err.status).toBe(0);
@ -69,7 +69,7 @@ export function main() {
done();
});
document.mockLoad();
})
});
});
});
}

View File

@ -13,7 +13,7 @@ export function main() {
describe('initialization', () => {
it('should be empty at construction', () => {
const body = new HttpParams();
expect(body.toString()).toEqual('')
expect(body.toString()).toEqual('');
});
it('should parse an existing url', () => {

View File

@ -271,7 +271,7 @@ export function main() {
done();
});
factory.mock.mockFlush(200, 'OK', 'Test');
})
});
});
describe('corrects for quirks', () => {
it('by normalizing 1223 status to 204', (done: DoneFn) => {

View File

@ -64,7 +64,7 @@ export function main() {
});
describe('HttpXsrfCookieExtractor', () => {
let document: {[key: string]: string};
let extractor: HttpXsrfCookieExtractor
let extractor: HttpXsrfCookieExtractor;
beforeEach(() => {
document = {
cookie: 'XSRF-TOKEN=test',

View File

@ -126,7 +126,7 @@ export class HttpClientTestingBackend implements HttpBackend, HttpTestingControl
const requests = open.map(testReq => {
const url = testReq.request.urlWithParams.split('?')[0];
const method = testReq.request.method;
return `${method} ${url}`
return `${method} ${url}`;
})
.join(', ');
throw new Error(`Expected no open requests, found ${open.length}: ${requests}`);