From 0d18bf6d2e3bb571c8c244385c57e553f1da07ba Mon Sep 17 00:00:00 2001 From: WANG Xuerui Date: Fri, 11 Oct 2024 15:19:26 +0800 Subject: [PATCH 01/25] build: yarn add --dev prettier --- package.json | 1 + yarn.lock | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/package.json b/package.json index 8d575a7f..d3a87b59 100644 --- a/package.json +++ b/package.json @@ -53,6 +53,7 @@ "@types/prismjs": "^1.26.4", "@types/react": "^18.3.11", "@types/react-router-dom": "^5.3.3", + "prettier": "^3.3.3", "typescript": "^5.6.3", "update-browserslist-db": "^1.1.1" }, diff --git a/yarn.lock b/yarn.lock index 4fc6a95f..a7bcafa4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4052,6 +4052,7 @@ __metadata: glob: "npm:^11.0.0" lodash: "npm:^4.17.21" mdast-util-find-and-replace: "npm:^3.0.1" + prettier: "npm:^3.3.3" prism-react-renderer: "npm:^2.4.0" prismjs: "npm:^1.29.0" react: "npm:^18.3.1" @@ -10827,6 +10828,15 @@ __metadata: languageName: node linkType: hard +"prettier@npm:^3.3.3": + version: 3.3.3 + resolution: "prettier@npm:3.3.3" + bin: + prettier: bin/prettier.cjs + checksum: 10c0/b85828b08e7505716324e4245549b9205c0cacb25342a030ba8885aba2039a115dbcf75a0b7ca3b37bc9d101ee61fab8113fc69ca3359f2a226f1ecc07ad2e26 + languageName: node + linkType: hard + "pretty-error@npm:^4.0.0": version: 4.0.0 resolution: "pretty-error@npm:4.0.0" From cb84962a1dbd116e8baeb1e75c48770ebc932a75 Mon Sep 17 00:00:00 2001 From: WANG Xuerui Date: Wed, 23 Oct 2024 18:38:42 +0800 Subject: [PATCH 02/25] build: configure prettier --- .prettierignore | 11 +++++++++++ .prettierrc.toml | 7 +++++++ 2 files changed, 18 insertions(+) create mode 100644 .prettierignore create mode 100644 .prettierrc.toml diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 00000000..ef23c29f --- /dev/null +++ b/.prettierignore @@ -0,0 +1,11 @@ +/.github +/.vscode +/.yarn +/3rdparty +/build +/node_modules +/scripts +/static +/yarn.lock +*.md +*.mdx diff --git a/.prettierrc.toml b/.prettierrc.toml new file mode 100644 index 00000000..0ec84f25 --- /dev/null +++ b/.prettierrc.toml @@ -0,0 +1,7 @@ +tabWidth = 2 +semi = false +singleQuote = true + +[[overrides]] +files = ["*.md", "*.mdx"] +options = { tabWidth = 4 } From 97413f999fb98556f0f15b9ff09eb29da6e88ebd Mon Sep 17 00:00:00 2001 From: WANG Xuerui Date: Sat, 26 Oct 2024 12:01:15 +0800 Subject: [PATCH 03/25] style: format with prettier --- docusaurus.config.ts | 18 +- sidebars.ts | 6 +- .../AsmDB/antdDecodeTreeAdapter.tsx | 119 ++++-- src/components/AsmDB/augmentedDecodeTree.tsx | 37 +- src/components/AsmDB/bitfield.ts | 8 +- src/components/AsmDB/bits.tsx | 82 ++-- .../AsmDB/encodingSpaceOverviewPage.tsx | 394 +++++++++++++----- src/components/AsmDB/index.module.css | 2 +- src/components/AsmDB/index.tsx | 10 +- src/components/AsmDB/inputImm.tsx | 41 +- src/components/AsmDB/inputMinifloat.tsx | 137 +++--- src/components/AsmDB/insn.ts | 11 +- src/components/AsmDB/insnExplainerPage.tsx | 8 +- src/components/AsmDB/insnFormat.ts | 71 ++-- src/components/AsmDB/insnFormatName.tsx | 14 +- src/components/AsmDB/insnListPage.tsx | 181 +++++--- src/components/AsmDB/manualFormatNames.ts | 99 +++-- src/components/AsmDB/minifloat.ts | 38 +- src/components/AsmDB/simd.ts | 9 +- src/components/AsmDB/vldi.ts | 48 +-- src/components/AsmDB/vldiHelperPage.tsx | 373 ++++++++++------- src/components/AuthorPage/index.tsx | 64 ++- src/components/BoolFlag.tsx | 10 +- src/components/CodeQualityIcon/index.tsx | 32 +- src/components/ColumnedList/index.tsx | 2 +- src/components/HomepageFeatures/index.tsx | 44 +- src/components/ProjectPage/index.tsx | 44 +- src/components/SupportStatusIcon/index.tsx | 62 ++- src/components/ThemeAwareAntdContainer.tsx | 10 +- src/css/custom.css | 11 +- src/pages/index.tsx | 21 +- src/plugins/awly-asmdb-plugin/index.ts | 17 +- src/plugins/awly-data-plugin/index.ts | 101 +++-- .../index.ts | 22 +- src/plugins/awly-remark-natlang-usage.ts | 8 +- src/plugins/prism-asmloong.ts | 26 +- src/theme/Footer/Copyright/index.tsx | 65 +-- src/theme/prism-include-languages.ts | 24 +- tsconfig.json | 2 +- 39 files changed, 1467 insertions(+), 804 deletions(-) diff --git a/docusaurus.config.ts b/docusaurus.config.ts index a2b1e6f2..42612ab7 100644 --- a/docusaurus.config.ts +++ b/docusaurus.config.ts @@ -154,11 +154,13 @@ const config: Config = { routeBasePath: 'newsletter', path: './newsletter', blogTitle: '每周一龙', - blogDescription: '龙架构新世界生态建设周报《每周一龙》(This Week in LoongArch)。每周一都为大家报道 LoongArch 社区最前线的第一手新鲜资讯!', - editUrl: 'https://github.com/loongson-community/areweloongyet/edit/main', + blogDescription: + '龙架构新世界生态建设周报《每周一龙》(This Week in LoongArch)。每周一都为大家报道 LoongArch 社区最前线的第一手新鲜资讯!', + editUrl: + 'https://github.com/loongson-community/areweloongyet/edit/main', beforeDefaultRemarkPlugins: commonBeforeDefaultRemarkPlugins, rehypePlugins: commonRehypePlugins, - onUntruncatedBlogPosts: 'throw', + onUntruncatedBlogPosts: 'throw', } satisfies BlogOptions, ], ], @@ -171,8 +173,7 @@ const config: Config = { sidebarPath: require.resolve('./sidebars.js'), // Please change this to your repo. // Remove this to remove the "edit this page" links. - editUrl: - 'https://github.com/loongson-community/areweloongyet', + editUrl: 'https://github.com/loongson-community/areweloongyet', beforeDefaultRemarkPlugins: commonBeforeDefaultRemarkPlugins, rehypePlugins: commonRehypePlugins, }, @@ -182,11 +183,10 @@ const config: Config = { showReadingTime: true, // Please change this to your repo. // Remove this to remove the "edit this page" links. - editUrl: - 'https://github.com/loongson-community/areweloongyet', + editUrl: 'https://github.com/loongson-community/areweloongyet', beforeDefaultRemarkPlugins: commonBeforeDefaultRemarkPlugins, rehypePlugins: commonRehypePlugins, - onUntruncatedBlogPosts: 'throw', + onUntruncatedBlogPosts: 'throw', }, theme: { customCss: require.resolve('./src/css/custom.css'), @@ -199,7 +199,7 @@ const config: Config = { [ '@easyops-cn/docusaurus-search-local', { - hashed: "filename", + hashed: 'filename', language: ['en', 'zh'], blogDir: ['blog', 'newsletter'], blogRouteBasePath: ['/blog', '/newsletter'], diff --git a/sidebars.ts b/sidebars.ts index e9861484..0b0889ab 100644 --- a/sidebars.ts +++ b/sidebars.ts @@ -1,7 +1,7 @@ -import type {SidebarsConfig} from '@docusaurus/plugin-content-docs' +import type { SidebarsConfig } from '@docusaurus/plugin-content-docs' const sidebars: SidebarsConfig = { - main: [{type: 'autogenerated', dirName: '.'}], -}; + main: [{ type: 'autogenerated', dirName: '.' }], +} export default sidebars diff --git a/src/components/AsmDB/antdDecodeTreeAdapter.tsx b/src/components/AsmDB/antdDecodeTreeAdapter.tsx index c0a8acae..72bbc595 100644 --- a/src/components/AsmDB/antdDecodeTreeAdapter.tsx +++ b/src/components/AsmDB/antdDecodeTreeAdapter.tsx @@ -1,11 +1,14 @@ -import { Tag, type TreeDataNode } from "antd" +import { Tag, type TreeDataNode } from 'antd' import { CheckOutlined, EyeOutlined } from '@ant-design/icons' import _ from 'lodash' import styles from './index.module.css' -import { type AugmentedDecodeTreeMatch, type AugmentedDecodeTreeNode } from "./augmentedDecodeTree" -import { bitfieldWidth, representBitfields } from "./bitfield" -import type { Bitfield } from "./types" +import { + type AugmentedDecodeTreeMatch, + type AugmentedDecodeTreeNode, +} from './augmentedDecodeTree' +import { bitfieldWidth, representBitfields } from './bitfield' +import type { Bitfield } from './types' function representMatchValue(val: number, bfs: Bitfield[]): string { const sortedBFs = _.sortBy(_.clone(bfs), 'lsb') @@ -24,10 +27,8 @@ type NodeTitleProps = { node?: AugmentedDecodeTreeNode } - function NodeTitle({ match, node }: NodeTitleProps): JSX.Element { - if (!match) - match = node.parentMatch + if (!match) match = node.parentMatch const matchNumber = match ? match.match : 0 const matchPattern = node ? node.key : match.key @@ -40,57 +41,109 @@ function NodeTitle({ match, node }: NodeTitleProps): JSX.Element { const postAttribs: JSX.Element[] = [] if (match?.fmt) if (node) - postAttribs.push(并确定格式为 {match.fmt}) + postAttribs.push( + + 并确定格式为 {match.fmt} + , + ) else - postAttribs.push({match.fmt}) + postAttribs.push( + + {match.fmt} + , + ) if (alias) - preAttribs.push({alias}) + preAttribs.push( + + {alias} + , + ) if (insn) { - return <> - {representMatchValue(matchNumber, lookAt)}: {preAttribs}{insn} - {postAttribs} - + return ( + <> + + {representMatchValue(matchNumber, lookAt)}: {preAttribs} + {insn} + + {postAttribs} + + ) } const root = matchPattern == 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' if (root) - postAttribs.push(主操作码) + postAttribs.push( + + 主操作码 + , + ) if (node) { const numAllocatedPrefixes = node.matches.length const numTotalPrefixes = 1 << bitfieldWidth(node.look_at) - if (numAllocatedPrefixes == numTotalPrefixes && node.numUsedInsnWords == node.numTotalInsnWords) { - postAttribs.push(子空间已满) + if ( + numAllocatedPrefixes == numTotalPrefixes && + node.numUsedInsnWords == node.numTotalInsnWords + ) { + postAttribs.push( + + 子空间已满 + , + ) } else { if (numAllocatedPrefixes == numTotalPrefixes) - postAttribs.push(子前缀空间已满) + postAttribs.push( + + 子前缀空间已满 + , + ) else - postAttribs.push(子前缀空间 {numAllocatedPrefixes}/{numTotalPrefixes}) + postAttribs.push( + + 子前缀空间 {numAllocatedPrefixes}/{numTotalPrefixes} + , + ) if (node.numUsedInsnWords == node.numTotalInsnWords) - postAttribs.push(子编码空间已满) + postAttribs.push( + + 子编码空间已满 + , + ) else - postAttribs.push(子编码空间已用 {(node.numUsedInsnWords / node.numTotalInsnWords * 100).toFixed(2)}%) + postAttribs.push( + + 子编码空间已用{' '} + {((node.numUsedInsnWords / node.numTotalInsnWords) * 100).toFixed( + 2, + )} + % + , + ) } } if (root) - return <> - 检查 [{representBitfields(lookAt)}] 位 + return ( + <> + 检查 [{representBitfields(lookAt)}] 位 + {postAttribs} + + ) + + return ( + <> + + {representMatchValue(matchNumber, parentLookAt)}: {preAttribs}检查 [ + {representBitfields(lookAt)}] 位 + {postAttribs} - - return <> - {representMatchValue(matchNumber, parentLookAt)}: {preAttribs}检查 [{representBitfields(lookAt)}] 位 - {postAttribs} - + ) } -function makeMatchNode( - m: AugmentedDecodeTreeMatch, -): TreeDataNode { - if (m.next) - return transformDecodeTreeForAntd(m.next) +function makeMatchNode(m: AugmentedDecodeTreeMatch): TreeDataNode { + if (m.next) return transformDecodeTreeForAntd(m.next) return { title: , diff --git a/src/components/AsmDB/augmentedDecodeTree.tsx b/src/components/AsmDB/augmentedDecodeTree.tsx index 90e6a385..454a0c92 100644 --- a/src/components/AsmDB/augmentedDecodeTree.tsx +++ b/src/components/AsmDB/augmentedDecodeTree.tsx @@ -1,6 +1,11 @@ import _ from 'lodash' -import { bitfieldWidth, bitfieldsToMask, mergeBitfields, restoreIntoBitfields } from './bitfield' +import { + bitfieldWidth, + bitfieldsToMask, + mergeBitfields, + restoreIntoBitfields, +} from './bitfield' import type { Bitfield, DecodeTreeMatch, DecodeTreeNode } from './types' const wellKnownMatchPatterns = { @@ -42,8 +47,7 @@ function makeMatchPatternKey(match: number, bfs: Bitfield[]): string { s.reverse() let y = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'.split('') for (const bf of bfs) - for (let i = bf.lsb; i < bf.lsb + bf.len; i++) - y[i] = s[i] + for (let i = bf.lsb; i < bf.lsb + bf.len; i++) y[i] = s[i] y.reverse() return y.join('') } @@ -72,7 +76,9 @@ export type AugmentedDecodeTreeNode = DecodeTreeNode & { possibleFmts: string[] } -export function augmentDecodeTree(node: DecodeTreeNode): AugmentedDecodeTreeNode { +export function augmentDecodeTree( + node: DecodeTreeNode, +): AugmentedDecodeTreeNode { let x = _.cloneDeep(node) as AugmentedDecodeTreeNode augmentDecodeTreeInplace(x, null, 0, []) return x @@ -89,8 +95,7 @@ function augmentDecodeTreeInplace( if (matchBitfieldsSoFar.length == 0) // 1 << 32 = 1... node.numTotalInsnWords = 0x100000000 - else - node.numTotalInsnWords = 1 << (32 - bitfieldWidth(matchBitfieldsSoFar)) + else node.numTotalInsnWords = 1 << (32 - bitfieldWidth(matchBitfieldsSoFar)) node.numUsedInsnWords = 0 @@ -145,20 +150,28 @@ function makeFlattenedAugmentedNode( } } -function flattenAugmentedDecodeTreeInto(node: AugmentedDecodeTreeNode, result: FlattenedAugmentedNode[]): void { +function flattenAugmentedDecodeTreeInto( + node: AugmentedDecodeTreeNode, + result: FlattenedAugmentedNode[], +): void { result.push(makeFlattenedAugmentedNode(node, null)) - result.push(...(_.map(node.matches, (x) => makeFlattenedAugmentedNode(null, x)))) + result.push( + ..._.map(node.matches, (x) => makeFlattenedAugmentedNode(null, x)), + ) for (const m of node.matches) - if (m.next) - flattenAugmentedDecodeTreeInto(m.next, result) + if (m.next) flattenAugmentedDecodeTreeInto(m.next, result) } -function flattenAugmentedDecodeTree(node: AugmentedDecodeTreeNode): FlattenedAugmentedNode[] { +function flattenAugmentedDecodeTree( + node: AugmentedDecodeTreeNode, +): FlattenedAugmentedNode[] { const result = [] flattenAugmentedDecodeTreeInto(node, result) return result } -export function mapifyAugmentedDecodeTree(node: AugmentedDecodeTreeNode): AugmentedNodeMap { +export function mapifyAugmentedDecodeTree( + node: AugmentedDecodeTreeNode, +): AugmentedNodeMap { return _.keyBy(flattenAugmentedDecodeTree(node), 'key') } diff --git a/src/components/AsmDB/bitfield.ts b/src/components/AsmDB/bitfield.ts index 5672e61d..f943364e 100644 --- a/src/components/AsmDB/bitfield.ts +++ b/src/components/AsmDB/bitfield.ts @@ -7,8 +7,7 @@ function representBitfield(bf: Bitfield): string { } export function representBitfields(bfs: Bitfield[]): string { - if (bfs.length == 1) - return representBitfield(bfs[0]) + if (bfs.length == 1) return representBitfield(bfs[0]) return _.map(_.reverse(_.cloneDeep(bfs)), representBitfield).join(',') } @@ -18,8 +17,7 @@ export function bitfieldWidth(bfs: Bitfield[]): number { export function mergeBitfields(a: Bitfield[], b: Bitfield[]): Bitfield[] { const tmp = _.sortBy(_.concat(_.cloneDeep(a), ..._.cloneDeep(b)), 'lsb') - if (tmp.length < 2) - return tmp + if (tmp.length < 2) return tmp for (let i = 1; i < tmp.length; i++) { if (tmp[i].lsb == tmp[i - 1].lsb + tmp[i - 1].len) { @@ -45,6 +43,6 @@ export function restoreIntoBitfields(num: number, bfs: Bitfield[]): number { export function bitfieldsToMask(bfs: Bitfield[]): number { let mask = 0 for (const bf of bfs) - mask |= (bf.len == 32 ? 0xffffffff : ((1 << bf.len) - 1)) << bf.lsb + mask |= (bf.len == 32 ? 0xffffffff : (1 << bf.len) - 1) << bf.lsb return mask } diff --git a/src/components/AsmDB/bits.tsx b/src/components/AsmDB/bits.tsx index cc2996d2..f2f687c7 100644 --- a/src/components/AsmDB/bits.tsx +++ b/src/components/AsmDB/bits.tsx @@ -27,21 +27,24 @@ type BitProps = { function littleEndianBitsFromU32(x: number): (0 | 1)[] { const y = new Array<0 | 1>(32) for (let i = 0; i < 32; i++) { - y[i] = (x & (1 << i)) ? 1 : 0 + y[i] = x & (1 << i) ? 1 : 0 } return y } -const Bit: React.FC> = (props) => { +const Bit: React.FC> = ( + props, +) => { const classNames = [props.className, styles.bit] - if (props.isEmphasized) - classNames.push(styles.bitEmph) - return { - props.isFixed ? props.value : props.placeholder - } + if (props.isEmphasized) classNames.push(styles.bitEmph) + return ( + + {props.isFixed ? props.value : props.placeholder} + + ) } function placeholderForBit( @@ -49,10 +52,8 @@ function placeholderForBit( isFixed: boolean, isBeingChecked: boolean, ): string | JSX.Element { - if (isFixed) - return null - if (hasFmt) - return '' + if (isFixed) return null + if (hasFmt) return '' return isBeingChecked ? : 'x' } @@ -148,7 +149,9 @@ export type BitsReprProps = { fmt?: InsnFormat } -export const BitsRepr: React.FC> = (props) => { +export const BitsRepr: React.FC< + BitsReprProps & React.HTMLAttributes +> = (props) => { const cookedBits = cookBits( props.word, props.mask, @@ -156,9 +159,13 @@ export const BitsRepr: React.FC - {cookedBits.map((b, i) => ())} - + return ( +
+ {cookedBits.map((b, i) => ( + + ))} +
+ ) } export function InsnBitsRepr(props: BitsOptions): JSX.Element { @@ -166,29 +173,50 @@ export function InsnBitsRepr(props: BitsOptions): JSX.Element { if (props.useManualSyntax) { const mfn = getManualInsnFormatName(props.insn) if (mfn == '') { - insnFormatDesc = + insnFormatDesc = ( + + ) } else { - insnFormatDesc = + insnFormatDesc = ( + + ) } } else { let mfnDesc = <> if (props.insn.manual_format && props.insn.manual_format.repr != '') { - mfnDesc = + mfnDesc = ( + + ) } - insnFormatDesc = <> - - {mfnDesc} - + insnFormatDesc = ( + <> + + {mfnDesc} + + ) } return (
- + {insnFormatDesc}
= 0x{props.insn.word.toString(16).padStart(8, '0')}
- ); + ) } diff --git a/src/components/AsmDB/encodingSpaceOverviewPage.tsx b/src/components/AsmDB/encodingSpaceOverviewPage.tsx index 07f926d1..f2556f47 100644 --- a/src/components/AsmDB/encodingSpaceOverviewPage.tsx +++ b/src/components/AsmDB/encodingSpaceOverviewPage.tsx @@ -4,7 +4,11 @@ import { useState } from 'react' import styles from './index.module.css' import { transformDecodeTreeForAntd } from './antdDecodeTreeAdapter' -import { augmentDecodeTree, mapifyAugmentedDecodeTree, type AugmentedNodeMap } from './augmentedDecodeTree' +import { + augmentDecodeTree, + mapifyAugmentedDecodeTree, + type AugmentedNodeMap, +} from './augmentedDecodeTree' import { bitfieldWidth, bitfieldsToMask } from './bitfield' import { BitsRepr } from './bits' import { parseInsnFormat } from './insnFormat' @@ -13,8 +17,7 @@ import type { AsmDBData, DecodeTreeNode } from './types' const { useBreakpoint } = Grid function decodeTreeDepth(node: DecodeTreeNode): number { - if (!node) - return 0 + if (!node) return 0 return 1 + _.max(_.map(node.matches, (x) => decodeTreeDepth(x.next))) } @@ -24,21 +27,25 @@ type DecodeTreeViewProps = { onMatchKeyChange?: (newVal: string) => void } -const DecodeTreeView: React.FC> = (props) => { +const DecodeTreeView: React.FC< + DecodeTreeViewProps & React.HTMLAttributes +> = (props) => { let onSelect = null if (props.onMatchKeyChange) onSelect = (sk: string[]) => props.onMatchKeyChange(sk[0]) - return + return ( + + ) } type DecodeTreeNodeDetailProps = { @@ -46,12 +53,16 @@ type DecodeTreeNodeDetailProps = { selectedKey: string } -const DecodeTreeNodeDetail: React.FC> = (props) => { +const DecodeTreeNodeDetail: React.FC< + DecodeTreeNodeDetailProps & React.HTMLAttributes +> = (props) => { if (!props.data.hasOwnProperty(props.selectedKey)) - return <> -

编码空间明细

-

在译码决策树中选择一个节点,以查看其详细信息。

- + return ( + <> +

编码空间明细

+

在译码决策树中选择一个节点,以查看其详细信息。

+ + ) const vertMargin = { marginTop: 16 } @@ -60,122 +71,287 @@ const DecodeTreeNodeDetail: React.FC -

{m.matched}

- - - - - - - - - - + return ( + <> +

{m.matched}

+ + + + + + + + + + + + + + + + + + + ) } // (sub)space const n = selectedNode.node const root = props.selectedKey == 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' const title = root ? '根编码空间' : '子编码空间' - const allocationRatio = n.numUsedInsnWords / n.numTotalInsnWords * 100 - const subspaceUsageRatio = root ? 1 : n.numTotalInsnWords / n.parentMatch.parentNode.numTotalInsnWords * 100 - const universeUsageRatio = root ? 1 : n.numTotalInsnWords / 0x100000000 * 1000 - const universeUsageRatioText = universeUsageRatio < 0.001 ? '< 0.001' : universeUsageRatio.toFixed(3).toString() + const allocationRatio = (n.numUsedInsnWords / n.numTotalInsnWords) * 100 + const subspaceUsageRatio = root + ? 1 + : (n.numTotalInsnWords / n.parentMatch.parentNode.numTotalInsnWords) * 100 + const universeUsageRatio = root + ? 1 + : (n.numTotalInsnWords / 0x100000000) * 1000 + const universeUsageRatioText = + universeUsageRatio < 0.001 + ? '< 0.001' + : universeUsageRatio.toFixed(3).toString() const numAllocatedPrefixes = n.matches.length const numTotalPrefixes = 1 << bitfieldWidth(n.look_at) let spaceUsageRatios = <> if (!root) - spaceUsageRatios = - - - + spaceUsageRatios = ( + + + + + + + + + ) let insnFmtDisplay - if (n.possibleFmts.length == 1) - insnFmtDisplay = n.possibleFmts[0] + if (n.possibleFmts.length == 1) insnFmtDisplay = n.possibleFmts[0] else if (n.possibleFmts.length < 50) - insnFmtDisplay = <> - {_.map(n.possibleFmts, (x) => {x})} + insnFmtDisplay = ( + <> + {_.map(n.possibleFmts, (x) => ( + {x} + ))} + + ) + else insnFmtDisplay = `${n.possibleFmts.length} 种` + + return ( + <> +

{title}

+ + + + + + + + + + {spaceUsageRatios} + + + + + + + + + + + + {/* https://github.com/ant-design/ant-design/issues/43830 */} + insnFmtDisplay} + style={vertMargin} + /> - else - insnFmtDisplay = `${n.possibleFmts.length} 种` - - return <> -

{title}

- - - - - - {spaceUsageRatios} - - - - - - {/* https://github.com/ant-design/ant-design/issues/43830 */} - insnFmtDisplay} style={vertMargin} /> - + ) } -export default function EncodingSpaceOverviewPage({ data }: { data: AsmDBData }): JSX.Element { +export default function EncodingSpaceOverviewPage({ + data, +}: { + data: AsmDBData +}): JSX.Element { const numInsns = data.insns.length const augmentedDecodeTree = augmentDecodeTree(data.decodetree) const augmentedDataMap = mapifyAugmentedDecodeTree(augmentedDecodeTree) const antdNode = transformDecodeTreeForAntd(augmentedDecodeTree) const depth = decodeTreeDepth(data.decodetree) const numAllocatedOpcodes = data.decodetree.matches.length - const numFirstPartyOpcodes = _.filter(data.decodetree.matches, (x) => x.match <= 0b011111).length - const numUnifiedExtOpcodes = _.filter(data.decodetree.matches, (x) => x.match >= 0b100000 && x.match <= 0b101111).length + const numFirstPartyOpcodes = _.filter( + data.decodetree.matches, + (x) => x.match <= 0b011111, + ).length + const numUnifiedExtOpcodes = _.filter( + data.decodetree.matches, + (x) => x.match >= 0b100000 && x.match <= 0b101111, + ).length const numInsnFormats = _.uniq(_.map(data.insns, (x) => x.format.repr)).length - const allocationRatio = augmentedDecodeTree.numUsedInsnWords / augmentedDecodeTree.numTotalInsnWords * 100 + const allocationRatio = + (augmentedDecodeTree.numUsedInsnWords / + augmentedDecodeTree.numTotalInsnWords) * + 100 // HACK: we know all insns are 1st-party so far, so no need to really filter anything - const firstPartyAllocationRatio = augmentedDecodeTree.numUsedInsnWords / 0x80000000 * 100 + const firstPartyAllocationRatio = + (augmentedDecodeTree.numUsedInsnWords / 0x80000000) * 100 const screens = useBreakpoint() - const [selectedMatchKey, setSelectedMatchKey] = useState('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx') - - return <> - - - - - - - - - - - - - - - - - - - - - - - - - - - + const [selectedMatchKey, setSelectedMatchKey] = useState( + 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', + ) + + return ( + <> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ) } diff --git a/src/components/AsmDB/index.module.css b/src/components/AsmDB/index.module.css index a9bb1e42..e0478343 100644 --- a/src/components/AsmDB/index.module.css +++ b/src/components/AsmDB/index.module.css @@ -24,7 +24,7 @@ .aliasTagAttrib, .insnFmtTagAttrib { - font-size: 14px; /* should follow default style of tree node titles */ + font-size: 14px; /* should follow default style of tree node titles */ line-height: 20px; } diff --git a/src/components/AsmDB/index.tsx b/src/components/AsmDB/index.tsx index e7c1f375..db341471 100644 --- a/src/components/AsmDB/index.tsx +++ b/src/components/AsmDB/index.tsx @@ -14,21 +14,21 @@ export default function AsmDBPage({ data }: { data: AsmDBData }): JSX.Element { const { path, url } = useRouteMatch() const sideNavItems: MenuProps['items'] = [ { - key: "encodingSpaceOverview", + key: 'encodingSpaceOverview', label: 编码空间总览, }, { - key: "insnList", + key: 'insnList', disabled: true, label: '指令列表(开发中)', }, { - key: "insnExplainer", + key: 'insnExplainer', disabled: true, label: '解读指令字(开发中)', }, { - key: "vldiHelper", + key: 'vldiHelper', label: VLDI 辅助, }, ] @@ -38,7 +38,7 @@ export default function AsmDBPage({ data }: { data: AsmDBData }): JSX.Element { {/* TODO: fixed sidebar */} - + = (1 << (width - 1)) ? imm - (1 << width) : imm, uimm: imm} +function makeSImmAndUImm( + signed: boolean, + width: number, + imm: number, +): SImmAndUImm { + if (signed) return { simm: imm, uimm: imm < 0 ? (1 << width) + imm : imm } + return { simm: imm >= 1 << (width - 1) ? imm - (1 << width) : imm, uimm: imm } } type InputImmProps = { @@ -21,12 +24,13 @@ type InputImmProps = { } function deriveValueDomain(signed: boolean, width: number): [number, number] { - if (signed) - return [-(1 << (width - 1)), (1 << (width - 1)) - 1] + if (signed) return [-(1 << (width - 1)), (1 << (width - 1)) - 1] return [0, (1 << width) - 1] } -export const InputImm: React.FC> = (props) => { +export const InputImm: React.FC< + InputImmProps & React.HTMLAttributes +> = (props) => { const [min, max] = deriveValueDomain(props.signed, props.bitWidth) const prompt = `${min} - ${max}` @@ -38,13 +42,18 @@ export const InputImm: React.FC - {/* the span seems required, Tooltip will crash otherwise */} - - - - + return ( + + {/* the span seems required, Tooltip will crash otherwise */} + + + + + ) } diff --git a/src/components/AsmDB/inputMinifloat.tsx b/src/components/AsmDB/inputMinifloat.tsx index a1f6a8cb..55147464 100644 --- a/src/components/AsmDB/inputMinifloat.tsx +++ b/src/components/AsmDB/inputMinifloat.tsx @@ -1,8 +1,8 @@ -import { InputNumber, Select, Tooltip } from "antd" -import { useState } from "react" +import { InputNumber, Select, Tooltip } from 'antd' +import { useState } from 'react' -import { reprFloatDetailingZeroStatus } from "./insn" -import { MinifloatFormat } from "./minifloat" +import { reprFloatDetailingZeroStatus } from './insn' +import { MinifloatFormat } from './minifloat' export type MinifloatValueEvent = { value: number @@ -16,23 +16,23 @@ type InputMinifloatProps = { onMinifloatValueChange?: (newVal: MinifloatValueEvent) => void } -export const InputMinifloat: React.FC> = (props) => { +export const InputMinifloat: React.FC< + InputMinifloatProps & React.HTMLAttributes +> = (props) => { const [bitRepr, setBitRepr] = useState(props.bitRepr ?? 0) - const { - neg, - isZero, - apparentExp, - unbiasedExp, - mantissa, - apparentMantissa, - } = props.fmt.decompose(bitRepr) + const { neg, isZero, apparentExp, unbiasedExp, mantissa, apparentMantissa } = + props.fmt.decompose(bitRepr) const signalChangeEvent = (bitRepr: number) => { - props.onMinifloatValueChange?.({value: props.fmt.asNumber(bitRepr), bitRepr}) + props.onMinifloatValueChange?.({ + value: props.fmt.asNumber(bitRepr), + bitRepr, + }) } const minApparentMantissa = props.fmt.implicitMantissaOffset - const maxApparentMantissa = props.fmt.maxMantissa + props.fmt.implicitMantissaOffset + const maxApparentMantissa = + props.fmt.maxMantissa + props.fmt.implicitMantissaOffset const fromApparentMantissa = (apparent: number): number => { return apparent - props.fmt.implicitMantissaOffset @@ -43,12 +43,13 @@ export const InputMinifloat: React.FC { - inputState = typeof inputState == "string" ? parseInt(inputState, 10) : inputState + inputState = + typeof inputState == 'string' ? parseInt(inputState, 10) : inputState return toApparentMantissa(inputState).toString(10) } const inputStateMantissaParser = (apparent: string): number => { - return fromApparentMantissa(parseInt(apparent ?? "0", 10)) + return fromApparentMantissa(parseInt(apparent ?? '0', 10)) } const inputStateMantissa = fromApparentMantissa(apparentMantissa) @@ -62,14 +63,17 @@ export const InputMinifloat: React.FC - + - - - + const signSelect = ( + + ) const onInputStateMantissaChange = (val: number | null) => { val = val ?? 0 - const newMantissa = toApparentMantissa(val) - props.fmt.implicitMantissaOffset + const newMantissa = + toApparentMantissa(val) - props.fmt.implicitMantissaOffset const newBitRepr = props.fmt.composeUnbiased(neg, unbiasedExp, newMantissa) setBitRepr(newBitRepr) signalChangeEvent(newBitRepr) @@ -83,41 +87,58 @@ export const InputMinifloat: React.FC - - - - - - const expInput = - - - - - - const equalOrRepresentsSign = isZero ? "表示" : "=" + const mantissaInput = ( + + + + + + ) + + const expInput = ( + + + + + + ) + + const equalOrRepresentsSign = isZero ? '表示' : '=' const numRepr = reprFloatDetailingZeroStatus(props.fmt.asNumber(bitRepr)) - const zeroNotes = props.fmt.supportsZero ? <> -
- 注意:如此处显示的有效数字为 {props.fmt.implicitMantissaOffset} 且指数为 {props.fmt.expBias + props.fmt.apparentExpBiasDelta},则表示 ±0。 - : <> - - return <> - {mantissaInput} × pow(2, {expInput}) {equalOrRepresentsSign} {numRepr} -
迷你浮点数格式:符号 1 位 + 指数 {props.fmt.expWidth} 位 (偏置 {props.fmt.expBias}) + 尾数 {props.fmt.mantissaWidth} 位。{props.fmt.supportsZero ? "支持" : "不支持"}表示零值。 - {zeroNotes} - + const zeroNotes = props.fmt.supportsZero ? ( + <> +
+ 注意:如此处显示的有效数字为 { + props.fmt.implicitMantissaOffset + } 且指数为 {props.fmt.expBias + props.fmt.apparentExpBiasDelta},则表示 + ±0。 + + ) : ( + <> + ) + + return ( + <> + {mantissaInput} × pow(2, {expInput}) {equalOrRepresentsSign}{' '} + {numRepr} +
+ 迷你浮点数格式:符号 1 位 + 指数 {props.fmt.expWidth} 位 (偏置{' '} + {props.fmt.expBias}) + 尾数 {props.fmt.mantissaWidth} 位。 + {props.fmt.supportsZero ? '支持' : '不支持'}表示零值。 + {zeroNotes} + + ) } diff --git a/src/components/AsmDB/insn.ts b/src/components/AsmDB/insn.ts index f6604b0f..f69dc82a 100644 --- a/src/components/AsmDB/insn.ts +++ b/src/components/AsmDB/insn.ts @@ -9,15 +9,14 @@ export function getInsnMnemonic(insn: Insn, useManualSyntax: boolean): string { export function toSImm(uimm: number, width: number): number export function toSImm(uimm: bigint, width: number): bigint export function toSImm(uimm: number | bigint, width: number): number | bigint { - if (typeof uimm == "bigint") - return BigInt.asIntN(width, uimm) + if (typeof uimm == 'bigint') return BigInt.asIntN(width, uimm) return Number(BigInt.asIntN(width, BigInt(uimm))) } export function toUImm(simm: number, width: number): bigint export function toUImm(simm: bigint, width: number): bigint export function toUImm(simm: number | bigint, width: number): bigint { - return BigInt.asUintN(width, typeof simm == "bigint" ? simm : BigInt(simm)) + return BigInt.asUintN(width, typeof simm == 'bigint' ? simm : BigInt(simm)) } export function toCHexLiteral(x: number | bigint): string { @@ -25,9 +24,7 @@ export function toCHexLiteral(x: number | bigint): string { } export function reprFloatDetailingZeroStatus(n: number): string { - if (Object.is(n, -0.0)) - return "-0" - if (Object.is(n, 0.0)) - return "0" + if (Object.is(n, -0.0)) return '-0' + if (Object.is(n, 0.0)) return '0' return n.toString() } diff --git a/src/components/AsmDB/insnExplainerPage.tsx b/src/components/AsmDB/insnExplainerPage.tsx index 8033ed4b..a0ee6f67 100644 --- a/src/components/AsmDB/insnExplainerPage.tsx +++ b/src/components/AsmDB/insnExplainerPage.tsx @@ -1,5 +1,9 @@ -import type { AsmDBData } from "./types" +import type { AsmDBData } from './types' -export default function InsnExplainerPage({ data }: { data: AsmDBData }): JSX.Element { +export default function InsnExplainerPage({ + data, +}: { + data: AsmDBData +}): JSX.Element { return

TODO

} diff --git a/src/components/AsmDB/insnFormat.ts b/src/components/AsmDB/insnFormat.ts index 4b30d451..842e59c2 100644 --- a/src/components/AsmDB/insnFormat.ts +++ b/src/components/AsmDB/insnFormat.ts @@ -1,14 +1,13 @@ -import _ from "lodash" +import _ from 'lodash' -import { ArgKind, type ArgSlot, type InsnArg, type InsnFormat } from "./types" +import { ArgKind, type ArgSlot, type InsnArg, type InsnFormat } from './types' export function isImmArg(a: InsnArg): boolean { return a.kind == ArgKind.SignedImm || a.kind == ArgKind.UnsignedImm } export function parseInsnFormat(s: string): InsnFormat { - if (s == 'EMPTY') - return { repr: s, args: [] } + if (s == 'EMPTY') return { repr: s, args: [] } const origInput = s const args: InsnArg[] = [] @@ -28,7 +27,7 @@ export function parseInsnFormat(s: string): InsnFormat { } } -function parseInsnArg(s: string): { remaining: string, arg: InsnArg } { +function parseInsnArg(s: string): { remaining: string; arg: InsnArg } { const fail = { remaining: s, arg: null } if (s.length == 0) // malformed input @@ -83,37 +82,37 @@ function parseInsnArg(s: string): { remaining: string, arg: InsnArg } { } const prefixKindMap = { - 'D': ArgKind.IntReg, - 'J': ArgKind.IntReg, - 'K': ArgKind.IntReg, - 'A': ArgKind.IntReg, - 'C': ArgKind.FCCReg, - 'F': ArgKind.FPReg, - 'T': ArgKind.ScratchReg, - 'V': ArgKind.VReg, - 'X': ArgKind.XReg, - 'S': ArgKind.SignedImm, - 'U': ArgKind.UnsignedImm, + D: ArgKind.IntReg, + J: ArgKind.IntReg, + K: ArgKind.IntReg, + A: ArgKind.IntReg, + C: ArgKind.FCCReg, + F: ArgKind.FPReg, + T: ArgKind.ScratchReg, + V: ArgKind.VReg, + X: ArgKind.XReg, + S: ArgKind.SignedImm, + U: ArgKind.UnsignedImm, } const regWidthMap = { - 'C': 3, - 'F': 5, - 'T': 2, - 'V': 5, - 'X': 5, + C: 3, + F: 5, + T: 2, + V: 5, + X: 5, } const lsbMap = { - 'd': 0, - 'j': 5, - 'k': 10, - 'a': 15, - 'm': 16, - 'n': 18, + d: 0, + j: 5, + k: 10, + a: 15, + m: 16, + n: 18, } -function parseArgSlots(s: string): { remaining: string, slots: ArgSlot[] } { +function parseArgSlots(s: string): { remaining: string; slots: ArgSlot[] } { const fail = { remaining: s, slots: null } if (s.length == 0) // malformed input @@ -121,11 +120,9 @@ function parseArgSlots(s: string): { remaining: string, slots: ArgSlot[] } { const slots: ArgSlot[] = [] while (s) { - const {remaining, finish, slot} = parseArgSlot(s) - if (finish) - break - if (!slot) - return fail + const { remaining, finish, slot } = parseArgSlot(s) + if (finish) break + if (!slot) return fail slots.push(slot) s = remaining } @@ -136,7 +133,11 @@ function parseArgSlots(s: string): { remaining: string, slots: ArgSlot[] } { } } -function parseArgSlot(s: string): { remaining: string, finish: boolean, slot?: ArgSlot } { +function parseArgSlot(s: string): { + remaining: string + finish: boolean + slot?: ArgSlot +} { const fail = { remaining: s, finish: false, slot: null } if (s.length == 0) // malformed input @@ -171,6 +172,6 @@ function parseArgSlot(s: string): { remaining: string, finish: boolean, slot?: A repr: s.slice(0, totalConsumed), offset: lsb, width, - } + }, } } diff --git a/src/components/AsmDB/insnFormatName.tsx b/src/components/AsmDB/insnFormatName.tsx index 1eddfd4d..7241b198 100644 --- a/src/components/AsmDB/insnFormatName.tsx +++ b/src/components/AsmDB/insnFormatName.tsx @@ -10,12 +10,18 @@ type InsnFormatNameOptions = { className?: string } -export default function InsnFormatName(props: InsnFormatNameOptions): JSX.Element { +export default function InsnFormatName( + props: InsnFormatNameOptions, +): JSX.Element { return ( - {props.overrideStr !== undefined ? props.overrideStr : props.fmt.args.map((x, argIdx) => ( - {x.repr} - ))} + {props.overrideStr !== undefined + ? props.overrideStr + : props.fmt.args.map((x, argIdx) => ( + + {x.repr} + + ))} ) } diff --git a/src/components/AsmDB/insnListPage.tsx b/src/components/AsmDB/insnListPage.tsx index 1fefdbf5..d8ac33c2 100644 --- a/src/components/AsmDB/insnListPage.tsx +++ b/src/components/AsmDB/insnListPage.tsx @@ -7,26 +7,36 @@ import { getInsnMnemonic } from './insn' import type { AsmDBData, Insn, SubsetFlags } from './types' function Subsets({ ss }: { ss: SubsetFlags }): JSX.Element { - if (ss.provisional) - return ( -

非正式指令

- ) + if (ss.provisional) return

非正式指令

return (

见于: - LA32 Primary, - LA32, - LA64, - LSX, - LASX, - LBT, - LVZ + + LA32 Primary, + + LA32, + + LA64, + + LSX, + + LASX, + + LBT, + + LVZ

) } -function AsmDBInsn({ insn, useManualSyntax }: { insn: Insn, useManualSyntax: boolean }): JSX.Element { +function AsmDBInsn({ + insn, + useManualSyntax, +}: { + insn: Insn + useManualSyntax: boolean +}): JSX.Element { return (

{getInsnMnemonic(insn, useManualSyntax)}

@@ -44,38 +54,46 @@ type AsmDBOptions = { function subsetFlagsToBitmask(x: SubsetFlags): number { let y = 0 - if (x.primary) - y |= 0b1 - if (x.la32) - y |= 0b10 - if (x.la64) - y |= 0b100 - if (x.lsx) - y |= 0b1000 - if (x.lasx) - y |= 0b10000 - if (x.lbt) - y |= 0b100000 - if (x.lvz) - y |= 0b1000000 - if (x.provisional) - y |= 0b10000000 + if (x.primary) y |= 0b1 + if (x.la32) y |= 0b10 + if (x.la64) y |= 0b100 + if (x.lsx) y |= 0b1000 + if (x.lasx) y |= 0b10000 + if (x.lbt) y |= 0b100000 + if (x.lvz) y |= 0b1000000 + if (x.provisional) y |= 0b10000000 return y } -function InsnList({ data, useManualSyntax, showSubset }: AsmDBOptions): JSX.Element { - const insnAndKeys = data.insns.map((x, i) => { return { insn: x, key: i } }) +function InsnList({ + data, + useManualSyntax, + showSubset, +}: AsmDBOptions): JSX.Element { + const insnAndKeys = data.insns.map((x, i) => { + return { insn: x, key: i } + }) const showSubsetMask = subsetFlagsToBitmask(showSubset) - const shownInsns = insnAndKeys.filter((x) => (subsetFlagsToBitmask(x.insn.subsets) & showSubsetMask) != 0) + const shownInsns = insnAndKeys.filter( + (x) => (subsetFlagsToBitmask(x.insn.subsets) & showSubsetMask) != 0, + ) return (
    - {shownInsns.map((x) =>
  • )} + {shownInsns.map((x) => ( +
  • + +
  • + ))}
) } -export default function InsnListPage({ data }: { data: AsmDBData }): JSX.Element { +export default function InsnListPage({ + data, +}: { + data: AsmDBData +}): JSX.Element { const [useManualSyntax, setUseManualSyntax] = useState(false) const [ss, setSelectedSubset] = useState({ primary: false, @@ -105,29 +123,80 @@ export default function InsnListPage({ data }: { data: AsmDBData }): JSX.Element } const subsetsConfig = [ - { name: 'LA32 Primary', get: () => ss.primary, action: alterSS((ss, x) => { ss.primary = x }) }, - { name: 'LA32', get: () => ss.la32, action: alterSS((ss, x) => { ss.la32 = x }) }, - { name: 'LA64', get: () => ss.la64, action: alterSS((ss, x) => { ss.la64 = x }) }, - { name: 'LSX', get: () => ss.lsx, action: alterSS((ss, x) => { ss.lsx = x }) }, - { name: 'LASX', get: () => ss.lasx, action: alterSS((ss, x) => { ss.lasx = x }) }, - { name: 'LBT', get: () => ss.lbt, action: alterSS((ss, x) => { ss.lbt = x }) }, - { name: 'LVZ', get: () => ss.lvz, action: alterSS((ss, x) => { ss.lvz = x }) }, - { name: '非正式指令', get: () => ss.provisional, action: alterSS((ss, x) => { ss.provisional = x }) }, + { + name: 'LA32 Primary', + get: () => ss.primary, + action: alterSS((ss, x) => { + ss.primary = x + }), + }, + { + name: 'LA32', + get: () => ss.la32, + action: alterSS((ss, x) => { + ss.la32 = x + }), + }, + { + name: 'LA64', + get: () => ss.la64, + action: alterSS((ss, x) => { + ss.la64 = x + }), + }, + { + name: 'LSX', + get: () => ss.lsx, + action: alterSS((ss, x) => { + ss.lsx = x + }), + }, + { + name: 'LASX', + get: () => ss.lasx, + action: alterSS((ss, x) => { + ss.lasx = x + }), + }, + { + name: 'LBT', + get: () => ss.lbt, + action: alterSS((ss, x) => { + ss.lbt = x + }), + }, + { + name: 'LVZ', + get: () => ss.lvz, + action: alterSS((ss, x) => { + ss.lvz = x + }), + }, + { + name: '非正式指令', + get: () => ss.provisional, + action: alterSS((ss, x) => { + ss.provisional = x + }), + }, ] - return <> - 以龙芯官方指定的指令助记符、汇编语法展示下列内容
- - 要看哪些指令? - {subsetsConfig.map((cfg, i) => cfg.action(e.target.checked)}>{cfg.name})} - - - + return ( + <> + + 以龙芯官方指定的指令助记符、汇编语法展示下列内容 +
+ 要看哪些指令? + {subsetsConfig.map((cfg, i) => ( + cfg.action(e.target.checked)} + > + {cfg.name} + + ))} + + + ) } diff --git a/src/components/AsmDB/manualFormatNames.ts b/src/components/AsmDB/manualFormatNames.ts index c6e1294c..2823f295 100644 --- a/src/components/AsmDB/manualFormatNames.ts +++ b/src/components/AsmDB/manualFormatNames.ts @@ -1,9 +1,8 @@ -import type { Insn } from "./types" +import type { Insn } from './types' export function getManualInsnFormatName(insn: Insn): string { const a = getManualInsnFormatNameFromRepr(insn.format.repr) - if (a != '') - return a + if (a != '') return a // if the manual format matches, it also counts // in particular, a few insns (FCSR ops) need this @@ -15,61 +14,61 @@ export function getManualInsnFormatName(insn: Insn): string { function getManualInsnFormatNameFromRepr(fmtRepr: string): string { switch (fmtRepr) { - case 'CdFj': - case 'CdJ': - case 'CdVj': - case 'DCj': - case 'DJ': - case 'DFj': - case 'DVj': - case 'FdCj': - case 'FdFj': - case 'FdJ': - case 'VdVj': - case 'VdJ': - return '2R' + case 'CdFj': + case 'CdJ': + case 'CdVj': + case 'DCj': + case 'DJ': + case 'DFj': + case 'DVj': + case 'FdCj': + case 'FdFj': + case 'FdJ': + case 'VdVj': + case 'VdJ': + return '2R' - case 'CdFjFk': - case 'DJK': - case 'FdFjFk': - case 'FdJK': - case 'VdJK': - case 'VdVjVk': - return '3R' + case 'CdFjFk': + case 'DJK': + case 'FdFjFk': + case 'FdJK': + case 'VdJK': + case 'VdVjVk': + return '3R' - case 'FdFjFkCa': - case 'FdFjFkFa': - case 'VdVjVkCa': - case 'VdVjVkVa': - return '4R' + case 'FdFjFkCa': + case 'FdFjFkFa': + case 'VdVjVkCa': + case 'VdVjVkVa': + return '4R' - case 'DJUk8': - case 'VdVjUk8': - return '2RI8' + case 'DJUk8': + case 'VdVjUk8': + return '2RI8' - case 'DJSk12': - case 'DJUk12': - case 'FdJSk12': - case 'VdJSk12': - case 'XdJSk12': - return '2RI12' + case 'DJSk12': + case 'DJUk12': + case 'FdJSk12': + case 'VdJSk12': + case 'XdJSk12': + return '2RI12' - case 'DJSk14': - case 'DJUk14': - case 'FdJSk14': - return '2RI14' + case 'DJSk14': + case 'DJUk14': + case 'FdJSk14': + return '2RI14' - case 'DJSk16': - return '2RI16' + case 'DJSk16': + return '2RI16' - case 'JSd5k16': - case 'CjSd5k16': - return '1RI21' + case 'JSd5k16': + case 'CjSd5k16': + return '1RI21' - case 'Sd10k16': - return 'I26' + case 'Sd10k16': + return 'I26' - default: - return '' + default: + return '' } } diff --git a/src/components/AsmDB/minifloat.ts b/src/components/AsmDB/minifloat.ts index d73eca1a..af4b751b 100644 --- a/src/components/AsmDB/minifloat.ts +++ b/src/components/AsmDB/minifloat.ts @@ -1,13 +1,13 @@ -import { toSImm, toUImm } from "./insn" +import { toSImm, toUImm } from './insn' export type MinifloatComponents = { - neg: boolean, - isZero: boolean, - biasedExp: number, - unbiasedExp: number, - apparentExp: number, - mantissa: number, - apparentMantissa: number, + neg: boolean + isZero: boolean + biasedExp: number + unbiasedExp: number + apparentExp: number + mantissa: number + apparentMantissa: number } export class MinifloatFormat { @@ -68,12 +68,14 @@ export class MinifloatFormat { } asNumber(bitRepr: number): number { - const {mantissa, biasedExp, unbiasedExp, neg} = this.decompose(bitRepr) + const { mantissa, biasedExp, unbiasedExp, neg } = this.decompose(bitRepr) if (this.supportsZero && unbiasedExp == 0 && mantissa == 0) { return neg ? -0.0 : 0.0 } - const n = (this.implicitMantissaOffset | mantissa) * (2 ** (biasedExp + this.apparentExpBiasDelta)) + const n = + (this.implicitMantissaOffset | mantissa) * + 2 ** (biasedExp + this.apparentExpBiasDelta) return neg ? -n : n } @@ -85,20 +87,28 @@ export class MinifloatFormat { composeUnbiased(neg: boolean, unbiasedExp: number, mantissa: number): number { let x = mantissa & ((1 << this.mantissaWidth) - 1) x |= Number(toUImm(unbiasedExp, this.expWidth)) << this.mantissaWidth - if (neg) - x |= 1 << (this.mantissaWidth + this.expWidth) + if (neg) x |= 1 << (this.mantissaWidth + this.expWidth) return x } decompose(bitExpr: number): MinifloatComponents { const neg = (bitExpr & (1 << (this.mantissaWidth + this.expWidth))) != 0 const mantissa = bitExpr & ((1 << this.mantissaWidth) - 1) - const unbiasedExpUImm = (bitExpr >> this.mantissaWidth) & ((1 << this.expWidth) - 1) + const unbiasedExpUImm = + (bitExpr >> this.mantissaWidth) & ((1 << this.expWidth) - 1) const isZero = this.supportsZero && mantissa == 0 && unbiasedExpUImm == 0 const unbiasedExp = toSImm(unbiasedExpUImm, this.expWidth) const biasedExp = this.biasExp(unbiasedExp) const apparentExp = biasedExp + this.apparentExpBiasDelta const apparentMantissa = this.implicitMantissaOffset | mantissa - return {neg, isZero, biasedExp, unbiasedExp, apparentExp, mantissa, apparentMantissa} + return { + neg, + isZero, + biasedExp, + unbiasedExp, + apparentExp, + mantissa, + apparentMantissa, + } } } diff --git a/src/components/AsmDB/simd.ts b/src/components/AsmDB/simd.ts index d9c8e449..7cb36c35 100644 --- a/src/components/AsmDB/simd.ts +++ b/src/components/AsmDB/simd.ts @@ -18,15 +18,18 @@ export const vecElemWidthBits: { [key in VecElemType]: number } = { [VecElemType.F64]: 64, } - export function isFloatElemTy(x: VecElemType): boolean { return x == VecElemType.F32 || x == VecElemType.F64 } -export function makeVectorTypeForC(vlen: Vlen, elemTy: VecElemType, signed: boolean): string { +export function makeVectorTypeForC( + vlen: Vlen, + elemTy: VecElemType, + signed: boolean, +): string { // "vXiXX", "vXuXX" or "vXfXX" const elemWidthBits = vecElemWidthBits[elemTy] const numElems = vlen / elemWidthBits - const kind = isFloatElemTy(elemTy) ? "f" : signed ? "i" : "u" + const kind = isFloatElemTy(elemTy) ? 'f' : signed ? 'i' : 'u' return `v${numElems}${kind}${elemWidthBits}` } diff --git a/src/components/AsmDB/vldi.ts b/src/components/AsmDB/vldi.ts index b21bc49d..5ff66430 100644 --- a/src/components/AsmDB/vldi.ts +++ b/src/components/AsmDB/vldi.ts @@ -1,6 +1,11 @@ -import { reprFloatDetailingZeroStatus, toCHexLiteral, toSImm, toUImm } from "./insn" -import { MinifloatFormat } from "./minifloat" -import { isFloatElemTy, VecElemType, vecElemWidthBits, Vlen } from "./simd" +import { + reprFloatDetailingZeroStatus, + toCHexLiteral, + toSImm, + toUImm, +} from './insn' +import { MinifloatFormat } from './minifloat' +import { isFloatElemTy, VecElemType, vecElemWidthBits, Vlen } from './simd' export const VldiMinifloatFormat = new MinifloatFormat(3, 2, 4, false) @@ -55,15 +60,14 @@ export const elemTypesByVldiFunction: { [key in VldiFunction]: VecElemType } = { [VldiFunction.BroadcastVldiMinifloatToF64]: VecElemType.F64, } -const vldiImmWidth = 13 // {v,xv}ldi imm is Sj13 +const vldiImmWidth = 13 // {v,xv}ldi imm is Sj13 export function makeVldiSImm( f: VldiFunction, dataUImm: number, minifloatBitRepr: number, ): number { - if (isFloatElemTy(elemTypesByVldiFunction[f])) - dataUImm = minifloatBitRepr + if (isFloatElemTy(elemTypesByVldiFunction[f])) dataUImm = minifloatBitRepr const uimm = (f << 8) | dataUImm return toSImm(uimm, vldiImmWidth) @@ -73,8 +77,7 @@ export function decomposeVldiSimm(simm: number): [VldiFunction, number] { const uimm = Number(toUImm(simm, vldiImmWidth)) const imm12_10 = (uimm >> 10) & 0b111 - if (imm12_10 == 0b000) - return [VldiFunction.BroadcastU8To8, uimm & 0xff] + if (imm12_10 == 0b000) return [VldiFunction.BroadcastU8To8, uimm & 0xff] else if (imm12_10 == 0b001 || imm12_10 == 0b010 || imm12_10 == 0b011) return [imm12_10 << 2, toSImm(uimm & 0x3ff, 10)] @@ -88,14 +91,17 @@ export function decomposeVldiSimm(simm: number): [VldiFunction, number] { function expandU8BitsToU64(uimm: number): bigint { let result = 0n for (let i = 0n; i < 8; i++) { - if (uimm & 1) - result |= 0xffn << (i * 8n) + if (uimm & 1) result |= 0xffn << (i * 8n) uimm >>= 1 } return result } -function performVldi(vlen: Vlen, f: VldiFunction, param: number): number[] | bigint[] { +function performVldi( + vlen: Vlen, + f: VldiFunction, + param: number, +): number[] | bigint[] { const elemTy = elemTypesByVldiFunction[f] const numElems = vlen / vecElemWidthBits[elemTy] @@ -132,8 +138,7 @@ function performVldi(vlen: Vlen, f: VldiFunction, param: number): number[] | big case VldiFunction.BroadcastVldiMinifloatToEvenF32: const result = Array(numElems).fill(0.0) - for (let i = 0; i < numElems; i += 2) - result[i] = param + for (let i = 0; i < numElems; i += 2) result[i] = param return result } } @@ -148,24 +153,17 @@ export function demonstrateVldiEffectInC( let elems = performVldi(vlen, f, param) const isElemsSigned = isOutputElemsSigned(f) - const shouldConvertElemsToSImm = ( - !isFloatElemTy(elemTy) && - !isElemsSigned && - treatElemsAsSigned - ) - const shouldConvertElemsToUImm = ( - !isFloatElemTy(elemTy) && - isElemsSigned && - !treatElemsAsSigned - ) + const shouldConvertElemsToSImm = + !isFloatElemTy(elemTy) && !isElemsSigned && treatElemsAsSigned + const shouldConvertElemsToUImm = + !isFloatElemTy(elemTy) && isElemsSigned && !treatElemsAsSigned if (shouldConvertElemsToSImm) elems = elems.map((x) => toSImm(x, vecElemWidthBits[elemTy])) else if (shouldConvertElemsToUImm) elems = elems.map((x) => toUImm(x, vecElemWidthBits[elemTy])) const repr = (x: number | bigint): string => { - if (isFloatElemTy(elemTy)) - return reprFloatDetailingZeroStatus(x as number) + if (isFloatElemTy(elemTy)) return reprFloatDetailingZeroStatus(x as number) return toCHexLiteral(x) } diff --git a/src/components/AsmDB/vldiHelperPage.tsx b/src/components/AsmDB/vldiHelperPage.tsx index c1814d6c..245d5dc7 100644 --- a/src/components/AsmDB/vldiHelperPage.tsx +++ b/src/components/AsmDB/vldiHelperPage.tsx @@ -1,10 +1,10 @@ import { Card, Checkbox, Col, Radio, RadioChangeEvent, Row, Space } from 'antd' import { Dispatch, SetStateAction, useState } from 'react' -import _ from "lodash" +import _ from 'lodash' import { InputImm, SImmAndUImm } from './inputImm' import { toCHexLiteral } from './insn' -import { VecElemType, Vlen, makeVectorTypeForC } from "./simd" +import { VecElemType, Vlen, makeVectorTypeForC } from './simd' import { VldiFunction, VldiMinifloatFormat, @@ -21,7 +21,9 @@ type VlenSelectProps = { onVlenChange?: (newVal: Vlen) => void } -const VlenSelect: React.FC> = (props) => { +const VlenSelect: React.FC< + VlenSelectProps & React.HTMLAttributes +> = (props) => { const [vlen, setVlen] = useState(props.vlen) const onChange = (e: RadioChangeEvent) => { @@ -30,20 +32,23 @@ const VlenSelect: React.FC - 128 位 (LSX) - 256 位 (LASX) - + return ( + + 128 位 (LSX) + 256 位 (LASX) + + ) } - type ElementTypeSelectProps = { elemTy: VecElemType onElementTypeChange?: (newVal: VecElemType) => void } -const ElementTypeSelect: React.FC> = (props) => { +const ElementTypeSelect: React.FC< + ElementTypeSelectProps & React.HTMLAttributes +> = (props) => { const [elemTy, setElemTy] = useState(props.elemTy) const onChange = (e: RadioChangeEvent) => { @@ -52,63 +57,112 @@ const ElementTypeSelect: React.FC - I8 (char) - I16 (short) - I32 (int) - I64 (long) - F32 (float) - F64 (double) - + return ( + + I8 (char) + I16 (short) + I32 (int) + I64 (long) + F32 (float) + F64 (double) + + ) } - const availableVldiFunctionsByElemTy = [ { elemTy: VecElemType.I8, avail: [ - { f: VldiFunction.BroadcastU8To8, desc: "取 8 位整数,广播(形式一)" }, - { f: VldiFunction.BroadcastU8To8Alternate, desc: "取 8 位整数,广播(形式二,等价于形式一)" }, + { f: VldiFunction.BroadcastU8To8, desc: '取 8 位整数,广播(形式一)' }, + { + f: VldiFunction.BroadcastU8To8Alternate, + desc: '取 8 位整数,广播(形式二,等价于形式一)', + }, ], }, { elemTy: VecElemType.I16, avail: [ - { f: VldiFunction.BroadcastS10To16, desc: "符号扩展 10 位整数到 16 位,广播" }, - { f: VldiFunction.BroadcastU8To16, desc: "零扩展 8 位整数到 16 位,广播" }, - { f: VldiFunction.BroadcastU8Shl8To16, desc: "零扩展 8 位整数到 16 位,左移 8 位,广播" }, + { + f: VldiFunction.BroadcastS10To16, + desc: '符号扩展 10 位整数到 16 位,广播', + }, + { + f: VldiFunction.BroadcastU8To16, + desc: '零扩展 8 位整数到 16 位,广播', + }, + { + f: VldiFunction.BroadcastU8Shl8To16, + desc: '零扩展 8 位整数到 16 位,左移 8 位,广播', + }, ], }, { elemTy: VecElemType.I32, avail: [ - { f: VldiFunction.BroadcastS10To32, desc: "符号扩展 10 位整数到 32 位,广播" }, - { f: VldiFunction.BroadcastU8To32, desc: "零扩展 8 位整数到 32 位,广播" }, - { f: VldiFunction.BroadcastU8Shl8To32, desc: "零扩展 8 位整数到 32 位,左移 8 位,广播" }, - { f: VldiFunction.BroadcastU8Shl16To32, desc: "零扩展 8 位整数到 32 位,左移 16 位,广播" }, - { f: VldiFunction.BroadcastU8Shl24To32, desc: "零扩展 8 位整数到 32 位,左移 24 位,广播" }, - { f: VldiFunction.BroadcastU8FFTo32, desc: "零扩展 8 位整数到 32 位,左移 8 位,低位以全 1 填充,广播" }, - { f: VldiFunction.BroadcastU8FFFFTo32, desc: "零扩展 8 位整数到 32 位,左移 16 位,低位以全 1 填充,广播" }, + { + f: VldiFunction.BroadcastS10To32, + desc: '符号扩展 10 位整数到 32 位,广播', + }, + { + f: VldiFunction.BroadcastU8To32, + desc: '零扩展 8 位整数到 32 位,广播', + }, + { + f: VldiFunction.BroadcastU8Shl8To32, + desc: '零扩展 8 位整数到 32 位,左移 8 位,广播', + }, + { + f: VldiFunction.BroadcastU8Shl16To32, + desc: '零扩展 8 位整数到 32 位,左移 16 位,广播', + }, + { + f: VldiFunction.BroadcastU8Shl24To32, + desc: '零扩展 8 位整数到 32 位,左移 24 位,广播', + }, + { + f: VldiFunction.BroadcastU8FFTo32, + desc: '零扩展 8 位整数到 32 位,左移 8 位,低位以全 1 填充,广播', + }, + { + f: VldiFunction.BroadcastU8FFFFTo32, + desc: '零扩展 8 位整数到 32 位,左移 16 位,低位以全 1 填充,广播', + }, ], }, { elemTy: VecElemType.I64, avail: [ - { f: VldiFunction.BroadcastS10To64, desc: "符号扩展 10 位整数到 64 位,广播" }, - { f: VldiFunction.BroadcastBitExpandedU8To64, desc: "取 8 位整数,将每位重复 8 次,广播" }, + { + f: VldiFunction.BroadcastS10To64, + desc: '符号扩展 10 位整数到 64 位,广播', + }, + { + f: VldiFunction.BroadcastBitExpandedU8To64, + desc: '取 8 位整数,将每位重复 8 次,广播', + }, ], }, { elemTy: VecElemType.F32, avail: [ - { f: VldiFunction.BroadcastVldiMinifloatToF32, desc: "转换迷你浮点数为 float,广播" }, - { f: VldiFunction.BroadcastVldiMinifloatToEvenF32, desc: "转换迷你浮点数为 float,广播到偶数编号元素,置零奇数编号元素" }, + { + f: VldiFunction.BroadcastVldiMinifloatToF32, + desc: '转换迷你浮点数为 float,广播', + }, + { + f: VldiFunction.BroadcastVldiMinifloatToEvenF32, + desc: '转换迷你浮点数为 float,广播到偶数编号元素,置零奇数编号元素', + }, ], }, { elemTy: VecElemType.F64, avail: [ - { f: VldiFunction.BroadcastVldiMinifloatToF64, desc: "转换迷你浮点数为 double,广播" }, + { + f: VldiFunction.BroadcastVldiMinifloatToF64, + desc: '转换迷你浮点数为 double,广播', + }, ], }, ] @@ -118,7 +172,11 @@ availableVldiFunctionsByElemTy.forEach((cfg) => { const myElemTy = cfg.elemTy availableFunctionRadiosByElemTy[myElemTy] = cfg.avail.map((entry) => { const key = `vldi-function-select-radio-${entry.f}` - return {entry.desc} + return ( + + {entry.desc} + + ) }) }) @@ -170,8 +228,13 @@ type VldiFunctionSelectState = { selectedFuncByElemTy: { [key in VecElemType]: VldiFunction } } -const VldiFunctionSelect: React.FC> = (props) => { - const [state, setState]: [VldiFunctionSelectState, Dispatch>] = useState({ +const VldiFunctionSelect: React.FC< + VldiFunctionSelectProps & React.HTMLAttributes +> = (props) => { + const [state, setState]: [ + VldiFunctionSelectState, + Dispatch>, + ] = useState({ elemTy: elemTypesByVldiFunction[props.vldiFunction], selectedFuncByElemTy: _.clone(defaultVldiFunctionsByElemTy), }) @@ -206,44 +269,63 @@ const VldiFunctionSelect: React.FC - - - 元素类型: - - - - - 装载操作: - - {availableFunctionRadiosByElemTy[state.elemTy]} - - - - - + return ( + + + + 元素类型: + + + + + + 装载操作: + + + {availableFunctionRadiosByElemTy[state.elemTy]} + + + + + + ) } export default function VldiHelperPage(): JSX.Element { const [elemTy, setElemTy] = useState(VecElemType.I8) - const [vlen, setVlen]: [Vlen, Dispatch>] = useState(128) + const [vlen, setVlen]: [Vlen, Dispatch>] = + useState(128) const [vldiFunction, setVldiFunction] = useState(VldiFunction.BroadcastU8To8) - const [immState, setImmState] = useState({input: 0, uimm: 0}) + const [immState, setImmState] = useState({ input: 0, uimm: 0 }) const [useSignedElems, setUseSignedElems] = useState(false) - const [minifloatVal, setMinifloatVal] = useState({value: 0.0, bitRepr: 0}) - - const intrinsicHeader = vlen == 128 ? "lsxintrin.h" : "lasxintrin.h" - const intrinsicName = vlen == 128 ? "__lsx_vldi" : "__lasx_xvldi" - const vldiSImm = makeVldiSImm(vldiFunction, immState.uimm, minifloatVal.bitRepr) + const [minifloatVal, setMinifloatVal] = useState({ value: 0.0, bitRepr: 0 }) + + const intrinsicHeader = vlen == 128 ? 'lsxintrin.h' : 'lasxintrin.h' + const intrinsicName = vlen == 128 ? '__lsx_vldi' : '__lasx_xvldi' + const vldiSImm = makeVldiSImm( + vldiFunction, + immState.uimm, + minifloatVal.bitRepr, + ) const vldiSImmHex = toCHexLiteral(vldiSImm) const resultCType = makeVectorTypeForC(vlen, elemTy, useSignedElems) - const resultDemoCodeLines = demonstrateVldiEffectInC(vlen, vldiSImm, useSignedElems) + const resultDemoCodeLines = demonstrateVldiEffectInC( + vlen, + vldiSImm, + useSignedElems, + ) const onImmChange = (newVal: number, interp: SImmAndUImm) => { - setImmState({input: newVal, uimm: interp.uimm}) + setImmState({ input: newVal, uimm: interp.uimm }) } const onUseSignedElemsChange = (e: CheckboxChangeEvent) => { @@ -254,23 +336,27 @@ export default function VldiHelperPage(): JSX.Element { const elemKey = `vldiHelperPage-inputPane-${key}` if (ux.isMinifloat) { - return + return ( + + ) } - return + return ( + + ) } - const dataInputPanes: {[key in VldiFunction]?: JSX.Element} = {} + const dataInputPanes: { [key in VldiFunction]?: JSX.Element } = {} _.forEach(dataInputUXByVldiFunction, (ux, key) => { dataInputPanes[key] = makeInputPane(ux, key) }) @@ -280,69 +366,76 @@ export default function VldiHelperPage(): JSX.Element { const marginTop = { style: { marginTop: 16, - } + }, } - return <> -

- 基于 - @jiegec - 的 - Unofficial LoongArch Intrinsics Guide - 制作。 -

- - - - - - - - - - - 装载参数:{dataInputPanes[vldiFunction]} - - - - - - - - - - 向量宽度: - - 视结果元素为有符号整数 - - - - - - -
-                #include <{intrinsicHeader}>
-
- {resultCType} val = ({resultCType}){intrinsicName}({vldiSImmHex});
- {resultDemoCodeLines.map((line, i) => {line}
)} -
- -
-
- -
- + return ( + <> +

+ 基于 + @jiegec的 + + Unofficial LoongArch Intrinsics Guide + + 制作。 +

+ + + + + + + + + + 装载参数:{dataInputPanes[vldiFunction]} + + + + + + + + + 向量宽度: + + + 视结果元素为有符号整数 + + + + + + +
+                  #include <{intrinsicHeader}>
+                  
+
+ {resultCType} val = ({resultCType}){intrinsicName}( + {vldiSImmHex}); +
+ {resultDemoCodeLines.map((line, i) => ( + + {line} +
+
+ ))} +
+ +
+
+ +
+ + ) } diff --git a/src/components/AuthorPage/index.tsx b/src/components/AuthorPage/index.tsx index e95c9754..1db5eed4 100644 --- a/src/components/AuthorPage/index.tsx +++ b/src/components/AuthorPage/index.tsx @@ -4,33 +4,63 @@ import { EntityKind, IAuthor } from '@site/src/types' function renderKind(k: EntityKind): JSX.Element { switch (k) { - case EntityKind.Community: - return (
  • 利益无关:社区贡献者
  • ) - case EntityKind.Corporate: - return (
  • 利益相关:龙芯生态企业
  • ) - case EntityKind.Loongson: - return (
  • 利益相关:龙芯员工
  • ) + case EntityKind.Community: + return ( +
  • + 利益无关:社区贡献者 +
  • + ) + case EntityKind.Corporate: + return ( +
  • + 利益相关:龙芯生态企业 +
  • + ) + case EntityKind.Loongson: + return ( +
  • + 利益相关:龙芯员工 +
  • + ) } } -export default function AuthorPage({data}: {data: IAuthor}): JSX.Element { +export default function AuthorPage({ data }: { data: IAuthor }): JSX.Element { return (

    {data.name}

    - ); + ) } diff --git a/src/components/BoolFlag.tsx b/src/components/BoolFlag.tsx index 6ebf780f..8791895b 100644 --- a/src/components/BoolFlag.tsx +++ b/src/components/BoolFlag.tsx @@ -4,11 +4,13 @@ type Options = { falseContent?: string } -export default function BoolFlag({val, trueContent, falseContent}: Options): JSX.Element { +export default function BoolFlag({ + val, + trueContent, + falseContent, +}: Options): JSX.Element { const t = trueContent ? trueContent : '✅' const f = falseContent ? falseContent : '❌' - return ( - {val ? t : f} - ) + return {val ? t : f} } diff --git a/src/components/CodeQualityIcon/index.tsx b/src/components/CodeQualityIcon/index.tsx index 59273636..ee6be01b 100644 --- a/src/components/CodeQualityIcon/index.tsx +++ b/src/components/CodeQualityIcon/index.tsx @@ -2,33 +2,43 @@ import { CodeQuality } from '../../types' function emojiForCodeQuality(x: CodeQuality): string { switch (x) { - case CodeQuality.NoCode: return '❔' - case CodeQuality.OnPar: return '🆗' - case CodeQuality.NeedsCleanup: return '🧹' - case CodeQuality.NeedsRework: return '⛔' + case CodeQuality.NoCode: + return '❔' + case CodeQuality.OnPar: + return '🆗' + case CodeQuality.NeedsCleanup: + return '🧹' + case CodeQuality.NeedsRework: + return '⛔' } } function descForCodeQuality(ss: CodeQuality): string { switch (ss) { - case CodeQuality.NoCode: return '不涉及代码,或代码不可见' - case CodeQuality.OnPar: return '符合规范' - case CodeQuality.NeedsCleanup: return '需要整理' - case CodeQuality.NeedsRework: return '需要重做' + case CodeQuality.NoCode: + return '不涉及代码,或代码不可见' + case CodeQuality.OnPar: + return '符合规范' + case CodeQuality.NeedsCleanup: + return '需要整理' + case CodeQuality.NeedsRework: + return '需要重做' } } - type Options = { val: CodeQuality showDesc?: boolean } -export default function CodeQualityIcon({val, showDesc}: Options): JSX.Element { +export default function CodeQualityIcon({ + val, + showDesc, +}: Options): JSX.Element { return ( <> {emojiForCodeQuality(val)} {showDesc ? {descForCodeQuality(val)} : ''} - ); + ) } diff --git a/src/components/ColumnedList/index.tsx b/src/components/ColumnedList/index.tsx index 66c3c223..6d7caaaa 100644 --- a/src/components/ColumnedList/index.tsx +++ b/src/components/ColumnedList/index.tsx @@ -12,5 +12,5 @@ export default function ColumnedList(props: Props): JSX.Element {
    {props.children}
    - ); + ) } diff --git a/src/components/HomepageFeatures/index.tsx b/src/components/HomepageFeatures/index.tsx index b19340ba..9c694045 100644 --- a/src/components/HomepageFeatures/index.tsx +++ b/src/components/HomepageFeatures/index.tsx @@ -8,41 +8,61 @@ import { IProject, IProjectCategory, SupportStatus } from '@site/src/types' import SupportStatusIcon from '../SupportStatusIcon' import styles from './styles.module.css' -function Project({val}: {val: IProject}) { - const distinctSupportStatuses = _.uniq(val.portingEfforts.map((x) => x.supportStatus)) - const statusesToShow = distinctSupportStatuses.length > 0 ? distinctSupportStatuses : [SupportStatus.UpForGrabs] +function Project({ val }: { val: IProject }) { + const distinctSupportStatuses = _.uniq( + val.portingEfforts.map((x) => x.supportStatus), + ) + const statusesToShow = + distinctSupportStatuses.length > 0 + ? distinctSupportStatuses + : [SupportStatus.UpForGrabs] const lowestGoodVersion = val.portingEfforts.reduce((prev, x) => { return x.goodSinceVersion != '' ? x.goodSinceVersion : prev }, '') return (
  • - {statusesToShow.map((x, idx) => ())} - {val.name} - {lowestGoodVersion != '' ? ≥ {lowestGoodVersion} : ''} + + {statusesToShow.map((x, idx) => ( + + ))} + + + {val.name} + + {lowestGoodVersion != '' ? ( + + {' '} + ≥ {lowestGoodVersion} + + ) : ( + '' + )}
  • ) } -function ProjectList({projects}: {projects: IProject[]}) { +function ProjectList({ projects }: { projects: IProject[] }) { const sortedProjects = _.clone(projects) sortedProjects.sort((a, b) => a.name.toLowerCase() > b.name.toLowerCase()) return (
      - {sortedProjects.map((x, idx) => ())} + {sortedProjects.map((x, idx) => ( + + ))}
    ) } -function ProjectCategory({val}: {val: IProjectCategory}) { +function ProjectCategory({ val }: { val: IProjectCategory }) { return (
    -
    +

    {val.name}

    - ); + ) } export default function HomepageFeatures(): JSX.Element { @@ -57,5 +77,5 @@ export default function HomepageFeatures(): JSX.Element {
    - ); + ) } diff --git a/src/components/ProjectPage/index.tsx b/src/components/ProjectPage/index.tsx index bb5b9f63..e5ce4c23 100644 --- a/src/components/ProjectPage/index.tsx +++ b/src/components/ProjectPage/index.tsx @@ -5,28 +5,36 @@ import SupportStatusIcon from '../SupportStatusIcon' import CodeQualityIcon from '../CodeQualityIcon' import styles from './styles.module.css' -function PortingEffort({data}: {data: IPortingEffort}): JSX.Element { +function PortingEffort({ data }: { data: IPortingEffort }): JSX.Element { return (
    - {data.desc ? + {data.desc ? ( <>
    说明
    {data.desc}
    - : ''} + ) : ( + '' + )}
    链接
    {data.link ? {data.link} : '无'}
    参与者
      - {data.authors.map((x, i) => (
    • {x}
    • ))} + {data.authors.map((x, i) => ( +
    • {x}
    • + ))}
    适配工作质量
    -
    +
    + +
    支持状态
    -
    +
    + +
    何时开始支持
    {data.releasedSinceVersion}
    何时支持完善
    @@ -36,7 +44,7 @@ function PortingEffort({data}: {data: IPortingEffort}): JSX.Element { ) } -export default function ProjectPage({data}: {data: IProject}): JSX.Element { +export default function ProjectPage({ data }: { data: IProject }): JSX.Element { return (
    @@ -46,17 +54,31 @@ export default function ProjectPage({data}: {data: IProject}): JSX.Element {

    项目概况

    首页
    -
    {data.homepageURL ? {data.homepageURL} : '暂缺'}
    +
    + {data.homepageURL ? ( + {data.homepageURL} + ) : ( + '暂缺' + )} +
    储存库
    -
    {data.repoURL ? {data.repoURL} : '暂缺'}
    +
    + {data.repoURL ? ( + {data.repoURL} + ) : ( + '暂缺' + )} +

    适配工作

    - {data.portingEfforts.map((x, i) => ())} + {data.portingEfforts.map((x, i) => ( + + ))}
    - ); + ) } diff --git a/src/components/SupportStatusIcon/index.tsx b/src/components/SupportStatusIcon/index.tsx index a6e98043..eb07b17d 100644 --- a/src/components/SupportStatusIcon/index.tsx +++ b/src/components/SupportStatusIcon/index.tsx @@ -2,43 +2,63 @@ import { SupportStatus } from '../../types' function emojiForSupportStatus(ss: SupportStatus): string { switch (ss) { - case SupportStatus.Unknown: return '❔' - case SupportStatus.Rejected: return '⛔' - case SupportStatus.CommercialOnly: return '💴' - case SupportStatus.Stalled: return '💤' - case SupportStatus.UpForGrabs: return '🈳' - case SupportStatus.WIP: return '🔧' - case SupportStatus.UnderReview: return '🔍' - case SupportStatus.WaitingRelease: return '⌛' - case SupportStatus.Released: return '✅' + case SupportStatus.Unknown: + return '❔' + case SupportStatus.Rejected: + return '⛔' + case SupportStatus.CommercialOnly: + return '💴' + case SupportStatus.Stalled: + return '💤' + case SupportStatus.UpForGrabs: + return '🈳' + case SupportStatus.WIP: + return '🔧' + case SupportStatus.UnderReview: + return '🔍' + case SupportStatus.WaitingRelease: + return '⌛' + case SupportStatus.Released: + return '✅' } } function descForSupportStatus(ss: SupportStatus): string { switch (ss) { - case SupportStatus.Unknown: return '未知' - case SupportStatus.Rejected: return '被拒绝' - case SupportStatus.CommercialOnly: return '仅有付费商业支持' - case SupportStatus.Stalled: return '进度受阻' - case SupportStatus.UpForGrabs: return '目前无人认领,先到先得' - case SupportStatus.WIP: return '施工中' - case SupportStatus.UnderReview: return '正在接受代码审查' - case SupportStatus.WaitingRelease: return '万事俱备,就差上游发版' - case SupportStatus.Released: return '已在正式上游版本发布' + case SupportStatus.Unknown: + return '未知' + case SupportStatus.Rejected: + return '被拒绝' + case SupportStatus.CommercialOnly: + return '仅有付费商业支持' + case SupportStatus.Stalled: + return '进度受阻' + case SupportStatus.UpForGrabs: + return '目前无人认领,先到先得' + case SupportStatus.WIP: + return '施工中' + case SupportStatus.UnderReview: + return '正在接受代码审查' + case SupportStatus.WaitingRelease: + return '万事俱备,就差上游发版' + case SupportStatus.Released: + return '已在正式上游版本发布' } } - type Options = { val: SupportStatus showDesc?: boolean } -export default function SupportStatusIcon({val, showDesc}: Options): JSX.Element { +export default function SupportStatusIcon({ + val, + showDesc, +}: Options): JSX.Element { return ( <> {emojiForSupportStatus(val)} {showDesc ? {descForSupportStatus(val)} : ''} - ); + ) } diff --git a/src/components/ThemeAwareAntdContainer.tsx b/src/components/ThemeAwareAntdContainer.tsx index 05f6f036..a6ccf21b 100644 --- a/src/components/ThemeAwareAntdContainer.tsx +++ b/src/components/ThemeAwareAntdContainer.tsx @@ -3,12 +3,18 @@ import { ConfigProvider, theme } from 'antd' import BrowserOnly from '@docusaurus/BrowserOnly' import { useColorMode } from '@docusaurus/theme-common' -export default function ThemeAwareAntdContainer(props: React.PropsWithChildren): JSX.Element { +export default function ThemeAwareAntdContainer( + props: React.PropsWithChildren, +): JSX.Element { const isDarkMode = useColorMode().colorMode == 'dark' const alg = isDarkMode ? theme.darkAlgorithm : theme.defaultAlgorithm return ( - {() => {props.children}} + {() => ( + + {props.children} + + )} ) } diff --git a/src/css/custom.css b/src/css/custom.css index 27e6339c..7b01b748 100644 --- a/src/css/custom.css +++ b/src/css/custom.css @@ -22,7 +22,9 @@ --ifm-heading-font-weight: 400; --docusaurus-highlighted-code-line-bg: rgba(0, 0, 0, 0.1); - --awly-font-family-emph: 'Noto Serif', serif, 'Times New Roman', 'Source Han Serif', '思源宋体', '宋体', 'SimSun', 'Noto Color Emoji', 'Apple Color Emoji', 'Segoe UI Emoji'; + --awly-font-family-emph: 'Noto Serif', serif, 'Times New Roman', + 'Source Han Serif', '思源宋体', '宋体', 'SimSun', 'Noto Color Emoji', + 'Apple Color Emoji', 'Segoe UI Emoji'; } /* For readability concerns, you should choose a lighter palette in dark mode. */ @@ -37,7 +39,12 @@ --docusaurus-highlighted-code-line-bg: rgba(0, 0, 0, 0.3); } -h1, h2, h3, h4, h5, h6 { +h1, +h2, +h3, +h4, +h5, +h6 { /* shear the Oswald glyphs for visual compatibility with Smiley Sans */ font-style: oblique 6deg; } diff --git a/src/pages/index.tsx b/src/pages/index.tsx index f5ddb324..76a95fcd 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -11,10 +11,19 @@ function HomepageHeader() {

    行则将至!

    - Linux 开源生态的多数基础组件,其最新版本都已包含 LoongArch 支持了。
    - 尽管龙芯公司仍未公开 LoongArch 手册的其余部分,但大量公开信息如 QEMU、内核适配已将相关指令编码与具体行为尽数披露,手册的缺失已不再能阻碍优化的脚步。
    - 我们预计将在 2023~2024 看到 LoongArch 新世界生态的突飞猛进,有您的参与会更快些。
    - 本站由社区建设维护,欢迎来坐坐! + Linux 开源生态的多数基础组件,其最新版本都已包含 LoongArch 支持了。 +
    + 尽管龙芯公司仍未公开 LoongArch 手册的其余部分,但大量公开信息如 + QEMU、内核适配已将相关指令编码与具体行为尽数披露,手册的缺失已不再能阻碍优化的脚步。 +
    + 我们预计将在 2023~2024 看到 LoongArch + 新世界生态的突飞猛进,有您的参与会更快些。 +
    + 本站由社区建设维护, + + 欢迎来坐坐 + + !

    @@ -23,9 +32,7 @@ function HomepageHeader() { export default function Home(): JSX.Element { return ( - +
    diff --git a/src/plugins/awly-asmdb-plugin/index.ts b/src/plugins/awly-asmdb-plugin/index.ts index 1af6217c..bfdf6647 100644 --- a/src/plugins/awly-asmdb-plugin/index.ts +++ b/src/plugins/awly-asmdb-plugin/index.ts @@ -12,13 +12,16 @@ export type PluginOptions = { type LoadedContent = string -function runGenerationScript(asmdbHelperPath: string, inputPaths: string[]): Promise { +function runGenerationScript( + asmdbHelperPath: string, + inputPaths: string[], +): Promise { return new Promise((resolve, reject) => { const subp = spawn(asmdbHelperPath, inputPaths) let stdout = '' let stderr = '' - subp.stdout.on('data', (data) => stdout += data) - subp.stderr.on('data', (data) => stderr += data) + subp.stdout.on('data', (data) => (stdout += data)) + subp.stderr.on('data', (data) => (stderr += data)) subp.on('close', (code) => { if (code == 0) { resolve(stdout) @@ -43,8 +46,12 @@ export default async function awlyAsmdbPlugin( return { name: 'awly-asmdb-plugin', async loadContent() { - const opcodeFiles = await glob('*.txt', { cwd: options.loongarchOpcodesPath }) - const inputPaths = opcodeFiles.map((x) => path.join(options.loongarchOpcodesPath, x)) + const opcodeFiles = await glob('*.txt', { + cwd: options.loongarchOpcodesPath, + }) + const inputPaths = opcodeFiles.map((x) => + path.join(options.loongarchOpcodesPath, x), + ) return await runGenerationScript(options.genAsmdbDataPath, inputPaths) }, async contentLoaded({ content, actions }) { diff --git a/src/plugins/awly-data-plugin/index.ts b/src/plugins/awly-data-plugin/index.ts index 98877805..4b02c5f2 100644 --- a/src/plugins/awly-data-plugin/index.ts +++ b/src/plugins/awly-data-plugin/index.ts @@ -5,7 +5,16 @@ import { glob } from 'glob' import yaml from 'yaml' import type { LoadContext, Plugin } from '@docusaurus/types' -import { CodeQuality, EntityKind, IAuthor, IPortingEffort, IProject, IProjectCategory, LoadedContent, SupportStatus } from '../../types' +import { + CodeQuality, + EntityKind, + IAuthor, + IPortingEffort, + IProject, + IProjectCategory, + LoadedContent, + SupportStatus, +} from '../../types' export type PluginOptions = { sourcePath: string @@ -51,42 +60,63 @@ async function readUTF8YAML(path: string): Promise { return yaml.parse(content) as T } -async function getCategoryMetadata(categoryDirPath: string): Promise { +async function getCategoryMetadata( + categoryDirPath: string, +): Promise { const indexPath = path.join(categoryDirPath, categoryIndexFilename) return readUTF8YAML(indexPath) } function parseEntityKind(x: string): EntityKind { switch (x) { - case 'Community': return EntityKind.Community - case 'Corporate': return EntityKind.Corporate - case 'Loongson': return EntityKind.Loongson - default: return EntityKind.Community + case 'Community': + return EntityKind.Community + case 'Corporate': + return EntityKind.Corporate + case 'Loongson': + return EntityKind.Loongson + default: + return EntityKind.Community } } function parseSupportStatus(x: string): SupportStatus { switch (x) { - case 'Unknown': return SupportStatus.Unknown - case 'Rejected': return SupportStatus.Rejected - case 'CommercialOnly': return SupportStatus.CommercialOnly - case 'Stalled': return SupportStatus.Stalled - case 'UpForGrabs': return SupportStatus.UpForGrabs - case 'WIP': return SupportStatus.WIP - case 'UnderReview': return SupportStatus.UnderReview - case 'WaitingRelease': return SupportStatus.WaitingRelease - case 'Released': return SupportStatus.Released - default: return SupportStatus.Unknown + case 'Unknown': + return SupportStatus.Unknown + case 'Rejected': + return SupportStatus.Rejected + case 'CommercialOnly': + return SupportStatus.CommercialOnly + case 'Stalled': + return SupportStatus.Stalled + case 'UpForGrabs': + return SupportStatus.UpForGrabs + case 'WIP': + return SupportStatus.WIP + case 'UnderReview': + return SupportStatus.UnderReview + case 'WaitingRelease': + return SupportStatus.WaitingRelease + case 'Released': + return SupportStatus.Released + default: + return SupportStatus.Unknown } } function parseCodeQuality(x: string): CodeQuality { switch (x) { - case 'NoCode': return CodeQuality.NoCode - case 'OnPar': return CodeQuality.OnPar - case 'NeedsCleanup': return CodeQuality.NeedsCleanup - case 'NeedsRework': return CodeQuality.NeedsRework - default: return CodeQuality.NoCode + case 'NoCode': + return CodeQuality.NoCode + case 'OnPar': + return CodeQuality.OnPar + case 'NeedsCleanup': + return CodeQuality.NeedsCleanup + case 'NeedsRework': + return CodeQuality.NeedsRework + default: + return CodeQuality.NoCode } } @@ -132,11 +162,10 @@ async function readProjectDef(p: string): Promise { } async function readCategories(sourcePath: string): Promise { - const categories: { code: string, name: string, projects: IProject[] }[] = [] + const categories: { code: string; name: string; projects: IProject[] }[] = [] const srcDir = await opendir(sourcePath) for await (const dirent of srcDir) { - if (!dirent.isDirectory()) - continue + if (!dirent.isDirectory()) continue const categoryDirPath = path.join(srcDir.path, dirent.name) @@ -148,7 +177,9 @@ async function readCategories(sourcePath: string): Promise { cwd: categoryDirPath, ignore: [categoryIndexFilename], }) - const projectDefPaths = projectDefFilenames.map((x) => path.join(categoryDirPath, x)) + const projectDefPaths = projectDefFilenames.map((x) => + path.join(categoryDirPath, x), + ) const projectDefs = await Promise.all(projectDefPaths.map(readProjectDef)) categories.push({ code: dirent.name, @@ -159,8 +190,10 @@ async function readCategories(sourcePath: string): Promise { // sort the categories lexicographically according to code (directory name) return categories - .sort((a, b) => a.code < b.code ? -1 : 0) - .map((x) => { return { name: x.name, projects: x.projects } }) + .sort((a, b) => (a.code < b.code ? -1 : 0)) + .map((x) => { + return { name: x.name, projects: x.projects } + }) } export default async function awlyDataPlugin( @@ -188,7 +221,10 @@ export default async function awlyDataPlugin( // generate pages for authors for (const [code, a] of content.authors.entries()) { - const dataPath = await createData(`porter.${code}.json`, JSON.stringify(a)) + const dataPath = await createData( + `porter.${code}.json`, + JSON.stringify(a), + ) addRoute({ path: `/porter/${code}`, component: '@site/src/components/AuthorPage', @@ -202,7 +238,10 @@ export default async function awlyDataPlugin( // generate pages for individual projects for (const cat of content.categories) { for (const proj of cat.projects) { - const dataPath = await createData(`project.${proj.code}.json`, JSON.stringify(proj)) + const dataPath = await createData( + `project.${proj.code}.json`, + JSON.stringify(proj), + ) addRoute({ path: `/project/${proj.code}`, component: '@site/src/components/ProjectPage', @@ -215,9 +254,7 @@ export default async function awlyDataPlugin( } }, getPathsToWatch() { - return [ - path.join(options.sourcePath, '**/*.yml'), - ] + return [path.join(options.sourcePath, '**/*.yml')] }, } } diff --git a/src/plugins/awly-rehype-annotate-overseas-links/index.ts b/src/plugins/awly-rehype-annotate-overseas-links/index.ts index 9b78852a..67706db6 100644 --- a/src/plugins/awly-rehype-annotate-overseas-links/index.ts +++ b/src/plugins/awly-rehype-annotate-overseas-links/index.ts @@ -1,18 +1,22 @@ -import { UrlMatch } from "@jsdevtools/rehype-url-inspector" +import { UrlMatch } from '@jsdevtools/rehype-url-inspector' // XXX: exceptions are hard-coded for now, to avoid having to make actual // DNS resolutions & GeoIP lookups during build time function isHostLikelyCNDomestic(hostname: string): boolean { if (hostname.endsWith('.cn')) { - if (hostname.endsWith('slackwarecn.cn')) - return false + if (hostname.endsWith('slackwarecn.cn')) return false return true } - if (hostname.endsWith('gitee.com') || hostname.endsWith('katyusha.net') - || hostname.endsWith('sseinfo.com') || hostname.endsWith('deepin.com') - || hostname.endsWith('deepin.org') || hostname.endsWith('qq.com')) + if ( + hostname.endsWith('gitee.com') || + hostname.endsWith('katyusha.net') || + hostname.endsWith('sseinfo.com') || + hostname.endsWith('deepin.com') || + hostname.endsWith('deepin.org') || + hostname.endsWith('qq.com') + ) return true return false @@ -25,12 +29,10 @@ export default function doAnnotateOverseasLinks({ url, node }: UrlMatch) { } const hostname = new URL(url).hostname - if (isHostLikelyCNDomestic(hostname)) - return + if (isHostLikelyCNDomestic(hostname)) return // console.log('annotating', url) if (node.properties.hasOwnProperty('class')) node.properties.class += ' link--overseas' - else - node.properties.class = 'link--overseas' + else node.properties.class = 'link--overseas' } diff --git a/src/plugins/awly-remark-natlang-usage.ts b/src/plugins/awly-remark-natlang-usage.ts index 870cb058..3a6f1a36 100644 --- a/src/plugins/awly-remark-natlang-usage.ts +++ b/src/plugins/awly-remark-natlang-usage.ts @@ -10,8 +10,8 @@ function produceErhuaMark(match: any): PhrasingContent { type: 'text', value: '', data: { - hName: 'small', - hChildren: [{ type: 'text', value: '儿' }], + hName: 'small', + hChildren: [{ type: 'text', value: '儿' }], }, } } @@ -19,8 +19,8 @@ function produceErhuaMark(match: any): PhrasingContent { export default function plugin(options: any) { return (tree: Nodes) => { findAndReplace(tree, [ - [":儿:", produceErhuaMark], - [":ta:", "tā"], + [':儿:', produceErhuaMark], + [':ta:', 'tā'], ]) } } diff --git a/src/plugins/prism-asmloong.ts b/src/plugins/prism-asmloong.ts index 9662b2e2..b6e38aac 100644 --- a/src/plugins/prism-asmloong.ts +++ b/src/plugins/prism-asmloong.ts @@ -1,27 +1,27 @@ Prism.languages.asmloong = { - 'comment': { + comment: { pattern: /\/\/.*/, - greedy: true + greedy: true, }, - 'string': { + string: { pattern: /(["'`])(?:\\.|(?!\1)[^\\\r\n])*\1/, - greedy: true + greedy: true, }, - 'directive': { + directive: { pattern: /\.(?:text|option)\b/, - alias: 'property' + alias: 'property', }, - 'register': { + register: { pattern: /\$(?:zero|ra|tp|sp|a[0-7]|t[0-8]|fp|s[0-9]|r\d|r[12]\d|r3[01])\b/, - alias: 'variable' + alias: 'variable', }, - 'opcode': { + opcode: { pattern: /\b(?:lu12i\.w|addi\.d)\b/, - alias: 'keyword' + alias: 'keyword', }, - 'reloc': { + reloc: { pattern: /\%(?:le_hi20|le_lo12)\b/, - alias: 'function' + alias: 'function', }, - 'punctuation': /[(),:]/, + punctuation: /[(),:]/, } diff --git a/src/theme/Footer/Copyright/index.tsx b/src/theme/Footer/Copyright/index.tsx index 464e9c96..25cdd8f3 100644 --- a/src/theme/Footer/Copyright/index.tsx +++ b/src/theme/Footer/Copyright/index.tsx @@ -3,36 +3,40 @@ import IconExternalLink from '@theme-original/Icon/ExternalLink' import styles from './styles.module.css' -function ICPBeianLink( - { - province, - recordNumber, - subRecordNumber, - }: { - province: string, - recordNumber: number, - subRecordNumber: number, - }, -): JSX.Element { +function ICPBeianLink({ + province, + recordNumber, + subRecordNumber, +}: { + province: string + recordNumber: number + subRecordNumber: number +}): JSX.Element { return ( - {province}ICP备{recordNumber}号-{subRecordNumber} + + {province}ICP备{recordNumber}号-{subRecordNumber} + ) } -function MPSBeianLink( - { - province, - recordNumber, - }: { - province: string, - recordNumber: number, - }, -): JSX.Element { +function MPSBeianLink({ + province, + recordNumber, +}: { + province: string + recordNumber: number +}): JSX.Element { const queryLinkURL = `http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=${recordNumber}` return ( <> - - {province}公网安备{recordNumber}号 + + + {province}公网安备{recordNumber}号 + ) } @@ -41,11 +45,22 @@ export default function CopyrightWrapper(props: any): JSX.Element { return ( <>

    - 形如此的链接,或部分形如此的链接,其目标主机可能位于中国大陆境外。如需跟进阅读却无法访问,请自行寻找解决方案。 + 形如此的链接,或部分 + + 形如此 + + + 的链接,其目标主机可能位于中国大陆境外。如需跟进阅读却无法访问,请自行寻找解决方案。

      -
    • +
    • + +
    • {/*
    • */}
    diff --git a/src/theme/prism-include-languages.ts b/src/theme/prism-include-languages.ts index 3a1db0ec..884d42cf 100644 --- a/src/theme/prism-include-languages.ts +++ b/src/theme/prism-include-languages.ts @@ -1,14 +1,14 @@ -import siteConfig from '@generated/docusaurus.config'; -import type * as PrismNamespace from 'prismjs'; -import type {Optional} from 'utility-types'; +import siteConfig from '@generated/docusaurus.config' +import type * as PrismNamespace from 'prismjs' +import type { Optional } from 'utility-types' export default function prismIncludeLanguages( PrismObject: typeof PrismNamespace, ): void { const { - themeConfig: {prism}, - } = siteConfig; - const {additionalLanguages} = prism as {additionalLanguages: string[]}; + themeConfig: { prism }, + } = siteConfig + const { additionalLanguages } = prism as { additionalLanguages: string[] } // Prism components work on the Prism instance on the window, while prism- // react-renderer uses its own Prism instance. We temporarily mount the @@ -16,19 +16,19 @@ export default function prismIncludeLanguages( // avoid polluting global namespace. // You can mutate PrismObject: registering plugins, deleting languages... As // long as you don't re-assign it - globalThis.Prism = PrismObject; + globalThis.Prism = PrismObject additionalLanguages.forEach((lang) => { if (lang === 'php') { // eslint-disable-next-line global-require - require('prismjs/components/prism-markup-templating.js'); + require('prismjs/components/prism-markup-templating.js') } // eslint-disable-next-line global-require, import/no-dynamic-require - require(`prismjs/components/prism-${lang}`); - }); + require(`prismjs/components/prism-${lang}`) + }) // AWLY addition(s) - require('../plugins/prism-asmloong'); + require('../plugins/prism-asmloong') - delete (globalThis as Optional).Prism; + delete (globalThis as Optional).Prism } diff --git a/tsconfig.json b/tsconfig.json index 04ce682b..46862fed 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,6 +7,6 @@ "module": "NodeNext", "moduleResolution": "NodeNext", "target": "ESNext", - "useDefineForClassFields": true, + "useDefineForClassFields": true } } From 129327fd5ec4aebea88a93bdfe3fc7db7f6a378b Mon Sep 17 00:00:00 2001 From: WANG Xuerui Date: Sat, 26 Oct 2024 13:32:50 +0800 Subject: [PATCH 04/25] refactor: fix TS error in prism-asmloong.ts --- src/plugins/prism-asmloong.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/plugins/prism-asmloong.ts b/src/plugins/prism-asmloong.ts index b6e38aac..1dcc6852 100644 --- a/src/plugins/prism-asmloong.ts +++ b/src/plugins/prism-asmloong.ts @@ -1,3 +1,5 @@ +import Prism from 'prismjs' + Prism.languages.asmloong = { comment: { pattern: /\/\/.*/, From 8965f8184c3dd695be4d0a62d9315e7f76ac4fe8 Mon Sep 17 00:00:00 2001 From: WANG Xuerui Date: Sat, 26 Oct 2024 13:35:00 +0800 Subject: [PATCH 05/25] build: add type declaration for mdast --- package.json | 1 + yarn.lock | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index d3a87b59..9b919ccd 100644 --- a/package.json +++ b/package.json @@ -49,6 +49,7 @@ "@types/glob": "^8.1.0", "@types/js-yaml": "^4.0.9", "@types/lodash": "^4.17.10", + "@types/mdast": "^4.0.4", "@types/node": "^22.7.5", "@types/prismjs": "^1.26.4", "@types/react": "^18.3.11", diff --git a/yarn.lock b/yarn.lock index a7bcafa4..52f81590 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3317,7 +3317,7 @@ __metadata: languageName: node linkType: hard -"@types/mdast@npm:^4.0.0, @types/mdast@npm:^4.0.2": +"@types/mdast@npm:^4.0.0, @types/mdast@npm:^4.0.2, @types/mdast@npm:^4.0.4": version: 4.0.4 resolution: "@types/mdast@npm:4.0.4" dependencies: @@ -4042,6 +4042,7 @@ __metadata: "@types/glob": "npm:^8.1.0" "@types/js-yaml": "npm:^4.0.9" "@types/lodash": "npm:^4.17.10" + "@types/mdast": "npm:^4.0.4" "@types/node": "npm:^22.7.5" "@types/prismjs": "npm:^1.26.4" "@types/react": "npm:^18.3.11" From dfd557b0b6e53c438151851915d427b3a42bec14 Mon Sep 17 00:00:00 2001 From: WANG Xuerui Date: Sat, 26 Oct 2024 13:57:25 +0800 Subject: [PATCH 06/25] refactor: fix ESM import in awly-remark-natlang-usage --- src/plugins/awly-remark-natlang-usage.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/plugins/awly-remark-natlang-usage.ts b/src/plugins/awly-remark-natlang-usage.ts index 3a6f1a36..e9fa1b63 100644 --- a/src/plugins/awly-remark-natlang-usage.ts +++ b/src/plugins/awly-remark-natlang-usage.ts @@ -1,5 +1,5 @@ import { Nodes, PhrasingContent } from 'mdast' -import { findAndReplace } from 'mdast-util-find-and-replace' +// import { findAndReplace } from 'mdast-util-find-and-replace' function produceErhuaMark(match: any): PhrasingContent { // this won't work @@ -16,7 +16,8 @@ function produceErhuaMark(match: any): PhrasingContent { } } -export default function plugin(options: any) { +export default async function plugin(options: any) { + const { findAndReplace } = await import('mdast-util-find-and-replace') return (tree: Nodes) => { findAndReplace(tree, [ [':儿:', produceErhuaMark], From 8ed63dbf2feb75077668002ebc629f4b93d2178e Mon Sep 17 00:00:00 2001 From: WANG Xuerui Date: Sat, 26 Oct 2024 14:01:56 +0800 Subject: [PATCH 07/25] refactor: fix TS error in HomepageFeatures/index.tsx --- src/components/HomepageFeatures/index.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/components/HomepageFeatures/index.tsx b/src/components/HomepageFeatures/index.tsx index 9c694045..3b6ed528 100644 --- a/src/components/HomepageFeatures/index.tsx +++ b/src/components/HomepageFeatures/index.tsx @@ -43,8 +43,7 @@ function Project({ val }: { val: IProject }) { } function ProjectList({ projects }: { projects: IProject[] }) { - const sortedProjects = _.clone(projects) - sortedProjects.sort((a, b) => a.name.toLowerCase() > b.name.toLowerCase()) + const sortedProjects = _.sortBy(projects, (x) => x.name.toLowerCase()) return (
      {sortedProjects.map((x, idx) => ( From 66b4cf72a4ba7404c000f914fcf9265488385f14 Mon Sep 17 00:00:00 2001 From: WANG Xuerui Date: Sat, 26 Oct 2024 14:09:56 +0800 Subject: [PATCH 08/25] build: bump Yarn to 4.5.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9b919ccd..55e63cc1 100644 --- a/package.json +++ b/package.json @@ -79,5 +79,5 @@ "engines": { "node": ">=20" }, - "packageManager": "yarn@4.5.0" + "packageManager": "yarn@4.5.1" } From c066b22044b292246834552d4a456fec0444c3ad Mon Sep 17 00:00:00 2001 From: WANG Xuerui Date: Sat, 26 Oct 2024 14:22:11 +0800 Subject: [PATCH 09/25] build: add typescript-eslint --- package.json | 4 + yarn.lock | 524 +++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 513 insertions(+), 15 deletions(-) diff --git a/package.json b/package.json index 55e63cc1..17be57cd 100644 --- a/package.json +++ b/package.json @@ -46,6 +46,8 @@ "devDependencies": { "@docusaurus/module-type-aliases": "3.5.2", "@docusaurus/tsconfig": "3.5.2", + "@eslint/js": "^9.13.0", + "@types/eslint__js": "^8.42.3", "@types/glob": "^8.1.0", "@types/js-yaml": "^4.0.9", "@types/lodash": "^4.17.10", @@ -54,8 +56,10 @@ "@types/prismjs": "^1.26.4", "@types/react": "^18.3.11", "@types/react-router-dom": "^5.3.3", + "eslint": "^9.13.0", "prettier": "^3.3.3", "typescript": "^5.6.3", + "typescript-eslint": "^8.11.0", "update-browserslist-db": "^1.1.1" }, "resolutions": { diff --git a/yarn.lock b/yarn.lock index 52f81590..41ab0046 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2282,6 +2282,82 @@ __metadata: languageName: node linkType: hard +"@eslint-community/eslint-utils@npm:^4.2.0, @eslint-community/eslint-utils@npm:^4.4.0": + version: 4.4.1 + resolution: "@eslint-community/eslint-utils@npm:4.4.1" + dependencies: + eslint-visitor-keys: "npm:^3.4.3" + peerDependencies: + eslint: ^6.0.0 || ^7.0.0 || >=8.0.0 + checksum: 10c0/2aa0ac2fc50ff3f234408b10900ed4f1a0b19352f21346ad4cc3d83a1271481bdda11097baa45d484dd564c895e0762a27a8240be7a256b3ad47129e96528252 + languageName: node + linkType: hard + +"@eslint-community/regexpp@npm:^4.10.0, @eslint-community/regexpp@npm:^4.11.0": + version: 4.11.2 + resolution: "@eslint-community/regexpp@npm:4.11.2" + checksum: 10c0/c6ab16307c64bc72ea05b9c1740734dfe4a3eea8f7cc395266eb7f04a0ab8f84fe58d41888e906c18bc56262b685eb3074443a0375fb8c44fb4ff20fdb11e250 + languageName: node + linkType: hard + +"@eslint/config-array@npm:^0.18.0": + version: 0.18.0 + resolution: "@eslint/config-array@npm:0.18.0" + dependencies: + "@eslint/object-schema": "npm:^2.1.4" + debug: "npm:^4.3.1" + minimatch: "npm:^3.1.2" + checksum: 10c0/0234aeb3e6b052ad2402a647d0b4f8a6aa71524bafe1adad0b8db1dfe94d7f5f26d67c80f79bb37ac61361a1d4b14bb8fb475efe501de37263cf55eabb79868f + languageName: node + linkType: hard + +"@eslint/core@npm:^0.7.0": + version: 0.7.0 + resolution: "@eslint/core@npm:0.7.0" + checksum: 10c0/3cdee8bc6cbb96ac6103d3ead42e59830019435839583c9eb352b94ed558bd78e7ffad5286dc710df21ec1e7bd8f52aa6574c62457a4dd0f01f3736fa4a7d87a + languageName: node + linkType: hard + +"@eslint/eslintrc@npm:^3.1.0": + version: 3.1.0 + resolution: "@eslint/eslintrc@npm:3.1.0" + dependencies: + ajv: "npm:^6.12.4" + debug: "npm:^4.3.2" + espree: "npm:^10.0.1" + globals: "npm:^14.0.0" + ignore: "npm:^5.2.0" + import-fresh: "npm:^3.2.1" + js-yaml: "npm:^4.1.0" + minimatch: "npm:^3.1.2" + strip-json-comments: "npm:^3.1.1" + checksum: 10c0/5b7332ed781edcfc98caa8dedbbb843abfb9bda2e86538529c843473f580e40c69eb894410eddc6702f487e9ee8f8cfa8df83213d43a8fdb549f23ce06699167 + languageName: node + linkType: hard + +"@eslint/js@npm:9.13.0, @eslint/js@npm:^9.13.0": + version: 9.13.0 + resolution: "@eslint/js@npm:9.13.0" + checksum: 10c0/672257bffe17777b8a98bd80438702904cc7a0b98b9c2e426a8a10929198b3553edf8a3fc20feed4133c02e7c8f7331a0ef1b23e5dab8e4469f7f1791beff1e0 + languageName: node + linkType: hard + +"@eslint/object-schema@npm:^2.1.4": + version: 2.1.4 + resolution: "@eslint/object-schema@npm:2.1.4" + checksum: 10c0/e9885532ea70e483fb007bf1275968b05bb15ebaa506d98560c41a41220d33d342e19023d5f2939fed6eb59676c1bda5c847c284b4b55fce521d282004da4dda + languageName: node + linkType: hard + +"@eslint/plugin-kit@npm:^0.2.0": + version: 0.2.1 + resolution: "@eslint/plugin-kit@npm:0.2.1" + dependencies: + levn: "npm:^0.4.1" + checksum: 10c0/34b1ecb35df97b0adeb6a43366fc1b8aa1a54d23fc9753019277e80a7295724fddb547a795fd59c9eb56d690bbf0d76d7f2286cb0f5db367a86a763d5acbde5f + languageName: node + linkType: hard + "@hapi/hoek@npm:^9.0.0, @hapi/hoek@npm:^9.3.0": version: 9.3.0 resolution: "@hapi/hoek@npm:9.3.0" @@ -2298,6 +2374,37 @@ __metadata: languageName: node linkType: hard +"@humanfs/core@npm:^0.19.0": + version: 0.19.0 + resolution: "@humanfs/core@npm:0.19.0" + checksum: 10c0/f87952d5caba6ae427a620eff783c5d0b6cef0cfc256dec359cdaa636c5f161edb8d8dad576742b3de7f0b2f222b34aad6870248e4b7d2177f013426cbcda232 + languageName: node + linkType: hard + +"@humanfs/node@npm:^0.16.5": + version: 0.16.5 + resolution: "@humanfs/node@npm:0.16.5" + dependencies: + "@humanfs/core": "npm:^0.19.0" + "@humanwhocodes/retry": "npm:^0.3.0" + checksum: 10c0/41c365ab09e7c9eaeed373d09243195aef616d6745608a36fc3e44506148c28843872f85e69e2bf5f1e992e194286155a1c1cecfcece6a2f43875e37cd243935 + languageName: node + linkType: hard + +"@humanwhocodes/module-importer@npm:^1.0.1": + version: 1.0.1 + resolution: "@humanwhocodes/module-importer@npm:1.0.1" + checksum: 10c0/909b69c3b86d482c26b3359db16e46a32e0fb30bd306a3c176b8313b9e7313dba0f37f519de6aa8b0a1921349e505f259d19475e123182416a506d7f87e7f529 + languageName: node + linkType: hard + +"@humanwhocodes/retry@npm:^0.3.0, @humanwhocodes/retry@npm:^0.3.1": + version: 0.3.1 + resolution: "@humanwhocodes/retry@npm:0.3.1" + checksum: 10c0/f0da1282dfb45e8120480b9e2e275e2ac9bbe1cf016d046fdad8e27cc1285c45bb9e711681237944445157b430093412b4446c1ab3fc4bb037861b5904101d3b + languageName: node + linkType: hard + "@isaacs/cliui@npm:^8.0.2": version: 8.0.2 resolution: "@isaacs/cliui@npm:8.0.2" @@ -3135,6 +3242,25 @@ __metadata: languageName: node linkType: hard +"@types/eslint@npm:*": + version: 9.6.1 + resolution: "@types/eslint@npm:9.6.1" + dependencies: + "@types/estree": "npm:*" + "@types/json-schema": "npm:*" + checksum: 10c0/69ba24fee600d1e4c5abe0df086c1a4d798abf13792d8cfab912d76817fe1a894359a1518557d21237fbaf6eda93c5ab9309143dee4c59ef54336d1b3570420e + languageName: node + linkType: hard + +"@types/eslint__js@npm:^8.42.3": + version: 8.42.3 + resolution: "@types/eslint__js@npm:8.42.3" + dependencies: + "@types/eslint": "npm:*" + checksum: 10c0/ccc5180b92155929a089ffb03ed62625216dcd5e46dd3197c6f82370ce8b52c7cb9df66c06b0a3017995409e023bc9eafe5a3f009e391960eacefaa1b62d9a56 + languageName: node + linkType: hard + "@types/estree-jsx@npm:^1.0.0": version: 1.0.5 resolution: "@types/estree-jsx@npm:1.0.5" @@ -3144,7 +3270,7 @@ __metadata: languageName: node linkType: hard -"@types/estree@npm:*, @types/estree@npm:^1.0.0, @types/estree@npm:^1.0.5": +"@types/estree@npm:*, @types/estree@npm:^1.0.0, @types/estree@npm:^1.0.5, @types/estree@npm:^1.0.6": version: 1.0.6 resolution: "@types/estree@npm:1.0.6" checksum: 10c0/cdfd751f6f9065442cd40957c07fd80361c962869aa853c1c2fd03e101af8b9389d8ff4955a43a6fcfa223dd387a089937f95be0f3eec21ca527039fd2d9859a @@ -3294,7 +3420,7 @@ __metadata: languageName: node linkType: hard -"@types/json-schema@npm:^7.0.4, @types/json-schema@npm:^7.0.5, @types/json-schema@npm:^7.0.8, @types/json-schema@npm:^7.0.9": +"@types/json-schema@npm:*, @types/json-schema@npm:^7.0.15, @types/json-schema@npm:^7.0.4, @types/json-schema@npm:^7.0.5, @types/json-schema@npm:^7.0.8, @types/json-schema@npm:^7.0.9": version: 7.0.15 resolution: "@types/json-schema@npm:7.0.15" checksum: 10c0/a996a745e6c5d60292f36731dd41341339d4eeed8180bb09226e5c8d23759067692b1d88e5d91d72ee83dfc00d3aca8e7bd43ea120516c17922cbcb7c3e252db @@ -3550,6 +3676,122 @@ __metadata: languageName: node linkType: hard +"@typescript-eslint/eslint-plugin@npm:8.11.0": + version: 8.11.0 + resolution: "@typescript-eslint/eslint-plugin@npm:8.11.0" + dependencies: + "@eslint-community/regexpp": "npm:^4.10.0" + "@typescript-eslint/scope-manager": "npm:8.11.0" + "@typescript-eslint/type-utils": "npm:8.11.0" + "@typescript-eslint/utils": "npm:8.11.0" + "@typescript-eslint/visitor-keys": "npm:8.11.0" + graphemer: "npm:^1.4.0" + ignore: "npm:^5.3.1" + natural-compare: "npm:^1.4.0" + ts-api-utils: "npm:^1.3.0" + peerDependencies: + "@typescript-eslint/parser": ^8.0.0 || ^8.0.0-alpha.0 + eslint: ^8.57.0 || ^9.0.0 + peerDependenciesMeta: + typescript: + optional: true + checksum: 10c0/be509f7bb0c0c596801059b06995a81a1c326cc6ac31d96a32f7b6b7d7b495f9bad4dc442aa6e923d22515e62c668d3c14695c68bd6e0be1d4bf72158b7fd2d6 + languageName: node + linkType: hard + +"@typescript-eslint/parser@npm:8.11.0": + version: 8.11.0 + resolution: "@typescript-eslint/parser@npm:8.11.0" + dependencies: + "@typescript-eslint/scope-manager": "npm:8.11.0" + "@typescript-eslint/types": "npm:8.11.0" + "@typescript-eslint/typescript-estree": "npm:8.11.0" + "@typescript-eslint/visitor-keys": "npm:8.11.0" + debug: "npm:^4.3.4" + peerDependencies: + eslint: ^8.57.0 || ^9.0.0 + peerDependenciesMeta: + typescript: + optional: true + checksum: 10c0/e83f239fec60697083e5dcb1c8948340e783ea6e043fe9a65d557faef8882963b09d69aacd736eb8ab18a768769a7bbfc3de0f1251d4bba080613541acb0741c + languageName: node + linkType: hard + +"@typescript-eslint/scope-manager@npm:8.11.0": + version: 8.11.0 + resolution: "@typescript-eslint/scope-manager@npm:8.11.0" + dependencies: + "@typescript-eslint/types": "npm:8.11.0" + "@typescript-eslint/visitor-keys": "npm:8.11.0" + checksum: 10c0/0910da62d8ae261711dd9f89d5c7d8e96ff13c50054436256e5a661309229cb49e3b8189c9468d36b6c4d3f7cddd121519ea78f9b18c9b869a808834b079b2ea + languageName: node + linkType: hard + +"@typescript-eslint/type-utils@npm:8.11.0": + version: 8.11.0 + resolution: "@typescript-eslint/type-utils@npm:8.11.0" + dependencies: + "@typescript-eslint/typescript-estree": "npm:8.11.0" + "@typescript-eslint/utils": "npm:8.11.0" + debug: "npm:^4.3.4" + ts-api-utils: "npm:^1.3.0" + peerDependenciesMeta: + typescript: + optional: true + checksum: 10c0/b69e31c1599ceeb20c29052a4ddb33a554174a3a4c55ee37d90c9b8250af6ef978a0b9ddbeefef4e83d62c4caea1bfa2d8088527f397bde69fb4ab9b360d794a + languageName: node + linkType: hard + +"@typescript-eslint/types@npm:8.11.0": + version: 8.11.0 + resolution: "@typescript-eslint/types@npm:8.11.0" + checksum: 10c0/5ccdd3eeee077a6fc8e7f4bc0e0cbc9327b1205a845253ec5c0c6c49ff915e853161df00c24a0ffb4b8ec745d3f153dd0e066400a021c844c026e31121f46699 + languageName: node + linkType: hard + +"@typescript-eslint/typescript-estree@npm:8.11.0": + version: 8.11.0 + resolution: "@typescript-eslint/typescript-estree@npm:8.11.0" + dependencies: + "@typescript-eslint/types": "npm:8.11.0" + "@typescript-eslint/visitor-keys": "npm:8.11.0" + debug: "npm:^4.3.4" + fast-glob: "npm:^3.3.2" + is-glob: "npm:^4.0.3" + minimatch: "npm:^9.0.4" + semver: "npm:^7.6.0" + ts-api-utils: "npm:^1.3.0" + peerDependenciesMeta: + typescript: + optional: true + checksum: 10c0/b629ad3cd32b005d5c1d67c36958a418f8672efebea869399834f4f201ebf90b942165eebb5c9d9799dcabdc2cc26e5fabb00629f76b158847f42e1a491a75a6 + languageName: node + linkType: hard + +"@typescript-eslint/utils@npm:8.11.0": + version: 8.11.0 + resolution: "@typescript-eslint/utils@npm:8.11.0" + dependencies: + "@eslint-community/eslint-utils": "npm:^4.4.0" + "@typescript-eslint/scope-manager": "npm:8.11.0" + "@typescript-eslint/types": "npm:8.11.0" + "@typescript-eslint/typescript-estree": "npm:8.11.0" + peerDependencies: + eslint: ^8.57.0 || ^9.0.0 + checksum: 10c0/bb5bcc8d928a55b22298e76f834ea6a9fe125a9ffeb6ac23bee0258b3ed32f41e281888a3d0be226a05e1011bb3b70e42a71a40366acdefea6779131c46bc522 + languageName: node + linkType: hard + +"@typescript-eslint/visitor-keys@npm:8.11.0": + version: 8.11.0 + resolution: "@typescript-eslint/visitor-keys@npm:8.11.0" + dependencies: + "@typescript-eslint/types": "npm:8.11.0" + eslint-visitor-keys: "npm:^3.4.3" + checksum: 10c0/7a5a49609fdc47e114fe59eee56393c90b122ec8e9520f90b0c5e189635ae1ccfa8e00108f641342c2c8f4637fe9d40c77927cf7c8248a3a660812cb4b7d0c08 + languageName: node + linkType: hard + "@ungap/structured-clone@npm:^1.0.0": version: 1.2.0 resolution: "@ungap/structured-clone@npm:1.2.0" @@ -3748,7 +3990,7 @@ __metadata: languageName: node linkType: hard -"acorn-jsx@npm:^5.0.0": +"acorn-jsx@npm:^5.0.0, acorn-jsx@npm:^5.3.2": version: 5.3.2 resolution: "acorn-jsx@npm:5.3.2" peerDependencies: @@ -3775,6 +4017,15 @@ __metadata: languageName: node linkType: hard +"acorn@npm:^8.12.0": + version: 8.13.0 + resolution: "acorn@npm:8.13.0" + bin: + acorn: bin/acorn + checksum: 10c0/f35dd53d68177c90699f4c37d0bb205b8abe036d955d0eb011ddb7f14a81e6fd0f18893731c457c1b5bd96754683f4c3d80d9a5585ddecaa53cdf84e0b3d68f7 + languageName: node + linkType: hard + "address@npm:^1.0.1, address@npm:^1.1.2": version: 1.2.2 resolution: "address@npm:1.2.2" @@ -3835,7 +4086,7 @@ __metadata: languageName: node linkType: hard -"ajv@npm:^6.12.2, ajv@npm:^6.12.5": +"ajv@npm:^6.12.2, ajv@npm:^6.12.4, ajv@npm:^6.12.5": version: 6.12.6 resolution: "ajv@npm:6.12.6" dependencies: @@ -4037,8 +4288,10 @@ __metadata: "@docusaurus/tsconfig": "npm:3.5.2" "@docusaurus/types": "npm:3.5.2" "@easyops-cn/docusaurus-search-local": "npm:^0.45.0" + "@eslint/js": "npm:^9.13.0" "@jsdevtools/rehype-url-inspector": "npm:^2.0.2" "@mdx-js/react": "npm:^3.0.1" + "@types/eslint__js": "npm:^8.42.3" "@types/glob": "npm:^8.1.0" "@types/js-yaml": "npm:^4.0.9" "@types/lodash": "npm:^4.17.10" @@ -4050,6 +4303,7 @@ __metadata: antd: "npm:^5.21.3" browserslist: "npm:^4.24.0" clsx: "npm:^2.1.1" + eslint: "npm:^9.13.0" glob: "npm:^11.0.0" lodash: "npm:^4.17.21" mdast-util-find-and-replace: "npm:^3.0.1" @@ -4060,6 +4314,7 @@ __metadata: react-dom: "npm:^18.3.1" react-router-dom: "npm:^5.3.4" typescript: "npm:^5.6.3" + typescript-eslint: "npm:^8.11.0" update-browserslist-db: "npm:^1.1.1" utility-types: "npm:^3.11.0" yaml: "npm:^2.5.1" @@ -5029,7 +5284,7 @@ __metadata: languageName: node linkType: hard -"cross-spawn@npm:^7.0.0, cross-spawn@npm:^7.0.3": +"cross-spawn@npm:^7.0.0, cross-spawn@npm:^7.0.2, cross-spawn@npm:^7.0.3": version: 7.0.3 resolution: "cross-spawn@npm:7.0.3" dependencies: @@ -5671,7 +5926,7 @@ __metadata: languageName: node linkType: hard -"debug@npm:4, debug@npm:^4.0.0, debug@npm:^4.1.0, debug@npm:^4.1.1, debug@npm:^4.2.0, debug@npm:^4.3.1, debug@npm:^4.3.4": +"debug@npm:4, debug@npm:^4.0.0, debug@npm:^4.1.0, debug@npm:^4.1.1, debug@npm:^4.2.0, debug@npm:^4.3.1, debug@npm:^4.3.2, debug@npm:^4.3.4": version: 4.3.7 resolution: "debug@npm:4.3.7" dependencies: @@ -5708,6 +5963,13 @@ __metadata: languageName: node linkType: hard +"deep-is@npm:^0.1.3": + version: 0.1.4 + resolution: "deep-is@npm:0.1.4" + checksum: 10c0/7f0ee496e0dff14a573dc6127f14c95061b448b87b995fc96c017ce0a1e66af1675e73f1d6064407975bc4ea6ab679497a29fff7b5b9c4e99cb10797c1ad0b4c + languageName: node + linkType: hard + "deepmerge@npm:^4.2.2, deepmerge@npm:^4.3.1": version: 4.3.1 resolution: "deepmerge@npm:4.3.1" @@ -6209,6 +6471,91 @@ __metadata: languageName: node linkType: hard +"eslint-scope@npm:^8.1.0": + version: 8.1.0 + resolution: "eslint-scope@npm:8.1.0" + dependencies: + esrecurse: "npm:^4.3.0" + estraverse: "npm:^5.2.0" + checksum: 10c0/ae1df7accae9ea90465c2ded70f7064d6d1f2962ef4cc87398855c4f0b3a5ab01063e0258d954bb94b184f6759febe04c3118195cab5c51978a7229948ba2875 + languageName: node + linkType: hard + +"eslint-visitor-keys@npm:^3.4.3": + version: 3.4.3 + resolution: "eslint-visitor-keys@npm:3.4.3" + checksum: 10c0/92708e882c0a5ffd88c23c0b404ac1628cf20104a108c745f240a13c332a11aac54f49a22d5762efbffc18ecbc9a580d1b7ad034bf5f3cc3307e5cbff2ec9820 + languageName: node + linkType: hard + +"eslint-visitor-keys@npm:^4.1.0": + version: 4.1.0 + resolution: "eslint-visitor-keys@npm:4.1.0" + checksum: 10c0/5483ef114c93a136aa234140d7aa3bd259488dae866d35cb0d0b52e6a158f614760a57256ac8d549acc590a87042cb40f6951815caa821e55dc4fd6ef4c722eb + languageName: node + linkType: hard + +"eslint@npm:^9.13.0": + version: 9.13.0 + resolution: "eslint@npm:9.13.0" + dependencies: + "@eslint-community/eslint-utils": "npm:^4.2.0" + "@eslint-community/regexpp": "npm:^4.11.0" + "@eslint/config-array": "npm:^0.18.0" + "@eslint/core": "npm:^0.7.0" + "@eslint/eslintrc": "npm:^3.1.0" + "@eslint/js": "npm:9.13.0" + "@eslint/plugin-kit": "npm:^0.2.0" + "@humanfs/node": "npm:^0.16.5" + "@humanwhocodes/module-importer": "npm:^1.0.1" + "@humanwhocodes/retry": "npm:^0.3.1" + "@types/estree": "npm:^1.0.6" + "@types/json-schema": "npm:^7.0.15" + ajv: "npm:^6.12.4" + chalk: "npm:^4.0.0" + cross-spawn: "npm:^7.0.2" + debug: "npm:^4.3.2" + escape-string-regexp: "npm:^4.0.0" + eslint-scope: "npm:^8.1.0" + eslint-visitor-keys: "npm:^4.1.0" + espree: "npm:^10.2.0" + esquery: "npm:^1.5.0" + esutils: "npm:^2.0.2" + fast-deep-equal: "npm:^3.1.3" + file-entry-cache: "npm:^8.0.0" + find-up: "npm:^5.0.0" + glob-parent: "npm:^6.0.2" + ignore: "npm:^5.2.0" + imurmurhash: "npm:^0.1.4" + is-glob: "npm:^4.0.0" + json-stable-stringify-without-jsonify: "npm:^1.0.1" + lodash.merge: "npm:^4.6.2" + minimatch: "npm:^3.1.2" + natural-compare: "npm:^1.4.0" + optionator: "npm:^0.9.3" + text-table: "npm:^0.2.0" + peerDependencies: + jiti: "*" + peerDependenciesMeta: + jiti: + optional: true + bin: + eslint: bin/eslint.js + checksum: 10c0/d3577444152182a9d8ea8c6a6acb073d3a2773ad73a6b646f432746583ec4bfcd6a44fcc2e37d05d276984e583c46c2d289b3b981ca8f8b4052756a152341d19 + languageName: node + linkType: hard + +"espree@npm:^10.0.1, espree@npm:^10.2.0": + version: 10.2.0 + resolution: "espree@npm:10.2.0" + dependencies: + acorn: "npm:^8.12.0" + acorn-jsx: "npm:^5.3.2" + eslint-visitor-keys: "npm:^4.1.0" + checksum: 10c0/2b6bfb683e7e5ab2e9513949879140898d80a2d9867ea1db6ff5b0256df81722633b60a7523a7c614f05a39aeea159dd09ad2a0e90c0e218732fc016f9086215 + languageName: node + linkType: hard + "esprima@npm:^4.0.0": version: 4.0.1 resolution: "esprima@npm:4.0.1" @@ -6219,6 +6566,15 @@ __metadata: languageName: node linkType: hard +"esquery@npm:^1.5.0": + version: 1.6.0 + resolution: "esquery@npm:1.6.0" + dependencies: + estraverse: "npm:^5.1.0" + checksum: 10c0/cb9065ec605f9da7a76ca6dadb0619dfb611e37a81e318732977d90fab50a256b95fee2d925fba7c2f3f0523aa16f91587246693bc09bc34d5a59575fe6e93d2 + languageName: node + linkType: hard + "esrecurse@npm:^4.3.0": version: 4.3.0 resolution: "esrecurse@npm:4.3.0" @@ -6235,7 +6591,7 @@ __metadata: languageName: node linkType: hard -"estraverse@npm:^5.2.0": +"estraverse@npm:^5.1.0, estraverse@npm:^5.2.0": version: 5.3.0 resolution: "estraverse@npm:5.3.0" checksum: 10c0/1ff9447b96263dec95d6d67431c5e0771eb9776427421260a3e2f0fdd5d6bd4f8e37a7338f5ad2880c9f143450c9b1e4fc2069060724570a49cf9cf0312bd107 @@ -6440,7 +6796,7 @@ __metadata: languageName: node linkType: hard -"fast-glob@npm:^3.2.11, fast-glob@npm:^3.2.9, fast-glob@npm:^3.3.0": +"fast-glob@npm:^3.2.11, fast-glob@npm:^3.2.9, fast-glob@npm:^3.3.0, fast-glob@npm:^3.3.2": version: 3.3.2 resolution: "fast-glob@npm:3.3.2" dependencies: @@ -6460,6 +6816,13 @@ __metadata: languageName: node linkType: hard +"fast-levenshtein@npm:^2.0.6": + version: 2.0.6 + resolution: "fast-levenshtein@npm:2.0.6" + checksum: 10c0/111972b37338bcb88f7d9e2c5907862c280ebf4234433b95bc611e518d192ccb2d38119c4ac86e26b668d75f7f3894f4ff5c4982899afced7ca78633b08287c4 + languageName: node + linkType: hard + "fast-uri@npm:^3.0.1": version: 3.0.2 resolution: "fast-uri@npm:3.0.2" @@ -6512,6 +6875,15 @@ __metadata: languageName: node linkType: hard +"file-entry-cache@npm:^8.0.0": + version: 8.0.0 + resolution: "file-entry-cache@npm:8.0.0" + dependencies: + flat-cache: "npm:^4.0.0" + checksum: 10c0/9e2b5938b1cd9b6d7e3612bdc533afd4ac17b2fc646569e9a8abbf2eb48e5eb8e316bc38815a3ef6a1b456f4107f0d0f055a614ca613e75db6bf9ff4d72c1638 + languageName: node + linkType: hard + "file-loader@npm:^6.2.0": version: 6.2.0 resolution: "file-loader@npm:6.2.0" @@ -6594,6 +6966,16 @@ __metadata: languageName: node linkType: hard +"flat-cache@npm:^4.0.0": + version: 4.0.1 + resolution: "flat-cache@npm:4.0.1" + dependencies: + flatted: "npm:^3.2.9" + keyv: "npm:^4.5.4" + checksum: 10c0/2c59d93e9faa2523e4fda6b4ada749bed432cfa28c8e251f33b25795e426a1c6dbada777afb1f74fcfff33934fdbdea921ee738fcc33e71adc9d6eca984a1cfc + languageName: node + linkType: hard + "flat@npm:^5.0.2": version: 5.0.2 resolution: "flat@npm:5.0.2" @@ -6603,6 +6985,13 @@ __metadata: languageName: node linkType: hard +"flatted@npm:^3.2.9": + version: 3.3.1 + resolution: "flatted@npm:3.3.1" + checksum: 10c0/324166b125ee07d4ca9bcf3a5f98d915d5db4f39d711fba640a3178b959919aae1f7cfd8aabcfef5826ed8aa8a2aa14cc85b2d7d18ff638ddf4ae3df39573eaf + languageName: node + linkType: hard + "follow-redirects@npm:^1.0.0": version: 1.15.9 resolution: "follow-redirects@npm:1.15.9" @@ -6831,7 +7220,7 @@ __metadata: languageName: node linkType: hard -"glob-parent@npm:^6.0.1": +"glob-parent@npm:^6.0.1, glob-parent@npm:^6.0.2": version: 6.0.2 resolution: "glob-parent@npm:6.0.2" dependencies: @@ -6929,6 +7318,13 @@ __metadata: languageName: node linkType: hard +"globals@npm:^14.0.0": + version: 14.0.0 + resolution: "globals@npm:14.0.0" + checksum: 10c0/b96ff42620c9231ad468d4c58ff42afee7777ee1c963013ff8aabe095a451d0ceeb8dcd8ef4cbd64d2538cef45f787a78ba3a9574f4a634438963e334471302d + languageName: node + linkType: hard + "globby@npm:^11.0.1, globby@npm:^11.0.4, globby@npm:^11.1.0": version: 11.1.0 resolution: "globby@npm:11.1.0" @@ -6998,6 +7394,13 @@ __metadata: languageName: node linkType: hard +"graphemer@npm:^1.4.0": + version: 1.4.0 + resolution: "graphemer@npm:1.4.0" + checksum: 10c0/e951259d8cd2e0d196c72ec711add7115d42eb9a8146c8eeda5b8d3ac91e5dd816b9cd68920726d9fd4490368e7ed86e9c423f40db87e2d8dfafa00fa17c3a31 + languageName: node + linkType: hard + "gray-matter@npm:^4.0.3": version: 4.0.3 resolution: "gray-matter@npm:4.0.3" @@ -7511,7 +7914,7 @@ __metadata: languageName: node linkType: hard -"ignore@npm:^5.2.0, ignore@npm:^5.2.4": +"ignore@npm:^5.2.0, ignore@npm:^5.2.4, ignore@npm:^5.3.1": version: 5.3.2 resolution: "ignore@npm:5.3.2" checksum: 10c0/f9f652c957983634ded1e7f02da3b559a0d4cc210fca3792cb67f1b153623c9c42efdc1c4121af171e295444459fc4a9201101fb041b1104a3c000bccb188337 @@ -7543,7 +7946,7 @@ __metadata: languageName: node linkType: hard -"import-fresh@npm:^3.1.0, import-fresh@npm:^3.3.0": +"import-fresh@npm:^3.1.0, import-fresh@npm:^3.2.1, import-fresh@npm:^3.3.0": version: 3.3.0 resolution: "import-fresh@npm:3.3.0" dependencies: @@ -7791,7 +8194,7 @@ __metadata: languageName: node linkType: hard -"is-glob@npm:^4.0.1, is-glob@npm:^4.0.3, is-glob@npm:~4.0.1": +"is-glob@npm:^4.0.0, is-glob@npm:^4.0.1, is-glob@npm:^4.0.3, is-glob@npm:~4.0.1": version: 4.0.3 resolution: "is-glob@npm:4.0.3" dependencies: @@ -8132,6 +8535,13 @@ __metadata: languageName: node linkType: hard +"json-stable-stringify-without-jsonify@npm:^1.0.1": + version: 1.0.1 + resolution: "json-stable-stringify-without-jsonify@npm:1.0.1" + checksum: 10c0/cb168b61fd4de83e58d09aaa6425ef71001bae30d260e2c57e7d09a5fd82223e2f22a042dedaab8db23b7d9ae46854b08bb1f91675a8be11c5cffebef5fb66a5 + languageName: node + linkType: hard + "json2mq@npm:^0.2.0": version: 0.2.0 resolution: "json2mq@npm:0.2.0" @@ -8174,7 +8584,7 @@ __metadata: languageName: node linkType: hard -"keyv@npm:^4.5.3": +"keyv@npm:^4.5.3, keyv@npm:^4.5.4": version: 4.5.4 resolution: "keyv@npm:4.5.4" dependencies: @@ -8253,6 +8663,16 @@ __metadata: languageName: node linkType: hard +"levn@npm:^0.4.1": + version: 0.4.1 + resolution: "levn@npm:0.4.1" + dependencies: + prelude-ls: "npm:^1.2.1" + type-check: "npm:~0.4.0" + checksum: 10c0/effb03cad7c89dfa5bd4f6989364bfc79994c2042ec5966cb9b95990e2edee5cd8969ddf42616a0373ac49fac1403437deaf6e9050fbbaa3546093a59b9ac94e + languageName: node + linkType: hard + "lilconfig@npm:^3.1.1": version: 3.1.2 resolution: "lilconfig@npm:3.1.2" @@ -8341,6 +8761,13 @@ __metadata: languageName: node linkType: hard +"lodash.merge@npm:^4.6.2": + version: 4.6.2 + resolution: "lodash.merge@npm:4.6.2" + checksum: 10c0/402fa16a1edd7538de5b5903a90228aa48eb5533986ba7fa26606a49db2572bf414ff73a2c9f5d5fd36b31c46a5d5c7e1527749c07cbcf965ccff5fbdf32c506 + languageName: node + linkType: hard + "lodash.uniq@npm:^4.5.0": version: 4.5.0 resolution: "lodash.uniq@npm:4.5.0" @@ -9634,7 +10061,7 @@ __metadata: languageName: node linkType: hard -"minimatch@npm:3.1.2, minimatch@npm:^3.0.4, minimatch@npm:^3.0.5, minimatch@npm:^3.1.1": +"minimatch@npm:3.1.2, minimatch@npm:^3.0.4, minimatch@npm:^3.0.5, minimatch@npm:^3.1.1, minimatch@npm:^3.1.2": version: 3.1.2 resolution: "minimatch@npm:3.1.2" dependencies: @@ -9810,6 +10237,13 @@ __metadata: languageName: node linkType: hard +"natural-compare@npm:^1.4.0": + version: 1.4.0 + resolution: "natural-compare@npm:1.4.0" + checksum: 10c0/f5f9a7974bfb28a91afafa254b197f0f22c684d4a1731763dda960d2c8e375b36c7d690e0d9dc8fba774c537af14a7e979129bca23d88d052fbeb9466955e447 + languageName: node + linkType: hard + "negotiator@npm:0.6.3, negotiator@npm:^0.6.3": version: 0.6.3 resolution: "negotiator@npm:0.6.3" @@ -10038,6 +10472,20 @@ __metadata: languageName: node linkType: hard +"optionator@npm:^0.9.3": + version: 0.9.4 + resolution: "optionator@npm:0.9.4" + dependencies: + deep-is: "npm:^0.1.3" + fast-levenshtein: "npm:^2.0.6" + levn: "npm:^0.4.1" + prelude-ls: "npm:^1.2.1" + type-check: "npm:^0.4.0" + word-wrap: "npm:^1.2.5" + checksum: 10c0/4afb687a059ee65b61df74dfe87d8d6815cd6883cb8b3d5883a910df72d0f5d029821f37025e4bccf4048873dbdb09acc6d303d27b8f76b1a80dd5a7d5334675 + languageName: node + linkType: hard + "p-cancelable@npm:^3.0.0": version: 3.0.0 resolution: "p-cancelable@npm:3.0.0" @@ -10829,6 +11277,13 @@ __metadata: languageName: node linkType: hard +"prelude-ls@npm:^1.2.1": + version: 1.2.1 + resolution: "prelude-ls@npm:1.2.1" + checksum: 10c0/b00d617431e7886c520a6f498a2e14c75ec58f6d93ba48c3b639cf241b54232d90daa05d83a9e9b9fef6baa63cb7e1e4602c2372fea5bc169668401eb127d0cd + languageName: node + linkType: hard + "prettier@npm:^3.3.3": version: 3.3.3 resolution: "prettier@npm:3.3.3" @@ -12335,7 +12790,7 @@ __metadata: languageName: node linkType: hard -"semver@npm:^7.3.2, semver@npm:^7.3.5, semver@npm:^7.3.7, semver@npm:^7.5.4": +"semver@npm:^7.3.2, semver@npm:^7.3.5, semver@npm:^7.3.7, semver@npm:^7.5.4, semver@npm:^7.6.0": version: 7.6.3 resolution: "semver@npm:7.6.3" bin: @@ -13118,6 +13573,15 @@ __metadata: languageName: node linkType: hard +"ts-api-utils@npm:^1.3.0": + version: 1.3.0 + resolution: "ts-api-utils@npm:1.3.0" + peerDependencies: + typescript: ">=4.2.0" + checksum: 10c0/f54a0ba9ed56ce66baea90a3fa087a484002e807f28a8ccb2d070c75e76bde64bd0f6dce98b3802834156306050871b67eec325cb4e918015a360a3f0868c77c + languageName: node + linkType: hard + "ts-dedent@npm:^2.2.0": version: 2.2.0 resolution: "ts-dedent@npm:2.2.0" @@ -13132,6 +13596,15 @@ __metadata: languageName: node linkType: hard +"type-check@npm:^0.4.0, type-check@npm:~0.4.0": + version: 0.4.0 + resolution: "type-check@npm:0.4.0" + dependencies: + prelude-ls: "npm:^1.2.1" + checksum: 10c0/7b3fd0ed43891e2080bf0c5c504b418fbb3e5c7b9708d3d015037ba2e6323a28152ec163bcb65212741fa5d2022e3075ac3c76440dbd344c9035f818e8ecee58 + languageName: node + linkType: hard + "type-fest@npm:^1.0.1": version: 1.4.0 resolution: "type-fest@npm:1.4.0" @@ -13165,6 +13638,20 @@ __metadata: languageName: node linkType: hard +"typescript-eslint@npm:^8.11.0": + version: 8.11.0 + resolution: "typescript-eslint@npm:8.11.0" + dependencies: + "@typescript-eslint/eslint-plugin": "npm:8.11.0" + "@typescript-eslint/parser": "npm:8.11.0" + "@typescript-eslint/utils": "npm:8.11.0" + peerDependenciesMeta: + typescript: + optional: true + checksum: 10c0/8f9b5916c9f47b0cbb26f142d1a266a6aaf33998ec87621252dffb56d8fe0ad01a944f8d8d837e4e6058153a1deee3557527d14fa7bf7ef80a927334529db6bd + languageName: node + linkType: hard + "typescript@npm:^5.6.3": version: 5.6.3 resolution: "typescript@npm:5.6.3" @@ -13834,6 +14321,13 @@ __metadata: languageName: node linkType: hard +"word-wrap@npm:^1.2.5": + version: 1.2.5 + resolution: "word-wrap@npm:1.2.5" + checksum: 10c0/e0e4a1ca27599c92a6ca4c32260e8a92e8a44f4ef6ef93f803f8ed823f486e0889fc0b93be4db59c8d51b3064951d25e43d434e95dc8c960cc3a63d65d00ba20 + languageName: node + linkType: hard + "wrap-ansi-cjs@npm:wrap-ansi@^7.0.0": version: 7.0.0 resolution: "wrap-ansi@npm:7.0.0" From c7f37e71a40630a8703e435d92708430053a4f84 Mon Sep 17 00:00:00 2001 From: WANG Xuerui Date: Sat, 26 Oct 2024 14:32:04 +0800 Subject: [PATCH 10/25] build: configure eslint --- eslint.config.mjs | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 eslint.config.mjs diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 00000000..c17ae4e5 --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,12 @@ +// @ts-check + +import eslint from '@eslint/js' +import tseslint from 'typescript-eslint' + +export default tseslint.config( + eslint.configs.recommended, + ...tseslint.configs.recommended, + { + ignores: ['.docusaurus/', '.yarn/', '.pnp.*', 'build/'], + }, +) From 7ad9c8203ad0b9b8dddc15f6ee30b745b1446bab Mon Sep 17 00:00:00 2001 From: WANG Xuerui Date: Sat, 26 Oct 2024 14:34:09 +0800 Subject: [PATCH 11/25] build: migrate babel config to TS --- babel.config.cts | 5 +++++ babel.config.js | 3 --- 2 files changed, 5 insertions(+), 3 deletions(-) create mode 100644 babel.config.cts delete mode 100644 babel.config.js diff --git a/babel.config.cts b/babel.config.cts new file mode 100644 index 00000000..9fa9bd3f --- /dev/null +++ b/babel.config.cts @@ -0,0 +1,5 @@ +import docusaurusPreset from '@docusaurus/core/lib/babel/preset' + +export default { + presets: [docusaurusPreset], +} diff --git a/babel.config.js b/babel.config.js deleted file mode 100644 index 67526481..00000000 --- a/babel.config.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - presets: [require.resolve('@docusaurus/core/lib/babel/preset')], -} From 493389b203d4aedc698dcfebaab74d124e73db5f Mon Sep 17 00:00:00 2001 From: WANG Xuerui Date: Sat, 26 Oct 2024 14:43:30 +0800 Subject: [PATCH 12/25] refactor(asmdb): make augmentedDecodeTree plain TS --- .../AsmDB/{augmentedDecodeTree.tsx => augmentedDecodeTree.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/components/AsmDB/{augmentedDecodeTree.tsx => augmentedDecodeTree.ts} (100%) diff --git a/src/components/AsmDB/augmentedDecodeTree.tsx b/src/components/AsmDB/augmentedDecodeTree.ts similarity index 100% rename from src/components/AsmDB/augmentedDecodeTree.tsx rename to src/components/AsmDB/augmentedDecodeTree.ts From 4fd18c3d1142cc8e86add7551c7f97e9ec4e80b8 Mon Sep 17 00:00:00 2001 From: WANG Xuerui Date: Sat, 26 Oct 2024 14:45:38 +0800 Subject: [PATCH 13/25] refactor: un-nest plugin directories --- .../{awly-asmdb-plugin/index.ts => awly-asmdb-plugin.ts} | 0 src/plugins/{awly-data-plugin/index.ts => awly-data-plugin.ts} | 2 +- .../index.ts => awly-rehype-annotate-overseas-links.ts} | 0 3 files changed, 1 insertion(+), 1 deletion(-) rename src/plugins/{awly-asmdb-plugin/index.ts => awly-asmdb-plugin.ts} (100%) rename src/plugins/{awly-data-plugin/index.ts => awly-data-plugin.ts} (99%) rename src/plugins/{awly-rehype-annotate-overseas-links/index.ts => awly-rehype-annotate-overseas-links.ts} (100%) diff --git a/src/plugins/awly-asmdb-plugin/index.ts b/src/plugins/awly-asmdb-plugin.ts similarity index 100% rename from src/plugins/awly-asmdb-plugin/index.ts rename to src/plugins/awly-asmdb-plugin.ts diff --git a/src/plugins/awly-data-plugin/index.ts b/src/plugins/awly-data-plugin.ts similarity index 99% rename from src/plugins/awly-data-plugin/index.ts rename to src/plugins/awly-data-plugin.ts index 4b02c5f2..ef277e53 100644 --- a/src/plugins/awly-data-plugin/index.ts +++ b/src/plugins/awly-data-plugin.ts @@ -14,7 +14,7 @@ import { IProjectCategory, LoadedContent, SupportStatus, -} from '../../types' +} from '../types' export type PluginOptions = { sourcePath: string diff --git a/src/plugins/awly-rehype-annotate-overseas-links/index.ts b/src/plugins/awly-rehype-annotate-overseas-links.ts similarity index 100% rename from src/plugins/awly-rehype-annotate-overseas-links/index.ts rename to src/plugins/awly-rehype-annotate-overseas-links.ts From 347d7c9e54a5d788fc71b8e38ac703f406116309 Mon Sep 17 00:00:00 2001 From: WANG Xuerui Date: Sat, 26 Oct 2024 14:56:48 +0800 Subject: [PATCH 14/25] refactor: fix eslint for ejected prism-include-languages --- src/theme/prism-include-languages.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/theme/prism-include-languages.ts b/src/theme/prism-include-languages.ts index 884d42cf..a159e0c1 100644 --- a/src/theme/prism-include-languages.ts +++ b/src/theme/prism-include-languages.ts @@ -20,14 +20,15 @@ export default function prismIncludeLanguages( additionalLanguages.forEach((lang) => { if (lang === 'php') { - // eslint-disable-next-line global-require + // eslint-disable-next-line @typescript-eslint/no-require-imports require('prismjs/components/prism-markup-templating.js') } - // eslint-disable-next-line global-require, import/no-dynamic-require + // eslint-disable-next-line @typescript-eslint/no-require-imports require(`prismjs/components/prism-${lang}`) }) // AWLY addition(s) + // eslint-disable-next-line @typescript-eslint/no-require-imports require('../plugins/prism-asmloong') delete (globalThis as Optional).Prism From a40202c753f6f039e413bf47c8755990d1ece7fd Mon Sep 17 00:00:00 2001 From: WANG Xuerui Date: Sat, 26 Oct 2024 14:58:09 +0800 Subject: [PATCH 15/25] refactor: fix prefer-const --- src/components/AsmDB/augmentedDecodeTree.ts | 6 +++--- src/components/AsmDB/insnListPage.tsx | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/AsmDB/augmentedDecodeTree.ts b/src/components/AsmDB/augmentedDecodeTree.ts index 454a0c92..2365ab91 100644 --- a/src/components/AsmDB/augmentedDecodeTree.ts +++ b/src/components/AsmDB/augmentedDecodeTree.ts @@ -43,9 +43,9 @@ function getWellKnownAlias(pat: string): string { } function makeMatchPatternKey(match: number, bfs: Bitfield[]): string { - let s = match.toString(2).padStart(32, '0').split('') + const s = match.toString(2).padStart(32, '0').split('') s.reverse() - let y = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'.split('') + const y = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'.split('') for (const bf of bfs) for (let i = bf.lsb; i < bf.lsb + bf.len; i++) y[i] = s[i] y.reverse() @@ -79,7 +79,7 @@ export type AugmentedDecodeTreeNode = DecodeTreeNode & { export function augmentDecodeTree( node: DecodeTreeNode, ): AugmentedDecodeTreeNode { - let x = _.cloneDeep(node) as AugmentedDecodeTreeNode + const x = _.cloneDeep(node) as AugmentedDecodeTreeNode augmentDecodeTreeInplace(x, null, 0, []) return x } diff --git a/src/components/AsmDB/insnListPage.tsx b/src/components/AsmDB/insnListPage.tsx index d8ac33c2..afdc02bc 100644 --- a/src/components/AsmDB/insnListPage.tsx +++ b/src/components/AsmDB/insnListPage.tsx @@ -107,7 +107,7 @@ export default function InsnListPage({ }) const alterSS = (modifier: (origSS: SubsetFlags, x: boolean) => void) => { return (x: boolean) => { - let newSS: SubsetFlags = { + const newSS: SubsetFlags = { primary: ss.primary, la32: ss.la32, la64: ss.la64, From dc15d033dd02b5c6f345ca60dd9d6cf4c0f1dc85 Mon Sep 17 00:00:00 2001 From: WANG Xuerui Date: Sat, 26 Oct 2024 15:09:06 +0800 Subject: [PATCH 16/25] build: update tsconfig to align with latest docusaurus preset --- tsconfig.json | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tsconfig.json b/tsconfig.json index 46862fed..ee5c3fec 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,12 +1,13 @@ { // This file is not used in compilation. It is here just for a nice editor experience. - "extends": "@docusaurus/tsconfig", + "extends": ["@docusaurus/tsconfig"], "compilerOptions": { "baseUrl": ".", "esModuleInterop": true, - "module": "NodeNext", - "moduleResolution": "NodeNext", - "target": "ESNext", + "lib": ["ES2022", "DOM"], + "module": "ESNext", + "moduleResolution": "Bundler", + "target": "ES2022", "useDefineForClassFields": true } } From fec7c295fdd4f1b335af3725c9249e344f540c72 Mon Sep 17 00:00:00 2001 From: WANG Xuerui Date: Sat, 26 Oct 2024 15:11:32 +0800 Subject: [PATCH 17/25] refactor: fix no-prototype-builtins --- src/components/AsmDB/augmentedDecodeTree.ts | 2 +- src/components/AsmDB/encodingSpaceOverviewPage.tsx | 2 +- src/components/AsmDB/insnFormat.ts | 6 +++--- src/plugins/awly-rehype-annotate-overseas-links.ts | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/AsmDB/augmentedDecodeTree.ts b/src/components/AsmDB/augmentedDecodeTree.ts index 2365ab91..241a84ae 100644 --- a/src/components/AsmDB/augmentedDecodeTree.ts +++ b/src/components/AsmDB/augmentedDecodeTree.ts @@ -37,7 +37,7 @@ const wellKnownMatchPatterns = { } function getWellKnownAlias(pat: string): string { - if (wellKnownMatchPatterns.hasOwnProperty(pat)) + if (Object.hasOwn(wellKnownMatchPatterns, pat)) return wellKnownMatchPatterns[pat] return '' } diff --git a/src/components/AsmDB/encodingSpaceOverviewPage.tsx b/src/components/AsmDB/encodingSpaceOverviewPage.tsx index f2556f47..eb969cad 100644 --- a/src/components/AsmDB/encodingSpaceOverviewPage.tsx +++ b/src/components/AsmDB/encodingSpaceOverviewPage.tsx @@ -56,7 +56,7 @@ type DecodeTreeNodeDetailProps = { const DecodeTreeNodeDetail: React.FC< DecodeTreeNodeDetailProps & React.HTMLAttributes > = (props) => { - if (!props.data.hasOwnProperty(props.selectedKey)) + if (!Object.hasOwn(props.data, props.selectedKey)) return ( <>

      编码空间明细

      diff --git a/src/components/AsmDB/insnFormat.ts b/src/components/AsmDB/insnFormat.ts index 842e59c2..35fd2b9e 100644 --- a/src/components/AsmDB/insnFormat.ts +++ b/src/components/AsmDB/insnFormat.ts @@ -34,7 +34,7 @@ function parseInsnArg(s: string): { remaining: string; arg: InsnArg } { return fail const prefix = s[0] - if (!prefixKindMap.hasOwnProperty(prefix)) + if (!Object.hasOwn(prefixKindMap, prefix)) // malformed input return fail @@ -144,8 +144,8 @@ function parseArgSlot(s: string): { return fail const lsbChar = s[0] - if (!lsbMap.hasOwnProperty(lsbChar)) { - if (prefixKindMap.hasOwnProperty(lsbChar)) + if (!Object.hasOwn(lsbMap, lsbChar)) { + if (Object.hasOwn(prefixKindMap, lsbChar)) // we've finished return { remaining: s, finish: true, slot: null } diff --git a/src/plugins/awly-rehype-annotate-overseas-links.ts b/src/plugins/awly-rehype-annotate-overseas-links.ts index 67706db6..0fd42369 100644 --- a/src/plugins/awly-rehype-annotate-overseas-links.ts +++ b/src/plugins/awly-rehype-annotate-overseas-links.ts @@ -32,7 +32,7 @@ export default function doAnnotateOverseasLinks({ url, node }: UrlMatch) { if (isHostLikelyCNDomestic(hostname)) return // console.log('annotating', url) - if (node.properties.hasOwnProperty('class')) + if (Object.hasOwn(node.properties, 'class')) node.properties.class += ' link--overseas' else node.properties.class = 'link--overseas' } From 2b8270c781059e435ca5e4cc496318dea237437b Mon Sep 17 00:00:00 2001 From: WANG Xuerui Date: Sat, 26 Oct 2024 15:44:04 +0800 Subject: [PATCH 18/25] refactor: fix typescript-eslint/no-explicit-any --- src/plugins/awly-data-plugin.ts | 5 ++--- src/plugins/awly-remark-natlang-usage.ts | 4 ++-- src/theme/Footer/Copyright/index.tsx | 4 ++-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/plugins/awly-data-plugin.ts b/src/plugins/awly-data-plugin.ts index ef277e53..2a7d8fc9 100644 --- a/src/plugins/awly-data-plugin.ts +++ b/src/plugins/awly-data-plugin.ts @@ -133,11 +133,10 @@ function parsePortingEffort(x: InputPortingEffort): IPortingEffort { } async function readAuthors(path: string): Promise> { - const content: any = await readUTF8YAML(path) + const content: { [key: string]: InputAuthor } = await readUTF8YAML(path) const result = new Map() - for (const [k, vv] of Object.entries(content)) { - const v = vv as InputAuthor + for (const [k, v] of Object.entries(content)) { result.set(k, { name: v.name, kind: parseEntityKind(v.kind), diff --git a/src/plugins/awly-remark-natlang-usage.ts b/src/plugins/awly-remark-natlang-usage.ts index e9fa1b63..8acc4f8c 100644 --- a/src/plugins/awly-remark-natlang-usage.ts +++ b/src/plugins/awly-remark-natlang-usage.ts @@ -1,7 +1,7 @@ import { Nodes, PhrasingContent } from 'mdast' // import { findAndReplace } from 'mdast-util-find-and-replace' -function produceErhuaMark(match: any): PhrasingContent { +function produceErhuaMark(): PhrasingContent { // this won't work // return { type: 'html', value: '' } // @@ -16,7 +16,7 @@ function produceErhuaMark(match: any): PhrasingContent { } } -export default async function plugin(options: any) { +export default async function plugin() { const { findAndReplace } = await import('mdast-util-find-and-replace') return (tree: Nodes) => { findAndReplace(tree, [ diff --git a/src/theme/Footer/Copyright/index.tsx b/src/theme/Footer/Copyright/index.tsx index 25cdd8f3..f118e3cd 100644 --- a/src/theme/Footer/Copyright/index.tsx +++ b/src/theme/Footer/Copyright/index.tsx @@ -1,4 +1,4 @@ -import Copyright from '@theme-original/Footer/Copyright' +import Copyright, { type Props } from '@theme-original/Footer/Copyright' import IconExternalLink from '@theme-original/Icon/ExternalLink' import styles from './styles.module.css' @@ -41,7 +41,7 @@ function MPSBeianLink({ ) } -export default function CopyrightWrapper(props: any): JSX.Element { +export default function CopyrightWrapper(props: typeof Props): JSX.Element { return ( <>

      From c0731adb09ee5651a4e270dffff079a3ff8f5d19 Mon Sep 17 00:00:00 2001 From: WANG Xuerui Date: Sat, 26 Oct 2024 15:45:16 +0800 Subject: [PATCH 19/25] refactor: fix no-useless-escape --- src/plugins/prism-asmloong.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/prism-asmloong.ts b/src/plugins/prism-asmloong.ts index 1dcc6852..9ef35ec5 100644 --- a/src/plugins/prism-asmloong.ts +++ b/src/plugins/prism-asmloong.ts @@ -22,7 +22,7 @@ Prism.languages.asmloong = { alias: 'keyword', }, reloc: { - pattern: /\%(?:le_hi20|le_lo12)\b/, + pattern: /%(?:le_hi20|le_lo12)\b/, alias: 'function', }, punctuation: /[(),:]/, From d01e3504d29d177d85f780fef97524fd20cea82c Mon Sep 17 00:00:00 2001 From: WANG Xuerui Date: Sat, 26 Oct 2024 15:46:10 +0800 Subject: [PATCH 20/25] refactor: fix no-case-declarations --- src/components/AsmDB/vldi.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/AsmDB/vldi.ts b/src/components/AsmDB/vldi.ts index 5ff66430..8883d06a 100644 --- a/src/components/AsmDB/vldi.ts +++ b/src/components/AsmDB/vldi.ts @@ -136,10 +136,11 @@ function performVldi( case VldiFunction.BroadcastBitExpandedU8To64: return Array(numElems).fill(expandU8BitsToU64(param)) - case VldiFunction.BroadcastVldiMinifloatToEvenF32: + case VldiFunction.BroadcastVldiMinifloatToEvenF32: { const result = Array(numElems).fill(0.0) for (let i = 0; i < numElems; i += 2) result[i] = param return result + } } } From febcd257e7aff23e703c079a767b228f02e08550 Mon Sep 17 00:00:00 2001 From: WANG Xuerui Date: Sat, 26 Oct 2024 18:01:30 +0800 Subject: [PATCH 21/25] refactor: fix typescript-eslint/no-unused-vars --- eslint.config.mjs | 16 ++++++++++++++++ src/components/AsmDB/insnExplainerPage.tsx | 2 +- src/components/AsmDB/vldiHelperPage.tsx | 4 ++-- src/plugins/awly-asmdb-plugin.ts | 2 +- src/plugins/awly-data-plugin.ts | 2 +- src/theme/Footer/Copyright/index.tsx | 2 +- 6 files changed, 22 insertions(+), 6 deletions(-) diff --git a/eslint.config.mjs b/eslint.config.mjs index c17ae4e5..17ff10a7 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -9,4 +9,20 @@ export default tseslint.config( { ignores: ['.docusaurus/', '.yarn/', '.pnp.*', 'build/'], }, + { + rules: { + '@typescript-eslint/no-unused-vars': [ + 'error', + { + args: 'all', + argsIgnorePattern: '^_', + caughtErrors: 'all', + caughtErrorsIgnorePattern: '^_', + destructuredArrayIgnorePattern: '^_', + varsIgnorePattern: '^_', + ignoreRestSiblings: true, + }, + ], + }, + }, ) diff --git a/src/components/AsmDB/insnExplainerPage.tsx b/src/components/AsmDB/insnExplainerPage.tsx index a0ee6f67..669f564b 100644 --- a/src/components/AsmDB/insnExplainerPage.tsx +++ b/src/components/AsmDB/insnExplainerPage.tsx @@ -1,7 +1,7 @@ import type { AsmDBData } from './types' export default function InsnExplainerPage({ - data, + data: _, }: { data: AsmDBData }): JSX.Element { diff --git a/src/components/AsmDB/vldiHelperPage.tsx b/src/components/AsmDB/vldiHelperPage.tsx index 245d5dc7..08206f3f 100644 --- a/src/components/AsmDB/vldiHelperPage.tsx +++ b/src/components/AsmDB/vldiHelperPage.tsx @@ -13,7 +13,7 @@ import { makeVldiSImm, } from './vldi' import { CheckboxChangeEvent } from 'antd/es/checkbox' -import { InputMinifloat, MinifloatValueEvent } from './inputMinifloat' +import { InputMinifloat } from './inputMinifloat' type VlenSelectProps = { vlen: Vlen @@ -328,7 +328,7 @@ export default function VldiHelperPage(): JSX.Element { setImmState({ input: newVal, uimm: interp.uimm }) } - const onUseSignedElemsChange = (e: CheckboxChangeEvent) => { + const onUseSignedElemsChange = (_: CheckboxChangeEvent) => { setUseSignedElems(!useSignedElems) } diff --git a/src/plugins/awly-asmdb-plugin.ts b/src/plugins/awly-asmdb-plugin.ts index bfdf6647..60802c14 100644 --- a/src/plugins/awly-asmdb-plugin.ts +++ b/src/plugins/awly-asmdb-plugin.ts @@ -40,7 +40,7 @@ function runGenerationScript( } export default async function awlyAsmdbPlugin( - ctx: LoadContext, + _ctx: LoadContext, options: PluginOptions, ): Promise> { return { diff --git a/src/plugins/awly-data-plugin.ts b/src/plugins/awly-data-plugin.ts index 2a7d8fc9..748f7280 100644 --- a/src/plugins/awly-data-plugin.ts +++ b/src/plugins/awly-data-plugin.ts @@ -196,7 +196,7 @@ async function readCategories(sourcePath: string): Promise { } export default async function awlyDataPlugin( - ctx: LoadContext, + _ctx: LoadContext, options: PluginOptions, ): Promise> { return { diff --git a/src/theme/Footer/Copyright/index.tsx b/src/theme/Footer/Copyright/index.tsx index f118e3cd..d7cf527d 100644 --- a/src/theme/Footer/Copyright/index.tsx +++ b/src/theme/Footer/Copyright/index.tsx @@ -19,7 +19,7 @@ function ICPBeianLink({ ) } -function MPSBeianLink({ +function _MPSBeianLink({ province, recordNumber, }: { From b61f2ce01470a60b3bd4b0320d88f9e859a9b496 Mon Sep 17 00:00:00 2001 From: WANG Xuerui Date: Sat, 26 Oct 2024 18:22:04 +0800 Subject: [PATCH 22/25] build: yarn dedupe --- yarn.lock | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/yarn.lock b/yarn.lock index 41ab0046..1cc7e5d1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4008,16 +4008,7 @@ __metadata: languageName: node linkType: hard -"acorn@npm:^8.0.0, acorn@npm:^8.0.4, acorn@npm:^8.11.0, acorn@npm:^8.7.1, acorn@npm:^8.8.2": - version: 8.12.1 - resolution: "acorn@npm:8.12.1" - bin: - acorn: bin/acorn - checksum: 10c0/51fb26cd678f914e13287e886da2d7021f8c2bc0ccc95e03d3e0447ee278dd3b40b9c57dc222acd5881adcf26f3edc40901a4953403232129e3876793cd17386 - languageName: node - linkType: hard - -"acorn@npm:^8.12.0": +"acorn@npm:^8.0.0, acorn@npm:^8.0.4, acorn@npm:^8.11.0, acorn@npm:^8.12.0, acorn@npm:^8.7.1, acorn@npm:^8.8.2": version: 8.13.0 resolution: "acorn@npm:8.13.0" bin: From 32ed489b2c8fb008065fcb3949548a1601a8650d Mon Sep 17 00:00:00 2001 From: WANG Xuerui Date: Sat, 26 Oct 2024 18:19:46 +0800 Subject: [PATCH 23/25] ci: add linting action for PRs --- .github/workflows/pr.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .github/workflows/pr.yml diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml new file mode 100644 index 00000000..2a4f4bef --- /dev/null +++ b/.github/workflows/pr.yml @@ -0,0 +1,29 @@ +name: PR checks + +on: + pull_request: + +jobs: + lints: + name: Lints + runs-on: ubuntu-latest + steps: + - name: Check out the source code + uses: actions/checkout@v4 + with: + submodules: true + - name: Enable Corepack for Yarn Modern + run: corepack enable + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: yarn + - name: Install dependencies + run: yarn install --immutable + - name: Check code style with Prettier + run: yarn prettier --check . + - name: Lint with ESLint + run: yarn eslint + - name: Type-check with tsc + run: yarn tsc From 5edbb5982c733567563731cf465602d6c95bb7d6 Mon Sep 17 00:00:00 2001 From: WANG Xuerui Date: Sat, 26 Oct 2024 18:34:04 +0800 Subject: [PATCH 24/25] ci: configure dependabot --- .github/dependabot.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..10357d56 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,14 @@ +version: 2 +updates: + - package-ecosystem: github-actions + directory: / + schedule: + interval: weekly + - package-ecosystem: yarn + directory: / + schedule: + interval: weekly + - package-ecosystem: gomod + directory: /scripts/asmdb + schedule: + interval: weekly From eb8403f8848ffaf40f0b80f8b63301e1adf69c74 Mon Sep 17 00:00:00 2001 From: WANG Xuerui Date: Sat, 26 Oct 2024 18:36:58 +0800 Subject: [PATCH 25/25] build: update editorconfig with more extensions --- .editorconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.editorconfig b/.editorconfig index e6b07665..86a154c6 100644 --- a/.editorconfig +++ b/.editorconfig @@ -9,10 +9,10 @@ indent_style = space insert_final_newline = true trim_trailing_whitespace = true -[{*.css,*.js,*.json,*.ts,*.tsx,*.yaml,*.yml}] +[{*.css,*.cjs,*.cts,*.js,*.json,*.mjs,*.mts,*.ts,*.tsx,*.yaml,*.yml}] indent_size = 2 -[*.md] +[{*.md,*.mdx}] indent_size = 4 [*.go]