Skip to content

Commit b2dd046

Browse files
committed
Reorganize files
1 parent 56da82e commit b2dd046

9 files changed

+28
-16
lines changed

index.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
'use strict'
2+
3+
/**
4+
* @typedef {import('./lib/react-markdown.js').ReactMarkdownOptions} Options
5+
* @typedef {import('./lib/ast-to-react.js').Components} Components
6+
*/
7+
8+
module.exports = require('./lib/react-markdown.js')
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

package.json

+10-7
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,13 @@
6767
"Dennis S <[email protected]>",
6868
"Evan Hensleigh <[email protected]>"
6969
],
70-
"types": "src/react-markdown.d.ts",
71-
"main": "src/react-markdown.js",
70+
"types": "index.d.ts",
71+
"main": "index.js",
7272
"unpkg": "react-markdown.min.js",
7373
"files": [
74-
"src/",
74+
"lib/",
75+
"index.d.ts",
76+
"index.js",
7577
"react-markdown.min.js"
7678
],
7779
"dependencies": {
@@ -123,8 +125,8 @@
123125
},
124126
"scripts": {
125127
"prepack": "npm run build && npm run format",
126-
"build:ts": "rimraf \"{src/**,test/**,}.d.ts\" && tsc && type-coverage",
127-
"build:umd": "esbuild src/react-markdown.js --bundle --minify --target=es2015 --outfile=react-markdown.min.js --global-name=ReactMarkdown --banner:js=\"(function (g, f) {typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = f() : typeof define === 'function' && define.amd ? define([], f) : (g = typeof globalThis !== 'undefined' ? globalThis : g || self, g.ReactMarkdown = f()); }(this, (function () { 'use strict';\" --footer:js=\"return ReactMarkdown;})));\"",
128+
"build:ts": "rimraf \"{lib/**,test/**,*}.d.ts\" && tsc && type-coverage",
129+
"build:umd": "esbuild index.js --bundle --minify --target=es2015 --outfile=react-markdown.min.js --global-name=ReactMarkdown --banner:js=\"(function (g, f) {typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = f() : typeof define === 'function' && define.amd ? define([], f) : (g = typeof globalThis !== 'undefined' ? globalThis : g || self, g.ReactMarkdown = f()); }(this, (function () { 'use strict';\" --footer:js=\"return ReactMarkdown;})));\"",
128130
"build": "run-s build:*",
129131
"format": "remark . -qfo --ignore-pattern test/ && prettier . -w --loglevel warn && xo --fix",
130132
"test": "run-s build format test:coverage",
@@ -158,7 +160,8 @@
158160
"ignoreCatch": true,
159161
"#": "below is ignored because some proptypes will `any`",
160162
"ignoreFiles": [
161-
"src/react-markdown.d.ts"
163+
"lib/react-markdown.d.ts",
164+
"index.d.ts"
162165
]
163166
},
164167
"prettier": {
@@ -179,7 +182,7 @@
179182
"overrides": [
180183
{
181184
"files": [
182-
"src/**/*.js"
185+
"lib/**/*.js"
183186
],
184187
"extends": [
185188
"plugin:es/restrict-to-es2015",

readme.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ abide by its terms.
590590

591591
[cm-html]: https://spec.commonmark.org/0.29/#html-blocks
592592

593-
[uri]: https://github.com/remarkjs/react-markdown/blob/main/src/uri-transformer.js
593+
[uri]: https://github.com/remarkjs/react-markdown/blob/main/lib/uri-transformer.js
594594

595595
[security]: #security
596596

test/test.jsx

+8-7
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const gfm = require('remark-gfm')
77
const visit = require('unist-util-visit')
88
const ReactDom = require('react-dom/server')
99
const raw = require('rehype-raw')
10-
const Markdown = require('../src/react-markdown.js')
10+
const Markdown = require('../index.js')
1111
const toc = require('remark-toc')
1212

1313
const own = {}.hasOwnProperty
@@ -19,7 +19,7 @@ const own = {}.hasOwnProperty
1919
* @typedef {import('hast').Element} Element
2020
* @typedef {import('hast').Text} Text
2121
* @typedef {import('react').ReactNode} ReactNode
22-
* @typedef {import('../src/ast-to-react').Components} Components
22+
* @typedef {import('../index.js').Components} Components
2323
*/
2424

2525
/**
@@ -39,7 +39,7 @@ test('should warn when passed `source`', () => {
3939
/** @type {unknown} */
4040
let message
4141

42-
console.warn = (d) => {
42+
console.warn = (/** @type {unknown} */ d) => {
4343
message = d
4444
}
4545

@@ -59,7 +59,7 @@ test('should warn when passed non-string children (number)', () => {
5959
let message
6060

6161
console.error = () => {}
62-
console.warn = (d) => {
62+
console.warn = (/** @type {unknown} */ d) => {
6363
message = d
6464
}
6565

@@ -80,7 +80,7 @@ test('should warn when passed non-string children (boolean)', () => {
8080
let message
8181

8282
console.error = () => {}
83-
console.warn = (d) => {
83+
console.warn = (/** @type {unknown} */ d) => {
8484
message = d
8585
}
8686

@@ -110,7 +110,7 @@ test('should warn when passed `allowDangerousHtml`', () => {
110110
/** @type {unknown} */
111111
let message
112112

113-
console.warn = (d) => {
113+
console.warn = (/** @type {unknown} */ d) => {
114114
message = d
115115
}
116116

@@ -1067,6 +1067,7 @@ test('should pass index of a node under its parent to components if `includeElem
10671067
* @param {object} props
10681068
* @param {Element} props.node
10691069
* @param {ReactNode[]} props.children
1070+
* @param {number} [props.index]
10701071
*/
10711072
const p = ({node, ...otherProps}) => {
10721073
assert.equal(typeof otherProps.index === 'number', true)
@@ -1082,7 +1083,7 @@ test('should pass index of a node under its parent to components if `includeElem
10821083
test('should be able to render components with forwardRef in HOC', () => {
10831084
/**
10841085
* @typedef {import('react').Ref<HTMLAnchorElement>} Ref
1085-
* @typedef {JSX.IntrinsicElements['a'] & import('../src/ast-to-react').ReactMarkdownProps} Props
1086+
* @typedef {JSX.IntrinsicElements['a'] & import('../lib/ast-to-react').ReactMarkdownProps} Props
10861087
*/
10871088

10881089
/**

tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"include": ["*.js", "src/**.js", "test/**.js"],
2+
"include": ["lib/**.js", "test/**.jsx", "index.js"],
33
"exclude": ["**/*.min.js"],
44
"compilerOptions": {
55
"target": "ES2015",

0 commit comments

Comments
 (0)