From 042531003e38e9e6f33d33eaf7f76dfd8da8079f Mon Sep 17 00:00:00 2001 From: Ruben Taelman Date: Wed, 8 Nov 2017 08:49:19 +0900 Subject: [PATCH] Improve style of uritemplate --- types/uritemplate/index.d.ts | 11 ++-- types/uritemplate/tslint.json | 78 +------------------------- types/uritemplate/uritemplate-tests.ts | 16 +++--- 3 files changed, 13 insertions(+), 92 deletions(-) diff --git a/types/uritemplate/index.d.ts b/types/uritemplate/index.d.ts index 338a27bd98..25dcb497b7 100644 --- a/types/uritemplate/index.d.ts +++ b/types/uritemplate/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for URI Template JS 0.3.4 +// Type definitions for URI Template JS 0.3 // Project: https://github.com/fxa/uritemplate-js // Definitions by: Chui Tey // Ruben Taelman @@ -10,7 +10,6 @@ */ export class UriTemplate { - /** * Expands template into a string using parameter * supplied @@ -18,10 +17,10 @@ export class UriTemplate { expand(data: {}): string; } -interface UriTemplateErrorOptions { - expressionText: string - message: string - position: number +export interface UriTemplateErrorOptions { + expressionText: string; + message: string; + position: number; } export class UriTemplateError { diff --git a/types/uritemplate/tslint.json b/types/uritemplate/tslint.json index a41bf5d19a..f93cf8562a 100644 --- a/types/uritemplate/tslint.json +++ b/types/uritemplate/tslint.json @@ -1,79 +1,3 @@ { - "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 - } + "extends": "dtslint/dt.json" } diff --git a/types/uritemplate/uritemplate-tests.ts b/types/uritemplate/uritemplate-tests.ts index a89e12024e..492488f8a3 100644 --- a/types/uritemplate/uritemplate-tests.ts +++ b/types/uritemplate/uritemplate-tests.ts @@ -1,28 +1,26 @@ - -import {parse as parseUriTemplate, UriTemplate, UriTemplateError} from "uritemplate"; +import { parse as parseUriTemplate, UriTemplate, UriTemplateError } from "uritemplate"; function test_uritemplate() { - // syntax check: UriTemplate.parse - var template: UriTemplate = parseUriTemplate('http://localhost/categories{/categoryId}{?sort,pageNumber}'); + const template: UriTemplate = parseUriTemplate('http://localhost/categories{/categoryId}{?sort,pageNumber}'); // syntax check: template.expand - var url: string = template.expand({ + const url: string = template.expand({ categoryId : 'shoes', sort: 'price', pageNumber: 8 }); // import module check - var expectedUrl: string = 'http://localhost/categories/shoes?sort=price&pageNumber=8'; - if (expectedUrl != url) { - throw `Expected ${expectedUrl}, got ${url}`; + const expectedUrl = 'http://localhost/categories/shoes?sort=price&pageNumber=8'; + if (expectedUrl !== url) { + throw new Error(`Expected ${expectedUrl}, got ${url}`); } else { console.log('Test passed'); } // syntax check: new UriTemplateError - let error: UriTemplateError = new UriTemplateError({ + const error: UriTemplateError = new UriTemplateError({ expressionText: 'error expression', message: 'error message', position: 5