|
32 | 32 | - [Install](#install) |
33 | 33 | - [Notice](#notice) |
34 | 34 | - [Usage](#usage) |
| 35 | + - [Classic](#classic) |
| 36 | + - [Flat Config](#flat-config) |
35 | 37 | - [Parser Options](#parser-options) |
36 | 38 | - [Rules](#rules) |
37 | 39 | - [mdx/remark](#mdxremark) |
@@ -74,26 +76,58 @@ See [#251](https://github.com/mdx-js/eslint-mdx/issues/251#issuecomment-73613922 |
74 | 76 |
|
75 | 77 | ## Usage |
76 | 78 |
|
77 | | -1. In your ESLint 8+ config file, just add: |
78 | | - |
79 | | - ```jsonc |
80 | | - { |
81 | | - "extends": ["plugin:mdx/recommended"], |
82 | | - // optional, if you want to lint code blocks at the same time |
83 | | - "settings": { |
84 | | - "mdx/code-blocks": true, |
85 | | - // optional, if you want to disable language mapper, set it to `false` |
86 | | - // if you want to override the default language mapper inside, you can provide your own |
87 | | - "mdx/language-mapper": {} |
88 | | - } |
89 | | - } |
90 | | - ``` |
91 | | - |
92 | | -2. Make sure ESLint knows to run on `.md` or `.mdx` files: |
93 | | - |
94 | | - ```sh |
95 | | - eslint . --ext js,md,mdx |
96 | | - ``` |
| 79 | +### Classic |
| 80 | + |
| 81 | +`.eslintrc` file: |
| 82 | + |
| 83 | +```jsonc |
| 84 | +{ |
| 85 | + "extends": ["plugin:mdx/recommended"], |
| 86 | + // optional, if you want to lint code blocks at the same time |
| 87 | + "settings": { |
| 88 | + "mdx/code-blocks": true, |
| 89 | + // optional, if you want to disable language mapper, set it to `false` |
| 90 | + // if you want to override the default language mapper inside, you can provide your own |
| 91 | + "mdx/language-mapper": {} |
| 92 | + } |
| 93 | +} |
| 94 | +``` |
| 95 | + |
| 96 | +### Flat Config |
| 97 | + |
| 98 | +`eslint.config.js` file: |
| 99 | + |
| 100 | +```js |
| 101 | +import * as mdx from 'eslint-plugin-mdx' |
| 102 | + |
| 103 | +export default [ |
| 104 | + { |
| 105 | + ...mdx.flat, |
| 106 | + // optional, if you want to lint code blocks at the same |
| 107 | + processor: mdx.createRemarkProcessor({ |
| 108 | + lintCodeBlocks: true, |
| 109 | + // optional, if you want to disable language mapper, set it to `false` |
| 110 | + // if you want to override the default language mapper inside, you can provide your own |
| 111 | + languageMapper: {}, |
| 112 | + }), |
| 113 | + }, |
| 114 | + { |
| 115 | + ...mdx.flatCodeBlocks, |
| 116 | + rules: { |
| 117 | + ...mdx.flatCodeBlocks.rules, |
| 118 | + // if you want to override some rules for code blocks |
| 119 | + 'no-var': 'error', |
| 120 | + 'prefer-const': 'error', |
| 121 | + }, |
| 122 | + }, |
| 123 | +] |
| 124 | +``` |
| 125 | + |
| 126 | +Then, make sure ESLint knows to run on `.md` or `.mdx` files: |
| 127 | + |
| 128 | +```sh |
| 129 | +eslint . --ext js,md,mdx |
| 130 | +``` |
97 | 131 |
|
98 | 132 | ## Parser Options |
99 | 133 |
|
|
0 commit comments