mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
Move tslint, tsconfig closer to defaults, fix all linting issues
This commit is contained in:
parent
40e24912b2
commit
75d009816c
@ -1,69 +1,62 @@
|
||||
let dummySocket: ng.websocket.IWebSocket;
|
||||
let dummyPromise: ng.IPromise<void>;
|
||||
let dummyScope: ng.IScope;
|
||||
import * as ng from 'angular';
|
||||
|
||||
let provider: ng.websocket.IWebSocketProvider = (url: string, protocols?:string[] | ng.websocket.IWebSocketConfigOptions, options?: ng.websocket.IWebSocketConfigOptions) => {
|
||||
return dummySocket;
|
||||
}
|
||||
(promise: angular.IPromise<void>, scope: ng.IScope, provider: ng.websocket.IWebSocketProvider) => {
|
||||
const socket = provider("wss://localhost");
|
||||
const socketWithProtocols = provider("wss://localhost", ["protocol-a", "protocol-b"]);
|
||||
|
||||
let socketWithProtocol = provider("wss://localhost", "protocol");
|
||||
let socketWithProtocols = provider("wss://localhost", ["protocol-a", "protocol-b"]);
|
||||
const socketWithOptions = provider("wss://localhost", {
|
||||
scope,
|
||||
rootScopeFailOver: true,
|
||||
useApplyAsync: true,
|
||||
initialTimeout: 100,
|
||||
maxTimeout: 300000,
|
||||
reconnectIfNotNormalClose: true,
|
||||
binaryType: "blob"
|
||||
});
|
||||
|
||||
let socketWithOptions = provider("wss://localhost", {
|
||||
scope: dummyScope,
|
||||
rootScopeFailOver: true,
|
||||
useApplyAsync: true,
|
||||
initialTimeout: 100,
|
||||
maxTimeout: 300000,
|
||||
reconnectIfNotNormalClose: true,
|
||||
binaryType: "blob"
|
||||
});
|
||||
const socketWithProtocolAndOptions = provider("wss://localhost", "protocol", {
|
||||
scope,
|
||||
rootScopeFailOver: true,
|
||||
useApplyAsync: true,
|
||||
initialTimeout: 100,
|
||||
maxTimeout: 300000,
|
||||
reconnectIfNotNormalClose: true,
|
||||
binaryType: "blob"
|
||||
});
|
||||
|
||||
let socketWithProtocolAndOptions = provider("wss://localhost", "protocol", {
|
||||
scope: dummyScope,
|
||||
rootScopeFailOver: true,
|
||||
useApplyAsync: true,
|
||||
initialTimeout: 100,
|
||||
maxTimeout: 300000,
|
||||
reconnectIfNotNormalClose: true,
|
||||
binaryType: "blob"
|
||||
});
|
||||
socket.onOpen((event: Event) => {})
|
||||
.onClose((event: Event) => {})
|
||||
.onError((event: Event) => {})
|
||||
.onMessage((event: Event) => {});
|
||||
|
||||
let socket = provider("wss://localhost");
|
||||
socket.onMessage((event: Event) => {}, { filter: /Some Filter/ })
|
||||
.onMessage((event: Event) => {}, { filter: 'Some Filter' })
|
||||
.onMessage((event: Event) => {}, { filter: 'Some Filter', autoApply: true })
|
||||
.onMessage((event: Event) => {}, { autoApply: false });
|
||||
|
||||
socket.onOpen((event) => {})
|
||||
.onClose((event) => {})
|
||||
.onError((event) => {})
|
||||
.onMessage((event) => {});
|
||||
socket.close(true);
|
||||
socket.close();
|
||||
|
||||
socket.onMessage((event) => {}, { filter: /Some Filter/ })
|
||||
.onMessage((event) => {}, { filter: 'Some Filter' })
|
||||
.onMessage((event) => {}, { filter: 'Some Filter', autoApply: true })
|
||||
.onMessage((event) => {}, { autoApply: false });
|
||||
socket.send("Some great data here!").finally(() => {});
|
||||
socket.send({ list: [1, 2, 3, 4] });
|
||||
|
||||
socket.close(true);
|
||||
socket.close();
|
||||
socket.socket.send("data");
|
||||
socket.socket.close();
|
||||
socket.socket.close(1);
|
||||
socket.socket.close(1, "reason");
|
||||
|
||||
socket.send("Some great data here!").finally(() => {});
|
||||
socket.send({ list: [1, 2, 3, 4] });
|
||||
socket.sendQueue.push({ message: "msg", defered: promise });
|
||||
|
||||
socket.socket.send("data");
|
||||
socket.socket.close();
|
||||
socket.socket.close(1);
|
||||
socket.socket.close(1, "reason");
|
||||
socket.onOpenCallbacks.push((event: Event) => {});
|
||||
socket.onCloseCallbacks.push((event: CloseEvent) => {});
|
||||
socket.onErrorCallbacks.push((event: Event) => {});
|
||||
socket.onMessageCallbacks.push({ fn: (event: MessageEvent) => {}, pattern: 'Some Filter', autoApply: true });
|
||||
socket.onMessageCallbacks.push({ fn: (event: MessageEvent) => {}, pattern: /Some Filter/, autoApply: true });
|
||||
socket.onMessageCallbacks.push({ fn: (event: MessageEvent) => {}, autoApply: true });
|
||||
|
||||
socket.sendQueue.push({ message: "msg", defered: dummyPromise });
|
||||
socket.readyState = 0;
|
||||
|
||||
socket.onOpenCallbacks.push((event: Event) => {});
|
||||
socket.onCloseCallbacks.push((event: CloseEvent) => {});
|
||||
socket.onErrorCallbacks.push((event: Event) => {});
|
||||
socket.onMessageCallbacks.push({ fn: (event: MessageEvent) => {}, pattern: 'Some Filter', autoApply: true });
|
||||
socket.onMessageCallbacks.push({ fn: (event: MessageEvent) => {}, pattern: /Some Filter/, autoApply: true });
|
||||
socket.onMessageCallbacks.push({ fn: (event: MessageEvent) => {}, pattern: undefined, autoApply: true });
|
||||
|
||||
socket.readyState = 0;
|
||||
|
||||
socket.initialTimeout = 10;
|
||||
|
||||
socket.maxTimeout = 5000;
|
||||
socket.initialTimeout = 10;
|
||||
|
||||
socket.maxTimeout = 5000;
|
||||
};
|
||||
|
||||
68
types/angular-websocket/index.d.ts
vendored
68
types/angular-websocket/index.d.ts
vendored
@ -1,4 +1,4 @@
|
||||
// Type definitions for angular-websocket v2.0
|
||||
// Type definitions for angular-websocket 2.0
|
||||
// Project: https://github.com/AngularClass/angular-websocket
|
||||
// Definitions by: Nick Veys <https://github.com/nickveys>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
@ -14,33 +14,32 @@ export type IWebSocketQueueItem = angular.websocket.IWebSocketQueueItem;
|
||||
export type IWebSocket = angular.websocket.IWebSocket;
|
||||
|
||||
declare module "angular" {
|
||||
export namespace websocket {
|
||||
|
||||
namespace websocket {
|
||||
/**
|
||||
* Options available to be specified for IWebSocketProvider.
|
||||
*/
|
||||
type IWebSocketConfigOptions = {
|
||||
scope?: angular.IScope;
|
||||
rootScopeFailOver?: boolean;
|
||||
useApplyAsync?: boolean;
|
||||
initialTimeout?: number;
|
||||
maxTimeout?: number;
|
||||
binaryType?: "blob" | "arraybuffer";
|
||||
reconnectIfNotNormalClose?: boolean;
|
||||
}
|
||||
interface IWebSocketProvider {
|
||||
/**
|
||||
* Creates and opens an IWebSocket instance.
|
||||
*
|
||||
* @param url url to connect to
|
||||
* @return websocket instance
|
||||
*/
|
||||
(url: string, protocols?: string | string[] | IWebSocketConfigOptions, options?: IWebSocketConfigOptions): IWebSocket;
|
||||
interface IWebSocketConfigOptions {
|
||||
scope?: IScope;
|
||||
rootScopeFailOver?: boolean;
|
||||
useApplyAsync?: boolean;
|
||||
initialTimeout?: number;
|
||||
maxTimeout?: number;
|
||||
binaryType?: "blob" | "arraybuffer";
|
||||
reconnectIfNotNormalClose?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and opens an IWebSocket instance.
|
||||
*
|
||||
* @param url url to connect to
|
||||
* @return websocket instance
|
||||
*/
|
||||
type IWebSocketProvider =
|
||||
(url: string, protocols?: string | string[] | IWebSocketConfigOptions,
|
||||
options?: IWebSocketConfigOptions) => IWebSocket;
|
||||
|
||||
/** Options available to be specified for IWebSocket.onMessage */
|
||||
type IWebSocketMessageOptions = {
|
||||
|
||||
interface IWebSocketMessageOptions {
|
||||
/**
|
||||
* If specified, only messages that match the filter will cause the message event
|
||||
* to be fired.
|
||||
@ -51,21 +50,20 @@ declare module "angular" {
|
||||
autoApply?: boolean;
|
||||
}
|
||||
|
||||
/** Type corresponding to onMessage callbaks stored in $Websocket#onMessageCallbacks instance. */
|
||||
type IWebSocketMessageHandler = {
|
||||
fn: (evt: MessageEvent) => void;
|
||||
pattern: string | RegExp;
|
||||
autoApply: boolean;
|
||||
/** Type corresponding to onMessage callbacks stored in $Websocket#onMessageCallbacks instance. */
|
||||
interface IWebSocketMessageHandler {
|
||||
fn: (evt: MessageEvent) => void;
|
||||
pattern?: string | RegExp;
|
||||
autoApply: boolean;
|
||||
}
|
||||
|
||||
/** Type corresponding to items stored in $WebSocket#sendQueue instance. */
|
||||
type IWebSocketQueueItem = {
|
||||
message: any;
|
||||
defered: angular.IPromise<void>;
|
||||
interface IWebSocketQueueItem {
|
||||
message: any;
|
||||
defered: IPromise<void>;
|
||||
}
|
||||
|
||||
interface IWebSocket {
|
||||
|
||||
/**
|
||||
* Adds a callback to be executed each time a socket connection is opened for
|
||||
* this instance.
|
||||
@ -115,7 +113,7 @@ declare module "angular" {
|
||||
*
|
||||
* @param data data to send, if this is an object, it will be stringified before sending
|
||||
*/
|
||||
send(data: string | {}): angular.IPromise<any>;
|
||||
send(data: string | {}): IPromise<any>;
|
||||
|
||||
/**
|
||||
* WebSocket instance.
|
||||
@ -130,7 +128,7 @@ declare module "angular" {
|
||||
/**
|
||||
* List of callbacks to be executed when the socket is opened.
|
||||
*/
|
||||
onOpenCallbacks: ((evt: Event) => void)[];
|
||||
onOpenCallbacks: Array<((evt: Event) => void)>;
|
||||
|
||||
/**
|
||||
* List of callbacks to be executed when a message is received from the socket.
|
||||
@ -140,12 +138,12 @@ declare module "angular" {
|
||||
/**
|
||||
* List of callbacks to be executed when an error is received from the socket.
|
||||
*/
|
||||
onErrorCallbacks: ((evt: Event) => void)[];
|
||||
onErrorCallbacks: Array<((evt: Event) => void)>;
|
||||
|
||||
/**
|
||||
* List of callbacks to be executed when the socket is closed.
|
||||
*/
|
||||
onCloseCallbacks: ((evt: CloseEvent) => void)[];
|
||||
onCloseCallbacks: Array<((evt: CloseEvent) => void)>;
|
||||
|
||||
/**
|
||||
* Returns either the readyState value from the underlying WebSocket instance
|
||||
|
||||
@ -1,8 +1,4 @@
|
||||
{
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"angular-websocket-tests.ts"
|
||||
],
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
@ -11,8 +7,8 @@
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"strictFunctionTypes": false,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
@ -20,5 +16,9 @@
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"angular-websocket-tests.ts"
|
||||
]
|
||||
}
|
||||
|
||||
@ -1,79 +1,6 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"adjacent-overload-signatures": false,
|
||||
"array-type": false,
|
||||
"arrow-return-shorthand": false,
|
||||
"ban-types": false,
|
||||
"callable-types": false,
|
||||
"comment-format": false,
|
||||
"dt-header": false,
|
||||
"eofline": false,
|
||||
"export-just-namespace": false,
|
||||
"import-spacing": false,
|
||||
"interface-name": false,
|
||||
"interface-over-type-literal": false,
|
||||
"jsdoc-format": false,
|
||||
"max-line-length": false,
|
||||
"member-access": false,
|
||||
"new-parens": false,
|
||||
"no-any-union": false,
|
||||
"no-boolean-literal-compare": false,
|
||||
"no-conditional-assignment": false,
|
||||
"no-consecutive-blank-lines": false,
|
||||
"no-construct": false,
|
||||
"no-declare-current-package": false,
|
||||
"no-duplicate-imports": false,
|
||||
"no-duplicate-variable": false,
|
||||
"no-empty-interface": false,
|
||||
"no-for-in-array": false,
|
||||
"no-inferrable-types": false,
|
||||
"no-internal-module": false,
|
||||
"no-irregular-whitespace": false,
|
||||
"no-mergeable-namespace": false,
|
||||
"no-misused-new": false,
|
||||
"no-namespace": false,
|
||||
"no-object-literal-type-assertion": false,
|
||||
"no-padding": false,
|
||||
"no-redundant-jsdoc": false,
|
||||
"no-redundant-jsdoc-2": false,
|
||||
"no-redundant-undefined": false,
|
||||
"no-reference-import": false,
|
||||
"no-relative-import-in-test": false,
|
||||
"no-self-import": false,
|
||||
"no-single-declare-module": false,
|
||||
"no-string-throw": false,
|
||||
"no-unnecessary-callback-wrapper": false,
|
||||
"no-unnecessary-class": false,
|
||||
"no-unnecessary-generics": false,
|
||||
"no-unnecessary-qualifier": false,
|
||||
"no-unnecessary-type-assertion": false,
|
||||
"no-useless-files": false,
|
||||
"no-var-keyword": false,
|
||||
"no-var-requires": false,
|
||||
"no-void-expression": false,
|
||||
"no-trailing-whitespace": false,
|
||||
"object-literal-key-quotes": false,
|
||||
"object-literal-shorthand": false,
|
||||
"one-line": false,
|
||||
"one-variable-per-declaration": false,
|
||||
"only-arrow-functions": false,
|
||||
"prefer-conditional-expression": false,
|
||||
"prefer-const": false,
|
||||
"prefer-declare-function": false,
|
||||
"prefer-for-of": false,
|
||||
"prefer-method-signature": false,
|
||||
"prefer-template": false,
|
||||
"radix": false,
|
||||
"semicolon": false,
|
||||
"space-before-function-paren": false,
|
||||
"space-within-parens": false,
|
||||
"strict-export-declare-modifiers": false,
|
||||
"trim-file": false,
|
||||
"triple-equals": false,
|
||||
"typedef-whitespace": false,
|
||||
"unified-signatures": false,
|
||||
"void-return": false,
|
||||
"whitespace": false
|
||||
"interface-name": false
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user