-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
remark-lint-local-links-valid 모노레포화 #434
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
e4cff41
`remark-lint-local-links-valid` 모노레포화
CirnoV 3759370
Github Packages Registry에 publish 하는 workflow 추가
CirnoV 3f641b2
Github Packages Registry에 대한 설명 추가
CirnoV fd3eada
lint workflow github packages 대응
CirnoV 7319bd5
모노레포가 workspace-root와 tsconfig 설정을 공유하도록 개선
CirnoV 5a38c47
github registry에서 workspace 참조로 변경 및 eslint에 ts-node 적용
CirnoV d2d31f6
lint action의 pnpm 버전을 9로 설정
CirnoV d109fa4
lint action에 NODE_OPTIONS 환경변수 추가
CirnoV aa03267
불필요한 tsup 설정 제거
CirnoV 8da62e3
Update package.json
CirnoV File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,13 +3,14 @@ | |
"private": true, | ||
"type": "module", | ||
"license": "AGPL-3.0-or-later", | ||
"repository": "https://github.com/portone-io/developers.portone.io", | ||
"scripts": { | ||
"dev": "astro dev", | ||
"start": "astro dev", | ||
"check": "pnpm typecheck && pnpm lint", | ||
"typecheck": "astro check", | ||
"lint:fix": "eslint --fix .", | ||
"lint": "eslint .", | ||
"lint:fix": "NODE_OPTIONS=\"$NODE_OPTIONS --loader ts-node/esm\" eslint --fix .", | ||
"lint": "NODE_OPTIONS=\"$NODE_OPTIONS --loader ts-node/esm\" eslint .", | ||
"build": "astro build", | ||
"preview": "astro preview", | ||
"astro": "astro" | ||
|
@@ -106,7 +107,7 @@ | |
"remark-lint-list-item-content-indent": "^3.1.2", | ||
"remark-lint-list-item-indent": "^3.1.2", | ||
"remark-lint-list-item-spacing": "^4.1.2", | ||
"remark-lint-local-links-valid": "github:portone-io/remark-lint-local-links-valid", | ||
"remark-lint-local-links-valid": "workspace:^", | ||
"remark-lint-maximum-line-length": "^3.1.3", | ||
"remark-lint-no-blockquote-without-marker": "^5.1.2", | ||
"remark-lint-no-consecutive-blank-lines": "^4.1.3", | ||
|
@@ -142,14 +143,15 @@ | |
"satori": "^0.10.13", | ||
"sharp": "^0.33.3", | ||
"string-width": "^5.1.2", | ||
"ts-node": "^10.9.2", | ||
"ts-pattern": "^5.1.1", | ||
"typescript": "^5.4.5", | ||
"unified": "^11.0.4", | ||
"unist-util-visit": "^5.0.0", | ||
"universal-cookie": "^7.1.4", | ||
"unocss": "^0.59.4" | ||
}, | ||
"packageManager": "[email protected].5", | ||
"packageManager": "[email protected].6", | ||
"pnpm": { | ||
"patchedDependencies": { | ||
"@shikijs/[email protected]": "patches/@[email protected]", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
## remark-lint-local-links-valid |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"name": "remark-lint-local-links-valid", | ||
"version": "0.1.1", | ||
"repository": "https://github.com/portone-io/developers.portone.io", | ||
"type": "module", | ||
"private": true, | ||
"main": "src/index.ts", | ||
"scripts": {}, | ||
"dependencies": { | ||
"unified-lint-rule": "^3.0.0", | ||
"unist-util-visit": "^5.0.0" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^20.12.7" | ||
}, | ||
"packageManager": "[email protected]" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import fs from "node:fs/promises"; | ||
import path from "node:path"; | ||
|
||
import { lintRule } from "unified-lint-rule"; | ||
import { visit } from "unist-util-visit"; | ||
|
||
interface Options { | ||
baseDir: string; | ||
excludePaths: string[]; | ||
redirects: Record<string, string>; | ||
} | ||
const remarkLintLocalLinksValid = lintRule( | ||
"remark-lint:local-links-valid", | ||
async (tree, file, options: Partial<Options>) => { | ||
if (!options.baseDir) { | ||
throw new Error("Missing required option `baseDir`"); | ||
} | ||
const baseDir = path.resolve(options.baseDir); | ||
const filePath = path.resolve(file.cwd, file.history[0] ?? ""); | ||
const excludePaths = | ||
options.excludePaths?.map((p) => path.join(baseDir, p)) ?? []; | ||
const redirects = options.redirects ?? {}; | ||
const tasks: Promise<void>[] = []; | ||
visit(tree, (node) => { | ||
if ( | ||
"url" in node && | ||
typeof node.url === "string" && | ||
node.type === "link" && | ||
isLocalLink(node.url) | ||
) { | ||
const url = node.url.split(/[#?]/)[0] || ""; | ||
let absPath = ""; | ||
if (path.isAbsolute(url)) { | ||
absPath = path.join(baseDir, url); | ||
} else { | ||
absPath = path.join(path.dirname(filePath), url); | ||
} | ||
const resolvedPath = resolveRedirect( | ||
redirects, | ||
path.relative(baseDir, absPath), | ||
); | ||
if (isLocalLink(resolvedPath) === false) { | ||
return; | ||
} | ||
absPath = path.join(baseDir, resolvedPath); | ||
if (excludePaths.some((p) => absPath.startsWith(p))) { | ||
return; | ||
} | ||
if (path.extname(absPath) !== "") { | ||
file.message("Local link should not have an extension", node); | ||
return; | ||
} | ||
const task = Promise.any( | ||
[".md", ".mdx"].map((ext) => fs.access(absPath + ext)), | ||
).catch(() => { | ||
file.message(`File not found: ${absPath}`, node); | ||
}); | ||
tasks.push(task); | ||
} | ||
}); | ||
await Promise.all(tasks); | ||
}, | ||
); | ||
const isLocalLink = (url: string): boolean => { | ||
try { | ||
new URL(url); | ||
} catch { | ||
return true; | ||
} | ||
return false; | ||
}; | ||
const resolveRedirect = ( | ||
redirects: Record<string, string>, | ||
url: string, | ||
): string => { | ||
let resolved = url; | ||
while (redirects[resolved]) { | ||
resolved = redirects[resolved]?.split(/[#?]/)[0] ?? resolved; | ||
} | ||
return resolved; | ||
}; | ||
export default remarkLintLocalLinksValid; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
"target": "ESNext", | ||
"module": "NodeNext", | ||
"moduleResolution": "NodeNext", | ||
"esModuleInterop": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"strict": true, | ||
"skipLibCheck": true | ||
}, | ||
"include": ["src"] | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tsx
를 사용했을 때 여전히 import 오류가 발생해서ts-node
로 구현했습니다