Skip to content

Commit

Permalink
types: add typescript typings for remark-mdx, remark-mdx-remove-expor…
Browse files Browse the repository at this point in the history
…ts, remark-mdx-remove-imports, @mdx-js/util (#1082)
  • Loading branch information
ChristianMurphy committed May 21, 2020
1 parent 65af47c commit e2eb4ee
Show file tree
Hide file tree
Showing 20 changed files with 210 additions and 31 deletions.
10 changes: 8 additions & 2 deletions packages/remark-mdx-remove-exports/package.json
Expand Up @@ -15,11 +15,14 @@
"Tim Neutkens <tim@vercel.com>",
"Matija Marohnić <matija.marohnic@gmail.com>",
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
"JounQin <admin@1stg.me> (https://www.1stg.me)"
"JounQin <admin@1stg.me> (https://www.1stg.me)",
"Christian Murphy <christian.murphy.42@gmail.com>"
],
"license": "MIT",
"types": "types/index.d.ts",
"files": [
"index.js"
"index.js",
"types/index.d.ts"
],
"keywords": [
"mdx",
Expand All @@ -29,6 +32,9 @@
"remark",
"mdxast"
],
"scripts": {
"test-types": "dtslint types"
},
"dependencies": {
"unist-util-remove": "2.0.0"
}
Expand Down
10 changes: 10 additions & 0 deletions packages/remark-mdx-remove-exports/types/index.d.ts
@@ -0,0 +1,10 @@
// TypeScript Version: 3.4

import {Plugin} from 'unified'

/**
* Remove export nodes from the MDXAST.
*/
declare const remarkMdxRemoveExports: Plugin<[]>

export = remarkMdxRemoveExports
@@ -0,0 +1,4 @@
import * as unified from 'unified'
import * as mdxRemoveExports from 'remark-mdx-remove-exports'

unified().use(mdxRemoveExports)
13 changes: 13 additions & 0 deletions packages/remark-mdx-remove-exports/types/tsconfig.json
@@ -0,0 +1,13 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": ["dom", "es6"],
"strict": true,
"skipLibCheck": true,
"baseUrl": ".",
"jsx": "react",
"paths": {
"remark-mdx-remove-exports": ["index.d.ts"]
}
}
}
7 changes: 7 additions & 0 deletions packages/remark-mdx-remove-exports/types/tslint.json
@@ -0,0 +1,7 @@
{
"extends": "dtslint/dtslint.json",
"rules": {
"whitespace": false,
"semicolon": false
}
}
10 changes: 8 additions & 2 deletions packages/remark-mdx-remove-imports/package.json
Expand Up @@ -15,11 +15,14 @@
"Tim Neutkens <tim@vercel.com>",
"Matija Marohnić <matija.marohnic@gmail.com>",
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
"JounQin <admin@1stg.me> (https://www.1stg.me)"
"JounQin <admin@1stg.me> (https://www.1stg.me)",
"Christian Murphy <christian.murphy.42@gmail.com>"
],
"license": "MIT",
"types": "types/index.d.ts",
"files": [
"index.js"
"index.js",
"types/index.d.ts"
],
"keywords": [
"mdx",
Expand All @@ -29,6 +32,9 @@
"remark",
"mdxast"
],
"scripts": {
"test-types": "dtslint types"
},
"dependencies": {
"unist-util-remove": "2.0.0"
}
Expand Down
10 changes: 10 additions & 0 deletions packages/remark-mdx-remove-imports/types/index.d.ts
@@ -0,0 +1,10 @@
// TypeScript Version: 3.4

import {Plugin} from 'unified'

/**
* Remove import nodes from the MDXAST.
*/
declare const remarkMdxRemoveImports: Plugin<[]>

export = remarkMdxRemoveImports
@@ -0,0 +1,4 @@
import * as unified from 'unified'
import * as mdxRemoveImports from 'remark-mdx-remove-imports'

unified().use(mdxRemoveImports)
13 changes: 13 additions & 0 deletions packages/remark-mdx-remove-imports/types/tsconfig.json
@@ -0,0 +1,13 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": ["dom", "es6"],
"strict": true,
"skipLibCheck": true,
"baseUrl": ".",
"jsx": "react",
"paths": {
"remark-mdx-remove-imports": ["index.d.ts"]
}
}
}
7 changes: 7 additions & 0 deletions packages/remark-mdx-remove-imports/types/tslint.json
@@ -0,0 +1,7 @@
{
"extends": "dtslint/dtslint.json",
"rules": {
"whitespace": false,
"semicolon": false
}
}
52 changes: 28 additions & 24 deletions packages/remark-mdx/package.json
Expand Up @@ -2,7 +2,24 @@
"name": "remark-mdx",
"version": "2.0.0-next.0",
"description": "remark plugin to add support for mdx",
"repository": "https://github.com/mdx-js/mdx/tree/master/packages/remark-mdx",
"bugs": "https://github.com/mdx-js/mdx/issues",
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
},
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
"contributors": [
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
"Christian Murphy <christian.murphy.42@gmail.com>"
],
"license": "MIT",
"types": "types/index.d.ts",
"files": [
"index.js",
"lib/",
"types/index.d.ts"
],
"keywords": [
"unified",
"remark",
Expand All @@ -15,20 +32,13 @@
"xml",
"mdx"
],
"repository": "https://github.com/mdx-js/mdx/tree/master/packages/remark-mdx",
"bugs": "https://github.com/mdx-js/mdx/issues",
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
"scripts": {
"format": "remark . -qfo && prettier --write \"**/*.js\" && xo --fix",
"test": "npm run format && npm run test-coverage",
"test-api": "node test",
"test-coverage": "nyc --reporter lcov tape test/index.js",
"test-types": "dtslint types"
},
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
"contributors": [
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
],
"files": [
"lib/",
"index.js"
],
"dependencies": {
"parse-entities": "^2.0.0",
"stringify-entities": "^3.0.0",
Expand All @@ -48,12 +58,6 @@
"unist-builder": "^2.0.0",
"xo": "^0.30.0"
},
"scripts": {
"format": "remark . -qfo && prettier --write \"**/*.js\" && xo --fix",
"test-api": "node test",
"test-coverage": "nyc --reporter lcov tape test/index.js",
"test": "npm run format && npm run test-coverage"
},
"nyc": {
"check-coverage": true,
"lines": 100,
Expand All @@ -68,6 +72,11 @@
"semi": false,
"trailingComma": "none"
},
"remarkConfig": {
"plugins": [
"preset-wooorm"
]
},
"xo": {
"prettier": true,
"esnext": false,
Expand All @@ -78,10 +87,5 @@
"no-self-compare": "off",
"no-lonely-if": "off"
}
},
"remarkConfig": {
"plugins": [
"preset-wooorm"
]
}
}
10 changes: 10 additions & 0 deletions packages/remark-mdx/types/index.d.ts
@@ -0,0 +1,10 @@
// TypeScript Version: 3.4

import {Plugin} from 'unified'

/**
* remark plugin to support MDX (Markdown 💛 JSX).
*/
declare const remarkMdx: Plugin<[]>

export = remarkMdx
4 changes: 4 additions & 0 deletions packages/remark-mdx/types/remark-mdx-test.ts
@@ -0,0 +1,4 @@
import * as unified from 'unified'
import * as mdx from 'remark-mdx'

unified().use(mdx)
13 changes: 13 additions & 0 deletions packages/remark-mdx/types/tsconfig.json
@@ -0,0 +1,13 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": ["dom", "es6"],
"strict": true,
"skipLibCheck": true,
"baseUrl": ".",
"jsx": "react",
"paths": {
"remark-mdx": ["index.d.ts"]
}
}
}
7 changes: 7 additions & 0 deletions packages/remark-mdx/types/tslint.json
@@ -0,0 +1,7 @@
{
"extends": "dtslint/dtslint.json",
"rules": {
"whitespace": false,
"semicolon": false
}
}
12 changes: 9 additions & 3 deletions packages/util/package.json
Expand Up @@ -11,11 +11,14 @@
},
"author": "John Otander <johnotander@gmail.com> (http://johnotander.com)",
"contributors": [
"JounQin <admin@1stg.me> (https://www.1stg.me)"
"JounQin <admin@1stg.me> (https://www.1stg.me)",
"Christian Murphy <christian.murphy.42@gmail.com>"
],
"license": "MIT",
"types": "types/index.d.ts",
"files": [
"index.js"
"index.js",
"types/index.d.ts"
],
"keywords": [
"mdx",
Expand All @@ -24,5 +27,8 @@
"jsx",
"remark",
"mdxast"
]
],
"scripts": {
"test-types": "dtslint types"
}
}
12 changes: 12 additions & 0 deletions packages/util/types/index.d.ts
@@ -0,0 +1,12 @@
// TypeScript Version: 3.4

export const EMPTY_NEWLINE: string
export function isImport(text: string): boolean
export function isExport(text: string): boolean
export function isExportDefault(text: string): boolean
export function isImportOrExport(text: string): boolean
export function startsWithCapitalLetter(text: string): boolean
export function isComment(text: string): boolean
export function getCommentContents(text: string): string
export function paramCase(text: string): string
export function toTemplateLiteral(text: string): string
23 changes: 23 additions & 0 deletions packages/util/types/mdx-js-util-test.ts
@@ -0,0 +1,23 @@
import {
EMPTY_NEWLINE,
isImport,
isExport,
isExportDefault,
isImportOrExport,
startsWithCapitalLetter,
isComment,
getCommentContents,
paramCase,
toTemplateLiteral
} from '@mdx-js/util'

EMPTY_NEWLINE // $ExpectType string
isImport('') // $ExpectType boolean
isExport('') // $ExpectType boolean
isExportDefault('') // $ExpectType boolean
isImportOrExport('') // $ExpectType boolean
startsWithCapitalLetter('') // $ExpectType boolean
isComment('') // $ExpectType boolean
getCommentContents('') // $ExpectType string
paramCase('') // $ExpectType string
toTemplateLiteral('') // $ExpectType string
13 changes: 13 additions & 0 deletions packages/util/types/tsconfig.json
@@ -0,0 +1,13 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": ["dom", "es6"],
"strict": true,
"skipLibCheck": true,
"baseUrl": ".",
"jsx": "react",
"paths": {
"@mdx-js/util": ["index.d.ts"]
}
}
}
7 changes: 7 additions & 0 deletions packages/util/types/tslint.json
@@ -0,0 +1,7 @@
{
"extends": "dtslint/dtslint.json",
"rules": {
"whitespace": false,
"semicolon": false
}
}

0 comments on commit e2eb4ee

Please sign in to comment.