UNPKG

8.18 kBMarkdownView Raw
1# remark-preset-prettier
2
3[![Travis](https://img.shields.io/travis/com/JounQin/remark-preset-prettier.svg)](https://travis-ci.com/JounQin/remark-preset-prettier)
4[![Codacy Grade](https://img.shields.io/codacy/grade/d2f82a40047a4b69bcfc2e8afc73ea83)](https://www.codacy.com/app/JounQin/remark-preset-prettier)
5[![type-coverage](https://img.shields.io/badge/dynamic/json.svg?label=type-coverage&prefix=%E2%89%A5&suffix=%&query=$.typeCoverage.atLeast&uri=https%3A%2F%2Fraw.githubusercontent.com%2FJounQin%2Fremark-preset-prettier%2Fmaster%2Fpackage.json)](https://github.com/plantain-00/type-coverage)
6[![npm](https://img.shields.io/npm/v/remark-preset-prettier.svg)](https://www.npmjs.com/package/remark-preset-prettier)
7[![GitHub release](https://img.shields.io/github/release/JounQin/remark-preset-prettier)](https://github.com/JounQin/remark-preset-prettier/releases)
8
9[![David Peer](https://img.shields.io/david/peer/JounQin/remark-preset-prettier.svg)](https://david-dm.org/JounQin/remark-preset-prettier?type=peer)
10[![David](https://img.shields.io/david/JounQin/remark-preset-prettier.svg)](https://david-dm.org/JounQin/remark-preset-prettier)
11[![David Dev](https://img.shields.io/david/dev/JounQin/remark-preset-prettier.svg)](https://david-dm.org/JounQin/remark-preset-prettier?type=dev)
12
13[![Conventional Commits](https://img.shields.io/badge/conventional%20commits-1.0.0-yellow.svg)](https://conventionalcommits.org)
14[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
15[![Code Style: Prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
16[![codechecks.io](https://raw.githubusercontent.com/codechecks/docs/master/images/badges/badge-default.svg?sanitize=true)](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
351. [blank-lines-1-0-2](https://www.npmjs.com/package/remark-lint-blank-lines-1-0-2)
362. [blockquote-indentation](https://www.npmjs.com/package/remark-lint-blockquote-indentation)
373. [books-links](https://www.npmjs.com/package/remark-lint-books-links)
384. [checkbox-character-style](https://www.npmjs.com/package/remark-lint-checkbox-character-style)
395. [code-block-style](https://www.npmjs.com/package/remark-lint-code-block-style)
406. [definition-case](https://www.npmjs.com/package/remark-lint-definition-case)
417. [definition-spacing](https://www.npmjs.com/package/remark-lint-definition-spacing)
428. [emphasis-marker](https://www.npmjs.com/package/remark-lint-emphasis-marker)
439. [fenced-code-marker](https://www.npmjs.com/package/remark-lint-fenced-code-marker)
4410. [final-newline](https://www.npmjs.com/package/remark-lint-final-newline)
4511. [hard-break-spaces](https://www.npmjs.com/package/remark-lint-hard-break-spaces)
4612. [heading-style](https://www.npmjs.com/package/remark-lint-heading-style)
4713. [heading-whitespace](https://www.npmjs.com/package/remark-lint-heading-whitespace)
4814. [link-title-style](https://www.npmjs.com/package/remark-lint-link-title-style)
4915. [list-item-bullet-indent](https://www.npmjs.com/package/remark-lint-list-item-bullet-indent)
5016. [list-item-content-indent](https://www.npmjs.com/package/remark-lint-list-item-content-indent)
5117. [list-item-indent](https://www.npmjs.com/package/remark-lint-list-item-indent)
5218. [list-item-spacing](https://www.npmjs.com/package/remark-lint-list-item-spacing)
5319. [maximum-line-length](https://www.npmjs.com/package/remark-lint-maximum-line-length)
5420. [no-blockquote-without-marker](https://www.npmjs.com/package/remark-lint-no-blockquote-without-marker)
5521. [no-consecutive-blank-lines](https://www.npmjs.com/package/remark-lint-no-consecutive-blank-lines)
5622. [no-heading-content-indent](https://www.npmjs.com/package/remark-lint-no-heading-content-indent)
5723. [no-inline-padding](https://www.npmjs.com/package/remark-lint-no-inline-padding)
5824. [no-long-code](https://www.npmjs.com/package/remark-lint-no-long-code)
5925. [no-table-indentation](https://www.npmjs.com/package/remark-lint-no-table-indentation)
6026. [ordered-list-marker-style](https://www.npmjs.com/package/remark-lint-ordered-list-marker-style)
6127. [ordered-list-marker-value](https://www.npmjs.com/package/remark-lint-ordered-list-marker-value)
6228. [rule-style](https://www.npmjs.com/package/remark-lint-rule-style)
6329. [spaces-around-number](https://www.npmjs.com/package/remark-lint-spaces-around-number)
6430. [spaces-around-word](https://www.npmjs.com/package/remark-lint-spaces-around-word)
6531. [strong-marker](https://www.npmjs.com/package/remark-lint-strong-marker)
6632. [table-cell-padding](https://www.npmjs.com/package/remark-lint-table-cell-padding)
6733. [table-pipe-alignment](https://www.npmjs.com/package/remark-lint-table-pipe-alignment)
6834. [table-pipes](https://www.npmjs.com/package/remark-lint-table-pipes)
6935. [unordered-list-marker-style](https://www.npmjs.com/package/remark-lint-unordered-list-marker-style)
70
71## Install
72
73```sh
74# yarn
75yarn add -D remark-preset-prettier
76
77# npm
78npm 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
98Please 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
109remark . --use preset-lint-consistent preset-lint-markdown-style-guide preset-lint-recommended preset-prettier
110```
111
112### Via Node API
113
114```js
115const report = require('vfile-reporter')
116const remark = require('remark')
117const consistent = require('remark-preset-lint-consistent')
118const styleGuide = require('remark-preset-lint-markdown-style-guide')
119const recommended = require('remark-preset-lint-recommended')
120const prettier = require('remark-preset-lint-prettier')
121
122const file = remark()
123 .use(consistent)
124 .use(styleGuide)
125 .use(recommended)
126 .use(prettier)
127 .processSync('_Hello world_')
128
129console.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
136However, [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
138If 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
142const wooorm = require('retext-preset-wooorm')
143
144module.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
162Detailed 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