Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: TS type information for remark-stringify and remark-parse #383

Merged
merged 21 commits into from
Jul 20, 2019
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
9ce1fe9
feat: TS type information for remark-stringify
mike-north Jan 11, 2019
6f6745b
ci: remove unnecessary Travis-CI jobs, and serialization of jobs
mike-north Jan 11, 2019
a53b3a6
ci: travis-ci - fail fast
mike-north Jan 11, 2019
c6e6fd5
ci: run TS type tests in node 10.0 instead of node 0.10
mike-north Jan 11, 2019
b6b70b8
chore: respond to code review feedback
mike-north Jan 15, 2019
b8fd5e7
feat: TS type information for remark-parse
mike-north Jan 11, 2019
55163c9
chore: respond to code review feedback
mike-north Jan 15, 2019
1c3c2c1
Fix type definitions
Rokt33r Jan 21, 2019
888707b
Fix type test of remark-stringify
Rokt33r Jan 21, 2019
5fe120c
Merge remote-tracking branch 'mike-north/parse-types' into stringify-…
Rokt33r Jan 21, 2019
89ee188
Fix remark-parse type definitions
Rokt33r Jan 21, 2019
84c229c
Add type test for the extending Parser example
Rokt33r Jan 21, 2019
7d12f1b
Revise types and add test for the extending Compiler example
Rokt33r Jan 21, 2019
356f2c9
Format tslint
Rokt33r Jan 21, 2019
4ab9dc9
Pull out dtslint and typescript devDependencies to master package.json
Rokt33r Jan 21, 2019
6debdcb
Make locator optional
Rokt33r Jan 21, 2019
33e8712
Discard extending paresr example in test
Rokt33r Jan 21, 2019
822c593
Merge remote-tracking branch 'upstream/master' into stringify-types
Rokt33r Jul 2, 2019
553c4e0
Merge branch 'master' into stringify-types
ChristianMurphy Jul 11, 2019
7ff9082
add typings for remark, leverage generic in stringify and parse
ChristianMurphy Jul 11, 2019
9011bf8
types: add support for type checking remark options
ChristianMurphy Jul 19, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 15 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
language: node_js
node_js:
mike-north marked this conversation as resolved.
Show resolved Hide resolved
- lts/boron
- node
sudo: false

jobs:
fail_fast: true
include:
- stage: Tests
name: 'Node LTS/Boron'
node_js: lts/boron
- name: 'Node Stable'
node_js: 10
- name: Type information Tests
node_js: 10
script: lerna run test:types

deploy:
provider: releases
skip_cleanup: true
api_key:
secure: GCfTZxoqpp1tMmslM5MTI13BLv+bvFhZUuhX+dQFbcVYODQKUjnUj9EBF10PJSTpYqm3GnGpxEoQ6RAUVxlH7rBQUFm4czaZPPgCDSZT3B8pszmQkl1aRyvdmXFoKfyNhFUwBUSsoBpM92wp/UrgIZ/CI0jLoIZbCwn4KH02rf8=
file:
- "remark.js"
- "remark.min.js"
- 'remark.js'
- 'remark.min.js'
on:
tags: true
5 changes: 4 additions & 1 deletion packages/remark-stringify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"index.js",
"lib"
mike-north marked this conversation as resolved.
Show resolved Hide resolved
],
"types": "types/index.d.ts",
"dependencies": {
"ccount": "^1.0.0",
"is-alphanumeric": "^1.0.0",
Expand All @@ -40,14 +41,16 @@
"xtend": "^4.0.1"
},
"devDependencies": {
"dtslint": "^0.4.2",
Rokt33r marked this conversation as resolved.
Show resolved Hide resolved
"tape": "^4.9.1",
"unified": "^7.0.0",
"unist-builder": "^1.0.3",
"unist-util-visit": "^1.4.0",
"wcwidth": "^1.0.1"
},
"scripts": {
"test": "tape test.js"
"test": "tape test.js",
"test:types": "dtslint types"
mike-north marked this conversation as resolved.
Show resolved Hide resolved
},
"xo": false
}
14 changes: 14 additions & 0 deletions packages/remark-stringify/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// TypeScript Version: 3.0

declare module 'remark-stringify' {
mike-north marked this conversation as resolved.
Show resolved Hide resolved
import {RemarkStringifyOptions} from 'remark-stringify/types'
Rokt33r marked this conversation as resolved.
Show resolved Hide resolved
import {Attacher, Compiler, Processor} from 'unified'
import {Node} from 'unist'

interface Stringify extends Attacher {
Compiler: Compiler
(this: Processor, options?: Partial<RemarkStringifyOptions>): void
}
const stringify: Stringify
export = stringify
}
18 changes: 18 additions & 0 deletions packages/remark-stringify/types/test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import * as remarkStringify from 'remark-stringify'
import {RemarkStringifyOptions} from 'remark-stringify/types'
import * as unified from 'unified'

const stringifyOptions: Partial<RemarkStringifyOptions> = {
gfm: true,
bullet: '*',
fences: true,
fence: '`',
incrementListMarker: false
}

unified().use(remarkStringify, stringifyOptions)

const badStringifyOptions: Partial<RemarkStringifyOptions> = {
// $ExpectError
gfm: 'true'
}
16 changes: 16 additions & 0 deletions packages/remark-stringify/types/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
mike-north marked this conversation as resolved.
Show resolved Hide resolved
"compilerOptions": {
"module": "commonjs",
"lib": ["es6"],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"noEmit": true,
"baseUrl": ".",
"paths": {
"remark-stringify": ["."],
"remark-stringify/*": ["./*"]
}
}
}
9 changes: 9 additions & 0 deletions packages/remark-stringify/types/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
mike-north marked this conversation as resolved.
Show resolved Hide resolved
"extends": "dtslint/dtslint.json", // Or "dtslint/dt.json" if on DefinitelyTyped
"rules": {
"semicolon": false,
"indent": false,
"whitespace": false,
"no-single-declare-module": false
}
}
21 changes: 21 additions & 0 deletions packages/remark-stringify/types/types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
export interface RemarkStringifyOptions {
gfm: boolean
commonmark: boolean
entities: boolean | 'numbers' | 'escape'
setext: boolean
closeAtx: boolean
looseTable: boolean
spacedTable: boolean
paddedTable: boolean
stringLength: (s: string) => number
fence: '~' | '`'
fences: boolean
bullet: '-' | '*' | '+'
listItemIndent: 'tab' | '1' | 'mixed'
incrementListMarker: boolean
rule: '-' | '_' | '*'
ruleRepetition: number
ruleSpaces: boolean
strong: '_' | '*'
emphasis: '_' | '*'
}