diff --git a/biome.json b/biome.json index c2eccbbf..586c7da1 100644 --- a/biome.json +++ b/biome.json @@ -5,7 +5,12 @@ "ignore": ["./out", "./coverage"] }, "linter": { - "enabled": true + "enabled": true, + "rules": { + "nursery": { + "useImportExtensions": "error" + } + } }, "formatter": { "enabled": true diff --git a/src/block/CodeBlock.ts b/src/block/CodeBlock.ts index b8f63646..a2ce39f1 100644 --- a/src/block/CodeBlock.ts +++ b/src/block/CodeBlock.ts @@ -1,4 +1,4 @@ -import type { Row } from "./Row"; +import type { Row } from "./Row.ts"; export interface CodeBlockPack { type: "codeBlock"; diff --git a/src/block/Line.ts b/src/block/Line.ts index 3eadfbc5..d8a6e6d8 100644 --- a/src/block/Line.ts +++ b/src/block/Line.ts @@ -1,7 +1,7 @@ -import { convertToNodes } from "./node"; +import { convertToNodes } from "./node/index.ts"; -import type { Row } from "./Row"; -import type { Node } from "./node/type"; +import type { Row } from "./Row.ts"; +import type { Node } from "./node/type.ts"; export interface LinePack { type: "line"; diff --git a/src/block/Pack.ts b/src/block/Pack.ts index 46ed3be0..552056f8 100644 --- a/src/block/Pack.ts +++ b/src/block/Pack.ts @@ -1,9 +1,9 @@ -import type { ParserOption } from "../parse"; -import type { CodeBlockPack } from "./CodeBlock"; -import type { LinePack } from "./Line"; -import type { Row } from "./Row"; -import type { TablePack } from "./Table"; -import type { TitlePack } from "./Title"; +import type { ParserOption } from "../parse.ts"; +import type { CodeBlockPack } from "./CodeBlock.ts"; +import type { LinePack } from "./Line.ts"; +import type { Row } from "./Row.ts"; +import type { TablePack } from "./Table.ts"; +import type { TitlePack } from "./Title.ts"; export type Pack = TitlePack | CodeBlockPack | TablePack | LinePack; diff --git a/src/block/Table.ts b/src/block/Table.ts index 5ec9b308..eaaea3af 100644 --- a/src/block/Table.ts +++ b/src/block/Table.ts @@ -1,7 +1,7 @@ -import { convertToNodes } from "./node"; +import { convertToNodes } from "./node/index.ts"; -import type { Row } from "./Row"; -import type { Node } from "./node/type"; +import type { Row } from "./Row.ts"; +import type { Node } from "./node/type.ts"; export interface TablePack { type: "table"; diff --git a/src/block/Title.ts b/src/block/Title.ts index 76c442ce..b612c979 100644 --- a/src/block/Title.ts +++ b/src/block/Title.ts @@ -1,4 +1,4 @@ -import type { Row } from "./Row"; +import type { Row } from "./Row.ts"; export interface TitlePack { type: "title"; diff --git a/src/block/index.ts b/src/block/index.ts index c1dc6634..e2a3ddaf 100644 --- a/src/block/index.ts +++ b/src/block/index.ts @@ -1,13 +1,13 @@ -import { convertToCodeBlock } from "./CodeBlock"; -import { convertToLine } from "./Line"; -import { convertToTable } from "./Table"; -import { convertToTitle } from "./Title"; +import { convertToCodeBlock } from "./CodeBlock.ts"; +import { convertToLine } from "./Line.ts"; +import { convertToTable } from "./Table.ts"; +import { convertToTitle } from "./Title.ts"; -import type { CodeBlock } from "./CodeBlock"; -import type { Line } from "./Line"; -import type { Pack } from "./Pack"; -import type { Table } from "./Table"; -import type { Title } from "./Title"; +import type { CodeBlock } from "./CodeBlock.ts"; +import type { Line } from "./Line.ts"; +import type { Pack } from "./Pack.ts"; +import type { Table } from "./Table.ts"; +import type { Title } from "./Title.ts"; /** * Scrapbox block type diff --git a/src/block/node/BlankNode.ts b/src/block/node/BlankNode.ts index bc319e86..9bdd9a40 100644 --- a/src/block/node/BlankNode.ts +++ b/src/block/node/BlankNode.ts @@ -1,9 +1,9 @@ -import { createPlainNode } from "./PlainNode"; -import { createNodeParser } from "./creator"; +import { createPlainNode } from "./PlainNode.ts"; +import { createNodeParser } from "./creator.ts"; -import type { NodeCreator } from "./creator"; -import type { NodeParser } from "./index"; -import type { BlankNode, PlainNode } from "./type"; +import type { NodeCreator } from "./creator.ts"; +import type { NodeParser } from "./index.ts"; +import type { BlankNode, PlainNode } from "./type.ts"; const blankRegExp = /\[\s+\]/; diff --git a/src/block/node/CodeNode.ts b/src/block/node/CodeNode.ts index dc8a3a96..3ef43009 100644 --- a/src/block/node/CodeNode.ts +++ b/src/block/node/CodeNode.ts @@ -1,9 +1,9 @@ -import { createPlainNode } from "./PlainNode"; -import { createNodeParser } from "./creator"; +import { createPlainNode } from "./PlainNode.ts"; +import { createNodeParser } from "./creator.ts"; -import type { NodeCreator } from "./creator"; -import type { NodeParser } from "./index"; -import type { CodeNode, PlainNode } from "./type"; +import type { NodeCreator } from "./creator.ts"; +import type { NodeParser } from "./index.ts"; +import type { CodeNode, PlainNode } from "./type.ts"; const codeRegExp = /`.*?`/; diff --git a/src/block/node/CommandLineNode.ts b/src/block/node/CommandLineNode.ts index fa760012..845bdd32 100644 --- a/src/block/node/CommandLineNode.ts +++ b/src/block/node/CommandLineNode.ts @@ -1,9 +1,9 @@ -import { createPlainNode } from "./PlainNode"; -import { createNodeParser } from "./creator"; +import { createPlainNode } from "./PlainNode.ts"; +import { createNodeParser } from "./creator.ts"; -import type { NodeCreator } from "./creator"; -import type { NodeParser } from "./index"; -import type { CommandLineNode, PlainNode } from "./type"; +import type { NodeCreator } from "./creator.ts"; +import type { NodeParser } from "./index.ts"; +import type { CommandLineNode, PlainNode } from "./type.ts"; const commandLineRegExp = /^[$%] .+$/; diff --git a/src/block/node/DecorationNode.ts b/src/block/node/DecorationNode.ts index 9701294d..3aff26a1 100644 --- a/src/block/node/DecorationNode.ts +++ b/src/block/node/DecorationNode.ts @@ -1,10 +1,10 @@ -import { createPlainNode } from "./PlainNode"; -import { createNodeParser } from "./creator"; -import { convertToNodes } from "./index"; +import { createPlainNode } from "./PlainNode.ts"; +import { createNodeParser } from "./creator.ts"; +import { convertToNodes } from "./index.ts"; -import type { NodeCreator } from "./creator"; -import type { NodeParser } from "./index"; -import type { DecorationNode, PlainNode } from "./type"; +import type { NodeCreator } from "./creator.ts"; +import type { NodeParser } from "./index.ts"; +import type { DecorationNode, PlainNode } from "./type.ts"; const decorationRegExp = /\[[!"#%&'()*+,\-./{|}<>_~]+ (?:\[[^[\]]+\]|[^\]])+\]/; diff --git a/src/block/node/ExternalLinkNode.ts b/src/block/node/ExternalLinkNode.ts index fef2cff7..cb63a7af 100644 --- a/src/block/node/ExternalLinkNode.ts +++ b/src/block/node/ExternalLinkNode.ts @@ -1,9 +1,9 @@ -import { createPlainNode } from "./PlainNode"; -import { createNodeParser } from "./creator"; +import { createPlainNode } from "./PlainNode.ts"; +import { createNodeParser } from "./creator.ts"; -import type { NodeCreator } from "./creator"; -import type { NodeParser } from "./index"; -import type { LinkNode, PlainNode } from "./type"; +import type { NodeCreator } from "./creator.ts"; +import type { NodeParser } from "./index.ts"; +import type { LinkNode, PlainNode } from "./type.ts"; const hrefFirstUrlRegExp = /\[https?:\/\/[^\s\]]+\s+[^\]]*[^\s]\]/; const contentFirstUrlRegExp = /\[[^[\]]*[^\s]\s+https?:\/\/[^\s\]]+\]/; diff --git a/src/block/node/FormulaNode.ts b/src/block/node/FormulaNode.ts index 32cc9080..3d66f6e4 100644 --- a/src/block/node/FormulaNode.ts +++ b/src/block/node/FormulaNode.ts @@ -1,8 +1,8 @@ -import { createPlainNode } from "./PlainNode"; -import { createNodeParser } from "./creator"; +import { createPlainNode } from "./PlainNode.ts"; +import { createNodeParser } from "./creator.ts"; -import type { NodeCreator } from "./creator"; -import type { FormulaNode, PlainNode } from "./type"; +import type { NodeCreator } from "./creator.ts"; +import type { FormulaNode, PlainNode } from "./type.ts"; const formulaWithTailHalfSpaceRegExp = /\[\$ .+? \]/; const formulaRegExp = /\[\$ [^\]]+\]/; diff --git a/src/block/node/GoogleMapNode.ts b/src/block/node/GoogleMapNode.ts index f5fb94e1..2d129677 100644 --- a/src/block/node/GoogleMapNode.ts +++ b/src/block/node/GoogleMapNode.ts @@ -1,8 +1,8 @@ -import { createPlainNode } from "./PlainNode"; -import { createNodeParser } from "./creator"; +import { createPlainNode } from "./PlainNode.ts"; +import { createNodeParser } from "./creator.ts"; -import type { NodeCreator } from "./creator"; -import type { GoogleMapNode, PlainNode } from "./type"; +import type { NodeCreator } from "./creator.ts"; +import type { GoogleMapNode, PlainNode } from "./type.ts"; const placeFirstGoogleMapRegExp = /\[([^\]]*[^\s])\s+([NS]\d+(?:\.\d+)?,[EW]\d+(?:\.\d+)?(?:,Z\d+)?)\]/; diff --git a/src/block/node/HashTagNode.ts b/src/block/node/HashTagNode.ts index 6c9c1143..328f5f7a 100644 --- a/src/block/node/HashTagNode.ts +++ b/src/block/node/HashTagNode.ts @@ -1,8 +1,8 @@ -import { createPlainNode } from "./PlainNode"; -import { createNodeParser } from "./creator"; +import { createPlainNode } from "./PlainNode.ts"; +import { createNodeParser } from "./creator.ts"; -import type { NodeCreator } from "./creator"; -import type { HashTagNode, PlainNode } from "./type"; +import type { NodeCreator } from "./creator.ts"; +import type { HashTagNode, PlainNode } from "./type.ts"; const hashTagRegExp = /(?:^|\s)#\S+/; diff --git a/src/block/node/HelpfeelNode.ts b/src/block/node/HelpfeelNode.ts index b446c6f6..b9b47a20 100644 --- a/src/block/node/HelpfeelNode.ts +++ b/src/block/node/HelpfeelNode.ts @@ -1,8 +1,8 @@ -import { createPlainNode } from "./PlainNode"; -import { createNodeParser } from "./creator"; +import { createPlainNode } from "./PlainNode.ts"; +import { createNodeParser } from "./creator.ts"; -import type { NodeCreator } from "./creator"; -import type { HelpfeelNode, PlainNode } from "./type"; +import type { NodeCreator } from "./creator.ts"; +import type { HelpfeelNode, PlainNode } from "./type.ts"; const helpfeelRegExp = /^\? .+$/; diff --git a/src/block/node/IconNode.ts b/src/block/node/IconNode.ts index e124e768..2c219c73 100644 --- a/src/block/node/IconNode.ts +++ b/src/block/node/IconNode.ts @@ -1,8 +1,8 @@ -import { createPlainNode } from "./PlainNode"; -import { createNodeParser } from "./creator"; +import { createPlainNode } from "./PlainNode.ts"; +import { createNodeParser } from "./creator.ts"; -import type { NodeCreator } from "./creator"; -import type { IconNode, PlainNode, StrongIconNode } from "./type"; +import type { NodeCreator } from "./creator.ts"; +import type { IconNode, PlainNode, StrongIconNode } from "./type.ts"; const iconRegExp = /\[[^[\]]*\.icon(?:\*[1-9]\d*)?\]/; diff --git a/src/block/node/ImageNode.ts b/src/block/node/ImageNode.ts index f4211a13..14d50058 100644 --- a/src/block/node/ImageNode.ts +++ b/src/block/node/ImageNode.ts @@ -1,8 +1,8 @@ -import { createPlainNode } from "./PlainNode"; -import { createNodeParser } from "./creator"; +import { createPlainNode } from "./PlainNode.ts"; +import { createNodeParser } from "./creator.ts"; -import type { NodeCreator } from "./creator"; -import type { ImageNode, PlainNode } from "./type"; +import type { NodeCreator } from "./creator.ts"; +import type { ImageNode, PlainNode } from "./type.ts"; const srcFirstStrongImageRegExp = /\[https?:\/\/[^\s\]]+\.(?:png|jpe?g|gif|svg)(?:\?[^\]\s]+)?(?:\s+https?:\/\/[^\s\]]+)?\]/i; diff --git a/src/block/node/InternalLinkNode.ts b/src/block/node/InternalLinkNode.ts index 9fc47b3b..8094dcd5 100644 --- a/src/block/node/InternalLinkNode.ts +++ b/src/block/node/InternalLinkNode.ts @@ -1,7 +1,7 @@ -import { createNodeParser } from "./creator"; +import { createNodeParser } from "./creator.ts"; -import type { NodeCreator } from "./creator"; -import type { LinkNode } from "./type"; +import type { NodeCreator } from "./creator.ts"; +import type { LinkNode } from "./type.ts"; const internalLinkRegExp = /\[\/?[^[\]]+\]/; diff --git a/src/block/node/NumberListNode.ts b/src/block/node/NumberListNode.ts index f00704ea..4030b5d8 100644 --- a/src/block/node/NumberListNode.ts +++ b/src/block/node/NumberListNode.ts @@ -1,9 +1,9 @@ -import { createPlainNode } from "./PlainNode"; -import { createNodeParser } from "./creator"; -import { convertToNodes } from "./index"; +import { createPlainNode } from "./PlainNode.ts"; +import { createNodeParser } from "./creator.ts"; +import { convertToNodes } from "./index.ts"; -import type { NodeCreator } from "./creator"; -import type { NumberListNode, PlainNode } from "./type"; +import type { NodeCreator } from "./creator.ts"; +import type { NumberListNode, PlainNode } from "./type.ts"; const numberListRegExp = /^[0-9]+\. .*$/; diff --git a/src/block/node/PlainNode.ts b/src/block/node/PlainNode.ts index 7ca9088f..05a79942 100644 --- a/src/block/node/PlainNode.ts +++ b/src/block/node/PlainNode.ts @@ -1,8 +1,8 @@ -import { createNodeParser } from "./creator"; +import { createNodeParser } from "./creator.ts"; -import type { NodeCreator } from "./creator"; -import type { NodeParser } from "./index"; -import type { PlainNode } from "./type"; +import type { NodeCreator } from "./creator.ts"; +import type { NodeParser } from "./index.ts"; +import type { PlainNode } from "./type.ts"; export const createPlainNode: NodeCreator = (raw) => [ { diff --git a/src/block/node/QuoteNode.ts b/src/block/node/QuoteNode.ts index bb07e0c3..9bec9aac 100644 --- a/src/block/node/QuoteNode.ts +++ b/src/block/node/QuoteNode.ts @@ -1,9 +1,9 @@ -import { createPlainNode } from "./PlainNode"; -import { createNodeParser } from "./creator"; -import { convertToNodes } from "./index"; +import { createPlainNode } from "./PlainNode.ts"; +import { createNodeParser } from "./creator.ts"; +import { convertToNodes } from "./index.ts"; -import type { NodeCreator } from "./creator"; -import type { PlainNode, QuoteNode } from "./type"; +import type { NodeCreator } from "./creator.ts"; +import type { PlainNode, QuoteNode } from "./type.ts"; const quoteRegExp = /^>.*$/; diff --git a/src/block/node/StrongIconNode.ts b/src/block/node/StrongIconNode.ts index 6fda1489..7864cf31 100644 --- a/src/block/node/StrongIconNode.ts +++ b/src/block/node/StrongIconNode.ts @@ -1,5 +1,5 @@ -import { generateIconNodeCreator } from "./IconNode"; -import { createNodeParser } from "./creator"; +import { generateIconNodeCreator } from "./IconNode.ts"; +import { createNodeParser } from "./creator.ts"; const strongIconRegExp = /\[\[[^[\]]*\.icon(?:\*\d+)?\]\]/; diff --git a/src/block/node/StrongImageNode.ts b/src/block/node/StrongImageNode.ts index f3ddea30..7883a5b1 100644 --- a/src/block/node/StrongImageNode.ts +++ b/src/block/node/StrongImageNode.ts @@ -1,8 +1,8 @@ -import { createPlainNode } from "./PlainNode"; -import { createNodeParser } from "./creator"; +import { createPlainNode } from "./PlainNode.ts"; +import { createNodeParser } from "./creator.ts"; -import type { NodeCreator } from "./creator"; -import type { PlainNode, StrongImageNode } from "./type"; +import type { NodeCreator } from "./creator.ts"; +import type { PlainNode, StrongImageNode } from "./type.ts"; const strongImageRegExp = /\[\[https?:\/\/[^\s\]]+\.(?:png|jpe?g|gif|svg)\]\]/i; const strongGyazoImageRegExp = diff --git a/src/block/node/StrongNode.ts b/src/block/node/StrongNode.ts index b52eb4a4..dca80f24 100644 --- a/src/block/node/StrongNode.ts +++ b/src/block/node/StrongNode.ts @@ -1,10 +1,10 @@ -import { createPlainNode } from "./PlainNode"; -import { createNodeParser } from "./creator"; -import { convertToNodes } from "./index"; +import { createPlainNode } from "./PlainNode.ts"; +import { createNodeParser } from "./creator.ts"; +import { convertToNodes } from "./index.ts"; -import type { NodeCreator } from "./creator"; -import type { NodeParser } from "./index"; -import type { PlainNode, StrongNode } from "./type"; +import type { NodeCreator } from "./creator.ts"; +import type { NodeParser } from "./index.ts"; +import type { PlainNode, StrongNode } from "./type.ts"; const strongRegExp = /\[\[(?:[^[]|\[[^[]).*?\]*\]\]/; diff --git a/src/block/node/creator.ts b/src/block/node/creator.ts index 2274b2b8..24fa759c 100644 --- a/src/block/node/creator.ts +++ b/src/block/node/creator.ts @@ -1,7 +1,7 @@ -import { convertToNodes } from "./index"; +import { convertToNodes } from "./index.ts"; -import type { NodeParser, NodeParserOption } from "./index"; -import type { Node } from "./type"; +import type { NodeParser, NodeParserOption } from "./index.ts"; +import type { Node } from "./type.ts"; export type NodeCreator = ( target: string, diff --git a/src/block/node/index.ts b/src/block/node/index.ts index 87a2b509..ddd19e4e 100644 --- a/src/block/node/index.ts +++ b/src/block/node/index.ts @@ -1,23 +1,23 @@ -import { BlankNodeParser } from "./BlankNode"; -import { CodeNodeParser } from "./CodeNode"; -import { CommandLineNodeParser } from "./CommandLineNode"; -import { DecorationNodeParser } from "./DecorationNode"; -import { ExternalLinkNodeParser } from "./ExternalLinkNode"; -import { FormulaNodeParser } from "./FormulaNode"; -import { GoogleMapNodeParser } from "./GoogleMapNode"; -import { HashTagNodeParser } from "./HashTagNode"; -import { HelpfeelNodeParser } from "./HelpfeelNode"; -import { IconNodeParser } from "./IconNode"; -import { ImageNodeParser } from "./ImageNode"; -import { InternalLinkNodeParser } from "./InternalLinkNode"; -import { NumberListNodeParser } from "./NumberListNode"; -import { PlainNodeParser } from "./PlainNode"; -import { QuoteNodeParser } from "./QuoteNode"; -import { StrongIconNodeParser } from "./StrongIconNode"; -import { StrongImageNodeParser } from "./StrongImageNode"; -import { StrongNodeParser } from "./StrongNode"; +import { BlankNodeParser } from "./BlankNode.ts"; +import { CodeNodeParser } from "./CodeNode.ts"; +import { CommandLineNodeParser } from "./CommandLineNode.ts"; +import { DecorationNodeParser } from "./DecorationNode.ts"; +import { ExternalLinkNodeParser } from "./ExternalLinkNode.ts"; +import { FormulaNodeParser } from "./FormulaNode.ts"; +import { GoogleMapNodeParser } from "./GoogleMapNode.ts"; +import { HashTagNodeParser } from "./HashTagNode.ts"; +import { HelpfeelNodeParser } from "./HelpfeelNode.ts"; +import { IconNodeParser } from "./IconNode.ts"; +import { ImageNodeParser } from "./ImageNode.ts"; +import { InternalLinkNodeParser } from "./InternalLinkNode.ts"; +import { NumberListNodeParser } from "./NumberListNode.ts"; +import { PlainNodeParser } from "./PlainNode.ts"; +import { QuoteNodeParser } from "./QuoteNode.ts"; +import { StrongIconNodeParser } from "./StrongIconNode.ts"; +import { StrongImageNodeParser } from "./StrongImageNode.ts"; +import { StrongNodeParser } from "./StrongNode.ts"; -import type { Node } from "./type"; +import type { Node } from "./type.ts"; export interface NodeParserOption { nested: boolean; diff --git a/src/block/node/type.ts b/src/block/node/type.ts index 8244f43d..3a5e7af5 100644 --- a/src/block/node/type.ts +++ b/src/block/node/type.ts @@ -1,4 +1,4 @@ -import type { Decoration } from "./DecorationNode"; +import type { Decoration } from "./DecorationNode.ts"; interface BaseNode { raw: string; diff --git a/src/index.ts b/src/index.ts index 264e4bb1..f8a1b96b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,10 +1,10 @@ -export { parse, getTitle } from "./parse"; -export type { ParserOption, Page } from "./parse"; -export type { Block } from "./block"; -export type { Title } from "./block/Title"; -export type { CodeBlock } from "./block/CodeBlock"; -export type { Table } from "./block/Table"; -export type { Line } from "./block/Line"; +export { parse, getTitle } from "./parse.ts"; +export type { ParserOption, Page } from "./parse.ts"; +export type { Block } from "./block/index.ts"; +export type { Title } from "./block/Title.ts"; +export type { CodeBlock } from "./block/CodeBlock.ts"; +export type { Table } from "./block/Table.ts"; +export type { Line } from "./block/Line.ts"; export type { Node, QuoteNode, @@ -23,5 +23,5 @@ export type { IconNode, HashTagNode, PlainNode, -} from "./block/node/type"; -export type { Decoration } from "./block/node/DecorationNode"; +} from "./block/node/type.ts"; +export type { Decoration } from "./block/node/DecorationNode.ts"; diff --git a/src/parse.ts b/src/parse.ts index 6196b154..8a1c231f 100644 --- a/src/parse.ts +++ b/src/parse.ts @@ -1,8 +1,8 @@ -import { convertToBlock } from "./block"; -import { packRows } from "./block/Pack"; -import { parseToRows } from "./block/Row"; +import { packRows } from "./block/Pack.ts"; +import { parseToRows } from "./block/Row.ts"; +import { convertToBlock } from "./block/index.ts"; -import type { Block } from "./block"; +import type { Block } from "./block/index.ts"; /** * parser option type diff --git a/tests/codeBlock/index.test.ts b/tests/codeBlock/index.test.ts index 6d7058f5..699f915b 100644 --- a/tests/codeBlock/index.test.ts +++ b/tests/codeBlock/index.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from "vitest"; -import { parse } from "../../src"; +import { parse } from "../../src/index.ts"; describe("Code Block", () => { it("Simple code block", () => { diff --git a/tests/line/blank.test.ts b/tests/line/blank.test.ts index 87469ee9..71af63cb 100644 --- a/tests/line/blank.test.ts +++ b/tests/line/blank.test.ts @@ -1,6 +1,6 @@ /* eslint-disable no-irregular-whitespace */ import { describe, expect, it } from "vitest"; -import { parse } from "../../src"; +import { parse } from "../../src/index.ts"; describe("blank", () => { it("Simple half-space blank", () => { diff --git a/tests/line/bullet.test.ts b/tests/line/bullet.test.ts index d40e0293..29f8e542 100644 --- a/tests/line/bullet.test.ts +++ b/tests/line/bullet.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from "vitest"; -import { parse } from "../../src"; +import { parse } from "../../src/index.ts"; describe("bullet", () => { it("Single-byte space indent", () => { diff --git a/tests/line/code.test.ts b/tests/line/code.test.ts index 15e34043..685f9693 100644 --- a/tests/line/code.test.ts +++ b/tests/line/code.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from "vitest"; -import { parse } from "../../src"; +import { parse } from "../../src/index.ts"; describe("code", () => { it("Simple code with backquote", () => { diff --git a/tests/line/commandLine.test.ts b/tests/line/commandLine.test.ts index 06e0ba50..5aebc73f 100644 --- a/tests/line/commandLine.test.ts +++ b/tests/line/commandLine.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from "vitest"; -import { parse } from "../../src"; +import { parse } from "../../src/index.ts"; describe("commandLine", () => { it("Simple command with $", () => { diff --git a/tests/line/decoration.test.ts b/tests/line/decoration.test.ts index 3f0cab5a..36e7024f 100644 --- a/tests/line/decoration.test.ts +++ b/tests/line/decoration.test.ts @@ -4,7 +4,7 @@ import { type DecorationNode, type Line, parse, -} from "../../src"; +} from "../../src/index.ts"; describe("decoration", () => { it("Simple decoration", () => { diff --git a/tests/line/formula.test.ts b/tests/line/formula.test.ts index c17bb971..04ab4b52 100644 --- a/tests/line/formula.test.ts +++ b/tests/line/formula.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from "vitest"; -import { parse } from "../../src"; +import { parse } from "../../src/index.ts"; describe("formula", () => { it("Simple formula", () => { diff --git a/tests/line/googleMap.test.ts b/tests/line/googleMap.test.ts index 1256df9e..f23f6a1d 100644 --- a/tests/line/googleMap.test.ts +++ b/tests/line/googleMap.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from "vitest"; -import { parse } from "../../src"; +import { parse } from "../../src/index.ts"; describe("googleMap", () => { it("Simple google map with NE", () => { diff --git a/tests/line/hashTag.test.ts b/tests/line/hashTag.test.ts index e900556a..449ef260 100644 --- a/tests/line/hashTag.test.ts +++ b/tests/line/hashTag.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from "vitest"; -import { parse } from "../../src"; +import { parse } from "../../src/index.ts"; describe("hashTag", () => { it("Simple hashTag", () => { diff --git a/tests/line/helpfeel.test.ts b/tests/line/helpfeel.test.ts index 5ca29e2b..16c6e596 100644 --- a/tests/line/helpfeel.test.ts +++ b/tests/line/helpfeel.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from "vitest"; -import { parse } from "../../src"; +import { parse } from "../../src/index.ts"; describe("helpfeel", () => { it("Simple helpfeel", () => { diff --git a/tests/line/icon.test.ts b/tests/line/icon.test.ts index fa56b3d5..cbe7f6b9 100644 --- a/tests/line/icon.test.ts +++ b/tests/line/icon.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from "vitest"; -import { parse } from "../../src"; +import { parse } from "../../src/index.ts"; describe("icon", () => { it("Simple root icon", () => { diff --git a/tests/line/image.test.ts b/tests/line/image.test.ts index 3e2b8f8a..038f301a 100644 --- a/tests/line/image.test.ts +++ b/tests/line/image.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from "vitest"; -import { parse } from "../../src"; +import { parse } from "../../src/index.ts"; describe("image", () => { it("Simple image", () => { diff --git a/tests/line/index.test.ts b/tests/line/index.test.ts index d92ce5dc..5553e304 100644 --- a/tests/line/index.test.ts +++ b/tests/line/index.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from "vitest"; -import { parse } from "../../src"; +import { parse } from "../../src/index.ts"; describe("line", () => { it("Line that have multi node", () => { diff --git a/tests/line/link.test.ts b/tests/line/link.test.ts index 23067dad..99a46e81 100644 --- a/tests/line/link.test.ts +++ b/tests/line/link.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from "vitest"; -import { parse } from "../../src"; +import { parse } from "../../src/index.ts"; describe("link", () => { it("Simple absolute link", () => { diff --git a/tests/line/numberList.test.ts b/tests/line/numberList.test.ts index 713d7e18..8f9aeaba 100644 --- a/tests/line/numberList.test.ts +++ b/tests/line/numberList.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from "vitest"; -import { parse } from "../../src"; +import { parse } from "../../src/index.ts"; describe("numberList", () => { it("Minimum numberList", () => { diff --git a/tests/line/plain.test.ts b/tests/line/plain.test.ts index a3c1d60c..7dc615e4 100644 --- a/tests/line/plain.test.ts +++ b/tests/line/plain.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from "vitest"; -import { parse } from "../../src"; +import { parse } from "../../src/index.ts"; describe("plain", () => { it("Simple plain text", () => { diff --git a/tests/line/quote.test.ts b/tests/line/quote.test.ts index b6483bbd..e2991f5a 100644 --- a/tests/line/quote.test.ts +++ b/tests/line/quote.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from "vitest"; -import { parse } from "../../src"; +import { parse } from "../../src/index.ts"; describe("quote", () => { it("Simple quote", () => { diff --git a/tests/line/strong.test.ts b/tests/line/strong.test.ts index 35ffd7a5..80a086c2 100644 --- a/tests/line/strong.test.ts +++ b/tests/line/strong.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from "vitest"; -import { parse } from "../../src"; +import { parse } from "../../src/index.ts"; describe("strong", () => { it("Simple strong", () => { diff --git a/tests/line/strongIcon.test.ts b/tests/line/strongIcon.test.ts index 8e6d702b..45b6973c 100644 --- a/tests/line/strongIcon.test.ts +++ b/tests/line/strongIcon.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from "vitest"; -import { parse } from "../../src"; +import { parse } from "../../src/index.ts"; describe("strongIcon", () => { it("Simple root strong icon", () => { diff --git a/tests/line/strongImage.test.ts b/tests/line/strongImage.test.ts index 21ba7a89..c743a58c 100644 --- a/tests/line/strongImage.test.ts +++ b/tests/line/strongImage.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from "vitest"; -import { parse } from "../../src"; +import { parse } from "../../src/index.ts"; describe("strongImage", () => { it("Simple strong image", () => { diff --git a/tests/page/index.test.ts b/tests/page/index.test.ts index 6e1de26d..dd095d79 100644 --- a/tests/page/index.test.ts +++ b/tests/page/index.test.ts @@ -1,6 +1,7 @@ import * as fs from "node:fs"; +import path from "node:path"; import { describe, expect, it } from "vitest"; -import { parse } from "../../src"; +import { parse } from "../../src/index.ts"; describe("page", () => { it("Empty page", () => { @@ -14,7 +15,9 @@ describe("page", () => { }); it("https://scrapbox.io/help/Syntax", () => { - const input = fs.readFileSync("./tests/page/input.txt").toString(); + const input = fs + .readFileSync(path.resolve("tests/page/input.txt")) + .toString(); expect(parse(input, { hasTitle: true })).toMatchSnapshot(); }); }); diff --git a/tests/table/index.test.ts b/tests/table/index.test.ts index d487e09c..c25cd7b4 100644 --- a/tests/table/index.test.ts +++ b/tests/table/index.test.ts @@ -1,6 +1,6 @@ /* eslint-disable no-tabs, no-irregular-whitespace */ import { describe, expect, it } from "vitest"; -import { parse } from "../../src"; +import { parse } from "../../src/index.ts"; describe("Table", () => { it("Simple table", () => { diff --git a/tests/title/index.test.ts b/tests/title/index.test.ts index bc1c9dcf..39a1d3fb 100644 --- a/tests/title/index.test.ts +++ b/tests/title/index.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from "vitest"; -import { getTitle } from "../../src"; +import { getTitle } from "../../src/index.ts"; describe("title", () => { it("Get title from simple page", () => { diff --git a/tsconfig.lint.json b/tsconfig.lint.json index 03b37193..0714f72a 100644 --- a/tsconfig.lint.json +++ b/tsconfig.lint.json @@ -1,6 +1,7 @@ { "extends": "./tsconfig", "compilerOptions": { + "emitDeclarationOnly": false, "noEmit": true }, "include": ["**/*"] diff --git a/vite.config.ts b/vite.config.ts index d5f57ced..01d36b33 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,30 +1,35 @@ /// import { resolve } from "node:path"; -import { defineConfig, type LibraryFormats } from "vite"; +import { type LibraryFormats, defineConfig } from "vite"; const formats = ["es", "cjs", "umd"] satisfies LibraryFormats[]; export default defineConfig({ - build: { - emptyOutDir: false, - outDir: "out", - lib: { - formats, - entry: resolve(__dirname, "src/index.ts"), - fileName: (format) => - (( - { - cjs: "index.cjs", - es: "index.mjs", - umd: "scrapbox-parser.umd.js", - } satisfies Record<(typeof formats)[number], string> - )[format]), - }, - }, - test: { - include: ["**/tests/**/*.test.ts"], - coverage: { - include: ["src/**/*.ts"], - }, - }, + build: { + emptyOutDir: false, + outDir: "out", + lib: { + formats, + entry: resolve(__dirname, "src/index.ts"), + name: "ScrapboxParser", + fileName: (format) => { + switch (format) { + case "cjs": + return "index.cjs"; + case "es": + return "index.mjs"; + case "umd": + return "scrapbox-parser.umd.js"; + default: + throw new Error(`unknown format: ${format}`); + } + }, + }, + }, + test: { + include: ["**/tests/**/*.test.ts"], + coverage: { + include: ["src/**/*.ts"], + }, + }, });