From 955ef7101d58c08699d1a6e76665e43ae3ab5d9c Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Thu, 17 Aug 2017 10:27:19 +0300 Subject: [PATCH] chore: remove some dead code --- .editorconfig | 31 +++++++++++++++++++++++++++++++ lib/utils/pipes.ts | 17 +++-------------- tests/unit/pipes.spec.js | 30 +----------------------------- 3 files changed, 35 insertions(+), 43 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..7303e2f6 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,31 @@ +[*] +charset=utf-8 +end_of_line=lf +insert_final_newline=false +indent_style=space +indent_size=4 + +[{.eslintrc,.babelrc,.stylelintrc,jest.config,*.json,*.jsb3,*.jsb2,*.bowerrc}] +indent_style=space +indent_size=2 + +[*.scss] +indent_style=space +indent_size=2 + +[*.styl] +indent_style=space +indent_size=2 + +[*.coffee] +indent_style=space +indent_size=2 + +[{.analysis_options,*.yml,*.yaml}] +indent_style=space +indent_size=2 + +[tslint.json] +indent_style=space +indent_size=2 + diff --git a/lib/utils/pipes.ts b/lib/utils/pipes.ts index 4f8a7802..549603a9 100644 --- a/lib/utils/pipes.ts +++ b/lib/utils/pipes.ts @@ -35,17 +35,6 @@ export class KeysPipe implements PipeTransform { } } -@Pipe({ name: 'jsonPointerEscape' }) -export class JsonPointerEscapePipe implements PipeTransform { - transform(value:string) { - if (isBlank(value)) return value; - if (!isString(value)) { - throw new InvalidPipeArgumentException(JsonPointerEscapePipe, value); - } - return JsonPointer.escape(value); - } -} - @Pipe({ name: 'marked' }) export class MarkedPipe implements PipeTransform { renderer: MdRenderer; @@ -58,7 +47,7 @@ export class MarkedPipe implements PipeTransform { transform(value:string) { if (isBlank(value)) return value; if (!isString(value)) { - throw new InvalidPipeArgumentException(JsonPointerEscapePipe, value); + throw new InvalidPipeArgumentException(MarkedPipe, value); } let res = `${this.renderer.renderMd(value)}`; return this.unstrustedSpec ? res : this.sanitizer.bypassSecurityTrustHtml(res); @@ -95,7 +84,7 @@ export class PrismPipe implements PipeTransform { } if (isBlank(value)) return value; if (!isString(value)) { - throw new InvalidPipeArgumentException(JsonPointerEscapePipe, value); + throw new InvalidPipeArgumentException(PrismPipe, value); } let lang = args[0].toString().trim().toLowerCase(); if (langMap[lang]) lang = langMap[lang]; @@ -138,5 +127,5 @@ export class CollectionFormatPipe implements PipeTransform { } export const REDOC_PIPES = [ - JsonPointerEscapePipe, MarkedPipe, SafePipe, PrismPipe, EncodeURIComponentPipe, JsonFormatter, KeysPipe, CollectionFormatPipe + MarkedPipe, SafePipe, PrismPipe, EncodeURIComponentPipe, JsonFormatter, KeysPipe, CollectionFormatPipe ]; diff --git a/tests/unit/pipes.spec.js b/tests/unit/pipes.spec.js index 1f6e4839..859ea385 100644 --- a/tests/unit/pipes.spec.js +++ b/tests/unit/pipes.spec.js @@ -1,6 +1,6 @@ 'use strict'; -import {KeysPipe, JsonPointerEscapePipe, MarkedPipe} from '../../lib/utils/pipes'; +import {KeysPipe, MarkedPipe} from '../../lib/utils/pipes'; describe('Pipes', () => { describe('KeysPipe', () => { @@ -33,34 +33,6 @@ describe('Pipes', () => { }); }); - describe('JsonPointerEscapePipe', () => { - let unescaped; - let escaped; - var pipe; - - beforeEach(() => { - unescaped = 'test/path~1'; - escaped = 'test~1path~01'; - pipe = new JsonPointerEscapePipe(); - }); - - describe('JsonPointerEscapePipe transform', () => { - it('should escpae pointer', () => { - var val = pipe.transform(unescaped); - val.should.be.equal(escaped); - }); - - it('should not support other objects', () => { - (() => pipe.transform(45)).should.throw(); - (() => pipe.transform({})).should.throw(); - }); - - it('should not throw on blank input', () => { - (() => pipe.transform()).should.not.throw(); - }); - }); - }); - describe('MarkedPipe', () => { let unmarked; let marked;