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,33 +2,33 @@
"use strict";
var shared = require("./shared");
const shared = require("./shared");
module.exports = {
"names": [ "MD044", "proper-names" ],
"description": "Proper names should have the correct capitalization",
"tags": [ "spelling" ],
"function": function MD044(params, onError) {
var names = params.config.names || [];
var codeBlocks = params.config.code_blocks;
var includeCodeBlocks = (codeBlocks === undefined) ? true : !!codeBlocks;
const names = params.config.names || [];
const codeBlocks = params.config.code_blocks;
const includeCodeBlocks = (codeBlocks === undefined) ? true : !!codeBlocks;
names.forEach(function forName(name) {
var escapedName = shared.escapeForRegExp(name);
var namePattern = "\\S*\\b(" + escapedName + ")\\b\\S*";
var anyNameRe = new RegExp(namePattern, "gi");
const escapedName = shared.escapeForRegExp(name);
const namePattern = "\\S*\\b(" + escapedName + ")\\b\\S*";
const anyNameRe = new RegExp(namePattern, "gi");
function forToken(token) {
var fenceOffset = (token.type === "fence") ? 1 : 0;
const fenceOffset = (token.type === "fence") ? 1 : 0;
token.content.split(shared.newLineRe)
.forEach(function forLine(line, index) {
var match = null;
let match = null;
while ((match = anyNameRe.exec(line)) !== null) {
var fullMatch = match[0];
const fullMatch = match[0];
if (!shared.bareUrlRe.test(fullMatch)) {
var wordMatch = fullMatch
const wordMatch = fullMatch
.replace(/^\W*/, "").replace(/\W*$/, "");
if (names.indexOf(wordMatch) === -1) {
var lineNumber = token.lineNumber + index + fenceOffset;
var range = [ match.index + 1, wordMatch.length ];
const lineNumber = token.lineNumber + index + fenceOffset;
const range = [ match.index + 1, wordMatch.length ];
shared.addErrorDetailIf(onError, lineNumber,
name, match[1], null, range);
}