You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -74,133 +72,36 @@ See [#251](https://github.com/mdx-js/eslint-mdx/issues/251#issuecomment-73613922
74
72
75
73
## Usage
76
74
77
-
1. In your ESLint config file:
78
-
79
-
1. If you're using `eslint >= 6.4.0`, just add:
80
-
81
-
```jsonc
82
-
{
83
-
"extends": ["plugin:mdx/recommended"],
84
-
// optional, if you want to lint code blocks at the same time
85
-
"settings": {
86
-
"mdx/code-blocks":true,
87
-
// optional, if you want to disable language mapper, set it to `false`
88
-
// if you want to override the default language mapper inside, you can provide your own
89
-
"mdx/language-mapper": {}
90
-
}
91
-
}
92
-
```
93
-
94
-
2. If you're using `eslint >=6.0.0 and <6.4.0`, add as following because it does not support overrides from npm pkg:
95
-
96
-
```jsonc
97
-
{
98
-
"extends": ["plugin:mdx/recommended"],
99
-
// optional, if you want to lint code blocks at the same time
100
-
"settings": {
101
-
"mdx/code-blocks": true,
102
-
// optional, if you want to disable language mapper, set it to `false`
103
-
// if you want to override the default language mapper inside, you can provide your own
104
-
"mdx/language-mapper": {}
105
-
},
106
-
"overrides": [
107
-
{
108
-
"files": ["*.md"],
109
-
"rules": {
110
-
"prettier/prettier": [
111
-
2,
112
-
{
113
-
// unnecessary if you're not using `eslint-plugin-prettier`, but required if you are
114
-
"parser":"markdown"
115
-
}
116
-
]
117
-
}
118
-
},
119
-
{
120
-
"files": ["*.mdx"],
121
-
"extends": ["plugin:mdx/overrides"]
122
-
},
123
-
{
124
-
"files":"**/*.{md,mdx}/**",
125
-
"extends":"plugin:mdx/code-blocks"
126
-
}
127
-
]
128
-
}
129
-
```
130
-
131
-
3. If you're using `eslint@^5.0.0`, you need to enable this parser/plugin manually, because `eslint@5` does not support `extends` for `overrides` property in its configuration:
// optional, if you want to lint code blocks at the same time
139
-
settings: {
140
-
'mdx/code-blocks': true,
141
-
// optional, if you want to disable language mapper, set it to `false`
142
-
// if you want to override the default language mapper inside, you can provide your own
143
-
'mdx/language-mapper': {},
144
-
},
145
-
overrides: [
146
-
{
147
-
files: ['*.md'],
148
-
rules: {
149
-
'prettier/prettier': [
150
-
2,
151
-
{
152
-
// unnecessary if you're not using `eslint-plugin-prettier`, but required if you are
153
-
parser:'markdown',
154
-
},
155
-
],
156
-
},
157
-
},
158
-
{
159
-
files: ['*.mdx'],
160
-
...configs.overrides,
161
-
},
162
-
{
163
-
files:'**/*.{md,mdx}/**',
164
-
...configs.codeBlocks,
165
-
},
166
-
],
167
-
}
168
-
```
75
+
1. In your ESLint 8+ config file, just add:
169
76
170
-
2. Make sure ESLint knows to run on `.md` or `.mdx` files:
171
-
172
-
```sh
173
-
eslint . --ext js,md,mdx
174
-
```
175
-
176
-
## Parser Options
177
-
178
-
1.`parser` (`string | ParserConfig | ParserFn`): Custom parser forES syntax is supported, although `@typescript-eslint/parser` or `@babel/eslint-parser` or `babel-eslint` will be detected automatically what means you actually do not need to do this:
179
-
180
-
```json
77
+
```jsonc
181
78
{
182
79
"extends": ["plugin:mdx/recommended"],
183
-
"parserOptions": {
184
-
"parser": "babel-eslint"
80
+
// optional, if you want to lint code blocks at the same time
81
+
"settings": {
82
+
"mdx/code-blocks":true,
83
+
// optional, if you want to disable language mapper, set it to `false`
84
+
// if you want to override the default language mapper inside, you can provide your own
85
+
"mdx/language-mapper": {}
185
86
}
186
87
}
187
88
```
188
89
189
-
2.`extensions` (`string | string[]`):`eslint-mdx` will only resolve `.mdx` files by default, files with other extensions will be resolved by the `parser`option. If you want to resolve other extensions as like `.mdx`, you can use this option.
190
-
191
-
3.`markdownExtensions` (`string | string[]`):`eslint-mdx` will only treat `.md` files as plain markdown by default, and will lint them via remark plugins. If you want to resolve other extensions as like `.md`, you can use this option.
90
+
2. Make sure ESLint knows to run on `.md` or `.mdx` files:
192
91
193
-
4.`ignoreRemarkConfig` (`boolean`): Ignore the `remark` configuration defined in the project.
92
+
```sh
93
+
eslint . --ext js,md,mdx
94
+
```
194
95
195
-
## Rules
96
+
## Parser Options
196
97
197
-
### mdx/no-jsx-html-comments
98
+
1.`extensions` (`string | string[]`): `eslint-mdx` will only resolve `.mdx` files by default, if you want to resolve other extensions as like `.mdx`, you can use this option.
198
99
199
-
_Fixable_:HTML style comments in jsx block is invalid, this rule will help you to fix it by transforming it to JSX style comments.
100
+
2.`markdownExtensions` (`string | string[]`): `eslint-mdx` will only treat `.md` files as plain markdown by default, and will lint them via remark plugins. If you want to resolve other extensions as like `.md`, you can use this option.
200
101
201
-
### mdx/no-unused-expressions
102
+
3.`ignoreRemarkConfig` (`boolean`): Ignore the `remark` configuration defined in the project.
202
103
203
-
[MDX][] can render `jsx` block automatically without exporting them, but [ESLint][] will report `no-unused-expressions` issue which could be unexpected, this rule is the replacement, so make sure that you've turned off the original `no-unused-expressions` rule.
104
+
## Rules
204
105
205
106
### mdx/remark
206
107
@@ -225,8 +126,6 @@ If you want to disable or change severity of some related rules, it won't work b
225
126
}
226
127
```
227
128
228
-
Some plugins are ESM and eslint don't supports them. So, a workaround is to set `ignoreRemarkConfig` to `true` and execute `remark-lint` through the terminal before running eslint. For example:`remark **/*.mdx --no-stdout && eslint . --fix --ext .mdx`.
229
-
230
129
## Prettier Integration
231
130
232
131
If you're using [remark-lint][] feature with [Prettier][] both together, you can try [remark-preset-prettier][] which helps you to _turn off all rules that are unnecessary or might conflict with [Prettier][]_.
0 commit comments