Skip to content

Commit

Permalink
chore(deps): update dependency typescript to v5.5.4 (#3043)
Browse files Browse the repository at this point in the history
* chore(deps): update dependency typescript to v5.5.4

* fix

* lint

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Dimitri POSTOLOV <[email protected]>
  • Loading branch information
renovate[bot] and dimaMachina authored Jul 23, 2024
1 parent 7219fea commit 27b9470
Show file tree
Hide file tree
Showing 11 changed files with 381 additions and 253 deletions.
4 changes: 4 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ module.exports = {
],
plugins: ['import', 'unicorn', 'sonarjs'],
rules: {
// 'no-extra-boolean-cast': [
// 'error',
// { enforceForInnerExpressions: true }
// ],
'prefer-object-has-own': 'error',
'logical-assignment-operators': [
'error',
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
"@ianvs/prettier-plugin-sort-imports": "4.3.1",
"@next/eslint-plugin-next": "14.2.5",
"@rollup/plugin-alias": "^5.0.0",
"@typescript-eslint/eslint-plugin": "7.16.1",
"@typescript-eslint/parser": "7.16.1",
"@typescript-eslint/eslint-plugin": "7.17.0",
"@typescript-eslint/parser": "7.17.0",
"eslint": "8.57.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-import": "2.29.1",
Expand All @@ -44,7 +44,7 @@
"tsup": "8.1.0",
"tsx": "^4.7.0",
"turbo": "2.0.9",
"typescript": "5.4.5"
"typescript": "5.5.4"
},
"pnpm": {
"overrides": {
Expand Down
22 changes: 11 additions & 11 deletions packages/nextra/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,19 +154,19 @@
"devDependencies": {
"@svgr/babel-plugin-remove-jsx-attribute": "^8.0.0",
"@testing-library/react": "^16.0.0",
"@types/estree": "^1.0.2",
"@types/graceful-fs": "^4.1.7",
"@types/hast": "^3.0.1",
"@types/mdast": "^3.0.13",
"@types/react": "^18.2.23",
"@types/webpack": "^5.28.3",
"@vitejs/plugin-react": "^4.1.0",
"@types/estree": "^1.0.5",
"@types/graceful-fs": "^4.1.9",
"@types/hast": "^3.0.4",
"@types/mdast": "^4.0.4",
"@types/react": "^18.3.3",
"@types/webpack": "^5.28.5",
"@vitejs/plugin-react": "^4.3.1",
"esbuild-plugin-svgr": "^2.1.0",
"next": "^14.2.5",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"unified": "^11.0.3",
"vitest": "^2.0.3"
"react": "^18.3.1",
"react-dom": "^18.3.1",
"unified": "^11.0.5",
"vitest": "^2.0.4"
},
"sideEffects": false
}
9 changes: 2 additions & 7 deletions packages/nextra/src/server/recma-plugins/recma-rewrite-jsx.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import type {
CallExpression,
FunctionDeclaration,
Program,
ReturnStatement
} from 'estree'
import type { CallExpression, FunctionDeclaration, Program } from 'estree'
import type { JsxAttribute } from 'estree-util-to-js/lib/jsx'
import type { Plugin } from 'unified'
import { visit } from 'unist-util-visit'
Expand Down Expand Up @@ -45,7 +40,7 @@ export const recmaRewriteJsx: Plugin<[], Program> =

const returnStatement = createMdxContent.body.body.find(
o => o.type === 'ReturnStatement'
) as ReturnStatement
)!

const { argument } = returnStatement as any

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { JsxAttribute } from 'estree-util-to-js/lib/jsx'
import type { Element } from 'hast'
import type { Element, Root } from 'hast'
import { toEstree } from 'hast-util-to-estree'
import type { Plugin } from 'unified'
import { visit } from 'unist-util-visit'
Expand All @@ -9,7 +9,7 @@ import { createAstObject } from '../utils.js'

export const rehypeExtractTocContent: Plugin<
[{ isRemoteContent?: boolean }],
any
Root
> =
({
// todo rethink this
Expand Down Expand Up @@ -104,7 +104,7 @@ export const rehypeExtractTocContent: Plugin<
]
}
}
})
} as any)

file.data.toc = toc
}
10 changes: 5 additions & 5 deletions packages/nextra/src/server/rehype-plugins/rehype-icon.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ImportDeclaration, ImportSpecifier } from 'estree'
import type { Element } from 'hast'
import type { Element, Root } from 'hast'
import type { Plugin } from 'unified'
import { visit } from 'unist-util-visit'

Expand Down Expand Up @@ -84,7 +84,7 @@ const isImportDeclaration = (node: any) =>
const isImportFrom = (node: any) =>
node.data.estree.body[0].source.value === 'nextra/icons'

export const rehypeIcon: Plugin<[], any> =
export const rehypeIcon: Plugin<[], Root> =
(replaces = REHYPE_ICON_DEFAULT_REPLACES) =>
ast => {
const imports = ast.children.filter(
Expand All @@ -106,7 +106,7 @@ export const rehypeIcon: Plugin<[], any> =

let findImportedName = ''
for (const { data } of imports) {
const [{ specifiers }] = data.estree.body
const [{ specifiers }] = (data as any).estree.body
const isMatch = (specifiers as ImportSpecifier[]).some(
spec => spec.imported.name === iconName
)
Expand All @@ -118,8 +118,8 @@ export const rehypeIcon: Plugin<[], any> =

if (!findImportedName) {
const importNode = createImport(iconName)
ast.children.push(importNode)
imports.push(importNode)
ast.children.push(importNode as any)
imports.push(importNode as any)
}
attachIconProp(preEl, findImportedName || iconName)
})
Expand Down
86 changes: 45 additions & 41 deletions packages/nextra/src/server/rehype-plugins/rehype.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Element } from 'hast'
import type { Element, Root } from 'hast'
import type { Options as RehypePrettyCodeOptions } from 'rehype-pretty-code'
import { bundledLanguages, getHighlighter } from 'shiki'
import type { Plugin } from 'unified'
Expand Down Expand Up @@ -39,7 +39,7 @@ export const DEFAULT_REHYPE_PRETTY_CODE_OPTIONS: RehypePrettyCodeOptions = {

export const rehypeParseCodeMeta: Plugin<
[{ defaultShowCopyCode?: boolean }],
any
Root
> =
({ defaultShowCopyCode }) =>
ast => {
Expand All @@ -66,50 +66,54 @@ export const rehypeParseCodeMeta: Plugin<
})
}

export const rehypeAttachCodeMeta: Plugin<[], any> = () => ast => {
visit(ast, [{ tagName: 'figure' }, { tagName: 'span' }], (node: Element) => {
const isRehypePrettyCode =
'data-rehype-pretty-code-figure' in node.properties
if (!isRehypePrettyCode) return
export const rehypeAttachCodeMeta: Plugin<[], Root> = () => ast => {
visit(
ast as any,
[{ tagName: 'figure' }, { tagName: 'span' }],
(node: Element) => {
const isRehypePrettyCode =
'data-rehype-pretty-code-figure' in node.properties
if (!isRehypePrettyCode) return

// remove <figure data-rehype-pretty-code-figure /> element that wraps <pre /> element
// because we'll wrap with our own <div />
const preEl: PreElement = Object.assign(node, node.children[0])
delete preEl.properties['data-theme']
// remove <figure data-rehype-pretty-code-figure /> element that wraps <pre /> element
// because we'll wrap with our own <div />
const preEl: PreElement = Object.assign(node, node.children[0])
delete preEl.properties['data-theme']

if (preEl.tagName === 'pre') {
const [codeEl] = preEl.children as Element[]
delete codeEl.properties['data-theme']
delete codeEl.properties['data-language']
if (preEl.tagName === 'pre') {
const [codeEl] = preEl.children as Element[]
delete codeEl.properties['data-theme']
delete codeEl.properties['data-language']

if (preEl.__hasWordWrap) {
preEl.properties['data-word-wrap'] = ''
}
if (preEl.__hasWordWrap) {
preEl.properties['data-word-wrap'] = ''
}

if (preEl.__filename) {
preEl.properties['data-filename'] = preEl.__filename
}
if (preEl.__hasCopyCode) {
preEl.properties['data-copy'] = ''
}
// @ts-expect-error fixme
if (preEl.type === 'mdxJsxFlowElement') {
if (node.properties.className === undefined)
delete node.properties.className
if (node.properties.style === undefined) delete node.properties.style
if (preEl.__filename) {
preEl.properties['data-filename'] = preEl.__filename
}
if (preEl.__hasCopyCode) {
preEl.properties['data-copy'] = ''
}
// @ts-expect-error fixme
if (preEl.type === 'mdxJsxFlowElement') {
if (node.properties.className === undefined)
delete node.properties.className
if (node.properties.style === undefined) delete node.properties.style
// @ts-expect-error fixme
preEl.attributes.push(
...Object.entries(node.properties).map(([name, value]) => ({
type: 'mdxJsxAttribute',
name,
value: Array.isArray(value) ? value.join(' ') : value
}))
)
}
} else {
// remove class="line"
// @ts-expect-error fixme
preEl.attributes.push(
...Object.entries(node.properties).map(([name, value]) => ({
type: 'mdxJsxAttribute',
name,
value: Array.isArray(value) ? value.join(' ') : value
}))
)
delete node.children[0].properties.className
}
} else {
// remove class="line"
// @ts-expect-error fixme
delete node.children[0].properties.className
}
})
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ export const remarkMdxDisableExplicitJsx: Plugin<
ast => {
const test = whiteList.map(name => ({ name }))
visit(ast, test, node => {
delete node.data!._mdxExplicitJsx
delete (node.data as any)._mdxExplicitJsx
})
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,12 @@ export const remarkMdxFrontMatter: Plugin<[], Root> =
ast.children.unshift(createNode({}))
}

// @ts-expect-error
const frontMatter = ast.children.find(node =>
// @ts-expect-error
isExportNode(node, 'frontMatter')
// @ts-expect-error -- fixme
const frontMatter = ast.children.find(
node =>
// @ts-expect-error -- fixme
isExportNode(node, 'frontMatter')
// @ts-expect-error -- fixme
).data.estree.body[0].declaration.declarations[0].init.properties

file.data.frontMatter = estreeToValue(frontMatter)
Expand Down
4 changes: 2 additions & 2 deletions packages/nextra/src/server/remark-plugins/remark-mdx-title.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ export const remarkMdxTitle: Plugin<[], Root> = () => (ast, file) => {
}

ast.children.unshift({
type: 'mdxjsEsm' as any,
type: 'mdxjsEsm',
data: {
estree: {
body: [createAstExportConst('title', { type: 'Literal', value: title })]
}
}
})
} as any)
file.data.title = title
}
Loading

0 comments on commit 27b9470

Please sign in to comment.