3.1.5 • Published 2 months ago

eslint-plugin-mdx v3.1.5

Weekly downloads
45,516
License
MIT
Repository
github
Last release
2 months ago

Travis Codecov type-coverage GitHub release David Dev

Conventional Commits code style: prettier lerna codechecks.io

ESLint Parser/Plugin for MDX, helps you lint all ES syntaxes excluding code block of course. Work perfectly with eslint-plugin-import, eslint-plugin-prettier or any other eslint plugins.

VSCode Extension Visual Studio Marketplace Version

VSCode MDX\: Integrates with VSCode ESLint, syntaxes highlighting and error reporting.

Packages

This repository is a monorepo managed by Lerna what means we actually publish several packages to npm from same codebase, including:

PackageDescriptionVersionPeer DependenciesDependencies
eslint-mdxESLint Parser for MDXnpmDavid PeerDavid
eslint-plugin-mdxESLint Plugin, Configuration and Rules for MDXnpmDavid PeerDavid

Install

# yarn
yarn add -D eslint-plugin-mdx

# npm
npm i -D eslint-plugin-mdx

Usage

  1. In your ESLint config file:

    1. If you're using eslint >= 6.0.0, add:

      {
        "extends": ["plugin:mdx/recommended"],
        "overrides": [
          {
            "files": ["*.mdx"],
            "extends": ["plugin:mdx/overrides"]
          }
        ]
      }
    2. If you're using eslint@^5.0.0, you need to enable this parser/plugin manually, because eslint@5 does not support extends for overrides property in its configuration:

      const { configs } = require('eslint-plugin-mdx')
      const rebass = require('rebass')
      
      module.exports = {
        extends: ['plugin:mdx/recommended'],
        overrides: [
          Object.assign(
            {
              files: ['*.mdx'],
            },
            configs.overrides,
          ),
        ],
      }
  2. Make sure ESLint knows to run on .mdx files:

    eslint . --ext js,mdx

Parser Options

  1. parser (string | ParserConfig | ParserFn): Custom parser for ES syntax is supported, although @typescript-eslint/parser or babel-eslint will be detected automatically what means you actually do not need to do this:

    {
      "extends": ["plugin:mdx/recommended"],
      "parserOptions": {
        "parser": "babel-eslint"
      }
    }
  2. extensions (string | string[]): eslint-mdx will only resolve .mdx files by default, files with other extensions will be resolved by the parser option. If you want to resolve other extensions as like .mdx, you can use this option.

Rules

mdx/no-jsx-html-comments

HTML style comments in jsx block is invalid, this rule will help you to fix it by transforming it to JSX style comments.

mdx/no-unescaped-entities

Inline JSX like Inline <Component /> is supported by MDX, but rule react/no-unescaped-entities from eslint-plugin-react is incompatible with it, mdx/no-unescaped-entities is the replacement.

mdx/no-unused-expressions

MDX can render jsx block automatically without exporting them, but ESLint will report no-unused-expressions issue which could be unexpected, this rule is a replacement of it, so make sure that you've turned off the original no-unused-expressions rule.

Limitation

This parser/plugin can only handle ES syntaxes for you, markdown related syntaxes will just be ignored, you can use markdownlint or remark-lint to lint that part.

I have a very preliminary idea to integrate with remark-lint.

Changelog

Detailed changes for each release are documented in CHANGELOG.md.

License

MIT © JounQin@1stG

@adapt-design-system/core@teambit/reacteslint-config-leedavidcseslint-config-rbower@infinitebrahmanuniverse/nolb-eslint-plugin-m@everything-registry/sub-chunk-1612kukuruzm-fe-eslint-configeslint-config-websoluteeslint-config-tmytekeslint-config-staxeslint-config-tuxsncteslint-config-1stgeslint-config-neoneslint-config-codefixlabseslint-config-doc-jseslint-config-doc-tseslint-config-docz-jseslint-config-docz-tseslint-config-react-3mergeeslint-config-re-taroeslint-config-krosseslint-config-mskcceslint-config-dsx-baseeslint-config-fukseslint-config-gagrigoryaneduodaptos_design_systemq3-ui-eslint@tunnckocore/eslint-config@gyldendal/kobber-eslint@elliemae/pui-cli@grupo-tiradentes/eslint-config@hexatool/eslint-config@fr8/gatsby-theme@kmart/eslint-config@mjolnir/eslint-config@kitschpatrol/eslint-config@kunlunjs/fabric@jlrickert/eslint-config-custom@looker/eslint-config@looker/eslint-config-oss@mullerstd/eslint-config@newhighsco/eslint-config@newlevelup/eslint-config@m-fe/eslint-config@hybrbase/eslint-config@flatfile/design-systemsx-config@mskcc/eslint-config@mallowigi/eslint-config@mariusz.sh/eslint-config@pilaton/eslint-config-markdown@lapidist/linting@snowball-tech/eslint-config@regionhalland/eslint-config-regionhalland@u3u/eslint-config@theguild/eslint-config@thiago_brolly/eslint-config@thiago_brolly/eslint-config-b@thundercraft5/eslint-plugin@preply-ds/eslint-config@sharegate/eslint-plugin@preply/eslint-config-ds@mattietea/eslint-config@paylivre/eslint-config@retail-ui/eslint-config@so1ve/eslint-config-basic@so1ve/eslint-config-js@react-hookz/eslint-config@so1ve/eslint-config@stefanprobst/eslint-config-mdx@staxjs/cli@styled-x/config@styledx/config@talend/scripts-config-eslint@talend/eslint-config@tangramdotdev/eslint-config@techytools/ui@switz/eslint-config@teambit/env@teambit/node@teambit/react.eslint-config-bit-react@wayofdev/eslint-config-bases@white-matrix/eslint-config@zolplay/eslint-config-next@vidispine/eslint-config-mdx@we-are-singular/eslint-config@workleap/eslint-plugin@wx-fc/eslint-config@yungezeit/eslint-config-storybook@adbayb/eslint-config@1stg/eslint-config@air/eslint-config@anolilab/eslint-config@aoeu/eslint-config@andrskr/eslint-config@apitree.cz/eslint-config@alexvyber/eslint-config@4design/eslint-config@3design/eslint-config
2.3.4

2 months ago

3.1.5

2 months ago

2.3.3

3 months ago

3.1.4

3 months ago

2.3.2

3 months ago

3.1.3

3 months ago

2.3.1

3 months ago

3.1.2

3 months ago

2.2.1

3 months ago

3.0.1

3 months ago

2.3.0

3 months ago

3.1.1

3 months ago

3.1.0

3 months ago

3.0.0

4 months ago

2.2.0

8 months ago

2.1.0

11 months ago

2.0.3

2 years ago

2.0.5

2 years ago

2.0.4

2 years ago

2.0.0-next.6

2 years ago

2.0.0-next.4

2 years ago

2.0.0-next.5

2 years ago

2.0.2

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.17.1

2 years ago

2.0.0-next.3

2 years ago

2.0.0-next.2

2 years ago

2.0.0-next.0

2 years ago

2.0.0-next.1

2 years ago

1.17.0

2 years ago

1.16.0

2 years ago

1.15.1

3 years ago

1.15.0

3 years ago

1.14.1

3 years ago

1.14.0

3 years ago

1.13.0

3 years ago

1.12.0

3 years ago

1.11.1

3 years ago

1.11.0

3 years ago

1.10.0

3 years ago

1.9.1

3 years ago

1.9.0

3 years ago

1.8.2

4 years ago

1.8.1

4 years ago

1.7.1

4 years ago

1.7.0

4 years ago

1.6.9

4 years ago

1.6.8

4 years ago

1.6.7

4 years ago

1.6.6

4 years ago

1.6.5

4 years ago

1.6.4

4 years ago

1.6.3

4 years ago

1.6.2

4 years ago

1.6.1

4 years ago

1.6.0

4 years ago

1.5.9

4 years ago

1.5.7

4 years ago

1.5.6

4 years ago

1.5.5

5 years ago

1.5.5-beta.1

5 years ago

1.5.4

5 years ago

1.5.3

5 years ago

1.5.3-beta.1

5 years ago

1.5.3-beta.0

5 years ago

1.5.2

5 years ago

1.5.1

5 years ago

1.5.0

5 years ago

1.4.6

5 years ago

1.4.5

5 years ago

1.4.4

5 years ago

1.4.3

5 years ago

1.4.2

5 years ago

1.4.1

5 years ago

1.4.0

5 years ago

1.3.1

5 years ago

1.3.0

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

0.11.3-beta.4

5 years ago

0.11.2

5 years ago

0.11.3-beta.2

5 years ago

1.0.2-beta.2

5 years ago

1.0.2-beta.1

5 years ago

1.0.2-beta

5 years ago

1.0.1

6 years ago

1.0.0

6 years ago