-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
close #61
- Loading branch information
Showing
15 changed files
with
2,082 additions
and
96 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
lib | ||
src/plugins.ts | ||
CHANGELOG.md | ||
!/.*.js |
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 |
---|---|---|
@@ -1,3 +1,6 @@ | ||
{ | ||
"extends": "@1stg" | ||
"extends": "@1stg", | ||
"rules": { | ||
"mdx/remark": 0 | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
CHANGELOG.md |
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,9 @@ | ||
export default { | ||
plugins: [ | ||
'remark-lint', | ||
'remark-preset-lint-consistent', | ||
'remark-preset-lint-markdown-style-guide', | ||
'remark-preset-lint-recommended', | ||
'./lib/index.js', | ||
], | ||
} |
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 |
---|---|---|
@@ -0,0 +1,98 @@ | ||
import fs from 'fs' | ||
import path from 'path' | ||
|
||
import prettier from 'prettier' | ||
|
||
const plugins = [ | ||
'blank-lines-1-0-2', | ||
'blockquote-indentation', | ||
'books-links', | ||
'checkbox-character-style', | ||
'code-block-style', | ||
'definition-case', | ||
'definition-spacing', | ||
'emphasis-marker', | ||
'fenced-code-marker', | ||
'final-newline', | ||
'hard-break-spaces', | ||
'heading-style', | ||
'heading-whitespace', | ||
'link-title-style', | ||
'list-item-bullet-indent', | ||
'list-item-content-indent', | ||
'list-item-indent', | ||
'list-item-spacing', | ||
'maximum-line-length', | ||
'no-blockquote-without-marker', | ||
'no-consecutive-blank-lines', | ||
'no-heading-content-indent', | ||
'no-inline-padding', | ||
'no-long-code', | ||
'no-table-indentation', | ||
'ordered-list-marker-style', | ||
'ordered-list-marker-value', | ||
'rule-style', | ||
'spaces-around-number', | ||
'spaces-around-word', | ||
'strong-marker', | ||
'table-cell-padding', | ||
'table-pipe-alignment', | ||
'table-pipes', | ||
'unordered-list-marker-style', | ||
] | ||
|
||
const camelCase = (val: string) => | ||
// type-coverage:ignore-next-line -- https://github.com/plantain-00/type-coverage/issues/96 | ||
val.replace(/-([\da-z])/g, ([_, $0]) => $0.toUpperCase()) | ||
|
||
const main = async () => { | ||
const pkgPath = path.resolve('package.json') | ||
|
||
const pkg = JSON.parse(await fs.promises.readFile(pkgPath, 'utf8')) as { | ||
dependencies?: Record<string, string> | ||
} | ||
|
||
await fs.promises.writeFile( | ||
pkgPath, | ||
prettier.format( | ||
JSON.stringify({ | ||
...pkg, | ||
dependencies: { | ||
...pkg.dependencies, | ||
...plugins.reduce<Record<string, string>>( | ||
(acc, plugin) => | ||
Object.assign(acc, { | ||
[`remark-lint-${plugin}`]: '*', | ||
}), | ||
{}, | ||
), | ||
}, | ||
}), | ||
{ | ||
filepath: pkgPath, | ||
}, | ||
), | ||
) | ||
|
||
const pluginsPath = path.resolve('src/plugins.ts') | ||
|
||
await fs.promises.writeFile( | ||
pluginsPath, | ||
prettier.format( | ||
[ | ||
'// @ts-nocheck', | ||
...plugins.map( | ||
plugin => `import ${camelCase(plugin)} from 'remark-lint-${plugin}'`, | ||
), | ||
`\nexport const plugins: Array<import('unified').Plugin> = [${plugins | ||
.map(plugin => camelCase(plugin)) | ||
.join(',')}]`, | ||
].join('\n'), | ||
{ | ||
filepath: pluginsPath, | ||
}, | ||
), | ||
) | ||
} | ||
|
||
main().catch(console.error) |
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,5 @@ | ||
import { plugins as _plugins } from './plugins.js' | ||
|
||
export const plugins = _plugins.map(plugin => [plugin, false] as const) | ||
|
||
export default { plugins } |
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,74 @@ | ||
// @ts-nocheck | ||
import blankLines102 from "remark-lint-blank-lines-1-0-2"; | ||
import blockquoteIndentation from "remark-lint-blockquote-indentation"; | ||
import booksLinks from "remark-lint-books-links"; | ||
import checkboxCharacterStyle from "remark-lint-checkbox-character-style"; | ||
import codeBlockStyle from "remark-lint-code-block-style"; | ||
import definitionCase from "remark-lint-definition-case"; | ||
import definitionSpacing from "remark-lint-definition-spacing"; | ||
import emphasisMarker from "remark-lint-emphasis-marker"; | ||
import fencedCodeMarker from "remark-lint-fenced-code-marker"; | ||
import finalNewline from "remark-lint-final-newline"; | ||
import hardBreakSpaces from "remark-lint-hard-break-spaces"; | ||
import headingStyle from "remark-lint-heading-style"; | ||
import headingWhitespace from "remark-lint-heading-whitespace"; | ||
import linkTitleStyle from "remark-lint-link-title-style"; | ||
import listItemBulletIndent from "remark-lint-list-item-bullet-indent"; | ||
import listItemContentIndent from "remark-lint-list-item-content-indent"; | ||
import listItemIndent from "remark-lint-list-item-indent"; | ||
import listItemSpacing from "remark-lint-list-item-spacing"; | ||
import maximumLineLength from "remark-lint-maximum-line-length"; | ||
import noBlockquoteWithoutMarker from "remark-lint-no-blockquote-without-marker"; | ||
import noConsecutiveBlankLines from "remark-lint-no-consecutive-blank-lines"; | ||
import noHeadingContentIndent from "remark-lint-no-heading-content-indent"; | ||
import noInlinePadding from "remark-lint-no-inline-padding"; | ||
import noLongCode from "remark-lint-no-long-code"; | ||
import noTableIndentation from "remark-lint-no-table-indentation"; | ||
import orderedListMarkerStyle from "remark-lint-ordered-list-marker-style"; | ||
import orderedListMarkerValue from "remark-lint-ordered-list-marker-value"; | ||
import ruleStyle from "remark-lint-rule-style"; | ||
import spacesAroundNumber from "remark-lint-spaces-around-number"; | ||
import spacesAroundWord from "remark-lint-spaces-around-word"; | ||
import strongMarker from "remark-lint-strong-marker"; | ||
import tableCellPadding from "remark-lint-table-cell-padding"; | ||
import tablePipeAlignment from "remark-lint-table-pipe-alignment"; | ||
import tablePipes from "remark-lint-table-pipes"; | ||
import unorderedListMarkerStyle from "remark-lint-unordered-list-marker-style"; | ||
|
||
export const plugins: Array<import("unified").Plugin> = [ | ||
blankLines102, | ||
blockquoteIndentation, | ||
booksLinks, | ||
checkboxCharacterStyle, | ||
codeBlockStyle, | ||
definitionCase, | ||
definitionSpacing, | ||
emphasisMarker, | ||
fencedCodeMarker, | ||
finalNewline, | ||
hardBreakSpaces, | ||
headingStyle, | ||
headingWhitespace, | ||
linkTitleStyle, | ||
listItemBulletIndent, | ||
listItemContentIndent, | ||
listItemIndent, | ||
listItemSpacing, | ||
maximumLineLength, | ||
noBlockquoteWithoutMarker, | ||
noConsecutiveBlankLines, | ||
noHeadingContentIndent, | ||
noInlinePadding, | ||
noLongCode, | ||
noTableIndentation, | ||
orderedListMarkerStyle, | ||
orderedListMarkerValue, | ||
ruleStyle, | ||
spacesAroundNumber, | ||
spacesAroundWord, | ||
strongMarker, | ||
tableCellPadding, | ||
tablePipeAlignment, | ||
tablePipes, | ||
unorderedListMarkerStyle, | ||
]; |
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 |
---|---|---|
@@ -1,6 +1,3 @@ | ||
{ | ||
"extends": "@1stg/tsconfig/lib", | ||
"compilerOptions": { | ||
"outDir": "lib" | ||
} | ||
"extends": "@1stg/tsconfig/lib" | ||
} |
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,8 @@ | ||
{ | ||
"extends": ".", | ||
"compilerOptions": { | ||
"outDir": "lib", | ||
"rootDir": "src" | ||
}, | ||
"include": ["src"] | ||
} |
Oops, something went wrong.