Skip to content

Commit

Permalink
chore: update babel-eslint, eslint and `eslint-config-i-am-meticu…
Browse files Browse the repository at this point in the history
…lous` to their latest versions

Lint all files
  • Loading branch information
medfreeman committed Dec 23, 2018
1 parent c2009d3 commit 942b276
Show file tree
Hide file tree
Showing 6 changed files with 621 additions and 531 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@
"ava": "^0.17.0",
"babel-cli": "^6.4.0",
"babel-core": "^6.4.0",
"babel-eslint": "^7.1.1",
"babel-eslint": "^10.0.1",
"babel-preset-es2015": "^6.3.13",
"babel-preset-stage-2": "^6.3.13",
"coveralls": "^2.11.9",
"eslint": "^3.12.2",
"eslint-config-i-am-meticulous": "^5.0.2",
"eslint": "^5.11.0",
"eslint-config-i-am-meticulous": "^11.0.0",
"eslint-plugin-import": "^2.2.0",
"markdown-it": "^8.2.2",
"npmpub": "^3.1.0",
Expand Down
50 changes: 34 additions & 16 deletions src/__tests__/anchor.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import test from "ava"
import test from "ava";

import mdIt from "./utils/md-it"
import mdIt from "./utils/md-it";

test("markdown-it-toc-and-anchor anchor", (t) => {
test("markdown-it-toc-and-anchor anchor", t => {
t.is(
mdIt(
`@[toc]
Expand All @@ -12,14 +12,14 @@ test("markdown-it-toc-and-anchor anchor", (t) => {
`,
{ anchorLink: true }
),
/* eslint-disable max-len */
`<p></p>
/* eslint-disable max-len */
`<p></p>
<h1 id="heading"><a class="markdownIt-Anchor" href="#heading">#</a> 'Heading' ?</h1>
<h1 id="lel"><a class="markdownIt-Anchor" href="#lel">#</a> $.lel!</h1>
<h1 id="lel-2"><a class="markdownIt-Anchor" href="#lel-2">#</a> $.lel?</h1>\n`,
/* eslint-enable max-len */
/* eslint-enable max-len */
"should add anchors"
)
);

t.is(
mdIt(
Expand All @@ -30,17 +30,17 @@ test("markdown-it-toc-and-anchor anchor", (t) => {
`,
{
anchorLink: true,
anchorLinkBefore: false,
anchorLinkBefore: false
}
),
/* eslint-disable max-len */
`<p></p>
/* eslint-disable max-len */
`<p></p>
<h1 id="heading">'Heading' ? <a class="markdownIt-Anchor" href="#heading">#</a></h1>
<h1 id="lel">$.lel! <a class="markdownIt-Anchor" href="#lel">#</a></h1>
<h1 id="lel-2">$.lel? <a class="markdownIt-Anchor" href="#lel-2">#</a></h1>\n`,
/* eslint-enable max-len */
/* eslint-enable max-len */
"should add anchors after"
)
);

t.is(
mdIt(
Expand All @@ -51,12 +51,30 @@ test("markdown-it-toc-and-anchor anchor", (t) => {
anchorClassName: "anchor",
anchorLinkSymbol: "",
anchorLinkSymbolClassName: "octicon octicon-link",
anchorLinkSpace: false,
anchorLinkSpace: false
}
),
`<p></p>
<h1 id="heading"><a class="anchor" href="#heading">` +
"<span class=\"octicon octicon-link\"></span></a>Heading</h1>\n",
'<span class="octicon octicon-link"></span></a>Heading</h1>\n',
"should support GitHub style anchor link"
)
})
);

t.is(
mdIt(
`@[toc]
# Heading`,
{
anchorLink: true,
anchorClassName: "anchor",
anchorLinkSymbol: "",
anchorLinkSymbolClassName: "octicon octicon-link",
anchorLinkSpace: false
}
),
`<p></p>
<h1 id="heading"><a class="anchor" href="#heading">` +
'<span class="octicon octicon-link"></span></a>Heading</h1>\n',
"should support empty heading"
);
});
105 changes: 51 additions & 54 deletions src/__tests__/toc-callback.js
Original file line number Diff line number Diff line change
@@ -1,82 +1,79 @@
import test from "ava"
import test from "ava";

import mdIt from "./utils/md-it"
import mdIt from "./utils/md-it";

test.cb("markdown-it-toc-and-anchor toc-callback", (t) => {
test.cb("markdown-it-toc-and-anchor toc-callback", t => {
const callback = function(tocMarkdown, tocArray, tocHtml) {
t.is(
tocMarkdown,
"* [Heading](#heading)\n",
"should work with disabled toc insertion + callback, returning toc only"
)
);
t.deepEqual(
tocArray,
[
{
content: "Heading",
anchor: "heading",
level: 1,
},
level: 1
}
],
"should work with disabled toc insertion + callback, returning toc only"
)
);
t.is(
tocHtml,
`<ul class="markdownIt-TOC">
<li><a href="#heading">Heading</a></li>
</ul>\n`,
"should work with disabled toc insertion + callback, returning toc only"
)
}
);
};

t.is(
mdIt(
"# Heading",
{
tocCallback: callback,
}
),
"<h1 id=\"heading\">Heading</h1>\n",
mdIt("# Heading", {
tocCallback: callback
}),
'<h1 id="heading">Heading</h1>\n',
"should work with disabled toc insertion + callback, returning heading only"
)
);

t.end()
})
t.end();
});

test.cb("markdown-it-toc-and-anchor toc-callback-toc", (t) => {
test.cb("markdown-it-toc-and-anchor toc-callback-toc", t => {
const callback = function(tocMarkdown, tocArray, tocHtml) {
t.is(
tocMarkdown,
"* [Heading](#heading)\n",
"should work with enabled toc insertion + callback, returning toc only"
)
);
t.deepEqual(
tocArray,
[
{
content: "Heading",
anchor: "heading",
level: 1,
},
level: 1
}
],
"should work with enabled toc insertion + callback, returning toc only"
)
);
t.is(
tocHtml,
`<ul class="markdownIt-TOC">
<li><a href="#heading">Heading</a></li>
</ul>\n`,
"should work with enabled toc insertion + callback, returning toc only"
)
}
);
};

t.is(
mdIt(
`@[toc]
# Heading`,
{
toc: true,
tocCallback: callback,
tocCallback: callback
}
),
`<p><ul class="markdownIt-TOC">
Expand All @@ -85,100 +82,100 @@ test.cb("markdown-it-toc-and-anchor toc-callback-toc", (t) => {
</p>
<h1 id="heading">Heading</h1>\n`,
"should also work with callback, returning toc and heading"
)
);

t.end()
})
t.end();
});

test.cb("markdown-it-toc-and-anchor toc-callback-md", (t) => {
test.cb("markdown-it-toc-and-anchor toc-callback-md", t => {
const callback = function(tocMarkdown, tocArray, tocHtml) {
t.is(
tocMarkdown,
"* [Heading](#heading)\n",
`should work with disabled toc insertion +
callback in md options, returning toc only`
)
);
t.deepEqual(
tocArray,
[
{
content: "Heading",
anchor: "heading",
level: 1,
},
level: 1
}
],
`should work with disabled toc insertion +
callback in md options, returning toc only`
)
);
t.is(
tocHtml,
`<ul class="markdownIt-TOC">
<li><a href="#heading">Heading</a></li>
</ul>\n`,
`should work with disabled toc insertion +
callback in md options, returning toc only`
)
}
);
};

t.is(
mdIt(
"# Heading",
{},
{
tocCallback: callback,
tocCallback: callback
}
),
"<h1 id=\"heading\">Heading</h1>\n",
'<h1 id="heading">Heading</h1>\n',
`should work with disabled toc insertion +
callback in md options, returning heading only`
)
);

t.end()
})
t.end();
});

test.cb("markdown-it-toc-and-anchor toc-callback-env", (t) => {
test.cb("markdown-it-toc-and-anchor toc-callback-env", t => {
const callback = function(tocMarkdown, tocArray, tocHtml) {
t.is(
tocMarkdown,
"* [Heading](#heading)\n",
`should work with disabled toc insertion +
callback in md render env, returning toc only`
)
);
t.deepEqual(
tocArray,
[
{
content: "Heading",
anchor: "heading",
level: 1,
},
level: 1
}
],
`should work with disabled toc insertion +
callback in md render env, returning toc only`
)
);
t.is(
tocHtml,
`<ul class="markdownIt-TOC">
<li><a href="#heading">Heading</a></li>
</ul>\n`,
`should work with disabled toc insertion +
callback in md render env, returning toc only`
)
}
);
};

t.is(
mdIt(
"# Heading",
{},
{},
{
tocCallback: callback,
tocCallback: callback
}
),
"<h1 id=\"heading\">Heading</h1>\n",
'<h1 id="heading">Heading</h1>\n',
`should work with disabled toc insertion +
callback in md render env, returning heading only`
)
);

t.end()
})
t.end();
});
Loading

0 comments on commit 942b276

Please sign in to comment.