{"name":"eslint-plugin-markdown","version":"2.0.0-rc.2","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 .","prepare":"node ./npm-prepare.js","test":"npm run lint && npm run test-cov","test-cov":"nyc _mocha -- -c tests/{examples,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":"^3.1.2","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/main.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 `main` 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\nExtending the `plugin:markdown/recommended` config will enable the Markdown processor on all `.md` files:\n\n```js\n// .eslintrc.js\nmodule.exports = {\n    extends: \"plugin:markdown/recommended\"\n};\n```\n\n#### Advanced Configuration\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>.\n[`overrides` glob patterns](https://eslint.org/docs/user-guide/configuring#configuration-based-on-glob-patterns) for these virtual filenames can customize configuration for code blocks without affecting regular 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#### Frequently-Disabled Rules\n\nSome rules that catch mistakes in regular code are less helpful in documentation.\nFor example, `no-undef` would flag variables that are declared outside of a code snippet because they aren't relevant to the example.\nThe `plugin:markdown/recommended` config disables these rules in Markdown files:\n\n- [`no-undef`](https://eslint.org/docs/rules/no-undef)\n- [`no-unused-expressions`](https://eslint.org/docs/rules/no-unused-expressions)\n- [`no-unused-vars`](https://eslint.org/docs/rules/no-unused-vars)\n- [`padded-blocks`](https://eslint.org/docs/rules/padded-blocks)\n\nUse [`overrides` glob patterns](https://eslint.org/docs/user-guide/configuring#configuration-based-on-glob-patterns) to disable more rules just for Markdown code blocks:\n\n```js\nmodule.exports = {\n    // ...\n    overrides: [\n        // ...\n        {\n            // 1. Target ```js code blocks in .md files.\n            files: [\"**/*.md/*.js\"],\n            rules: {\n                // 2. Disable other rules.\n                \"no-console\": \"off\",\n                \"import/no-unresolved\": \"off\"\n            }\n        }\n    ]\n};\n```\n\n#### Strict Mode\n\n`\"use strict\"` directives in every code block would be annoying.\nThe `plugin:markdown/recommended` config enables the [`impliedStrict` parser option](https://eslint.org/docs/user-guide/configuring#specifying-parser-options) and disables the [`strict` rule](https://eslint.org/docs/rules/strict) in Markdown files.\nThis opts into strict mode parsing without repeated `\"use strict\"` directives.\n\n#### Unsatisfiable Rules\n\nMarkdown code blocks are not real files, so ESLint's file-format rules do not apply.\nThe `plugin:markdown/recommended` config disables these rules in Markdown files:\n\n- [`eol-last`](https://eslint.org/docs/rules/eol-last): The Markdown parser trims trailing newlines from code blocks.\n- [`unicode-bom`](https://eslint.org/docs/rules/unicode-bom): Markdown code blocks do not have Unicode Byte Order Marks.\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## 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":"140adf42a9e103c5fdce5338b737fa0a7c47d38c","_id":"eslint-plugin-markdown@2.0.0-rc.2","_nodeVersion":"12.19.0","_npmVersion":"6.14.8","dist":{"integrity":"sha512-wAxyQrvO86besEKriqGteceBxRtm1IEBn+Ci5i2hwchU1PYLnLxO73NroY74JpbzinER0zDOeZQeqwiuGTmdsA==","shasum":"0826da576df004f9823453fc8e66bd8cab8477d3","tarball":"http://registry-npm.ywwl.com/eslint-plugin-markdown/download/eslint-plugin-markdown-2.0.0-rc.2.tgz","fileCount":7,"unpackedSize":38391,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgFi1zCRA9TVsSAnZWagAAcgoQAI98dO4l6McFzAWjGhqF\nRN7NPotdA2L8WuOoj9l/b2z5lhrSwcXa/3Dx5lody5Ar0616FMl6yIxXwDBE\nB7+07ncBSWt66FNT7V2wGyZWs78OzEFR9xMuqHXN5uaZ1ackVCrUGH8Zpaq7\nB4wVMHslT6NCb/e52R35ZdLP3GRkSIlN99iEgx6z+CYtrb1DMrPLxY7ruKRx\nVIbVfxljq1sPYYC+iAaolwoaIUdq53gowctxPgS6tKXFuP1f0imPC6jrxTmN\no+gz57J03nAehfUEkmwji2btB8XqUFFsm6eDUnMOYsFMFiejCZ259R+nO3Vs\nQNgj2h62uBg4U95WegXHKW9khwbTKonePZMOFIzPqNuogM+suWwptzWZ0kDB\nkufhhePwMRmi7iF2Ce43ikHwO8r4rTMJUwazmaGo1vV/s8Xj3cm9IjWiwl69\nxHk+wK8qYu7phJ+PMDhkf6FJbn6eLHda5zBNgAJpDgmR1+4UnsyzUPoYtxE7\nXTCx4u8jfV5arucdBHmvRAPdpiU2Y6k1PAZwLDQOiFnLoLoH4VsyhRDE2FE5\nJ7loTtZUn8fw7+fRwfUA9DGtS7bN+26UkNa0of3GDvFZlM3WVuwc9wvN7Fap\ngd7jL4ZcctSwa92UGIPmgPY4Lh5EtI1DkM/cK9P2kYl4JwDu2civNpJs9YTb\n7gEM\r\n=RszZ\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC/TBr37CPeB5A4M3N6IcVHbwQmeW7zPZJjKAj5vAfuLAIhAPoke5IUOSP5CLVPIZsKiNeav89RzolHtGwD6vkCJDmT"}],"size":12672,"noattachment":false,"key":"/eslint-plugin-markdown/-/eslint-plugin-markdown-2.0.0-rc.2.tgz"},"_npmUser":{"name":"eslintbot","email":"nicholas+eslint@nczconsulting.com"},"directories":{},"maintainers":[{"name":"eslintbot","email":"nicholas+eslint@nczconsulting.com"},{"name":"btmills","email":"mills.brandont@gmail.com"},{"name":"nzakas","email":"nicholas@nczconsulting.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/eslint-plugin-markdown_2.0.0-rc.2_1612066163036_0.8796640180618469"},"_hasShrinkwrap":false,"publish_time":1612066163203,"deprecated":"Please use @eslint/markdown instead","_cnpm_publish_time":1612066163203,"dist-tags":{"latest":"5.1.0","next":"2.0.0-rc.2"}}