1 | # remark-preset-prettier
|
2 |
|
3 | [](https://travis-ci.com/JounQin/remark-preset-prettier)
|
4 | [](https://www.codacy.com/app/JounQin/remark-preset-prettier)
|
5 | [](https://github.com/plantain-00/type-coverage)
|
6 | [](https://www.npmjs.com/package/remark-preset-prettier)
|
7 | [](https://github.com/JounQin/remark-preset-prettier/releases)
|
8 |
|
9 | [](https://david-dm.org/JounQin/remark-preset-prettier?type=peer)
|
10 | [](https://david-dm.org/JounQin/remark-preset-prettier)
|
11 | [](https://david-dm.org/JounQin/remark-preset-prettier?type=dev)
|
12 |
|
13 | [](https://conventionalcommits.org)
|
14 | [](https://standardjs.com)
|
15 | [](https://github.com/prettier/prettier)
|
16 | [](https://codechecks.io)
|
17 |
|
18 | > Turns off all rules that are unnecessary or might conflict with [Prettier][].
|
19 |
|
20 | ## TOC <!-- omit in toc -->
|
21 |
|
22 | - [Disabled remark-lint plugins](#disabled-remark-lint-plugins)
|
23 | - [Install](#install)
|
24 | - [Usage](#usage)
|
25 | - [Via config like `.remarkrc`](#via-config-like-remarkrc)
|
26 | - [Via ESLint(recommended)](#via-eslintrecommended)
|
27 | - [Via remark-cli](#via-remark-cli)
|
28 | - [Via Node API](#via-node-api)
|
29 | - [[remark-retext][] issue](#remark-retext-issue)
|
30 | - [Changelog](#changelog)
|
31 | - [License](#license)
|
32 |
|
33 | ## Disabled remark-lint plugins
|
34 |
|
35 | 1. [blank-lines-1-0-2](https://www.npmjs.com/package/remark-lint-blank-lines-1-0-2)
|
36 | 2. [blockquote-indentation](https://www.npmjs.com/package/remark-lint-blockquote-indentation)
|
37 | 3. [books-links](https://www.npmjs.com/package/remark-lint-books-links)
|
38 | 4. [checkbox-character-style](https://www.npmjs.com/package/remark-lint-checkbox-character-style)
|
39 | 5. [code-block-style](https://www.npmjs.com/package/remark-lint-code-block-style)
|
40 | 6. [definition-case](https://www.npmjs.com/package/remark-lint-definition-case)
|
41 | 7. [definition-spacing](https://www.npmjs.com/package/remark-lint-definition-spacing)
|
42 | 8. [emphasis-marker](https://www.npmjs.com/package/remark-lint-emphasis-marker)
|
43 | 9. [fenced-code-marker](https://www.npmjs.com/package/remark-lint-fenced-code-marker)
|
44 | 10. [final-newline](https://www.npmjs.com/package/remark-lint-final-newline)
|
45 | 11. [hard-break-spaces](https://www.npmjs.com/package/remark-lint-hard-break-spaces)
|
46 | 12. [heading-style](https://www.npmjs.com/package/remark-lint-heading-style)
|
47 | 13. [heading-whitespace](https://www.npmjs.com/package/remark-lint-heading-whitespace)
|
48 | 14. [link-title-style](https://www.npmjs.com/package/remark-lint-link-title-style)
|
49 | 15. [list-item-bullet-indent](https://www.npmjs.com/package/remark-lint-list-item-bullet-indent)
|
50 | 16. [list-item-content-indent](https://www.npmjs.com/package/remark-lint-list-item-content-indent)
|
51 | 17. [list-item-indent](https://www.npmjs.com/package/remark-lint-list-item-indent)
|
52 | 18. [list-item-spacing](https://www.npmjs.com/package/remark-lint-list-item-spacing)
|
53 | 19. [maximum-line-length](https://www.npmjs.com/package/remark-lint-maximum-line-length)
|
54 | 20. [no-blockquote-without-marker](https://www.npmjs.com/package/remark-lint-no-blockquote-without-marker)
|
55 | 21. [no-consecutive-blank-lines](https://www.npmjs.com/package/remark-lint-no-consecutive-blank-lines)
|
56 | 22. [no-heading-content-indent](https://www.npmjs.com/package/remark-lint-no-heading-content-indent)
|
57 | 23. [no-inline-padding](https://www.npmjs.com/package/remark-lint-no-inline-padding)
|
58 | 24. [no-long-code](https://www.npmjs.com/package/remark-lint-no-long-code)
|
59 | 25. [no-table-indentation](https://www.npmjs.com/package/remark-lint-no-table-indentation)
|
60 | 26. [ordered-list-marker-style](https://www.npmjs.com/package/remark-lint-ordered-list-marker-style)
|
61 | 27. [ordered-list-marker-value](https://www.npmjs.com/package/remark-lint-ordered-list-marker-value)
|
62 | 28. [rule-style](https://www.npmjs.com/package/remark-lint-rule-style)
|
63 | 29. [spaces-around-number](https://www.npmjs.com/package/remark-lint-spaces-around-number)
|
64 | 30. [spaces-around-word](https://www.npmjs.com/package/remark-lint-spaces-around-word)
|
65 | 31. [strong-marker](https://www.npmjs.com/package/remark-lint-strong-marker)
|
66 | 32. [table-cell-padding](https://www.npmjs.com/package/remark-lint-table-cell-padding)
|
67 | 33. [table-pipe-alignment](https://www.npmjs.com/package/remark-lint-table-pipe-alignment)
|
68 | 34. [table-pipes](https://www.npmjs.com/package/remark-lint-table-pipes)
|
69 | 35. [unordered-list-marker-style](https://www.npmjs.com/package/remark-lint-unordered-list-marker-style)
|
70 |
|
71 | ## Install
|
72 |
|
73 | ```sh
|
74 | # yarn
|
75 | yarn add -D remark-preset-prettier
|
76 |
|
77 | # npm
|
78 | npm i -D remark-preset-prettier
|
79 | ```
|
80 |
|
81 | ## Usage
|
82 |
|
83 | ### Via [config](https://github.com/remarkjs/remark/tree/master/packages/remark-cli) like `.remarkrc`
|
84 |
|
85 | ```json
|
86 | {
|
87 | "plugins": [
|
88 | "preset-lint-consistent",
|
89 | "preset-lint-markdown-style-guide",
|
90 | "preset-lint-recommended",
|
91 | "preset-prettier"
|
92 | ]
|
93 | }
|
94 | ```
|
95 |
|
96 | ### Via ESLint(recommended)
|
97 |
|
98 | Please use _[eslint-plugin-mdx][]_ which works perfectly with [ESLint][] and [Remark][] both together.
|
99 |
|
100 | ```jsonc
|
101 | {
|
102 | "extends": "plugin:mdx/recommended"
|
103 | }
|
104 | ```
|
105 |
|
106 | ### Via remark-cli
|
107 |
|
108 | ```sh
|
109 | remark . --use preset-lint-consistent preset-lint-markdown-style-guide preset-lint-recommended preset-prettier
|
110 | ```
|
111 |
|
112 | ### Via Node API
|
113 |
|
114 | ```js
|
115 | const report = require('vfile-reporter')
|
116 | const remark = require('remark')
|
117 | const consistent = require('remark-preset-lint-consistent')
|
118 | const styleGuide = require('remark-preset-lint-markdown-style-guide')
|
119 | const recommended = require('remark-preset-lint-recommended')
|
120 | const prettier = require('remark-preset-lint-prettier')
|
121 |
|
122 | const file = remark()
|
123 | .use(consistent)
|
124 | .use(styleGuide)
|
125 | .use(recommended)
|
126 | .use(prettier)
|
127 | .processSync('_Hello world_')
|
128 |
|
129 | console.log(report(file))
|
130 | ```
|
131 |
|
132 | ## [remark-retext][] issue
|
133 |
|
134 | [retext-sentence-spacing][] is a plugin of [retext][], and [remark-retext][] makes it possible to use [retext][] plugins together with [remark][], and [retext-sentence-spacing][] may conflict with [Prettier][].
|
135 |
|
136 | However, [remark-retext][] can only be enabled once what means we can not simply disable rule [retext-sentence-spacing][] in this preset which is actually meaningless.
|
137 |
|
138 | If you do have problems between [retext-sentence-spacing][] and [Prettier][], you have to override the whole configuration of [remark-retext][] like following:
|
139 |
|
140 | ```js
|
141 | // .remarkrc.js
|
142 | const wooorm = require('retext-preset-wooorm')
|
143 |
|
144 | module.exports = {
|
145 | plugins: [
|
146 | 'preset-wooorm', // other preset(s) or plugin(s)
|
147 | 'preset-prettier',
|
148 | [
|
149 | 'retext',
|
150 | unified()
|
151 | .use(wooorm) // retext preset(s)
|
152 | .use({
|
153 | plugins: [[require('retext-sentence-spacing'), false]],
|
154 | }),
|
155 | ],
|
156 | ],
|
157 | }
|
158 | ```
|
159 |
|
160 | ## Changelog
|
161 |
|
162 | Detailed changes for each release are documented in [CHANGELOG.md](./CHANGELOG.md).
|
163 |
|
164 | ## License
|
165 |
|
166 | [MIT][] © [JounQin][]@[1stG.me][]
|
167 |
|
168 | [1stg.me]: https://www.1stg.me
|
169 | [eslint]: https://eslint.org
|
170 | [eslint-plugin-mdx]: https://github.com/rx-ts/eslint-mdx
|
171 | [jounqin]: https://GitHub.com/JounQin
|
172 | [mit]: http://opensource.org/licenses/MIT
|
173 | [prettier]: https://prettier.io
|
174 | [remark]: https://github.com/remarkjs/remark
|
175 | [remark-retext]: https://github.com/remarkjs/remark-retext
|
176 | [retext]: https://github.com/retextjs/retext
|
177 | [retext-sentence-spacing]: https://github.com/retextjs/retext-sentence-spacing
|