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 trailingSpaceRe = /\s+$/;
const trailingSpaceRe = /\s+$/;
module.exports = {
"names": [ "MD009", "no-trailing-spaces" ],
"description": "Trailing spaces",
"tags": [ "whitespace" ],
"function": function MD009(params, onError) {
var brSpaces = params.config.br_spaces || 0;
var listItemEmptyLines = params.config.list_item_empty_lines;
var allowListItemEmptyLines =
const brSpaces = params.config.br_spaces || 0;
const listItemEmptyLines = params.config.list_item_empty_lines;
const allowListItemEmptyLines =
(listItemEmptyLines === undefined) ? false : !!listItemEmptyLines;
var listItemLineNumbers = [];
const listItemLineNumbers = [];
if (allowListItemEmptyLines) {
shared.filterTokens(params, "list_item_open", function forToken(token) {
for (var i = token.map[0]; i < token.map[1]; i++) {
for (let i = token.map[0]; i < token.map[1]; i++) {
listItemLineNumbers.push(i + 1);
}
});
}
shared.forEachLine(function forLine(line, lineIndex) {
var lineNumber = lineIndex + 1;
const lineNumber = lineIndex + 1;
if (trailingSpaceRe.test(line) &&
(listItemLineNumbers.indexOf(lineNumber) === -1)) {
var expected = (brSpaces < 2) ? 0 : brSpaces;
const expected = (brSpaces < 2) ? 0 : brSpaces;
shared.addErrorDetailIf(onError, lineNumber,
expected, line.length - shared.trimRight(line).length, null,
shared.rangeFromRegExp(line, trailingSpaceRe));