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

Updates remark-toc, remark-gfm, and rehype-autolink-headings libraries #1244

Merged
merged 5 commits into from
Jan 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions __mocks__/rehype-autolink-headings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* Manual Mocking the rehype-autolink-headings library because our jest and typscript
* configuration doesn't use esm modules yet. After the package update,
* rehype-autolink-headings is a fully ESM module now and the reason this is being
* manual mocked is because it is being mocked as a CommonJS module.
* Here is the link: https://jestjs.io/docs/manual-mocks#mocking-node-modules
*/
const autolink = () => {
flacial marked this conversation as resolved.
Show resolved Hide resolved
console.log('Manual Mocking of rehype-autolink-headings module')
}

module.exports = {
autolink
}
13 changes: 13 additions & 0 deletions __mocks__/remark-gfm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* Manual Mocking the remark-gfm library because our jest and typscript
* configuration doesn't use esm modules yet. After the package update,
* remark-gfm is a fully ESM module now and the reason this is being
* manual mocked is because it is being mocked as a CommonJS module.
* Here is the link: https://jestjs.io/docs/manual-mocks#mocking-node-modules
*/
const gfm = () => {
flacial marked this conversation as resolved.
Show resolved Hide resolved
console.log('Manual Mocking remark-gfm module')
}

module.exports = {
gfm
}
13 changes: 13 additions & 0 deletions __mocks__/remark-toc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* Manual Mocking the remark-toc library because our jest and typscript
* configuration doesn't use esm modules yet. After the package update,
* remark-toc is a fully ESM module now and the reason this is being
* manual mocked is because it is being mocked as a CommonJS module.
* Here is the link: https://jestjs.io/docs/manual-mocks#mocking-node-modules
*/
const toc = () => {
console.log('Manual Mocking of remark-toc module')
}

module.exports = {
toc
}
6 changes: 3 additions & 3 deletions helpers/static/parseMDX.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { serialize } from 'next-mdx-remote/serialize'
import { MDXRemoteSerializeResult } from 'next-mdx-remote'
import matter from 'gray-matter'
import toc from 'remark-toc'
import gfm from 'remark-gfm'
import autolink from 'rehype-autolink-headings'

const autolink = require('rehype-autolink-headings')
const slug = require('remark-slug')
const toc = require('remark-toc')
const gfm = require('remark-gfm')

type ParsedMDX = {
(fileContents: Buffer, onlyFront?: boolean): Promise<{
Expand Down
2 changes: 1 addition & 1 deletion jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const config: Config.InitialOptions = {
setupFilesAfterEnv: ['<rootDir>/jest.env.js'],
testEnvironment: 'jsdom',
testPathIgnorePatterns: ['__tests__/utils/', 'node_modules/', '.next/'],
transformIgnorePatterns: ['node_modules/']
transformIgnorePatterns: ['node_modules/(?!(remark-toc)/)']
}

export default config
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@
"react-bootstrap": "^1.6.1",
"react-dom": "^17.0.2",
"react-feather": "^2.0.9",
"rehype-autolink-headings": "^5.1.0",
"sass": "^1.49.0",
"rehype-autolink-headings": "^6.1.0",
"use-undo": "^1.0.5",
"winston": "^3.4.0",
"yup": "^0.32.11"
Expand Down Expand Up @@ -116,10 +116,10 @@
"prettier": "^2.5.1",
"prisma": "^2.29.1",
"react-test-renderer": "^17.0.1",
"remark-gfm": "^1.0.0",
"remark-gfm": "^3.0.1",
"remark-slug": "^6.1.0",
"remark-toc": "^7.2.0",
"sass-loader": "^10.2.1",
"remark-toc": "^8.0.1",
"svgo": "^2.8.0",
"ts-node": "^10.4.0",
"typescript": "^4.5.5"
Expand Down
Loading