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
Copy file name to clipboardExpand all lines: README.md
+28-15Lines changed: 28 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -167,8 +167,6 @@ To temporarily disable linting of Markdown documents, run the `markdownlint.togg
167
167
168
168
## Configure
169
169
170
-
### markdownlint.config
171
-
172
170
By default (i.e., without customizing anything), all rules are enabled *except*[`MD013`/`line-length`](https://github.com/DavidAnson/markdownlint/blob/v0.37.4/doc/md013.md) because many files include lines longer than the conventional 80 character limit:
173
171
174
172
```json
@@ -178,15 +176,14 @@ By default (i.e., without customizing anything), all rules are enabled *except*
178
176
```
179
177
180
178
Rules can be enabled, disabled, and customized by creating a [JSON](https://en.wikipedia.org/wiki/JSON) file named `.markdownlint.jsonc`/`.markdownlint.json` or a [YAML](https://en.wikipedia.org/wiki/YAML) file named `.markdownlint.yaml`/`.markdownlint.yml` or a [JavaScript](https://en.wikipedia.org/wiki/JavaScript) file named `.markdownlint.cjs` in any directory of a project.
181
-
Additionally, options (which include rules and things like [`markdown-it` plugins](https://www.npmjs.com/search?q=keywords:markdown-it-plugin) and other settings) can be configured by creating a JSON file named `.markdownlint-cli2.jsonc` or a YAML file named `.markdownlint-cli2.yaml` or a JavaScript file named `.markdownlint-cli2.cjs` in any directory of a project.
179
+
Additionally, options (which include rules and things like [`markdown-it` plugins](https://www.npmjs.com/search?q=keywords:markdown-it-plugin) and other settings) can be configured by creating a JSON file named `.markdownlint-cli2.jsonc` or a YAML file named `.markdownlint-cli2.yaml` or a JavaScript file named `.markdownlint-cli2.cjs` in any directory of a project. Rules can also be configured using VS Code's support for [user and workspace settings](https://code.visualstudio.com/docs/customization/userandworkspace).
182
180
183
181
> For more information about configuration file precedence and complete examples, see the [Configuration section of the markdownlint-cli2 README.md](https://github.com/DavidAnson/markdownlint-cli2#configuration).
184
182
185
183
A custom configuration is often defined by a `.markdownlint.json` file in the root of the project:
186
184
187
185
```json
188
186
{
189
-
"default": true,
190
187
"MD003": { "style": "atx_closed" },
191
188
"MD007": { "indent": 4 },
192
189
"no-hard-tabs": false
@@ -204,15 +201,29 @@ To extend another configuration file, such a file can use the `extends` property
204
201
205
202
Files referenced via `extends` do not need to be part of the current project (but usually are).
206
203
207
-
Rules can also be configured using VS Code's support for [user and workspace settings](https://code.visualstudio.com/docs/customization/userandworkspace).
204
+
Configuration sources have the following precedence (in decreasing order):
205
+
206
+
*`.markdownlint-cli2.{jsonc,yaml,cjs}` file in the same or parent directory
207
+
*`.markdownlint.{jsonc,json,yaml,yml,cjs}` file in the same or parent directory
208
+
* Visual Studio Code user/workspace settings (see [markdownlint.config](#markdownlintconfig) and [markdownlint.configFile](#markdownlintconfigfile) below)
209
+
* Default configuration (see above)
210
+
211
+
Configuration changes saved to any location take effect immediately. Files referenced via `extends` are not monitored for changes. Inherited configuration can be explicitly disabled (or re-enabled) in any configuration file.
212
+
213
+
When a workspace is open, running the `markdownlint.openConfigFile` command (from the Command Palette or by binding it to a keyboard shortcut) will open an editor for the `.markdownlint-cli2.{jsonc,yaml,cjs}` or `.markdownlint.{jsonc,json,yaml,yml,cjs}` configuration file in the root of the workspace. If none of these files exist, a new `.markdownlint.json` containing the default rule configuration will be opened in the editor in the "pending save" state.
214
+
215
+
> **Note**: Because JavaScript is cached by VS Code after being loaded, edits to `.markdownlint.cjs`/`.markdownlint-cli2.cjs` require a restart of VS Code.
216
+
217
+
### markdownlint.config
218
+
219
+
> **Note**: When possible, using a project-local configuration file is preferred because it works with command-line tools and is easier for collaboration.
208
220
209
-
The above configuration might look like the following in VS Code's user settings file:
221
+
The configuration above might look like the following in VS Code's user settings file:
210
222
211
223
```json
212
224
{
213
225
"editor.someSetting": true,
214
226
"markdownlint.config": {
215
-
"default": true,
216
227
"MD003": { "style": "atx_closed" },
217
228
"MD007": { "indent": 4 },
218
229
"no-hard-tabs": false
@@ -228,18 +239,20 @@ When using `extends`:
228
239
* File paths referenced by `extends` from workspace settings are resolved relative to the workspace folder.
229
240
* VS Code's [predefined variables](https://code.visualstudio.com/docs/editor/variables-reference)`${userHome}` and `${workspaceFolder}` can be used within an `extends` path from user or workspace settings to override the default behavior.
230
241
231
-
Configuration sources have the following precedence (in decreasing order):
242
+
### markdownlint.configFile
232
243
233
-
*`.markdownlint-cli2.{jsonc,yaml,cjs}` file in the same or parent directory
234
-
*`.markdownlint.{jsonc,json,yaml,yml,cjs}` file in the same or parent directory
235
-
* Visual Studio Code user/workspace settings
236
-
* Default configuration (see above)
244
+
The default behavior of locating configuration files in the root of a project works well most of the time. However, projects that store configuration files in a different location can set `configFile` to the relative path of that file. All the [`markdownlint-cli2` configuration files used with `--config`](https://github.com/DavidAnson/markdownlint-cli2?tab=readme-ov-file#command-line) are supported.
237
245
238
-
Configuration changes saved to any location take effect immediately. Files referenced via `extends` are not monitored for changes. Inherited configuration can be explicitly disabled (or re-enabled) in any configuration file.
246
+
This looks like the following in VS Code's user settings:
239
247
240
-
When a workspace is open, running the `markdownlint.openConfigFile` command (from the Command Palette or by binding it to a keyboard shortcut) will open an editor for the `.markdownlint-cli2.{jsonc,yaml,cjs}` or `.markdownlint.{jsonc,json,yaml,yml,cjs}` configuration file in the root of the workspace. If none of these files exist, a new `.markdownlint.json` containing the default rule configuration will be opened in the editor in the "pending save" state.
> **Note**: Because JavaScript is cached by VS Code after being loaded, edits to `.markdownlint.cjs`/`.markdownlint-cli2.cjs` require a restart of VS Code.
255
+
If [markdownlint.config](#markdownlintconfig)is also set, the settings from `configFile` take precedence.
0 commit comments