From cbb4cc1d217c77db8ae4b9479dd80ef03bceb28b Mon Sep 17 00:00:00 2001 From: Junyoung Choi Date: Wed, 15 Jan 2020 17:40:27 +0900 Subject: [PATCH] Rename hast-format to hast (#41542) --- types/hast-format/hast-format-tests.ts | 95 ----------------------- types/hast-format/tslint.json | 1 - types/hast/hast-tests.ts | 86 ++++++++++++++++++++ types/{hast-format => hast}/index.d.ts | 17 ++-- types/{hast-format => hast}/tsconfig.json | 2 +- types/hast/tslint.json | 6 ++ 6 files changed, 100 insertions(+), 107 deletions(-) delete mode 100644 types/hast-format/hast-format-tests.ts delete mode 100644 types/hast-format/tslint.json create mode 100644 types/hast/hast-tests.ts rename types/{hast-format => hast}/index.d.ts (89%) rename types/{hast-format => hast}/tsconfig.json (87%) create mode 100644 types/hast/tslint.json diff --git a/types/hast-format/hast-format-tests.ts b/types/hast-format/hast-format-tests.ts deleted file mode 100644 index 65f5bc896e..0000000000 --- a/types/hast-format/hast-format-tests.ts +++ /dev/null @@ -1,95 +0,0 @@ -import { Data, Point, Position } from "unist"; -import { - Parent, - Properties, - Literal, - Root, - Element, - DocType, - Comment, - Text -} from "hast-format"; - -const data: Data = { - string: "string", - number: 1, - object: { - key: "value" - }, - array: [], - boolean: true, - null: null -}; - -const point: Point = { - line: 1, - column: 1, - offset: 0 -}; - -const position: Position = { - start: point, - end: point, - indent: [1] -}; - -const literal: Literal = { - type: "text", - data, - point, - value: "value" -}; - -const comment: Comment = { - type: "comment", - data, - point, - value: "value" -}; - -const text: Text = { - type: "text", - data, - point, - value: "value" -}; - -const docType: DocType = { - type: "doctype", - name: "name", - public: "public", - system: "system" -}; - -const element: Element = getElement(); - -const parent: Parent = { - type: "parent", - data, - position, - children: [getElement(), docType, comment, text] -}; - -const root: Root = { - type: "root", - data, - position, - children: [getElement(), docType, comment, text] -}; - -const properties: Properties = { - propertyName1: "propertyValue1", - propertyName2: ["propertyValue2", "propertyValue3"], - propertyName3: true, - propertyName4: 47 -}; - -function getElement(): Element { - return { - type: "element", - tagName: "tagName", - properties, - content: root, - children: [element, comment, text] - }; -} diff --git a/types/hast-format/tslint.json b/types/hast-format/tslint.json deleted file mode 100644 index 3db14f85ea..0000000000 --- a/types/hast-format/tslint.json +++ /dev/null @@ -1 +0,0 @@ -{ "extends": "dtslint/dt.json" } diff --git a/types/hast/hast-tests.ts b/types/hast/hast-tests.ts new file mode 100644 index 0000000000..68699d6dd3 --- /dev/null +++ b/types/hast/hast-tests.ts @@ -0,0 +1,86 @@ +import { Data, Point, Position } from 'unist'; +import { Parent, Properties, Literal, Root, Element, DocType, Comment, Text } from 'hast'; + +const data: Data = { + string: 'string', + number: 1, + object: { + key: 'value', + }, + array: [], + boolean: true, + null: null, +}; + +const point: Point = { + line: 1, + column: 1, + offset: 0, +}; + +const position: Position = { + start: point, + end: point, + indent: [1], +}; + +const literal: Literal = { + type: 'text', + data, + point, + value: 'value', +}; + +const comment: Comment = { + type: 'comment', + data, + point, + value: 'value', +}; + +const text: Text = { + type: 'text', + data, + point, + value: 'value', +}; + +const docType: DocType = { + type: 'doctype', + name: 'name', + public: 'public', + system: 'system', +}; + +const element: Element = getElement(); + +const parent: Parent = { + type: 'parent', + data, + position, + children: [getElement(), docType, comment, text], +}; + +const root: Root = { + type: 'root', + data, + position, + children: [getElement(), docType, comment, text], +}; + +const properties: Properties = { + propertyName1: 'propertyValue1', + propertyName2: ['propertyValue2', 'propertyValue3'], + propertyName3: true, + propertyName4: 47, +}; + +function getElement(): Element { + return { + type: 'element', + tagName: 'tagName', + properties, + content: root, + children: [element, comment, text], + }; +} diff --git a/types/hast-format/index.d.ts b/types/hast/index.d.ts similarity index 89% rename from types/hast-format/index.d.ts rename to types/hast/index.d.ts index 2edfad5439..85aa548b3b 100644 --- a/types/hast-format/index.d.ts +++ b/types/hast/index.d.ts @@ -1,14 +1,11 @@ // Type definitions for non-npm package Hast 2.3 // Project: https://github.com/syntax-tree/hast // Definitions by: lukeggchapman +// Junyoung Choi // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 3.0 -import { - Parent as UnistParent, - Literal as UnistLiteral, - Node as UnistNode -} from "unist"; +import { Parent as UnistParent, Literal as UnistLiteral, Node as UnistNode } from 'unist'; export { UnistNode as Node }; @@ -38,7 +35,7 @@ export interface Root extends Parent { /** * Represents this variant of a Node. */ - type: "root"; + type: 'root'; } /** @@ -48,7 +45,7 @@ export interface Element extends Parent { /** * Represents this variant of a Node. */ - type: "element"; + type: 'element'; /** * Represents the element’s local name. @@ -85,7 +82,7 @@ export interface DocType extends UnistNode { /** * Represents this variant of a Node. */ - type: "doctype"; + type: 'doctype'; name: string; @@ -107,7 +104,7 @@ export interface Comment extends Literal { /** * Represents this variant of a Literal. */ - type: "comment"; + type: 'comment'; } /** @@ -117,5 +114,5 @@ export interface Text extends Literal { /** * Represents this variant of a Literal. */ - type: "text"; + type: 'text'; } diff --git a/types/hast-format/tsconfig.json b/types/hast/tsconfig.json similarity index 87% rename from types/hast-format/tsconfig.json rename to types/hast/tsconfig.json index 77a86e4e25..e185cc4991 100644 --- a/types/hast-format/tsconfig.json +++ b/types/hast/tsconfig.json @@ -12,5 +12,5 @@ "noEmit": true, "forceConsistentCasingInFileNames": true }, - "files": ["index.d.ts", "hast-format-tests.ts"] + "files": ["index.d.ts", "hast-tests.ts"] } diff --git a/types/hast/tslint.json b/types/hast/tslint.json new file mode 100644 index 0000000000..5c1c77d301 --- /dev/null +++ b/types/hast/tslint.json @@ -0,0 +1,6 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + "npm-naming": false + } +}