Socket
Socket
Sign inDemoInstall

eslint-mdx

Package Overview
Dependencies
Maintainers
4
Versions
109
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-mdx - npm Package Compare versions

Comparing version 1.17.0 to 2.0.0-next.0

20

package.json
{
"name": "eslint-mdx",
"version": "1.17.0",
"version": "2.0.0-next.0",
"description": "ESLint Parser for MDX",

@@ -14,3 +14,3 @@ "repository": "git+https://github.com/mdx-js/eslint-mdx.git",

"engines": {
"node": ">=10.0.0"
"node": ">=12.20"
},

@@ -21,4 +21,3 @@ "main": "lib/index.js",

"files": [
"lib",
"typings.d.ts"
"lib"
],

@@ -33,13 +32,14 @@ "keywords": [

"peerDependencies": {
"eslint": ">=5.0.0"
"eslint": ">=8.0.0"
},
"dependencies": {
"cosmiconfig": "^7.0.1",
"remark-mdx": "^1.6.22",
"remark-parse": "^8.0.3",
"remark-stringify": "^8.1.1",
"remark-mdx": "^2.1.0",
"remark-parse": "^10.0.1",
"remark-stringify": "^10.0.2",
"synckit": "^0.6.0",
"tslib": "^2.3.1",
"unified": "^9.2.2"
"unified": "^10.1.2"
},
"gitHead": "16c5934530b2f55059dcb7695707f721a693a0d6"
"gitHead": "bafa756a1da0e6aac954344d67b6f3ea7725befa"
}

@@ -37,4 +37,2 @@ <p align="center">

- [Rules](#rules)
- [mdx/no-jsx-html-comments](#mdxno-jsx-html-comments)
- [mdx/no-unused-expressions](#mdxno-unused-expressions)
- [mdx/remark](#mdxremark)

@@ -78,95 +76,17 @@ - [Prettier Integration](#prettier-integration)

1. In your ESLint config file:
1. In your ESLint 8+ config file, just add:
1. If you're using `eslint >= 6.4.0`, just add:
```jsonc
{
"extends": ["plugin:mdx/recommended"],
// optional, if you want to lint code blocks at the same time
"settings": {
"mdx/code-blocks": true,
// optional, if you want to disable language mapper, set it to `false`
// if you want to override the default language mapper inside, you can provide your own
"mdx/language-mapper": {}
}
}
```
```jsonc
{
"extends": ["plugin:mdx/recommended"],
// optional, if you want to lint code blocks at the same time
"settings": {
"mdx/code-blocks": true,
// optional, if you want to disable language mapper, set it to `false`
// if you want to override the default language mapper inside, you can provide your own
"mdx/language-mapper": {}
}
}
```
2. If you're using `eslint >=6.0.0 and <6.4.0`, add as following because it does not support overrides from npm pkg:
```jsonc
{
"extends": ["plugin:mdx/recommended"],
// optional, if you want to lint code blocks at the same time
"settings": {
"mdx/code-blocks": true,
// optional, if you want to disable language mapper, set it to `false`
// if you want to override the default language mapper inside, you can provide your own
"mdx/language-mapper": {}
},
"overrides": [
{
"files": ["*.md"],
"rules": {
"prettier/prettier": [
2,
{
// unnecessary if you're not using `eslint-plugin-prettier`, but required if you are
"parser": "markdown"
}
]
}
},
{
"files": ["*.mdx"],
"extends": ["plugin:mdx/overrides"]
},
{
"files": "**/*.{md,mdx}/**",
"extends": "plugin:mdx/code-blocks"
}
]
}
```
3. 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:
```js
const configs = require('eslint-plugin-mdx/lib/configs')
module.exports = {
extends: ['plugin:mdx/recommended'],
// optional, if you want to lint code blocks at the same time
settings: {
'mdx/code-blocks': true,
// optional, if you want to disable language mapper, set it to `false`
// if you want to override the default language mapper inside, you can provide your own
'mdx/language-mapper': {},
},
overrides: [
{
files: ['*.md'],
rules: {
'prettier/prettier': [
2,
{
// unnecessary if you're not using `eslint-plugin-prettier`, but required if you are
parser: 'markdown',
},
],
},
},
{
files: ['*.mdx'],
...configs.overrides,
},
{
files: '**/*.{md,mdx}/**',
...configs.codeBlocks,
},
],
}
```
2. Make sure ESLint knows to run on `.md` or `.mdx` files:

@@ -180,29 +100,10 @@

1. `parser` (`string | ParserConfig | ParserFn`): Custom parser for ES syntax is supported, although `@typescript-eslint/parser` or `@babel/eslint-parser` or `babel-eslint` will be detected automatically what means you actually do not need to do this:
1. `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.
```json
{
"extends": ["plugin:mdx/recommended"],
"parserOptions": {
"parser": "babel-eslint"
}
}
```
2. `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.
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.
3. `ignoreRemarkConfig` (`boolean`): Ignore the `remark` configuration defined in the project.
3. `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.
4. `ignoreRemarkConfig` (`boolean`): Ignore the `remark` configuration defined in the project.
## Rules
### mdx/no-jsx-html-comments
_Fixable_: 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-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 the replacement, so make sure that you've turned off the original `no-unused-expressions` rule.
### mdx/remark

@@ -231,4 +132,2 @@

Some plugins are ESM and eslint don't supports them. So, a workaround is to set `ignoreRemarkConfig` to `true` and execute `remark-lint` through the terminal before running eslint. For example: `remark **/*.mdx --no-stdout && eslint . --fix --ext .mdx`.
## Prettier Integration

@@ -235,0 +134,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc