Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps-dev): bump markdownlint from 0.36.1 to 0.37.3 #135

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
18 changes: 0 additions & 18 deletions .eslintrc.js

This file was deleted.

24 changes: 24 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"root": true,
"parserOptions": {
"ecmaVersion": 2020
},
"env": {
"es6": true,
"node": true,
"jest": true
},
"plugins": ["github"],
"extends": ["plugin:github/recommended"],
"rules": {
"filenames/match-regex": "off",
"i18n-text/no-en": "off",
"import/extensions": ["error", { "js": "ignorePackages"}],
"import/no-unresolved": [
"error",
{
"ignore": ["^markdownlint/.+"]
}
]
}
}
12 changes: 0 additions & 12 deletions .markdownlint-cli2.cjs

This file was deleted.

15 changes: 15 additions & 0 deletions .markdownlint-cli2.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { init } from "./index.js";
JoyceZhu marked this conversation as resolved.
Show resolved Hide resolved

const configOptions = await init({
default: false,
"heading-increment": true,
"no-alt-text": true,
"single-h1": true,
"no-emphasis-as-heading": true,
"first-line-heading": true,
});
const options = {
config: configOptions,
customRules: ["./index.js"],
};
export default options;
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
14
18
34 changes: 20 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ See [`markdownlint` rules](https://github.com/DavidAnson/markdownlint#rules--ali

**Important**: We support the use of `markdownlint` through [`markdownlint-cli2`](https://github.com/DavidAnson/markdownlint-cli2) instead of `markdownlint-cli` for compatibility with the [`vscode-markdownlint`](https://github.com/DavidAnson/vscode-markdownlint) plugin.

1. Create a `.markdownlint-cli2.cjs` file in the root of your repository.
1. Create a `.markdownlint-cli2.mjs` file in the root of your repository.

```bash
touch .markdownlint-cli2.cjs
touch .markdownlint-cli2.mjs
```

2. Install packages.
Expand All @@ -44,36 +44,39 @@ See [`markdownlint` rules](https://github.com/DavidAnson/markdownlint#rules--ali
}
```

4. Edit `.markdownlint-cli2.cjs` file to suit your needs. Start with
4. Edit `.markdownlint-cli2.mjs` file to suit your needs. Start with

```js
const options = require('@github/markdownlint-github').init()
module.exports = {
config: options,
import configOptions, {init} from "@github/markdownlint-github"
const options = {
config: init(),
customRules: ["@github/markdownlint-github"],
outputFormatters: [
[ "markdownlint-cli2-formatter-pretty", { "appendLink": true } ] // ensures the error message includes a link to the rule documentation
]
}
export default options
```

Or, you can also pass in configuration options that you wish to override the default. Read more at [Customizing configurations](#customizing-configurations).
Or, you can also pass in configuration options that you wish to override the default. Read more at [Customizing configurations](#customizing-configurations).
This looks like:

```js
const options = require('@github/markdownlint-github').init({
import configOptions, {init} from "@github/markdownlint-github"
const overriddenOptions = init({
'fenced-code-language': false, // Custom overrides
})
module.exports = {
config: options,
const options = {
config: overriddenOptions,
customRules: ["@github/markdownlint-github"],
outputFormatters: [
[ "markdownlint-cli2-formatter-pretty", { "appendLink": true } ]
]
}
export default options
```

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.
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.

### Customizing configurations

Expand All @@ -89,13 +92,15 @@ To review configurations supported by `markdownlint`, see [`markdownlint-cli2` c

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.

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:
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:

```js
module.exports = require('@github/markdownlint-github').init({
import configOptions, {init} from "@github/markdownlint-github"
const options = init({
"some-rule": true,
customRules: ["@github/markdownlint-github", "some-rule.js"],
})
export default options
```

See [`markdownlint-cli2` configuration](https://github.com/DavidAnson/markdownlint-cli2#configuration).
Expand All @@ -104,7 +109,8 @@ Consider upstreaming any rules you find useful as proposals to this repository.

## License

This project is licensed under the terms of the MIT open source license. Please refer to [MIT](./LICENSE.txt) for the full terms.
This project is licensed under the terms of the MIT open source license. Please
refer to [the MIT license](./LICENSE.txt) for the full terms.

## Maintainers

Expand Down
32 changes: 19 additions & 13 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
const _ = require("lodash");
import { readFile } from "fs/promises";
import _ from "lodash-es";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

regular lodash is synchronous

import { githubMarkdownLint } from "./src/rules/index.js";

const accessibilityRules = require("./style/accessibility.json");
const base = require("./style/base.json");
const gitHubCustomRules = require("./src/rules/index").rules;
const offByDefault = ["no-empty-alt-text"];

module.exports = [...gitHubCustomRules];
export async function init(consumerConfig) {
// left overwrites right
const accessibilityRules = JSON.parse(
await readFile(new URL("./style/accessibility.json", import.meta.url)),
);

const offByDefault = ["no-empty-alt-text"];
const base = JSON.parse(
await readFile(new URL("./style/base.json", import.meta.url)),
);

for (const rule of gitHubCustomRules) {
const ruleName = rule.names[1];
base[ruleName] = offByDefault.includes(ruleName) ? false : true;
}
for (const rule of githubMarkdownLint) {
const ruleName = rule.names[1];
base[ruleName] = offByDefault.includes(ruleName) ? false : true;
}

module.exports.init = function init(consumerConfig) {
// left overwrites right
return _.defaultsDeep(consumerConfig, accessibilityRules, base);
};
}

export default githubMarkdownLint;
4 changes: 4 additions & 0 deletions jest.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"transform": {
}
}
Loading