-
Notifications
You must be signed in to change notification settings - Fork 3
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
Update README.md #31
Merged
Merged
Update README.md #31
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,13 @@ | ||
# GitHub Flavored Markdown Linting | ||
|
||
We are using the [`markdownlint`](https://github.com/DavidAnson/markdownlint) library (via [`markdownlint-cli2`](https://github.com/DavidAnson/markdownlint-cli2) and adding our opinions and custom rules to it. | ||
|
||
To review behaviors supported by `markdownlint`, particularly how to enable or disable rules, see [`markdownlint-cli2` configuration](https://github.com/DavidAnson/markdownlint-cli2#configuration). | ||
This repository provides GitHub's recommended [`markdownlint`](https://github.com/DavidAnson/markdownlint) configurations, and additional rules for use on GitHub open source and internal projects. | ||
|
||
## Opinions | ||
|
||
At GitHub, we have opinions about how our markdown should be written. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seemed redundant so removing. |
||
|
||
In addition to defaults defined by `markdownlint`, we use this repository to enforce rules not defined by default, including our own custom rules. | ||
|
||
See our opinions codified in [index.js](./index.js). | ||
|
||
### Should I disable rules enabled by this plugin? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moving this down after the setup where it makes more sense. |
||
|
||
This plugin will enable the defaults defined by `markdownlint`. Several of these pertain to stylistic practices. You may choose to disable these rules if you determine it doesn't provide value for your project. | ||
|
||
However, others of these rules should **NOT** be disabled because they encourage best accessibility practices. Disabling these rules will negatively impact accessibility. These rules are specified in [accessibility.json](./accessibility.json). | ||
See opinions codified in [index.js](./index.js). | ||
|
||
## Rules | ||
|
||
|
@@ -29,19 +20,20 @@ See [`markdownlint` rules](https://github.com/DavidAnson/markdownlint#rules--ali | |
|
||
## Usage | ||
|
||
**Note**: We recommend configuring [`markdownlint-cli2`](https://github.com/DavidAnson/markdownlint-cli2) over `markdownlint-cli` for compatibility with the [vscode-markdownlint](https://github.com/DavidAnson/vscode-markdownlint) plugin. | ||
**Important**: We support the use of `markdownlint` through [`markdownlint-cli2`](https://github.com/DavidAnson/markdownlint-cli2) instead of `markdownlint-cli` for compatability 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.cjs` file in the root of your repository. | ||
|
||
```bash | ||
touch .markdownlint-cli2.cjs | ||
``` | ||
|
||
2. Install packages | ||
2. Install packages. | ||
|
||
- ```bash | ||
npm install -D markdownlint-cli2 # if updating existing package, check for updates | ||
npm install -D @github/markdownlint-github [--@github:registry=https://registry.npmjs.org] | ||
npm install -D markdownlint-cli2-formatter-pretty | ||
``` | ||
|
||
3. Add/modify your linting script in `package.json`. | ||
|
@@ -57,22 +49,39 @@ See [`markdownlint` rules](https://github.com/DavidAnson/markdownlint#rules--ali | |
module.exports = { | ||
config: options, | ||
customRules: ["@github/markdownlint-github"], | ||
outputFormatters: [ | ||
[ "markdownlint-cli2-formatter-pretty", { "appendLink": true } ] // ensures the error message includes a link to the rule documentation | ||
] | ||
} | ||
``` | ||
|
||
Or, you can also pass in configuration options that you wish to override the default. This looks like: | ||
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({ | ||
'fenced-code-language': false, | ||
'fenced-code-language': false, // Custom overrides | ||
}) | ||
module.exports = { | ||
config: options, | ||
customRules: ["@github/markdownlint-github"], | ||
outputFormatters: [ | ||
[ "markdownlint-cli2-formatter-pretty", { "appendLink": true } ] | ||
] | ||
} | ||
``` | ||
|
||
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 configuartion, you will need to reload the VSCode window (`Ctrl+Shift+P` -> `Reload Window`) to ensure the extension syncs. | ||
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. | ||
|
||
### Customizing configurations | ||
|
||
You may determine that the defaults set by this plugin are not suitable for your project. | ||
|
||
This plugin will pull in the the defaults defined by `markdownlint`, several of which pertain to stylistic practices. You may choose to disable these rules if you determine it doesn't provide value for your project. | ||
|
||
However, others of these rules should **NOT** be disabled because they encourage best accessibility practices. Disabling these rules will negatively impact accessibility. These rules are defined in [accessibility.json](./accessibility.json). | ||
|
||
To review configurations supported by `markdownlint`, see [`markdownlint-cli2` configuration](https://github.com/DavidAnson/markdownlint-cli2#configuration). | ||
|
||
### Advanced: Adding custom rules in your codebase | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved portions of this down into the setup section.