textlint rule to lint JavaScript in Markdown with ESLint.
Warning
Now you can Lint CodeBlock code in ESLint by using @eslint/markdown. Therefore, this rule is maintenance mode
ESLint can lint Markdown files using eslint-plugin-markdown. But eslint-plugin-markdown doesn't support disabling Markdown (HTML) comments for ignoring some CodeBlocks.
textlint can filter some CodeBlocks using textlint-filter-rule-comments:
<!-- textlint-disable -->
```js
var ignore = "This is ignored"
```
<!-- textlint-enable -->
Sometimes, we want to write broken JavaScript code into a JS CodeBlock for syntax highlight:
This is error example of parsing:
<!-- textlint-disable eslint -->
```js
// This is invalid example
const const;
```
<!-- textlint-enable eslint -->
To ignore ESLint parsing errors that cannot be ignored from the config file, you can use ignoreParsingErrors
:
{
"rules": {
"eslint": {
"configFile": "path/to/.eslintrc",
"ignoreParsingErrors": true
}
}
}
Install with npm:
npm install textlint-rule-eslint eslint
Support Versions:
textlint-rule-eslint@5
: Support ESLint 9textlint-rule-eslint@4
: Support ESLint 8
Via .textlintrc
(recommended):
{
"rules": {
"eslint": {
// Required: path to eslint.config file
"configFile": "./path/to/eslint.config.mjs"
}
}
}
Via CLI:
textlint --rule eslint README.md
configFile
: string- Required
- path to .eslintrc file
langs
:string[]
- Default:
["js", "javascript", "node", "jsx"]
- recognize lang of CodeBlock
- Default:
ignoreParsingErrors
:Boolean
- Default:
false
- ignore ESLint parsing errors while still reporting other ESLint errors
- Default:
{
"rules": {
"eslint": {
// Required: path to eslint.config file
"configFile": "./path/to/eslint.config.mjs",
// recognize lang of CodeBlock as JavaScript
"langs": ["js", "javascript", "node", "jsx"],
// Ignore ESLint parsing errors
"ignoreParsingErrors": true
}
}
}
textlint-rule-eslint support
--fix
option.
See https://github.com/textlint/textlint/#fixable for more details.
See Releases page.
Install devDependencies and Run npm test
:
npm ci && npm test
Pull requests and stars are always welcome.
For bugs and feature requests, please create an issue.
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
MIT © azu