{"name":"eslint-plugin-markdown","version":"2.0.0-alpha.0","description":"An ESLint plugin to lint JavaScript in Markdown code fences.","license":"MIT","author":{"name":"Brandon Mills","url":"https://github.com/btmills"},"repository":{"type":"git","url":"git+https://github.com/eslint/eslint-plugin-markdown.git"},"bugs":{"url":"https://github.com/eslint/eslint-plugin-markdown/issues"},"homepage":"https://github.com/eslint/eslint-plugin-markdown#readme","keywords":["eslint","eslintplugin","markdown","lint","linter"],"scripts":{"lint":"eslint --ext js,md .","test":"npm run lint && npm run test-cov","test-cov":"nyc _mocha -- -c tests/lib/**/*.js","generate-release":"eslint-generate-release","generate-alpharelease":"eslint-generate-prerelease alpha","generate-betarelease":"eslint-generate-prerelease beta","generate-rcrelease":"eslint-generate-prerelease rc","publish-release":"eslint-publish-release"},"main":"index.js","devDependencies":{"chai":"^4.2.0","eslint":"^6.8.0","eslint-config-eslint":"^6.0.0","eslint-plugin-jsdoc":"^15.9.5","eslint-plugin-node":"^9.0.0","eslint-release":"^1.2.0","mocha":"^6.2.2","nyc":"^14.1.1"},"dependencies":{"remark-parse":"^5.0.0","unified":"^6.1.2"},"peerDependencies":{"eslint":">=6.0.0"},"engines":{"node":"^8.10.0 || ^10.12.0 || >= 12.0.0"},"readme":"# eslint-plugin-markdown\n\n[![npm Version](https://img.shields.io/npm/v/eslint-plugin-markdown.svg)](https://www.npmjs.com/package/eslint-plugin-markdown)\n[![Build Status](https://img.shields.io/github/workflow/status/eslint/eslint-plugin-markdown/CI/master.svg)](https://github.com/eslint/eslint-plugin-markdown/actions)\n\nLint JS, JSX, TypeScript, and more inside Markdown.\n\n<img\n    src=\"screenshot.png\"\n    height=\"142\"\n    width=\"432\"\n    alt=\"A JS code snippet in a Markdown editor has red squiggly underlines. A tooltip explains the problem.\"\n/>\n\n> 🚧 This documentation is for an unfinished v2 release in progress in the `master` branch. The latest stable documentation is in the [`v1` branch](https://github.com/eslint/eslint-plugin-markdown/tree/v1).\n\n## Usage\n\n### Installing\n\nInstall the plugin alongside ESLint v6 or greater:\n\n```sh\nnpm install --save-dev eslint eslint-plugin-markdown@next\n```\n\n### Configuring\n\nAdd the plugin to your `.eslintrc` and use the `processor` option in an `overrides` entry to enable the plugin's `markdown/markdown` processor on Markdown files.\nEach fenced code block inside a Markdown document has a virtual filename appended to the Markdown file's path.\nThe virtual filename's extension will match the fenced code block's syntax tag, so for example, <code>```js</code> code blocks in <code>README.md</code> would match <code>README.md/*.js</code>.\nFor more information on configuring processors, refer to the [ESLint documentation](https://eslint.org/docs/user-guide/configuring#specifying-processor).\n\n```js\n// .eslintrc.js\nmodule.exports = {\n    // 1. Add the plugin.\n    plugins: [\"markdown\"],\n    overrides: [\n        {\n            // 2. Enable the Markdown processor for all .md files.\n            files: [\"**/*.md\"],\n            processor: \"markdown/markdown\"\n        },\n        {\n            // 3. Optionally, customize the configuration ESLint uses for ```js\n            // fenced code blocks inside .md files.\n            files: [\"**/*.md/*.js\"],\n            // ...\n            rules: {\n                // ...\n            }\n        }\n    ]\n};\n```\n\n#### Migrating from `eslint-plugin-markdown` v1\n\n`eslint-plugin-markdown` v1 used an older version of ESLint's processor API.\nThe Markdown processor automatically ran on `.md`, `.mkdn`, `.mdown`, and `.markdown` files, and it only extracted fenced code blocks marked with `js`, `javascript`, `jsx`, or `node` syntax.\nConfiguration specifically for fenced code blocks went inside an `overrides` entry with a `files` pattern matching the containing Markdown document's filename that applied to all fenced code blocks inside the file.\n\n```js\n// .eslintrc.js for eslint-plugin-markdown v1\nmodule.exports = {\n    plugins: [\"markdown\"],\n    overrides: [\n        {\n            files: [\"**/*.md\"],\n            // In v1, configuration for fenced code blocks went inside an\n            // `overrides` entry with a .md pattern, for example:\n            parserOptions: {\n                ecmaFeatures: {\n                    impliedStrict: true\n                }\n            },\n            rules: {\n                \"no-console\": \"off\"\n            }\n        }\n    ]\n};\n```\n\n[RFC3](https://github.com/eslint/rfcs/blob/master/designs/2018-processors-improvements/README.md) designed a new processor API to remove these limitations, and the new API was [implemented](https://github.com/eslint/eslint/pull/11552) as part of ESLint v6.\n`eslint-plugin-markdown` v2 uses this new API.\n\n```bash\n$ npm install --save-dev eslint@latest eslint-plugin-markdown@next\n```\n\nAll of the Markdown file extensions that were previously hard-coded are now fully configurable in `.eslintrc.js`.\nUse the new `processor` option to apply the `markdown/markdown` processor on any Markdown documents matching a `files` pattern.\nEach fenced code block inside a Markdown document has a virtual filename appended to the Markdown file's path.\nThe virtual filename's extension will match the fenced code block's syntax tag, so for example, <code>```js</code> code blocks in <code>README.md</code> would match <code>README.md/*.js</code>.\n\n```js\n// eslintrc.js for eslint-plugin-markdown v2\nmodule.exports = {\n    plugins: [\"markdown\"],\n    overrides: [\n        {\n            // In v2, explicitly apply eslint-plugin-markdown's `markdown`\n            // processor on any Markdown files you want to lint.\n            files: [\"**/*.md\"],\n            processor: \"markdown/markdown\"\n        },\n        {\n            // In v2, configuration for fenced code blocks is separate from the\n            // containing Markdown file. Each code block has a virtual filename\n            // appended to the Markdown file's path.\n            files: [\"**/*.md/*.js\"],\n            // Configuration for fenced code blocks goes with the override for\n            // the code block's virtual filename, for example:\n            parserOptions: {\n                ecmaFeatures: {\n                    impliedStrict: true\n                }\n            },\n            rules: {\n                \"no-console\": \"off\"\n            }\n        }\n    ]\n};\n```\n\nIf you need to precisely mimic the behavior of v1 with the hard-coded Markdown extensions and fenced code block syntaxes, you can use those as glob patterns in `overrides[].files`:\n\n```js\n// eslintrc.js for v2 mimicking v1 behavior\nmodule.exports = {\n    plugins: [\"markdown\"],\n    overrides: [\n        {\n            files: [\"**/*.{md,mkdn,mdown,markdown}\"],\n            processor: \"markdown/markdown\"\n        },\n        {\n            files: [\"**/*.{md,mkdn,mdown,markdown}/*.{js,javascript,jsx,node}\"]\n            // ...\n        }\n    ]\n};\n```\n\n### Running\n\n#### ESLint v7\n\nYou can run ESLint as usual and do not need to use the `--ext` option.\nESLint v7 [automatically lints file extensions specified in `overrides[].files` patterns in config files](https://github.com/eslint/rfcs/blob/0253e3a95511c65d622eaa387eb73f824249b467/designs/2019-additional-lint-targets/README.md).\n\n#### ESLint v6\n\nUse the [`--ext` option](https://eslint.org/docs/user-guide/command-line-interface#ext) to include `.js` and `.md` extensions in ESLint's file search:\n\n```sh\neslint --ext js,md .\n```\n\n### Autofixing\n\nWith this plugin, [ESLint's `--fix` option](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some issues in your Markdown fenced code blocks.\nTo enable this, pass the `--fix` flag when you run ESLint:\n\n```bash\neslint --fix .\n```\n\n## What Gets Linted?\n\nWith this plugin, ESLint will lint [fenced code blocks](https://help.github.com/articles/github-flavored-markdown/#fenced-code-blocks) in your Markdown documents:\n\n````markdown\n```js\n// This gets linted\nvar answer = 6 * 7;\nconsole.log(answer);\n```\n\nHere is some regular Markdown text that will be ignored.\n\n```js\n// This also gets linted\n\n/* eslint quotes: [2, \"double\"] */\n\nfunction hello() {\n    console.log(\"Hello, world!\");\n}\nhello();\n```\n\n```jsx\n// This can be linted too if you add `.jsx` files to `overrides` in ESLint v7\n// or pass `--ext jsx` in ESLint v6.\nvar div = <div className=\"jsx\"></div>;\n```\n````\n\nBlocks that don't specify a syntax are ignored:\n\n````markdown\n```\nThis is plain text and doesn't get linted.\n```\n````\n\nUnless a fenced code block's syntax appears as a file extension in `overrides[].files` in ESLint v7, it will be ignored.\nIf using ESLint v6, you must also include the extension with the `--ext` option.\n\n````markdown\n```python\nprint(\"This doesn't get linted either.\")\n```\n````\n\n## Configuration Comments\n\nThe processor will convert HTML comments immediately preceding a code block into JavaScript block comments and insert them at the beginning of the source code that it passes to ESLint.\nThis permits configuring ESLint via configuration comments while keeping the configuration comments themselves hidden when the markdown is rendered.\nComment bodies are passed through unmodified, so the plugin supports any [configuration comments](http://eslint.org/docs/user-guide/configuring) supported by ESLint itself.\n\nThis example enables the `browser` environment, disables the `no-alert` rule, and configures the `quotes` rule to prefer single quotes:\n\n````markdown\n<!-- eslint-env browser -->\n<!-- eslint-disable no-alert -->\n<!-- eslint quotes: [\"error\", \"single\"] -->\n\n```js\nalert('Hello, world!');\n```\n````\n\nEach code block in a file is linted separately, so configuration comments apply only to the code block that immediately follows.\n\n````markdown\nAssuming `no-alert` is enabled in `.eslintrc`, the first code block will have no error from `no-alert`:\n\n<!-- eslint-env browser -->\n<!-- eslint-disable no-alert -->\n\n```js\nalert(\"Hello, world!\");\n```\n\nBut the next code block will have an error from `no-alert`:\n\n<!-- eslint-env browser -->\n\n```js\nalert(\"Hello, world!\");\n```\n````\n\n### Skipping Blocks\n\nSometimes it can be useful to have code blocks marked with `js` even though they don't contain valid JavaScript syntax, such as commented JSON blobs that need `js` syntax highlighting.\nStandard `eslint-disable` comments only silence rule reporting, but ESLint still reports any syntax errors it finds.\nIn cases where a code block should not even be parsed, insert a non-standard `<!-- eslint-skip -->` comment before the block, and this plugin will hide the following block from ESLint.\nNeither rule nor syntax errors will be reported.\n\n````markdown\nThere are comments in this JSON, so we use `js` syntax for better\nhighlighting. Skip the block to prevent warnings about invalid syntax.\n\n<!-- eslint-skip -->\n\n```js\n{\n    // This code block is hidden from ESLint.\n    \"hello\": \"world\"\n}\n```\n\n```js\nconsole.log(\"This code block is linted normally.\");\n```\n````\n\n## Unsatisfiable Rules\n\nSince 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:\n\n- `eol-last`\n- `unicode-bom`\n\n### Project or directory-wide overrides for code snippets\n\nGiven that code snippets often lack full context, and adding full context through configuration comments may be too cumbersome to apply for each snippet, one may wish to instead set defaults for all one's JavaScript snippets in a manner that applies to all Markdown files within your project (or a specific directory).\n\nESLint allows a configuration property `overrides` which has a `files` property which accepts a [glob pattern](https://eslint.org/docs/user-guide/configuring#configuration-based-on-glob-patterns), allowing you to designate files (such as all `md` files) whose rules will be overridden.\n\nThe following example shows the disabling of a few commonly problematic rules for code snippets.\nIt also points to the fact that some rules (e.g., `padded-blocks`) may be more appealing for disabling given that one may wish for documentation to be more liberal in providing padding for readability.\n\n```js\n// .eslintrc.js\nmodule.exports = {\n    plugins: [\"markdown\"],\n    overrides: [\n        {\n            files: [\"**/*.md\"],\n            processor: \"markdown/markdown\"\n        },\n        {\n            files: [\"**/*.md/*.js\"],\n            rules: {\n                \"no-undef\": \"off\",\n                \"no-unused-vars\": \"off\",\n                \"no-console\": \"off\",\n                \"padded-blocks\": \"off\"\n            }\n        }\n    ]\n};\n```\n\n### Overriding `strict`\n\nThe `strict` rule is technically satisfiable inside of Markdown code blocks, but writing a `\"use strict\"` directive at the top of every code block is tedious and distracting.\nWe recommend a glob pattern for `.md` files containing `.js` blocks to disable `strict` and enable the `impliedStrict` [parser option](https://eslint.org/docs/user-guide/configuring#specifying-parser-options) so the code blocks still parse in strict mode:\n\n```js\n// .eslintrc.js\nmodule.exports = {\n    plugins: [\"markdown\"],\n    overrides: [\n        {\n            files: [\"**/*.md\"],\n            processor: \"markdown/markdown\"\n        },\n        {\n            files: [\"**/*.md/*.js\"],\n            parserOptions: {\n                ecmaFeatures: {\n                    impliedStrict: true\n                }\n            }\n        }\n    ]\n};\n```\n\n## Editor Integrations\n\n### VSCode\n\n[`vscode-eslint`](https://github.com/microsoft/vscode-eslint) has built-in support for the Markdown processor.\n\n### Atom\n\nThe [`linter-eslint`](https://atom.io/packages/linter-eslint) package allows for linting within the [Atom IDE](https://atom.io/).\n\nIn order to see `eslint-plugin-markdown` work its magic within Markdown code blocks in your Atom editor, you can go to `linter-eslint`'s settings and within \"List of scopes to run ESLint on...\", add the cursor scope \"source.gfm\".\n\nHowever, this reports a problem when viewing Markdown which does not have configuration, so you may wish to use the cursor scope \"source.embedded.js\", but note that `eslint-plugin-markdown` configuration comments and skip directives won't work in this context.\n\n## Contributing\n\n```sh\n$ git clone https://github.com/eslint/eslint-plugin-markdown.git\n$ cd eslint-plugin-markdown\n$ npm install\n$ npm test\n```\n\nThis project follows the [ESLint contribution guidelines](http://eslint.org/docs/developer-guide/contributing/).\n","readmeFilename":"README.md","gitHead":"2bc93523e006b482a4c57a251c221e7b8711b66b","_id":"eslint-plugin-markdown@2.0.0-alpha.0","_nodeVersion":"12.16.1","_npmVersion":"6.14.4","dist":{"integrity":"sha512-NIp6WBiGDRWkGuuG1s5biJ55s4E+B5wbfrIlf3m8cLeTFD2ijkxrP1l3LXx0BexnL7XL2Hz5Ce1e2nOazdaTHg==","shasum":"4316c3dc32e37cefbae6cd6b6676344a2982e5e8","tarball":"http://registry-npm.ywwl.com/eslint-plugin-markdown/download/eslint-plugin-markdown-2.0.0-alpha.0.tgz","fileCount":7,"unpackedSize":34254,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJek3khCRA9TVsSAnZWagAAjbkP/R+Uyjb2GBZR0UGKrQr+\nORkXVVDKSDlW1LauKy0+CIpOUnp8sVX14RGHwlSybLaP0t8ftRZsC/CPiyMd\nm0wrx4vvgvT8bQtQ7lb+jersit2Ty1v86er5YmigJCnWiaTsHqm4aaZWdvqv\nYVMo7Z0cYW9wFpdHvChU8AEgyZObkCnS7bJj2X4xWkLG+1pMnkMffmt7zVB5\naO7sn/bVy14wbote+/WUzuna/BOvMJVMzMVznb6XHorXGjz4LM2/WM55pl8i\n3PUXdRQNVGw5dMntBhGawmZMSjnHflO0GUgFeKXAjRj7ATBl6bOp66r6Uj4E\ngMoShgZpyAGKx9ggp0t0Sb9IwKCvU/4vjMje+3Z/FGSLCDXVhPOOscIzM4tt\noM7lDlQfLf49VNYMZ5bp67K1ldBCsSeEVFcxLihomYZplngkEvEEH94XNr6w\n0R56FnkMdLVRKO4Asc4ncY14XL+A6a/v7WxFWhengyJNo5X6wbydc5XgsRSf\nZ9Vv2HYrqPvnstcdH/BlFNWmHZupnJvYSU0ybFRjD8DuWBk8mk4DK2VyyQPy\nBM2ZvHN504Y8jM/jLUeBkaQuz6IdFn0qDRMOAm7uM2tj4eG0sPCQahPOXRAd\ntm9LQE+exW/JwNDpIOI1GyTKy4JE0j8o2xgEiF1LinMHfy7CJIg7cWAhritg\nAkJ9\r\n=ey3t\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICe0K5Er2j42WADrTq1V8nDaCJkIydB00tVIPx9og/crAiByH2QhGR5cLT5ra6XSu5+WNu8RtiYEtNf14nT3kGCfLQ=="}],"size":11628,"noattachment":false,"key":"/eslint-plugin-markdown/-/eslint-plugin-markdown-2.0.0-alpha.0.tgz"},"maintainers":[{"email":"mills.brandont@gmail.com","name":"btmills"},{"email":"nicholas+eslint@nczconsulting.com","name":"eslintbot"},{"email":"kai@kaicataldo.com","name":"kaicataldo"},{"email":"nicholas@nczconsulting.com","name":"nzakas"}],"_npmUser":{"name":"eslintbot","email":"nicholas+eslint@nczconsulting.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/eslint-plugin-markdown_2.0.0-alpha.0_1586723105475_0.8644973265448375"},"_hasShrinkwrap":false,"publish_time":1586723105657,"deprecated":"Please use @eslint/markdown instead","_cnpm_publish_time":1586723105657,"dist-tags":{"latest":"5.1.0","next":"2.0.0-rc.2"}}