Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
eslint-plugin-markdown
Advanced tools
An ESLint plugin to lint JavaScript in Markdown code fences.
The eslint-plugin-markdown package allows you to lint JavaScript code blocks within Markdown files using ESLint. This is particularly useful for ensuring that code snippets in documentation are up to standard and free of errors.
Linting JavaScript Code Blocks in Markdown
This configuration allows ESLint to process JavaScript code blocks within Markdown files. By specifying the `markdown/markdown` processor, ESLint will recognize and lint the JavaScript code embedded in Markdown.
```json
{
"overrides": [
{
"files": ["**/*.md"],
"processor": "markdown/markdown"
}
]
}
```
Custom ESLint Rules for Markdown
This configuration applies custom ESLint rules specifically to JavaScript code blocks within Markdown files. In this example, the `no-console` rule is enforced, which will trigger an error if `console` statements are found in the code blocks.
```json
{
"overrides": [
{
"files": ["**/*.md/*.js"],
"rules": {
"no-console": "error"
}
}
]
}
```
Linting Specific Code Blocks
This configuration allows you to lint only specific code blocks within a Markdown file. By defining the `start` and `end` markers, you can control which parts of the Markdown file are subject to linting.
```json
{
"overrides": [
{
"files": ["**/*.md"],
"processor": "markdown/markdown",
"settings": {
"markdown/code-blocks": [
{
"language": "js",
"start": "<!-- eslint-enable -->",
"end": "<!-- eslint-disable -->"
}
]
}
}
]
}
```
remark-lint is a plugin for remark, a Markdown processor powered by plugins. It provides a set of rules to lint Markdown files, ensuring consistency and quality. Unlike eslint-plugin-markdown, which focuses on linting JavaScript code within Markdown, remark-lint is designed to lint the Markdown content itself.
markdownlint is a Node.js style checker and lint tool for Markdown files. It provides a set of rules to enforce consistent Markdown style and formatting. While eslint-plugin-markdown focuses on JavaScript code within Markdown, markdownlint is dedicated to the Markdown syntax and structure.
markdown-it is a Markdown parser that can be extended with plugins to add custom functionality. While it is not a linter, it can be used in conjunction with other tools to process and validate Markdown content. It is more flexible and general-purpose compared to eslint-plugin-markdown, which is specifically for linting JavaScript code in Markdown.
An ESLint plugin to lint JavaScript in Markdown.
Supported extensions are .markdown
, .mdown
, .mkdn
, and .md
.
Install the plugin:
npm install --save-dev eslint eslint-plugin-markdown
Add it to your .eslintrc
:
{
"plugins": [
"markdown"
]
}
Run ESLint on .md
files:
eslint --ext md .
It will lint js
, javascript
, jsx
, or node
fenced code blocks in your Markdown documents:
```js
// This gets linted
var answer = 6 * 7;
console.log(answer);
```
```JavaScript
// This also gets linted
/* eslint quotes: [2, "double"] */
function hello() {
console.log("Hello, world!");
}
hello();
```
```jsx
// This gets linted too
var div = <div className="jsx"></div>;
```
```node
// And this
console.log(process.version);
```
Blocks that don't specify either js
, javascript
, jsx
, or node
syntax are ignored:
```
This is plain text and doesn't get linted.
```
```python
print("This doesn't get linted either.")
```
Since code blocks are not files themselves but embedded inside a Markdown document, some rules do not apply to Markdown code blocks, and messages from these rules are automatically suppressed:
eol-last
$ git clone https://github.com/eslint/eslint-plugin-markdown.git
$ cd eslint-plugin-markdown
$ npm link
$ npm link eslint-plugin-markdown
$ npm test
This project follows the ESLint contribution guidelines.
FAQs
An ESLint plugin to lint JavaScript in Markdown code fences.
The npm package eslint-plugin-markdown receives a total of 439,386 weekly downloads. As such, eslint-plugin-markdown popularity was classified as popular.
We found that eslint-plugin-markdown demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.