From d77b868584c988483fdb7892ccc5af09c6d99f1c Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Fri, 9 Jan 2015 21:52:47 -0800 Subject: JS linter improvements. --- js/lib/blocks.js | 3 ++- js/lib/index.js | 2 +- js/lib/inlines.js | 8 ++------ 3 files changed, 5 insertions(+), 8 deletions(-) (limited to 'js/lib') diff --git a/js/lib/blocks.js b/js/lib/blocks.js index f965fd7..2939afe 100644 --- a/js/lib/blocks.js +++ b/js/lib/blocks.js @@ -16,7 +16,7 @@ var isBlank = function(s) { // Convert tabs to spaces on each line using a 4-space tab stop. var detabLine = function(text) { "use strict"; - if (text.indexOf('\0') !== -1) { + if (text.indexOf('\u0000') !== -1) { // replace NUL for security text = text.replace(/\0/g, '\uFFFD'); } @@ -637,6 +637,7 @@ var processInlines = function(block) { }; var Document = function() { + "use strict"; var doc = new Node('Document', [[1, 1], [0, 0]]); doc.string_content = undefined; doc.strings = []; diff --git a/js/lib/index.js b/js/lib/index.js index 8b26946..d0532c6 100755 --- a/js/lib/index.js +++ b/js/lib/index.js @@ -14,7 +14,7 @@ var util = require('util'); var renderAST = function(tree) { - return util.inspect(tree.toAST(), {depth: 20}); + return util.inspect(tree.toAST(), {depth: 20}) + '\n'; }; module.exports.Node = require('./node'); diff --git a/js/lib/inlines.js b/js/lib/inlines.js index 405c6c9..0b40dfd 100644 --- a/js/lib/inlines.js +++ b/js/lib/inlines.js @@ -6,7 +6,6 @@ var entityToChar = require('./html5-entities.js').entityToChar; // Constants for character codes: var C_NEWLINE = 10; -var C_SPACE = 32; var C_ASTERISK = 42; var C_UNDERSCORE = 95; var C_BACKTICK = 96; @@ -62,18 +61,15 @@ var reLinkDestination = new RegExp( var reEscapable = new RegExp(ESCAPABLE); -var reAllEscapedChar = new RegExp('\\\\(' + ESCAPABLE + ')', 'g'); - var reEntityHere = new RegExp('^' + ENTITY, 'i'); -var reEntity = new RegExp(ENTITY, 'gi'); - var reEntityOrEscapedChar = new RegExp('\\\\' + ESCAPABLE + '|' + ENTITY, 'gi'); // Matches a string of non-special characters. var reMain = /^[^\n`\[\]\\!<&*_]+/m; var unescapeChar = function(s) { + "use strict"; if (s[0] === '\\') { return s[1]; } else { @@ -687,7 +683,7 @@ var parseNewline = function(block) { if (lastc && lastc.t === 'Text') { var sps = / *$/.exec(lastc.literal)[0].length; if (sps > 0) { - lastc.literal = lastc.literal.replace(/ *$/,''); + lastc.literal = lastc.literal.replace(/ *$/, ''); } block.appendChild(new Node(sps >= 2 ? 'Hardbreak' : 'Softbreak')); } else { -- cgit v1.2.3