Convert var to const/let (except in browser-only code).

This commit is contained in:
David Anson 2018-04-27 22:05:34 -07:00
parent 78c1af7bfd
commit 213aef4564
56 changed files with 524 additions and 518 deletions

View file

@ -2,32 +2,32 @@
"use strict";
var shared = require("./shared");
const shared = require("./shared");
var labelRe = /^\s*\[.*[^\\]]:/;
const labelRe = /^\s*\[.*[^\\]]:/;
module.exports = {
"names": [ "MD013", "line-length" ],
"description": "Line length",
"tags": [ "line_length" ],
"function": function MD013(params, onError) {
var lineLength = params.config.line_length || 80;
var codeBlocks = params.config.code_blocks;
var includeCodeBlocks = (codeBlocks === undefined) ? true : !!codeBlocks;
var tables = params.config.tables;
var includeTables = (tables === undefined) ? true : !!tables;
var headings = params.config.headings;
const lineLength = params.config.line_length || 80;
const codeBlocks = params.config.code_blocks;
const includeCodeBlocks = (codeBlocks === undefined) ? true : !!codeBlocks;
const tables = params.config.tables;
const includeTables = (tables === undefined) ? true : !!tables;
let headings = params.config.headings;
if (headings === undefined) {
headings = params.config.headers;
}
var includeHeadings = (headings === undefined) ? true : !!headings;
var headingLineNumbers = [];
const includeHeadings = (headings === undefined) ? true : !!headings;
const headingLineNumbers = [];
if (!includeHeadings) {
shared.forEachHeading(params, function forHeading(heading) {
headingLineNumbers.push(heading.lineNumber);
});
}
var tokenTypeMap = {
const tokenTypeMap = {
"em_open": "e",
"em_close": "E",
"link_open": "l",
@ -36,9 +36,9 @@ module.exports = {
"strong_close": "S",
"text": "T"
};
var linkOnlyLineNumbers = [];
const linkOnlyLineNumbers = [];
shared.filterTokens(params, "inline", function forToken(token) {
var childTokenTypes = "";
let childTokenTypes = "";
token.children.forEach(function forChild(child) {
if (child.type !== "text" || child.content !== "") {
childTokenTypes += tokenTypeMap[child.type] || "x";
@ -48,10 +48,10 @@ module.exports = {
linkOnlyLineNumbers.push(token.lineNumber);
}
});
var longLineRe = new RegExp("^(.{" + lineLength + "})(.*\\s.*)$");
const longLineRe = new RegExp("^(.{" + lineLength + "})(.*\\s.*)$");
shared.forEachLine(
function forLine(line, lineIndex, inCode, onFence, inTable) {
var lineNumber = lineIndex + 1;
const lineNumber = lineIndex + 1;
if ((includeCodeBlocks || !inCode) &&
(includeTables || !inTable) &&
(includeHeadings || (headingLineNumbers.indexOf(lineNumber)) < 0) &&