eslint-mdx
Advanced tools
Comparing version
{ | ||
"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" | ||
} |
133
README.md
@@ -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 @@ |
Empty package
Supply chain riskPackage does not contain any code. It may be removed, is name squatting, or the result of a faulty package publish.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
1
-88.89%10484
-90.73%8
14.29%3
-88.89%0
-100%1
Infinity%164
-38.11%2
Infinity%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated
Updated
Updated
Updated