diff --git a/.eslintrc.yml b/.eslintrc.yml index e11a93f..4bdbff5 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -142,6 +142,7 @@ rules: no-void: 2 no-with: 2 object-curly-spacing: [ 2, always, { "objectsInObjects": true, "arraysInObjects": true } ] + one-var: [ 2, { initialized: 'never' } ] operator-assignment: 1 # Postponed #operator-linebreak: [ 2, after ] diff --git a/lib/common/utils.mjs b/lib/common/utils.mjs index 8da3f9d..f4e5648 100644 --- a/lib/common/utils.mjs +++ b/lib/common/utils.mjs @@ -65,8 +65,8 @@ function fromCodePoint (c) { /*eslint no-bitwise:0*/ if (c > 0xffff) { c -= 0x10000 - const surrogate1 = 0xd800 + (c >> 10), - surrogate2 = 0xdc00 + (c & 0x3ff) + const surrogate1 = 0xd800 + (c >> 10) + const surrogate2 = 0xdc00 + (c & 0x3ff) return String.fromCharCode(surrogate1, surrogate2) } diff --git a/lib/rules_block/table.mjs b/lib/rules_block/table.mjs index ff5d141..bf8e8c7 100644 --- a/lib/rules_block/table.mjs +++ b/lib/rules_block/table.mjs @@ -3,8 +3,8 @@ import { isSpace } from '../common/utils.mjs' function getLine (state, line) { - const pos = state.bMarks[line] + state.tShift[line], - max = state.eMarks[line] + const pos = state.bMarks[line] + state.tShift[line] + const max = state.eMarks[line] return state.src.slice(pos, max) } diff --git a/lib/rules_core/replacements.mjs b/lib/rules_core/replacements.mjs index 15678fa..8695757 100644 --- a/lib/rules_core/replacements.mjs +++ b/lib/rules_core/replacements.mjs @@ -31,10 +31,10 @@ function replaceFn (match, name) { } function replace_scoped (inlineTokens) { - let i, token, inside_autolink = 0 + let inside_autolink = 0 - for (i = inlineTokens.length - 1; i >= 0; i--) { - token = inlineTokens[i] + for (let i = inlineTokens.length - 1; i >= 0; i--) { + const token = inlineTokens[i] if (token.type === 'text' && !inside_autolink) { token.content = token.content.replace(SCOPED_ABBR_RE, replaceFn) @@ -51,10 +51,10 @@ function replace_scoped (inlineTokens) { } function replace_rare (inlineTokens) { - let i, token, inside_autolink = 0 + let inside_autolink = 0 - for (i = inlineTokens.length - 1; i >= 0; i--) { - token = inlineTokens[i] + for (let i = inlineTokens.length - 1; i >= 0; i--) { + const token = inlineTokens[i] if (token.type === 'text' && !inside_autolink) { if (RARE_RE.test(token.content)) { diff --git a/lib/rules_inline/fragments_join.mjs b/lib/rules_inline/fragments_join.mjs index 1831e07..04e579d 100644 --- a/lib/rules_inline/fragments_join.mjs +++ b/lib/rules_inline/fragments_join.mjs @@ -8,8 +8,8 @@ // export default function fragments_join (state) { - let curr, last, - level = 0 + let curr, last + let level = 0 const tokens = state.tokens const max = state.tokens.length diff --git a/lib/rules_inline/image.mjs b/lib/rules_inline/image.mjs index 946fe20..31b0b3c 100644 --- a/lib/rules_inline/image.mjs +++ b/lib/rules_inline/image.mjs @@ -4,15 +4,8 @@ import { normalizeReference, isSpace } from '../common/utils.mjs' export default function image (state, silent) { - let code, - content, - label, - pos, - ref, - res, - title, - start, - href = '' + let code, content, label, pos, ref, res, title, start + let href = '' const oldPos = state.pos const max = state.posMax diff --git a/lib/rules_inline/link.mjs b/lib/rules_inline/link.mjs index 46aad51..b145173 100644 --- a/lib/rules_inline/link.mjs +++ b/lib/rules_inline/link.mjs @@ -3,14 +3,11 @@ import { normalizeReference, isSpace } from '../common/utils.mjs' export default function link (state, silent) { - let code, - label, - res, - ref, - href = '', - title = '', - start = state.pos, - parseReference = true + let code, label, res, ref + let href = '' + let title = '' + let start = state.pos + let parseReference = true if (state.src.charCodeAt(state.pos) !== 0x5B/* [ */) { return false } diff --git a/lib/token.mjs b/lib/token.mjs index 81f463c..2b2de48 100644 --- a/lib/token.mjs +++ b/lib/token.mjs @@ -151,8 +151,8 @@ Token.prototype.attrPush = function attrPush (attrData) { * Set `name` attribute to `value`. Override old value if exists. **/ Token.prototype.attrSet = function attrSet (name, value) { - const idx = this.attrIndex(name), - attrData = [name, value] + const idx = this.attrIndex(name) + const attrData = [name, value] if (idx < 0) { this.attrPush(attrData) diff --git a/support/specsplit.mjs b/support/specsplit.mjs index 9407845..7b017ae 100755 --- a/support/specsplit.mjs +++ b/support/specsplit.mjs @@ -61,8 +61,9 @@ function readFile (filename, encoding, callback) { //////////////////////////////////////////////////////////////////////////////// readFile(options.spec, 'utf8', function (error, input) { - const good = [], bad = [], - markdown = markdownit('commonmark') + const good = [] + const bad = [] + const markdown = markdownit('commonmark') if (error) { if (error.code === 'ENOENT') { diff --git a/test/misc.mjs b/test/misc.mjs index a6aeba3..a9376b6 100644 --- a/test/misc.mjs +++ b/test/misc.mjs @@ -446,8 +446,8 @@ describe('Token attributes', function () { it('.attrJoin', function () { const md = markdownit() - const tokens = md.parse('```'), - t = tokens[0] + const tokens = md.parse('```') + const t = tokens[0] t.attrJoin('class', 'foo') t.attrJoin('class', 'bar') @@ -461,8 +461,8 @@ describe('Token attributes', function () { it('.attrSet', function () { const md = markdownit() - const tokens = md.parse('```'), - t = tokens[0] + const tokens = md.parse('```') + const t = tokens[0] t.attrSet('class', 'foo') @@ -482,8 +482,8 @@ describe('Token attributes', function () { it('.attrGet', function () { const md = markdownit() - const tokens = md.parse('```'), - t = tokens[0] + const tokens = md.parse('```') + const t = tokens[0] assert.strictEqual(t.attrGet('myattr'), null)