From 5f2ca8c55a6d0feb8ab4e8c4d183e57ecf6eff5c Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Thu, 5 Mar 2020 12:54:53 -0800 Subject: [PATCH] feat(gravatar): missing 1.8 version features (#42843) - correct DT header and package version - `profile_url` method - `cdn` options property - `forceProtocol` aligned with documented `protocol` - adding new method resulted in module shape correction (export `url` and `profile_url` directly from the module - tests updated - update tslint config https://github.com/emerleite/node-gravatar#usage https://github.com/emerleite/node-gravatar#examples https://github.com/emerleite/node-gravatar/blob/dd76e570872ffb5cd215874aeb91c3c5eff06ff0/Changelog.md#180 Thanks! --- types/gravatar/gravatar-tests.ts | 33 ++++++++++++---------- types/gravatar/index.d.ts | 48 ++++++++++++++++++++------------ types/gravatar/tslint.json | 15 ++-------- 3 files changed, 51 insertions(+), 45 deletions(-) diff --git a/types/gravatar/gravatar-tests.ts b/types/gravatar/gravatar-tests.ts index 9fa79a2d40..90c470b344 100644 --- a/types/gravatar/gravatar-tests.ts +++ b/types/gravatar/gravatar-tests.ts @@ -1,16 +1,21 @@ - - import gravatar = require('gravatar'); -gravatar.url("email@example.com"); -gravatar.url("email@example.com", { s: "200", r: "pg", d: "404" }); -gravatar.url("email@example.com", { size: "200", r: "pg", d: "404" }); -gravatar.url("email@example.com", { s: "200" }); -gravatar.url("email@example.com", { default: "404" }); -gravatar.url("email@example.com", { s: "200", rating: "pg", d: "404" }, true); -gravatar.url("email@example.com", { s: "200", r: "pg", default: "404" }, false); -gravatar.url("email@example.com", { d: "404" }, false); -gravatar.url("email@example.com", { forcedefault: "y" }, false); -gravatar.url("email@example.com", { f: "y" }); -gravatar.url("email@example.com", { protocol: "https" }); -gravatar.url("email@example.com", { format: "xml" }); +gravatar.url('email@example.com'); +gravatar.url('email@example.com', { s: '200', r: 'pg', d: '404' }); +gravatar.url('email@example.com', { size: '200', r: 'pg', d: '404' }); +gravatar.url('email@example.com', { s: '200' }); +gravatar.url('email@example.com', { default: '404' }); +gravatar.url('email@example.com', { s: '200', rating: 'pg', d: '404' }, true); +gravatar.url('email@example.com', { s: '200', r: 'pg', default: '404' }, false); +gravatar.url('email@example.com', { d: '404' }, false); +gravatar.url('email@example.com', { forcedefault: 'y' }, false); +gravatar.url('email@example.com', { f: 'y' }); +gravatar.url('email@example.com', { protocol: 'https' }); +gravatar.url('email@example.com', { format: 'xml' }); +gravatar.profile_url('email@example.com'); +gravatar.profile_url('email@example.com', {}); +gravatar.profile_url('email@example.com', {}, true); +gravatar.profile_url('emerleite@gmail.com', { protocol: 'https' }); +gravatar.profile_url('emerleite@gmail.com', { protocol: 'http', format: 'qr' }); +gravatar.url('email@example.com', { cdn: 'http://cdn-gravatar.wuweixing.com' }); +gravatar.profile_url('email@example.com', { cdn: 'http://cdn-gravatar.wuweixing.com' }); diff --git a/types/gravatar/index.d.ts b/types/gravatar/index.d.ts index 161ba459af..534cdc48e3 100644 --- a/types/gravatar/index.d.ts +++ b/types/gravatar/index.d.ts @@ -1,23 +1,35 @@ -// Type definitions for gravatar v1.8.0 +// Type definitions for gravatar 1.8 // Project: https://github.com/emerleite/node-gravatar // Definitions by: Denis Sokolov +// Piotr Błażejewicz // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -declare namespace GravatarModule { - type Options = { - d?: string - default?: string - f?: string - forcedefault?: string - format?: string - protocol?: string - r?: string - rating?: string - s?: string - size?: string - } - - function url(email: string, options?: Options, forceProtocol?: boolean): string; +export interface Options { + cdn?: string; + d?: string; + default?: string; + f?: string; + forcedefault?: string; + format?: string; + protocol?: string; + r?: string; + rating?: string; + s?: string; + size?: string; } - -export = GravatarModule; +/** + * @param email - The gravatar email + * @param [options] - Query string options + * @param [protocol] - Define if will use no protocol, http or https gravatar URL. + * Default is 'undefined', which generates URLs without protocol. + * True to force https and false to force http + */ +export function url(email: string, options?: Options, protocol?: boolean): string; +/** + * @param email - The gravatar email + * @param [options] - Query string options + * @param [protocol] - Define if will use no protocol, http or https gravatar URL. + * Default is 'undefined', which generates URLs without protocol. + * True to force https and false to force http + */ +export function profile_url(email: string, options?: Options, protocol?: boolean): string; diff --git a/types/gravatar/tslint.json b/types/gravatar/tslint.json index eff86ecb12..f93cf8562a 100644 --- a/types/gravatar/tslint.json +++ b/types/gravatar/tslint.json @@ -1,14 +1,3 @@ { - "extends": "dtslint/dt.json", - "rules": { - "callable-types": false, - "dt-header": false, - "export-just-namespace": false, - "interface-over-type-literal": false, - "no-consecutive-blank-lines": false, - "no-redundant-jsdoc": false, - "prefer-method-signature": false, - "semicolon": false, - "trim-file": false - } -} \ No newline at end of file + "extends": "dtslint/dt.json" +}