{"id":13596805,"url":"https://github.com/mdx-js/eslint-mdx","last_synced_at":"2025-05-14T15:00:28.848Z","repository":{"id":35048635,"uuid":"199383942","full_name":"mdx-js/eslint-mdx","owner":"mdx-js","description":"ESLint Parser/Plugin for MDX","archived":false,"fork":false,"pushed_at":"2025-05-01T03:13:10.000Z","size":10430,"stargazers_count":285,"open_issues_count":13,"forks_count":34,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-05-08T20:44:00.854Z","etag":null,"topics":["eslint","eslint-mdx","eslint-parser","eslint-plugin","eslint-plugin-mdx","mdx"],"latest_commit_sha":null,"homepage":"https://npmjs.org/eslint-plugin-mdx","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mdx-js.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"unifiedjs","open_collective":"unified","thanks_dev":"u/gh/mdx-js"}},"created_at":"2019-07-29T05:26:12.000Z","updated_at":"2025-05-01T03:13:13.000Z","dependencies_parsed_at":"2023-12-21T18:25:06.249Z","dependency_job_id":"7a662fff-4e95-49e3-a398-a7b03231ed95","html_url":"https://github.com/mdx-js/eslint-mdx","commit_stats":{"total_commits":404,"total_committers":14,"mean_commits":"28.857142857142858","dds":0.3564356435643564,"last_synced_commit":"d6fc093fb32ab58fb226e8cf42ac77399b8a4758"},"previous_names":["rx-ts/eslint-mdx"],"tags_count":146,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdx-js%2Feslint-mdx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdx-js%2Feslint-mdx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdx-js%2Feslint-mdx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdx-js%2Feslint-mdx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mdx-js","download_url":"https://codeload.github.com/mdx-js/eslint-mdx/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254168125,"owners_count":22026090,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["eslint","eslint-mdx","eslint-parser","eslint-plugin","eslint-plugin-mdx","mdx"],"created_at":"2024-08-01T16:02:48.850Z","updated_at":"2025-05-14T15:00:28.747Z","avatar_url":"https://github.com/mdx-js.png","language":"TypeScript","funding_links":["https://github.com/sponsors/unifiedjs","https://opencollective.com/unified","https://thanks.dev/u/gh/mdx-js","https://github.com/sponsors/JounQin","https://opencollective.com/1stG","https://opencollective.com/rxts","https://opencollective.com/unts"],"categories":["TypeScript","Projects"],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://eslint.org\"\u003e\n    \u003cimg src=\"https://eslint.org/icon.svg\" height=\"50\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"#readme\"\u003e\n    \u003cimg src=\"https://rx-ts.github.io/assets/heart.svg\" height=\"50\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/mdx-js/mdx\"\u003e\n    \u003cimg src=\"https://avatars.githubusercontent.com/u/37453691\"  height=\"50\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n[![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/mdx-js/eslint-mdx/ci.yml?branch=master)](https://github.com/mdx-js/eslint-mdx/actions/workflows/ci.yml?query=branch%3Amaster)\n[![Codecov](https://img.shields.io/codecov/c/gh/mdx-js/eslint-mdx)](https://codecov.io/gh/mdx-js/eslint-mdx)\n[![type-coverage](https://img.shields.io/badge/dynamic/json.svg?label=type-coverage\u0026prefix=%E2%89%A5\u0026suffix=%\u0026query=$.typeCoverage.atLeast\u0026uri=https%3A%2F%2Fraw.githubusercontent.com%2Fmdx-js%2Feslint-mdx%2Fmaster%2Fpackage.json)](https://github.com/plantain-00/type-coverage)\n[![GitHub release](https://img.shields.io/github/release/mdx-js/eslint-mdx)](https://github.com/mdx-js/eslint-mdx/releases)\n\n[![Renovate enabled](https://img.shields.io/badge/renovate-enabled-brightgreen.svg)](https://renovatebot.com)\n[![Conventional Commits](https://img.shields.io/badge/conventional%20commits-1.0.0-yellow.svg)](https://conventionalcommits.org)\n[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier)\n[![changesets](https://img.shields.io/badge/maintained%20with-changesets-176de3.svg)](https://github.com/changesets/changesets)\n\n\u003e [ESLint][] Parser/Plugin for [MDX][], helps you lint all ES syntaxes.\n\u003e Linting `code` blocks can be enabled with `mdx/code-blocks` setting too!\n\u003e Work perfectly with `eslint-plugin-import`, `eslint-plugin-prettier` or any other eslint plugins.\n\u003e And also can be integrated with [remark-lint][] plugins to lint markdown syntaxes.\n\n## TOC \u003c!-- omit in toc --\u003e\n\n- [VSCode Extension](#vscode-extension)\n- [Packages](#packages)\n- [Install](#install)\n- [Notice](#notice)\n- [Usage](#usage)\n  - [Classic Config](#classic-config)\n  - [Flat Config](#flat-config)\n- [Parser Options](#parser-options)\n- [Parser API](#parser-api)\n  - [`MDXCode`](#mdxcode)\n  - [`MDXHeading`](#mdxheading)\n  - [Typings](#typings)\n- [Rules](#rules)\n  - [mdx/remark](#mdxremark)\n- [Prettier Integration](#prettier-integration)\n- [Sponsors](#sponsors)\n- [Backers](#backers)\n- [Changelog](#changelog)\n- [License](#license)\n\n## VSCode Extension\n\n[![Visual Studio Marketplace Version](https://img.shields.io/visual-studio-marketplace/v/unifiedjs.vscode-mdx)](https://marketplace.visualstudio.com/items?itemName=unifiedjs.vscode-mdx)\n\n[VSCode MDX][]: Integrates with [VSCode ESLint][], syntaxes highlighting and error reporting.\n\n## Packages\n\nThis repository is a monorepo managed by [changesets][] what means we actually publish several packages to npm from same codebase, including:\n\n| Package                                            | Description                                    | Version                                                                                                       |\n| -------------------------------------------------- | ---------------------------------------------- | ------------------------------------------------------------------------------------------------------------- |\n| [`eslint-mdx`](/packages/eslint-mdx)               | ESLint Parser for MDX                          | [![npm](https://img.shields.io/npm/v/eslint-mdx.svg)](https://www.npmjs.com/package/eslint-mdx)               |\n| [`eslint-plugin-mdx`](/packages/eslint-plugin-mdx) | ESLint Plugin, Configuration and Rules for MDX | [![npm](https://img.shields.io/npm/v/eslint-plugin-mdx.svg)](https://www.npmjs.com/package/eslint-plugin-mdx) |\n\n## Install\n\n```sh\n# yarn\nyarn add -D eslint-plugin-mdx\n\n# npm\nnpm i -D eslint-plugin-mdx\n```\n\n## Notice\n\n1. If you're using multi languages, `js/jsx/ts/tsx/vue`, etc for example, you'd better to always use [`overrides`](https://eslint.org/docs/user-guide/configuring/configuration-files#how-do-overrides-work) ([Classic Config](#classic-config)) or [`files`](https://eslint.org/docs/latest/use/configure/configuration-files#specifying-files-and-ignores) ([Flag Config](#flat-config)) feature of ESLint, because configs may be overridden by following configs.\n\n   See [#251](https://github.com/mdx-js/eslint-mdx/issues/251#issuecomment-736139224) for more details.\n\n2. If you're using `{/* eslint-disable-line mdx/remark */}` with `prettier`, this won't work because `prettier` will add a blank line after the comment, which makes it invalid. You can use `{/* eslint-disable mdx/remark */}` paired with `{/* eslint-enable mdx/remark */}` instead:\n\n   \u003c!-- eslint-skip --\u003e\n\n   ```mdx\n   {/* eslint-disable mdx/remark */}\n\n   # Heading\n\n   {/* eslint-enable mdx/remark */}\n   ```\n\n## Usage\n\n### Classic Config\n\n`.eslintrc` file:\n\n```jsonc\n{\n  \"extends\": [\"plugin:mdx/recommended\"],\n  // optional, if you want to lint code blocks at the same time\n  \"settings\": {\n    \"mdx/code-blocks\": true,\n    // optional, if you want to disable language mapper, set it to `false`\n    // if you want to override the default language mapper inside, you can provide your own\n    \"mdx/language-mapper\": {},\n  },\n}\n```\n\n### Flat Config\n\n`eslint.config.js` file:\n\n```js\nimport * as mdx from 'eslint-plugin-mdx'\n\nexport default [\n  {\n    ...mdx.flat,\n    // optional, if you want to lint code blocks at the same\n    processor: mdx.createRemarkProcessor({\n      lintCodeBlocks: true,\n      // optional, if you want to disable language mapper, set it to `false`\n      // if you want to override the default language mapper inside, you can provide your own\n      languageMapper: {},\n    }),\n  },\n  {\n    ...mdx.flatCodeBlocks,\n    rules: {\n      ...mdx.flatCodeBlocks.rules,\n      // if you want to override some rules for code blocks\n      'no-var': 'error',\n      'prefer-const': 'error',\n    },\n  },\n]\n```\n\nThen, make sure ESLint knows to run on `.md` or `.mdx` files:\n\n```sh\neslint . --ext js,md,mdx\n```\n\n## Parser Options\n\n1. `extensions` (`string | string[]`): `eslint-mdx` will only resolve `.mdx` files by default, if you want to resolve other extensions as like `.mdx`, you can use this option.\n\n2. `markdownExtensions` (`string | string[]`): `eslint-mdx` will only treat `.md` files as plain markdown by default, and will lint them via remark plugins. If you want to resolve other extensions as like `.md`, you can use this option.\n\n3. `ignoreRemarkConfig` (`boolean`): Ignore the `remark` configuration defined in the project.\n\n## Parser API\n\n### `MDXCode`\n\nA new `MDXCode` estree node type is exported from `eslint-mdx` which represents code blocks in `mdx` like the following:\n\n````mdx\n\u003cdiv\u003e\n  ```js\n  export function foo() {\n    return 'bar'\n  }\n  ```\n\u003c/div\u003e\n````\n\nSee also \u003chttps://github.com/syntax-tree/mdast#code\u003e\n\n### `MDXHeading`\n\nA new `MDXHeading` estree node type is exported from `eslint-mdx` which represents markdown heading in `mdx` like the following:\n\n\u003c!-- mdx v2+ incompatible --\u003e\n\u003c!-- prettier-ignore --\u003e\n```mdx\n\u003cdiv\u003e\n# Here's a text gradient short code!\n\u003c/div\u003e\n```\n\nSee also \u003chttps://github.com/syntax-tree/mdast#heading\u003e\n\n### Typings\n\n```ts\nimport type { BaseNode } from 'estree'\nimport type { JSXElement } from 'estree-jsx'\n\nexport interface MDXCode extends BaseNode {\n  type: 'MDXCode'\n  value: string\n  lang?: string | null\n  meta?: string | null\n}\n\nexport type HeadingDepth = 1 | 2 | 3 | 4 | 5 | 6\n\nexport interface MDXHeading extends BaseNode {\n  type: 'MDXHeading'\n  depth: HeadingDepth\n  children: JSXElement['children']\n}\n```\n\n## Rules\n\n### mdx/remark\n\n_possible fixable depends on your remark plugins_:\n\nIntegration with [remark-lint][] plugins, it will read [remark's configuration](https://github.com/remarkjs/remark/tree/master/packages/remark-cli#remark-cli) automatically via [unified-engine][]. But `.remarkignore` will not be respected, you should use `.eslintignore` instead.\n\nIf you want to disable or change severity of some related rules, it won't work by setting rules in eslint config like `'remark-lint-no-duplicate-headings': 0`, you should change your remark config instead like following:\n\n```jsonc\n{\n  \"plugins\": [\n    \"@1stg/remark-config\",\n    // change to error severity, notice `[]` is required\n    [\"lint-no-duplicate-headings\", [2]],\n    // disable following plugin\n    [\n      \"lint-no-multiple-toplevel-headings\",\n      [0], // or false\n    ],\n  ],\n}\n```\n\n## Prettier Integration\n\nIf you're using [remark-lint][] feature with [Prettier][] both together, you can try [remark-preset-prettier][] which helps you to _turn off all rules that are unnecessary or might conflict with [Prettier][]_.\n\n```json\n{\n  \"plugins\": [\n    \"preset-lint-consistent\",\n    \"preset-lint-recommended\",\n    \"preset-lint-markdown-style-guide\",\n    \"preset-prettier\"\n  ]\n}\n```\n\n[![Sponsors](https://raw.githubusercontent.com/1stG/static/master/sponsors.svg)](https://github.com/sponsors/JounQin)\n\n## Sponsors\n\n| 1stG                                                                                                                   | RxTS                                                                                                                   | UnTS                                                                                                                   |\n| ---------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |\n| [![1stG Open Collective sponsors](https://opencollective.com/1stG/organizations.svg)](https://opencollective.com/1stG) | [![RxTS Open Collective sponsors](https://opencollective.com/rxts/organizations.svg)](https://opencollective.com/rxts) | [![UnTS Open Collective sponsors](https://opencollective.com/unts/organizations.svg)](https://opencollective.com/unts) |\n\n[![unified Open Collective backers and sponsors](https://opencollective.com/unified/organizations.svg)](https://opencollective.com/unified)\n\n## Backers\n\n| 1stG                                                                                                                | RxTS                                                                                                                | UnTS                                                                                                                |\n| ------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- |\n| [![1stG Open Collective backers](https://opencollective.com/1stG/individuals.svg)](https://opencollective.com/1stG) | [![RxTS Open Collective backers](https://opencollective.com/rxts/individuals.svg)](https://opencollective.com/rxts) | [![UnTS Open Collective backers](https://opencollective.com/unts/individuals.svg)](https://opencollective.com/unts) |\n\n[![unified Open Collective backers and sponsors](https://opencollective.com/unified/individuals.svg)](https://opencollective.com/unified)\n\n## Changelog\n\nDetailed changes for each release are documented in [CHANGELOG.md](./CHANGELOG.md).\n\n## License\n\n[MIT][] © [JounQin][]@[1stG.me][]\n\n[1stg.me]: https://www.1stg.me\n[changesets]: https://github.com/changesets/changesets\n[eslint]: https://eslint.org\n[jounqin]: https://github.com/JounQin\n[mdx]: https://github.com/mdx-js/mdx\n[mit]: http://opensource.org/licenses/MIT\n[prettier]: https://prettier.io\n[remark-lint]: https://github.com/remarkjs/remark-lint\n[remark-preset-prettier]: https://github.com/un-ts/remark-preset-prettier\n[unified-engine]: https://github.com/unifiedjs/unified-engine\n[vscode eslint]: https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint\n[vscode mdx]: https://github.com/mdx-js/mdx-analyzer/tree/main/packages/vscode-mdx\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmdx-js%2Feslint-mdx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmdx-js%2Feslint-mdx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmdx-js%2Feslint-mdx/lists"}