包详细信息

@rxts/eslint-plugin-mdx

rx-ts245MIT不推荐使用0.11.2

This package has been renamed to eslint-plugin-mdx, please migrate to >=1.1.0

ESLint Plugin for MDX

eslint, eslint-plugin, eslint-plugin-mdx, mdx

自述文件

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:

Package Description Version Peer Dependencies Dependencies
eslint-mdx ESLint Parser for MDX npm David Peer David
@rxts/eslint-plugin-mdx ESLint Plugin, Configuration and Rules for MDX npm David Peer David

Install

# yarn
yarn add -D @rxts/eslint-plugin-mdx

# npm
npm i -D @rxts/eslint-plugin-mdx

Usage

  1. In your ESLint config file:

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

      {
        "extends": ["plugin:@rxts/mdx/recommended"],
        "overrides": [
          {
            "files": ["*.mdx"],
            "extends": ["plugin:@rxts/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('@rxts/eslint-plugin-mdx')
      const rebass = require('rebass')
      
      module.exports = {
        extends: ['plugin:@rxts/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:@rxts/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

@rxts/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.

@rxts/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, @rxts/mdx/no-unescaped-entities is the replacement.

@rxts/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

更新日志

Change Log

All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines.

0.11.2 (2019-08-13)

Note: Version bump only for package @rxts/eslint-plugin-mdx

0.11.1 (2019-08-12)

Note: Version bump only for package @rxts/eslint-plugin-mdx

0.11.0 (2019-08-11)

Features

  • all rebass components considered as global variables (a36a69b)
  • overrides react/jsx-no-undef to allow globals (f7d5194)

0.10.0 (2019-08-11)

Features

  • remove deprecated functions, test coverage 100% (fd2694e)

0.9.11 (2019-08-10)

Note: Version bump only for package @rxts/eslint-plugin-mdx

0.9.10 (2019-08-10)

Note: Version bump only for package @rxts/eslint-plugin-mdx

0.9.9 (2019-08-10)

Note: Version bump only for package @rxts/eslint-plugin-mdx

0.9.8 (2019-08-10)

Note: Version bump only for package @rxts/eslint-plugin-mdx

0.9.6 (2019-08-07)

Bug Fixes

  • custom parser resolved undefined error (1bbb1ff)

0.9.5 (2019-08-05)

Bug Fixes

  • options unchangeable issue for default parser (e76c483)

0.9.4 (2019-08-05)

Bug Fixes

  • adjacent jsx nodes should be allowed in mdx (8456381)
  • skip combine jsx nodes for root/jsx node (90583f7)

0.9.3 (2019-08-04)

Bug Fixes

  • error from typescript parser in plain object (f634e40)

0.9.1 (2019-08-03)

Bug Fixes

  • always extends base config (530160a)

0.9.0 (2019-08-03)

Features

  • support other extensions, detect parsers automatically (5386098)

0.8.1 (2019-08-03)

Features

  • split into two packages, use lerna as publisher (#22) (349b1ff), closes #21

0.8.0 (2019-08-03)

Features

  • split into two packages, use lerna as publisher (#22) (349b1ff), closes #21

0.7.1 (2019-08-03)

Features

  • export a parse function for compatibility usage (0fdaf9f)

0.7.0 (2019-08-02)

Features

  • add new rule no-unescaped-entities (dca8633)

0.6.0 (2019-08-02)

Features

  • add new rule no-jsx-html-comments, close #13 (67ba91e)
  • processor support for normalize comments in jsx [ci skip] (114831c)

0.5.0 (2019-07-31)

Features

  • add @rxts/mdx/no-unused-expressions rule to replace eslint's (5d62b55)

0.4.1 (2019-07-31)

Features

  • perf: extract parseMdx, exports everything in package (1f965a1)

0.4.0 (2019-07-31)

Features

  • add body and comments into ast, fix #12 (5b28bd5)

0.3.1 (2019-07-30)

Bug Fixes

  • .* could not match multi lines, use [\s\S]* instead, close #4 (f7e7efe)

0.3.0 (2019-07-30)

Bug Fixes

  • inline jsx and comment parsing error, close #4, #7 (5297a0b)

0.2.1 (2019-07-30)

Bug Fixes

  • eslint@5 is actually supported (e470ddc)

0.2.0 (2019-07-30)

Features

  • support custom parser like babel-eslint (b718574)

0.1.3 (2019-07-29)

Bug Fixes

  • upgrade peer dependency eslint to >= 6.0.0 (#3 #4) (f0ab288)

0.1.2 (2019-07-29)

Bug Fixes

  • show correct column and line on lint error (90c5390)

0.1.1 (2019-07-29)

Bug Fixes

  • overrides in node_modules seems not working (d2f1535)

0.1.0 (2019-07-29)

Features