Remove state from shared.js, move to cache.js.

This commit is contained in:
David Anson 2019-04-10 21:26:59 -07:00
parent 827e1acb56
commit f614f3e1ce
17 changed files with 124 additions and 98 deletions

View file

@ -2,8 +2,8 @@
"use strict";
const shared = require("./shared");
const { addErrorContext, forEachLine, isBlankLine } = shared;
const { addErrorContext, forEachLine, isBlankLine } = require("./shared");
const { lineMetadata } = require("./cache");
module.exports = {
"names": [ "MD031", "blanks-around-fences" ],
@ -11,7 +11,7 @@ module.exports = {
"tags": [ "code", "blank_lines" ],
"function": function MD031(params, onError) {
const { lines } = params;
forEachLine(function forLine(line, i, inCode, onFence) {
forEachLine(lineMetadata(), (line, i, inCode, onFence) => {
if (((onFence > 0) && !isBlankLine(lines[i - 1])) ||
((onFence < 0) && !isBlankLine(lines[i + 1]))) {
addErrorContext(onError, i + 1, lines[i].trim());