From 7dc3ecf0f6b50067defb29126a8e359927766ab3 Mon Sep 17 00:00:00 2001 From: Simon Lydell Date: Sat, 26 Oct 2019 17:14:32 +0200 Subject: [PATCH] Add tests for eslint-plugin-markdown --- examples/.eslintrc.js | 5 ++++ examples/markdown.md | 34 ++++++++++++++++++++++ package-lock.json | 17 +++++++++++ package.json | 3 +- test/__snapshots__/examples.test.js.snap | 37 ++++++++++++++++++++++++ 5 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 examples/markdown.md diff --git a/examples/.eslintrc.js b/examples/.eslintrc.js index fa652d7..3608073 100644 --- a/examples/.eslintrc.js +++ b/examples/.eslintrc.js @@ -92,5 +92,10 @@ module.exports = { parser: vue.configs.base.parser, plugins: ["vue"], }, + { + // Markdown JS code blocks. + files: ["*.md"], + plugins: ["markdown"], + }, ], }; diff --git a/examples/markdown.md b/examples/markdown.md new file mode 100644 index 0000000..68a0c6c --- /dev/null +++ b/examples/markdown.md @@ -0,0 +1,34 @@ +# Markdown + +```js +import b1 from "b" +import a1 from "a"; +``` + +Some text. + +```js +code(); + +import b2 from "b"; +import a2 from "a"; + +code() + +import c2 from "c"; + +import e2 from "e"; +import d2 from "d" + +;[].forEach() +``` + +- Item 1. +- Item 2. + + ```js + import b3 from "b" + import a3 from "a" + ``` + +End text. diff --git a/package-lock.json b/package-lock.json index 3d8891c..4ab0b64 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1832,6 +1832,17 @@ } } }, + "eslint-plugin-markdown": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-markdown/-/eslint-plugin-markdown-1.0.1.tgz", + "integrity": "sha512-nAUURNHJGPooBMZMP23FmTbh3LTdgoSqeFBv9FA3fYrJ+vDUJxrp6nKiQF4iDNAmnWQnmnrDvV61BmIF4X9QAQ==", + "dev": true, + "requires": { + "object-assign": "^4.0.1", + "remark-parse": "^5.0.0", + "unified": "^6.1.2" + } + }, "eslint-plugin-prettier": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-3.1.0.tgz", @@ -4480,6 +4491,12 @@ "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==", "dev": true }, + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", + "dev": true + }, "object-copy": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/object-copy/-/object-copy-0.1.0.tgz", diff --git a/package.json b/package.json index 1f89017..3139254 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "scripts": { "eslint": "eslint .", "eslint:fix": "npm run eslint -- --fix", - "eslint:examples": "eslint --rulesdir src --no-ignore --fix-dry-run --format json --report-unused-disable-directives examples --ext .js,.ts,.vue", + "eslint:examples": "eslint --rulesdir src --no-ignore --fix-dry-run --format json --report-unused-disable-directives examples --ext .js,.ts,.vue,.md", "prettier": "prettier --write \"*.md\"", "doctoc": "doctoc README.md", "jest": "jest", @@ -43,6 +43,7 @@ "eslint-config-lydell": "14.0.0", "eslint-plugin-import": "2.18.2", "eslint-plugin-jest": "22.17.0", + "eslint-plugin-markdown": "^1.0.1", "eslint-plugin-prettier": "3.1.0", "eslint-plugin-vue": "5.2.3", "jest": "24.9.0", diff --git a/test/__snapshots__/examples.test.js.snap b/test/__snapshots__/examples.test.js.snap index 41b7ced..d8a9aac 100644 --- a/test/__snapshots__/examples.test.js.snap +++ b/test/__snapshots__/examples.test.js.snap @@ -102,6 +102,43 @@ import Thing from "side-effects"; `; +exports[`examples markdown.md 1`] = ` +# Markdown + +\`\`\`js +import a1 from "a"; +import b1 from "b" +\`\`\` + +Some text. + +\`\`\`js +code(); + +import a2 from "a"; +import b2 from "b"; + +code() + +import c2 from "c"; +import d2 from "d" +import e2 from "e"; + +;[].forEach() +\`\`\` + +- Item 1. +- Item 2. + + \`\`\`js + import a3 from "a" + import b3 from "b" + \`\`\` + +End text. + +`; + exports[`examples prettier-comments.js 1`] = ` /* eslint prettier/prettier: "error" */ // This is just a test to make sure that this plugin plays well with Prettier.