Skip to content

Commit 3bd1c70

Browse files
committed
Update README with ESM examples
1 parent d6d4f78 commit 3bd1c70

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

README.md

+16-10
Original file line numberDiff line numberDiff line change
@@ -47,33 +47,36 @@ See [`markdownlint` rules](https://github.com/DavidAnson/markdownlint#rules--ali
4747
4. Edit `.markdownlint-cli2.mjs` file to suit your needs. Start with
4848

4949
```js
50-
const options = require('@github/markdownlint-github').init()
51-
module.exports = {
52-
config: options,
50+
import configOptions, {init} from "@github/markdownlint-github"
51+
const options = {
52+
config: init(),
5353
customRules: ["@github/markdownlint-github"],
5454
outputFormatters: [
5555
[ "markdownlint-cli2-formatter-pretty", { "appendLink": true } ] // ensures the error message includes a link to the rule documentation
5656
]
5757
}
58+
export default options
5859
```
5960
6061
Or, you can also pass in configuration options that you wish to override the default. Read more at [Customizing configurations](#customizing-configurations).
6162
This looks like:
6263
6364
```js
64-
const options = require('@github/markdownlint-github').init({
65+
import configOptions, {init} from "@github/markdownlint-github"
66+
const overriddenOptions = init({
6567
'fenced-code-language': false, // Custom overrides
6668
})
67-
module.exports = {
68-
config: options,
69+
const options = {
70+
config: overriddenOptions,
6971
customRules: ["@github/markdownlint-github"],
7072
outputFormatters: [
7173
[ "markdownlint-cli2-formatter-pretty", { "appendLink": true } ]
7274
]
7375
}
76+
export default options
7477
```
7578
76-
5. Install the [`vscode-markdownlint`](https://marketplace.visualstudio.com/items?itemName=DavidAnson.vscode-markdownlint) plugin to ensure `markdownlint` violations are surfaced in the file. This plugin should flag rules based off your `.markdownlint-cli2.cjs` configuration. When you make edits to your configuration, you will need to reload the VSCode window (`Ctrl+Shift+P` -> `Reload Window`) to ensure the extension syncs. If your project runs on Codespaces, consider adding this extension to your `.devcontainer/devcontainer.json` so that this extension is installed to new Codespaces by default.
79+
5. Install the [`vscode-markdownlint`](https://marketplace.visualstudio.com/items?itemName=DavidAnson.vscode-markdownlint) plugin to ensure `markdownlint` violations are surfaced in the file. This plugin should flag rules based off your `.markdownlint-cli2.mjs` configuration. When you make edits to your configuration, you will need to reload the VSCode window (`Ctrl+Shift+P` -> `Reload Window`) to ensure the extension syncs. If your project runs on Codespaces, consider adding this extension to your `.devcontainer/devcontainer.json` so that this extension is installed to new Codespaces by default.
7780
7881
### Customizing configurations
7982
@@ -89,13 +92,15 @@ To review configurations supported by `markdownlint`, see [`markdownlint-cli2` c
8992
9093
You may write custom rules within your repository. Follow the [custom rules guide in `markdownlint`](https://github.com/DavidAnson/markdownlint/blob/main/doc/CustomRules.md) to write your rule.
9194
92-
The rule will need to be enabled in the configuration. For instance, if you introduce `some-rule.js` with the name "some-rule", you must set the path of the custom rule in the `.markdownlint-cli2.cjs` file:
95+
The rule will need to be enabled in the configuration. For instance, if you introduce `some-rule.js` with the name "some-rule", you must set the path of the custom rule in the `.markdownlint-cli2.mjs` file:
9396
9497
```js
95-
module.exports = require('@github/markdownlint-github').init({
98+
import configOptions, {init} from "@github/markdownlint-github"
99+
const options = init({
96100
"some-rule": true,
97101
customRules: ["@github/markdownlint-github", "some-rule.js"],
98102
})
103+
export default options
99104
```
100105
101106
See [`markdownlint-cli2` configuration](https://github.com/DavidAnson/markdownlint-cli2#configuration).
@@ -104,7 +109,8 @@ Consider upstreaming any rules you find useful as proposals to this repository.
104109
105110
## License
106111
107-
This project is licensed under the terms of the MIT open source license. Please refer to [MIT](./LICENSE.txt) for the full terms.
112+
This project is licensed under the terms of the MIT open source license. Please
113+
refer to [the MIT license](./LICENSE.txt) for the full terms.
108114
109115
## Maintainers
110116

0 commit comments

Comments
 (0)