Skip to content

Commit 767028f

Browse files
committed
feat: Create project
1 parent 8663389 commit 767028f

File tree

13 files changed

+373
-0
lines changed

13 files changed

+373
-0
lines changed

.editorconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*.{js,ts,json}]
4+
indent_style = tab
5+
indent_size = 2
6+
charset = utf-8
7+
trim_trailing_whitespace = true
8+
insert_final_newline = true
9+
end_of_line = lf

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules/
2+
lib/

.tool-versions

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
bun 1.0.36
2+
nodejs 20.12.0

LICENSE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
MIT License
2+
3+
Copyright (c) 2024 3w36zj6
4+
Copyright (c) 2015 azu
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in all
14+
copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
SOFTWARE.

README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# textlint-plugin-mdx
2+
3+
[textlint](https://github.com/textlint/textlint) plugin to lint [MDX](https://mdxjs.com/)
4+
5+
## Installation
6+
7+
```sh
8+
# npm
9+
npm install textlint-plugin-mdx
10+
11+
# Yarn
12+
yarn add textlint-plugin-mdx
13+
14+
# pnpm
15+
pnpm add textlint-plugin-mdx
16+
17+
# Bun
18+
bun add textlint-plugin-mdx
19+
```
20+
21+
## Usage
22+
23+
```json
24+
{
25+
"plugins": {
26+
"mdx": true
27+
}
28+
}
29+
```
30+
31+
## Options
32+
33+
- `extensions`: `string[]`
34+
- Additional file extensions for MDX
35+
36+
## Contributing
37+
38+
1. Fork it!
39+
2. Create your feature branch: `git checkout -b my-new-feature`
40+
3. Commit your changes: `git commit -am 'Add some feature'`
41+
4. Push to the branch: `git push origin my-new-feature`
42+
5. Submit a pull request :D
43+
44+
## License
45+
46+
[MIT License](LICENSE)

biome.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/1.6.3/schema.json",
3+
"organizeImports": {
4+
"enabled": true
5+
},
6+
"linter": {
7+
"enabled": true,
8+
"rules": {
9+
"recommended": true
10+
}
11+
},
12+
"vcs": {
13+
"enabled": true,
14+
"clientKind": "git",
15+
"useIgnoreFile": true
16+
}
17+
}

bun.lockb

267 KB
Binary file not shown.

package.json

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
"name": "textlint-plugin-mdx",
3+
"version": "1.0.0",
4+
"description": "textlint plugin to lint MDX",
5+
"keywords": ["textlint", "textlintplugin", "plugin", "lint", "mdx"],
6+
"repository": "https://github.com/3w36zj6/textlint-plugin-mdx",
7+
"funding": {
8+
"type": "github",
9+
"url": "https://github.com/sponsors/3w36zj6"
10+
},
11+
"license": "MIT",
12+
"author": "3w36zj6",
13+
"main": "lib/index.js",
14+
"files": ["lib"],
15+
"scripts": {
16+
"build": "esbuild --bundle src/*.ts --outdir=lib --platform=node",
17+
"clean": "rm -frv lib",
18+
"format": "biome format --write .",
19+
"format:check": "biome format .",
20+
"lint": "biome lint .",
21+
"lint:fix": "biome lint --apply .",
22+
"check": "biome check .",
23+
"test": "vitest"
24+
},
25+
"dependencies": {
26+
"remark-footnotes": "^4.0.1",
27+
"remark-frontmatter": "^5.0.0",
28+
"remark-gfm": "^4.0.0",
29+
"remark-mdx": "^3.0.1",
30+
"remark-parse": "^11.0.0",
31+
"traverse": "^0.6.8",
32+
"unified": "^11.0.4"
33+
},
34+
"devDependencies": {
35+
"@biomejs/biome": "^1.6.3",
36+
"@textlint/ast-node-types": "^14.0.4",
37+
"@textlint/ast-tester": "^14.0.4",
38+
"@textlint/types": "^14.0.4",
39+
"@types/node": "^20.12.2",
40+
"@types/traverse": "^0.6.36",
41+
"bun-types": "latest",
42+
"esbuild": "^0.20.2",
43+
"textlint-scripts": "^14.0.4",
44+
"textlint-tester": "^14.0.4",
45+
"tsc": "^2.0.4",
46+
"typescript": "^5.4.3",
47+
"vitest": "^1.4.0"
48+
},
49+
"peerDependencies": {
50+
"typescript": "^5.0.0"
51+
}
52+
}

src/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { MdxProcessor } from "./mdxProcessor";
2+
3+
export default {
4+
Processor: MdxProcessor,
5+
};

src/mapping/markdown-syntax-map.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// LICENSE : MIT
2+
import { ASTNodeTypes } from "@textlint/ast-node-types";
3+
4+
export const SyntaxMap = {
5+
root: ASTNodeTypes.Document,
6+
paragraph: ASTNodeTypes.Paragraph,
7+
blockquote: ASTNodeTypes.BlockQuote,
8+
listItem: ASTNodeTypes.ListItem,
9+
list: ASTNodeTypes.List,
10+
Bullet: "Bullet", // no need?
11+
heading: ASTNodeTypes.Header,
12+
code: ASTNodeTypes.CodeBlock,
13+
HtmlBlock: ASTNodeTypes.HtmlBlock,
14+
thematicBreak: ASTNodeTypes.HorizontalRule,
15+
// inline block
16+
text: ASTNodeTypes.Str,
17+
break: ASTNodeTypes.Break,
18+
emphasis: ASTNodeTypes.Emphasis,
19+
strong: ASTNodeTypes.Strong,
20+
html: ASTNodeTypes.Html,
21+
link: ASTNodeTypes.Link,
22+
image: ASTNodeTypes.Image,
23+
inlineCode: ASTNodeTypes.Code,
24+
delete: ASTNodeTypes.Delete,
25+
// remark(markdown) extension
26+
// Following type is not in @textlint/ast-node-types
27+
yaml: "Yaml",
28+
table: "Table",
29+
tableRow: "TableRow",
30+
tableCell: "TableCell",
31+
linkReference: "LinkReference",
32+
imageReference: "ImageReference",
33+
footnoteReference: "FootnoteReference", // textlint@12+
34+
definition: "Definition",
35+
/**
36+
* @deprecated
37+
*/
38+
ReferenceDef: ASTNodeTypes.ReferenceDef,
39+
} as const;

0 commit comments

Comments
 (0)