-
Notifications
You must be signed in to change notification settings - Fork 79
docs: add migration docs #559
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
1ae2b0b
docs: add migration docs
michaelfaith 3f574bb
address lint errors
michaelfaith 4c9541a
add additional package managers and fix important notices
michaelfaith 517e57a
update config section
michaelfaith cc39e9e
add link to README
michaelfaith 1ebbe17
address feedback
michaelfaith 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
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,158 @@ | ||
| # Migration | ||
|
|
||
| ## From `eslint-plugin-markdown` | ||
|
|
||
| Starting with v6, `@eslint/markdown` officially replaced `eslint-plugin-markdown`. | ||
| You can take the following steps to migrate from the old package. | ||
|
|
||
| <!-- eslint-disable-next-line markdown/no-missing-label-refs -- This should be fixed in https://github.com/eslint/markdown/issues/294 --> | ||
| > [!NOTE] | ||
| > `@eslint/markdown` requires that you're on at least ESLint v9.15.0. | ||
|
|
||
| ### Update dependencies | ||
|
|
||
| - `npm remove eslint-plugin-markdown` | ||
| - `npm add -D @eslint/markdown` | ||
|
|
||
| ### Update `eslint.config.js/ts` | ||
|
|
||
| Make the following updates to your config, based on how you're currently using `eslint-plugin-markdown`. | ||
|
|
||
| #### Configs | ||
|
|
||
| ```diff | ||
| // eslint.config.js | ||
| import { defineConfig } from "eslint/config"; | ||
| - import markdown from "eslint-plugin-markdown"; | ||
| + import markdown from "@eslint/markdown"; | ||
|
|
||
| export default defineConfig([ | ||
| - ...markdown.configs.recommended, | ||
| + { | ||
| + name: "your-project/markdown-rules", | ||
| + files: ["**/*.md"], | ||
| + plugins: { | ||
| + markdown | ||
| + }, | ||
| + extends: ["markdown/recommended"] | ||
| }, | ||
|
|
||
| // your other configs | ||
| ]); | ||
|
|
||
| ``` | ||
|
|
||
| <!-- eslint-disable-next-line markdown/no-missing-label-refs -- This should be fixed in https://github.com/eslint/markdown/issues/294 --> | ||
| > [!IMPORTANT] | ||
| > Because this plugin uses a new language to power its linting, you may need to update the other configs you're using so that you limit those to only apply to `js / ts` files. | ||
| > Otherwise, those rules will be applied to markdown files now, too, which can lead to unexpected failures. | ||
|
|
||
| ```js | ||
| // eslint.config.js | ||
| import { defineConfig } from "eslint/config"; | ||
| import js from "@eslint/js"; | ||
| import markdown from "@eslint/markdown"; | ||
|
|
||
| export default defineConfig([ | ||
| { | ||
| name: "your-project/recommended-rules", | ||
| files: ["**/*.js"], | ||
| plugins: { | ||
| js, | ||
| }, | ||
| extends: ["js/recommended"], | ||
| }, | ||
| { | ||
| name: "your-project/markdown-rules", | ||
| files: ["**/*.md"], | ||
| plugins: { | ||
| markdown | ||
| }, | ||
| extends: ["markdown/recommended"] | ||
| }, | ||
| ]); | ||
| ``` | ||
|
|
||
| If you were previously applying rules from other languages to code blocks within your markdown files, you can use this plugin's `processor` config to still allow for that. | ||
|
|
||
| ```js | ||
| // eslint.config.js | ||
| import { defineConfig } from "eslint/config"; | ||
| import markdown from "@eslint/markdown"; | ||
|
|
||
| export default defineConfig([ | ||
| { | ||
| name: "your-project/markdown-processor", | ||
| files: ["**/*.md"], | ||
| plugins: { | ||
| markdown | ||
| }, | ||
| extends: ["markdown/processor"] | ||
| }, | ||
| // your other configs | ||
| ]); | ||
| ``` | ||
|
|
||
| <!-- eslint-disable-next-line markdown/no-missing-label-refs -- This should be fixed in https://github.com/eslint/markdown/issues/294 --> | ||
| > [!WARNING] | ||
| > It is not currently possible to use both the language-based `recommended` config and the processor-based `processor` config, due to a limitation in ESLint core. | ||
| > We hope at some point in the future the core will have a solution for this. | ||
|
|
||
| #### Rules Only | ||
|
|
||
| `@eslint/markdown` is significantly different in its architecture than `eslint-plugin-markdown`, and uses the language feature of `ESLint`, rather than using a processor. | ||
| As a result, if you want to configure rules directly (instead of using the recommended config), you'll have to set up the language instead of the processor. | ||
|
|
||
| ```diff | ||
| // eslint.config.js | ||
| import { defineConfig } from "eslint/config"; | ||
| - import markdown from "eslint-plugin-markdown"; | ||
| + import markdown from "@eslint/markdown"; | ||
|
|
||
| export default defineConfig([ | ||
| { | ||
| files: ["**/*.md"], | ||
| plugins: { | ||
| markdown, | ||
| }, | ||
| - processor: "markdown/markdown" | ||
| + language: "markdown/commonmark", | ||
| rules: { | ||
| "markdown/no-html": "error", | ||
| }, | ||
| }, | ||
| ]); | ||
|
|
||
| ``` | ||
| <!-- eslint-disable-next-line markdown/no-missing-label-refs -- This should be fixed in https://github.com/eslint/markdown/issues/294 --> | ||
| > [!IMPORTANT] | ||
| > Because this plugin uses a new language to power its linting, you may need to update the other configs you're using so that you limit those to only apply to `js / ts` files. | ||
| > Otherwise, those rules will be applied to markdown files now, too, which can lead to unexpected failures. | ||
|
|
||
| ```js | ||
| // eslint.config.js | ||
| import { defineConfig } from "eslint/config"; | ||
| import js from "@eslint/js"; | ||
| import markdown from "@eslint/markdown"; | ||
|
|
||
| export default defineConfig([ | ||
| { | ||
| name: "your-project/recommended-rules", | ||
| files: ["**/*.js"], | ||
| plugins: { | ||
| js, | ||
| }, | ||
| extends: ["js/recommended"], | ||
| }, | ||
| { | ||
| files: ["**/*.md"], | ||
| plugins: { | ||
| markdown, | ||
| }, | ||
| language: "markdown/commonmark", | ||
| rules: { | ||
| "markdown/no-html": "error", | ||
| }, | ||
| }, | ||
| ]); | ||
| ``` |
This file contains hidden or 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
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.
Uh oh!
There was an error while loading. Please reload this page.