From 7dfcf69b71daaab43d8b99baebc8a7bc26b4ad8e Mon Sep 17 00:00:00 2001 From: Vitaly Puzrin Date: Tue, 28 Nov 2023 05:34:40 +0200 Subject: [PATCH] standard: no spaces near array brackets --- .eslintrc.yml | 2 +- benchmark/benchmark.mjs | 2 +- lib/index.mjs | 12 +++++------ lib/parser_block.mjs | 22 ++++++++++---------- lib/parser_core.mjs | 14 ++++++------- lib/parser_inline.mjs | 32 +++++++++++++++--------------- lib/renderer.mjs | 2 +- lib/ruler.mjs | 8 ++++---- lib/rules_block/blockquote.mjs | 2 +- lib/rules_block/code.mjs | 2 +- lib/rules_block/fence.mjs | 2 +- lib/rules_block/heading.mjs | 4 ++-- lib/rules_block/hr.mjs | 2 +- lib/rules_block/html_block.mjs | 16 +++++++-------- lib/rules_block/lheading.mjs | 4 ++-- lib/rules_block/list.mjs | 6 +++--- lib/rules_block/paragraph.mjs | 4 ++-- lib/rules_block/table.mjs | 14 ++++++------- lib/rules_core/block.mjs | 2 +- lib/rules_core/linkify.mjs | 2 +- lib/rules_inline/autolink.mjs | 4 ++-- lib/rules_inline/balance_pairs.mjs | 2 +- lib/rules_inline/image.mjs | 4 ++-- lib/rules_inline/link.mjs | 4 ++-- lib/rules_inline/linkify.mjs | 2 +- lib/token.mjs | 6 +++--- support/demo_template/index.mjs | 2 +- support/specsplit.mjs | 2 +- test/babelmark-responder.mjs | 2 +- test/misc.mjs | 18 ++++++++--------- test/ruler.mjs | 8 ++++---- test/token.mjs | 4 ++-- 32 files changed, 106 insertions(+), 106 deletions(-) diff --git a/.eslintrc.yml b/.eslintrc.yml index 14d45ee..e11a93f 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -25,7 +25,7 @@ rules: prefer-const: 2 no-const-assign: 2 accessor-pairs: 2 - array-bracket-spacing: [ 2, "always", { "singleValue": true, "objectsInArrays": true, "arraysInArrays": true } ] + array-bracket-spacing: [ 2, never ] block-scoped-var: 2 block-spacing: 2 brace-style: [ 2, '1tbs', { allowSingleLine: true } ] diff --git a/benchmark/benchmark.mjs b/benchmark/benchmark.mjs index b364258..69374bd 100755 --- a/benchmark/benchmark.mjs +++ b/benchmark/benchmark.mjs @@ -71,7 +71,7 @@ function select (patterns) { const result = [] if (!(patterns instanceof Array)) { - patterns = [ patterns ] + patterns = [patterns] } function checkName (name) { diff --git a/lib/index.mjs b/lib/index.mjs index 0650506..c271fc8 100644 --- a/lib/index.mjs +++ b/lib/index.mjs @@ -42,7 +42,7 @@ function validateLink (url) { //////////////////////////////////////////////////////////////////////////////// -const RECODE_HOSTNAME_FOR = [ 'http:', 'https:', 'mailto:' ] +const RECODE_HOSTNAME_FOR = ['http:', 'https:', 'mailto:'] function normalizeLink (url) { const parsed = mdurl.parse(url, true) @@ -431,9 +431,9 @@ MarkdownIt.prototype.configure = function (presets) { MarkdownIt.prototype.enable = function (list, ignoreInvalid) { let result = [] - if (!Array.isArray(list)) { list = [ list ] } + if (!Array.isArray(list)) { list = [list] } - [ 'core', 'block', 'inline' ].forEach(function (chain) { + ['core', 'block', 'inline'].forEach(function (chain) { result = result.concat(this[chain].ruler.enable(list, true)) }, this) @@ -459,9 +459,9 @@ MarkdownIt.prototype.enable = function (list, ignoreInvalid) { MarkdownIt.prototype.disable = function (list, ignoreInvalid) { let result = [] - if (!Array.isArray(list)) { list = [ list ] } + if (!Array.isArray(list)) { list = [list] } - [ 'core', 'block', 'inline' ].forEach(function (chain) { + ['core', 'block', 'inline'].forEach(function (chain) { result = result.concat(this[chain].ruler.disable(list, true)) }, this) @@ -493,7 +493,7 @@ MarkdownIt.prototype.disable = function (list, ignoreInvalid) { * ``` **/ MarkdownIt.prototype.use = function (plugin /*, params, ... */) { - const args = [ this ].concat(Array.prototype.slice.call(arguments, 1)) + const args = [this].concat(Array.prototype.slice.call(arguments, 1)) plugin.apply(plugin, args) return this } diff --git a/lib/parser_block.mjs b/lib/parser_block.mjs index c7b7d7a..27be2f7 100644 --- a/lib/parser_block.mjs +++ b/lib/parser_block.mjs @@ -22,17 +22,17 @@ import r_paragraph from './rules_block/paragraph.mjs' const _rules = [ // First 2 params - rule name & source. Secondary array - list of rules, // which can be terminated by this one. - [ 'table', r_table, [ 'paragraph', 'reference' ] ], - [ 'code', r_code ], - [ 'fence', r_fence, [ 'paragraph', 'reference', 'blockquote', 'list' ] ], - [ 'blockquote', r_blockquote, [ 'paragraph', 'reference', 'blockquote', 'list' ] ], - [ 'hr', r_hr, [ 'paragraph', 'reference', 'blockquote', 'list' ] ], - [ 'list', r_list, [ 'paragraph', 'reference', 'blockquote' ] ], - [ 'reference', r_reference ], - [ 'html_block', r_html_block, [ 'paragraph', 'reference', 'blockquote' ] ], - [ 'heading', r_heading, [ 'paragraph', 'reference', 'blockquote' ] ], - [ 'lheading', r_lheading ], - [ 'paragraph', r_paragraph ] + ['table', r_table, ['paragraph', 'reference']], + ['code', r_code], + ['fence', r_fence, ['paragraph', 'reference', 'blockquote', 'list']], + ['blockquote', r_blockquote, ['paragraph', 'reference', 'blockquote', 'list']], + ['hr', r_hr, ['paragraph', 'reference', 'blockquote', 'list']], + ['list', r_list, ['paragraph', 'reference', 'blockquote']], + ['reference', r_reference], + ['html_block', r_html_block, ['paragraph', 'reference', 'blockquote']], + ['heading', r_heading, ['paragraph', 'reference', 'blockquote']], + ['lheading', r_lheading], + ['paragraph', r_paragraph] ] diff --git a/lib/parser_core.mjs b/lib/parser_core.mjs index 77a1379..62878d9 100644 --- a/lib/parser_core.mjs +++ b/lib/parser_core.mjs @@ -18,15 +18,15 @@ import r_text_join from './rules_core/text_join.mjs' const _rules = [ - [ 'normalize', r_normalize ], - [ 'block', r_block ], - [ 'inline', r_inline ], - [ 'linkify', r_linkify ], - [ 'replacements', r_replacements ], - [ 'smartquotes', r_smartquotes ], + ['normalize', r_normalize], + ['block', r_block], + ['inline', r_inline], + ['linkify', r_linkify], + ['replacements', r_replacements], + ['smartquotes', r_smartquotes], // `text_join` finds `text_special` tokens (for escape sequences) // and joins them with the rest of the text - [ 'text_join', r_text_join ] + ['text_join', r_text_join] ] diff --git a/lib/parser_inline.mjs b/lib/parser_inline.mjs index 6add04e..4f282e7 100644 --- a/lib/parser_inline.mjs +++ b/lib/parser_inline.mjs @@ -29,18 +29,18 @@ import r_fragments_join from './rules_inline/fragments_join.mjs' // Parser rules const _rules = [ - [ 'text', r_text ], - [ 'linkify', r_linkify ], - [ 'newline', r_newline ], - [ 'escape', r_escape ], - [ 'backticks', r_backticks ], - [ 'strikethrough', r_strikethrough.tokenize ], - [ 'emphasis', r_emphasis.tokenize ], - [ 'link', r_link ], - [ 'image', r_image ], - [ 'autolink', r_autolink ], - [ 'html_inline', r_html_inline ], - [ 'entity', r_entity ] + ['text', r_text], + ['linkify', r_linkify], + ['newline', r_newline], + ['escape', r_escape], + ['backticks', r_backticks], + ['strikethrough', r_strikethrough.tokenize], + ['emphasis', r_emphasis.tokenize], + ['link', r_link], + ['image', r_image], + ['autolink', r_autolink], + ['html_inline', r_html_inline], + ['entity', r_entity] ] // `rule2` ruleset was created specifically for emphasis/strikethrough @@ -49,12 +49,12 @@ const _rules = [ // Don't use this for anything except pairs (plugins working with `balance_pairs`). // const _rules2 = [ - [ 'balance_pairs', r_balance_pairs ], - [ 'strikethrough', r_strikethrough.postProcess ], - [ 'emphasis', r_emphasis.postProcess ], + ['balance_pairs', r_balance_pairs], + ['strikethrough', r_strikethrough.postProcess], + ['emphasis', r_emphasis.postProcess], // rules for pairs separate '**' into its own text tokens, which may be left unused, // rule below merges unused segments back with the rest of the text - [ 'fragments_join', r_fragments_join ] + ['fragments_join', r_fragments_join] ] diff --git a/lib/renderer.mjs b/lib/renderer.mjs index 19fa4b0..7fe20fb 100644 --- a/lib/renderer.mjs +++ b/lib/renderer.mjs @@ -62,7 +62,7 @@ default_rules.fence = function (tokens, idx, options, env, slf) { const tmpAttrs = token.attrs ? token.attrs.slice() : [] if (i < 0) { - tmpAttrs.push([ 'class', options.langPrefix + langName ]) + tmpAttrs.push(['class', options.langPrefix + langName]) } else { tmpAttrs[i] = tmpAttrs[i].slice() tmpAttrs[i][1] += ' ' + options.langPrefix + langName diff --git a/lib/ruler.mjs b/lib/ruler.mjs index 42156ab..375cf4e 100644 --- a/lib/ruler.mjs +++ b/lib/ruler.mjs @@ -60,7 +60,7 @@ Ruler.prototype.__find__ = function (name) { // Ruler.prototype.__compile__ = function () { const self = this - const chains = [ '' ] + const chains = [''] // collect unique names self.__rules__.forEach(function (rule) { @@ -256,7 +256,7 @@ Ruler.prototype.push = function (ruleName, fn, options) { * See also [[Ruler.disable]], [[Ruler.enableOnly]]. **/ Ruler.prototype.enable = function (list, ignoreInvalid) { - if (!Array.isArray(list)) { list = [ list ] } + if (!Array.isArray(list)) { list = [list] } const result = [] @@ -288,7 +288,7 @@ Ruler.prototype.enable = function (list, ignoreInvalid) { * See also [[Ruler.disable]], [[Ruler.enable]]. **/ Ruler.prototype.enableOnly = function (list, ignoreInvalid) { - if (!Array.isArray(list)) { list = [ list ] } + if (!Array.isArray(list)) { list = [list] } this.__rules__.forEach(function (rule) { rule.enabled = false }) @@ -309,7 +309,7 @@ Ruler.prototype.enableOnly = function (list, ignoreInvalid) { * See also [[Ruler.enable]], [[Ruler.enableOnly]]. **/ Ruler.prototype.disable = function (list, ignoreInvalid) { - if (!Array.isArray(list)) { list = [ list ] } + if (!Array.isArray(list)) { list = [list] } const result = [] diff --git a/lib/rules_block/blockquote.mjs b/lib/rules_block/blockquote.mjs index 14edc14..b61da02 100644 --- a/lib/rules_block/blockquote.mjs +++ b/lib/rules_block/blockquote.mjs @@ -183,7 +183,7 @@ export default function blockquote (state, startLine, endLine, silent) { const token_o = state.push('blockquote_open', 'blockquote', 1) token_o.markup = '>' - const lines = [ startLine, 0 ] + const lines = [startLine, 0] token_o.map = lines state.md.block.tokenize(state, startLine, nextLine) diff --git a/lib/rules_block/code.mjs b/lib/rules_block/code.mjs index 52926c9..ae2897d 100644 --- a/lib/rules_block/code.mjs +++ b/lib/rules_block/code.mjs @@ -24,7 +24,7 @@ export default function code (state, startLine, endLine/*, silent*/) { const token = state.push('code_block', 'code', 0) token.content = state.getLines(startLine, last, 4 + state.blkIndent, false) + '\n' - token.map = [ startLine, state.line ] + token.map = [startLine, state.line] return true } diff --git a/lib/rules_block/fence.mjs b/lib/rules_block/fence.mjs index 59d49f5..930f7b3 100644 --- a/lib/rules_block/fence.mjs +++ b/lib/rules_block/fence.mjs @@ -88,7 +88,7 @@ export default function fence (state, startLine, endLine, silent) { token.info = params token.content = state.getLines(startLine + 1, nextLine, len, true) token.markup = markup - token.map = [ startLine, state.line ] + token.map = [startLine, state.line] return true } diff --git a/lib/rules_block/heading.mjs b/lib/rules_block/heading.mjs index 6a971fa..d2f7b79 100644 --- a/lib/rules_block/heading.mjs +++ b/lib/rules_block/heading.mjs @@ -37,11 +37,11 @@ export default function heading (state, startLine, endLine, silent) { const token_o = state.push('heading_open', 'h' + String(level), 1) token_o.markup = '########'.slice(0, level) - token_o.map = [ startLine, state.line ] + token_o.map = [startLine, state.line] const token_i = state.push('inline', '', 0) token_i.content = state.src.slice(pos, max).trim() - token_i.map = [ startLine, state.line ] + token_i.map = [startLine, state.line] token_i.children = [] const token_c = state.push('heading_close', 'h' + String(level), -1) diff --git a/lib/rules_block/hr.mjs b/lib/rules_block/hr.mjs index a776c7d..d467b21 100644 --- a/lib/rules_block/hr.mjs +++ b/lib/rules_block/hr.mjs @@ -33,7 +33,7 @@ export default function hr (state, startLine, endLine, silent) { state.line = startLine + 1 const token = state.push('hr', 'hr', 0) - token.map = [ startLine, state.line ] + token.map = [startLine, state.line] token.markup = Array(cnt + 1).join(String.fromCharCode(marker)) return true diff --git a/lib/rules_block/html_block.mjs b/lib/rules_block/html_block.mjs index f44da53..69435f0 100644 --- a/lib/rules_block/html_block.mjs +++ b/lib/rules_block/html_block.mjs @@ -7,13 +7,13 @@ import { HTML_OPEN_CLOSE_TAG_RE } from '../common/html_re.mjs' // last argument defines whether it can terminate a paragraph or not // const HTML_SEQUENCES = [ - [ /^<(script|pre|style|textarea)(?=(\s|>|$))/i, /<\/(script|pre|style|textarea)>/i, true ], - [ /^/, true ], - [ /^<\?/, /\?>/, true ], - [ /^/, true ], - [ /^/, true ], - [ new RegExp('^|$))', 'i'), /^$/, true ], - [ new RegExp(HTML_OPEN_CLOSE_TAG_RE.source + '\\s*$'), /^$/, false ] + [/^<(script|pre|style|textarea)(?=(\s|>|$))/i, /<\/(script|pre|style|textarea)>/i, true], + [/^/, true], + [/^<\?/, /\?>/, true], + [/^/, true], + [/^/, true], + [new RegExp('^|$))', 'i'), /^$/, true], + [new RegExp(HTML_OPEN_CLOSE_TAG_RE.source + '\\s*$'), /^$/, false] ] @@ -63,7 +63,7 @@ export default function html_block (state, startLine, endLine, silent) { state.line = nextLine const token = state.push('html_block', '', 0) - token.map = [ startLine, nextLine ] + token.map = [startLine, nextLine] token.content = state.getLines(startLine, nextLine, state.blkIndent, true) return true diff --git a/lib/rules_block/lheading.mjs b/lib/rules_block/lheading.mjs index 6776c6b..0ff177b 100644 --- a/lib/rules_block/lheading.mjs +++ b/lib/rules_block/lheading.mjs @@ -66,11 +66,11 @@ export default function lheading (state, startLine, endLine/*, silent*/) { const token_o = state.push('heading_open', 'h' + String(level), 1) token_o.markup = String.fromCharCode(marker) - token_o.map = [ startLine, state.line ] + token_o.map = [startLine, state.line] const token_i = state.push('inline', '', 0) token_i.content = content - token_i.map = [ startLine, state.line - 1 ] + token_i.map = [startLine, state.line - 1] token_i.children = [] const token_c = state.push('heading_close', 'h' + String(level), -1) diff --git a/lib/rules_block/list.mjs b/lib/rules_block/list.mjs index 97e8b3a..5fe4ec6 100644 --- a/lib/rules_block/list.mjs +++ b/lib/rules_block/list.mjs @@ -166,14 +166,14 @@ export default function list (state, startLine, endLine, silent) { if (isOrdered) { token = state.push('ordered_list_open', 'ol', 1) if (markerValue !== 1) { - token.attrs = [ [ 'start', markerValue ] ] + token.attrs = [['start', markerValue]] } } else { token = state.push('bullet_list_open', 'ul', 1) } - const listLines = [ nextLine, 0 ] + const listLines = [nextLine, 0] token.map = listLines token.markup = String.fromCharCode(markerCharCode) @@ -229,7 +229,7 @@ export default function list (state, startLine, endLine, silent) { // Run subparser & write tokens token = state.push('list_item_open', 'li', 1) token.markup = String.fromCharCode(markerCharCode) - const itemLines = [ nextLine, 0 ] + const itemLines = [nextLine, 0] token.map = itemLines if (isOrdered) { token.info = state.src.slice(start, posAfterMarker - 1) diff --git a/lib/rules_block/paragraph.mjs b/lib/rules_block/paragraph.mjs index f451215..6ecdcef 100644 --- a/lib/rules_block/paragraph.mjs +++ b/lib/rules_block/paragraph.mjs @@ -31,11 +31,11 @@ export default function paragraph (state, startLine, endLine) { state.line = nextLine const token_o = state.push('paragraph_open', 'p', 1) - token_o.map = [ startLine, state.line ] + token_o.map = [startLine, state.line] const token_i = state.push('inline', '', 0) token_i.content = content - token_i.map = [ startLine, state.line ] + token_i.map = [startLine, state.line] token_i.children = [] state.push('paragraph_close', 'p', -1) diff --git a/lib/rules_block/table.mjs b/lib/rules_block/table.mjs index dac69c8..ff5d141 100644 --- a/lib/rules_block/table.mjs +++ b/lib/rules_block/table.mjs @@ -132,19 +132,19 @@ export default function table (state, startLine, endLine, silent) { const terminatorRules = state.md.block.ruler.getRules('blockquote') const token_to = state.push('table_open', 'table', 1) - const tableLines = [ startLine, 0 ] + const tableLines = [startLine, 0] token_to.map = tableLines const token_tho = state.push('thead_open', 'thead', 1) - token_tho.map = [ startLine, startLine + 1 ] + token_tho.map = [startLine, startLine + 1] const token_htro = state.push('tr_open', 'tr', 1) - token_htro.map = [ startLine, startLine + 1 ] + token_htro.map = [startLine, startLine + 1] for (let i = 0; i < columns.length; i++) { const token_ho = state.push('th_open', 'th', 1) if (aligns[i]) { - token_ho.attrs = [ [ 'style', 'text-align:' + aligns[i] ] ] + token_ho.attrs = [['style', 'text-align:' + aligns[i]]] } const token_il = state.push('inline', '', 0) @@ -180,16 +180,16 @@ export default function table (state, startLine, endLine, silent) { if (nextLine === startLine + 2) { const token_tbo = state.push('tbody_open', 'tbody', 1) - token_tbo.map = tbodyLines = [ startLine + 2, 0 ] + token_tbo.map = tbodyLines = [startLine + 2, 0] } const token_tro = state.push('tr_open', 'tr', 1) - token_tro.map = [ nextLine, nextLine + 1 ] + token_tro.map = [nextLine, nextLine + 1] for (let i = 0; i < columnCount; i++) { const token_tdo = state.push('td_open', 'td', 1) if (aligns[i]) { - token_tdo.attrs = [ [ 'style', 'text-align:' + aligns[i] ] ] + token_tdo.attrs = [['style', 'text-align:' + aligns[i]]] } const token_il = state.push('inline', '', 0) diff --git a/lib/rules_core/block.mjs b/lib/rules_core/block.mjs index 0774897..526cb48 100644 --- a/lib/rules_core/block.mjs +++ b/lib/rules_core/block.mjs @@ -4,7 +4,7 @@ export default function block (state) { if (state.inlineMode) { token = new state.Token('inline', '', 0) token.content = state.src - token.map = [ 0, 1 ] + token.map = [0, 1] token.children = [] state.tokens.push(token) } else { diff --git a/lib/rules_core/linkify.mjs b/lib/rules_core/linkify.mjs index b6576b9..85e6b82 100644 --- a/lib/rules_core/linkify.mjs +++ b/lib/rules_core/linkify.mjs @@ -103,7 +103,7 @@ export default function linkify (state) { } const token_o = new state.Token('link_open', 'a', 1) - token_o.attrs = [ [ 'href', fullUrl ] ] + token_o.attrs = [['href', fullUrl]] token_o.level = level++ token_o.markup = 'linkify' token_o.info = 'auto' diff --git a/lib/rules_inline/autolink.mjs b/lib/rules_inline/autolink.mjs index ddfcbe3..d9e34a1 100644 --- a/lib/rules_inline/autolink.mjs +++ b/lib/rules_inline/autolink.mjs @@ -30,7 +30,7 @@ export default function autolink (state, silent) { if (!silent) { const token_o = state.push('link_open', 'a', 1) - token_o.attrs = [ [ 'href', fullUrl ] ] + token_o.attrs = [['href', fullUrl]] token_o.markup = 'autolink' token_o.info = 'auto' @@ -52,7 +52,7 @@ export default function autolink (state, silent) { if (!silent) { const token_o = state.push('link_open', 'a', 1) - token_o.attrs = [ [ 'href', fullUrl ] ] + token_o.attrs = [['href', fullUrl]] token_o.markup = 'autolink' token_o.info = 'auto' diff --git a/lib/rules_inline/balance_pairs.mjs b/lib/rules_inline/balance_pairs.mjs index a0ed3cf..261ec91 100644 --- a/lib/rules_inline/balance_pairs.mjs +++ b/lib/rules_inline/balance_pairs.mjs @@ -40,7 +40,7 @@ function processDelimiters (delimiters) { // and for whether this closer can be an opener; // https://github.com/commonmark/cmark/commit/34250e12ccebdc6372b8b49c44fab57c72443460 if (!openersBottom.hasOwnProperty(closer.marker)) { - openersBottom[closer.marker] = [ -1, -1, -1, -1, -1, -1 ] + openersBottom[closer.marker] = [-1, -1, -1, -1, -1, -1] } const minOpenerIdx = openersBottom[closer.marker][(closer.open ? 3 : 0) + (closer.length % 3)] diff --git a/lib/rules_inline/image.mjs b/lib/rules_inline/image.mjs index 0e4c1bf..946fe20 100644 --- a/lib/rules_inline/image.mjs +++ b/lib/rules_inline/image.mjs @@ -130,13 +130,13 @@ export default function image (state, silent) { ) const token = state.push('image', 'img', 0) - const attrs = [ [ 'src', href ], [ 'alt', '' ] ] + const attrs = [['src', href], ['alt', '']] token.attrs = attrs token.children = tokens token.content = content if (title) { - attrs.push([ 'title', title ]) + attrs.push(['title', title]) } } diff --git a/lib/rules_inline/link.mjs b/lib/rules_inline/link.mjs index c1854c5..46aad51 100644 --- a/lib/rules_inline/link.mjs +++ b/lib/rules_inline/link.mjs @@ -123,10 +123,10 @@ export default function link (state, silent) { state.posMax = labelEnd const token_o = state.push('link_open', 'a', 1) - const attrs = [ [ 'href', href ] ] + const attrs = [['href', href]] token_o.attrs = attrs if (title) { - attrs.push([ 'title', title ]) + attrs.push(['title', title]) } state.linkLevel++ diff --git a/lib/rules_inline/linkify.mjs b/lib/rules_inline/linkify.mjs index 50d898a..a2304ba 100644 --- a/lib/rules_inline/linkify.mjs +++ b/lib/rules_inline/linkify.mjs @@ -40,7 +40,7 @@ export default function linkify (state, silent) { state.pending = state.pending.slice(0, -proto.length) const token_o = state.push('link_open', 'a', 1) - token_o.attrs = [ [ 'href', fullUrl ] ] + token_o.attrs = [['href', fullUrl]] token_o.markup = 'linkify' token_o.info = 'auto' diff --git a/lib/token.mjs b/lib/token.mjs index 606271b..81f463c 100644 --- a/lib/token.mjs +++ b/lib/token.mjs @@ -140,7 +140,7 @@ Token.prototype.attrPush = function attrPush (attrData) { if (this.attrs) { this.attrs.push(attrData) } else { - this.attrs = [ attrData ] + this.attrs = [attrData] } } @@ -152,7 +152,7 @@ Token.prototype.attrPush = function attrPush (attrData) { **/ Token.prototype.attrSet = function attrSet (name, value) { const idx = this.attrIndex(name), - attrData = [ name, value ] + attrData = [name, value] if (idx < 0) { this.attrPush(attrData) @@ -187,7 +187,7 @@ Token.prototype.attrJoin = function attrJoin (name, value) { const idx = this.attrIndex(name) if (idx < 0) { - this.attrPush([ name, value ]) + this.attrPush([name, value]) } else { this.attrs[idx][1] = this.attrs[idx][1] + ' ' + value } diff --git a/support/demo_template/index.mjs b/support/demo_template/index.mjs index 042bfdd..44b69bb 100644 --- a/support/demo_template/index.mjs +++ b/support/demo_template/index.mjs @@ -343,7 +343,7 @@ function loadPermalink () { }) // sanitize for sure - if ([ 'html', 'src', 'debug' ].indexOf(defaults._view) === -1) { + if (['html', 'src', 'debug'].indexOf(defaults._view) === -1) { defaults._view = 'html' } } diff --git a/support/specsplit.mjs b/support/specsplit.mjs index 407b589..9407845 100755 --- a/support/specsplit.mjs +++ b/support/specsplit.mjs @@ -16,7 +16,7 @@ const cli = new argparse.ArgumentParser({ cli.add_argument('type', { help: 'type of examples to filter', nargs: '?', - choices: [ 'good', 'bad' ] + choices: ['good', 'bad'] }) cli.add_argument('-s', '--spec', { diff --git a/test/babelmark-responder.mjs b/test/babelmark-responder.mjs index d774591..1f08155 100644 --- a/test/babelmark-responder.mjs +++ b/test/babelmark-responder.mjs @@ -13,7 +13,7 @@ describe('babelmark responder app', function () { before(async () => { app = execFile( 'node', - [ '../support/babelmark-responder.mjs' ], + ['../support/babelmark-responder.mjs'], { cwd: new URL('.', import.meta.url), env: Object.assign({}, process.env, { PORT: PORT }) diff --git a/test/misc.mjs b/test/misc.mjs index e44d76f..a6aeba3 100644 --- a/test/misc.mjs +++ b/test/misc.mjs @@ -106,7 +106,7 @@ describe('API', function () { } // Disable 2 rule in each chain & compare result - md.disable([ 'block', 'inline', 'code', 'fence', 'emphasis', 'entity' ]) + md.disable(['block', 'inline', 'code', 'fence', 'emphasis', 'entity']) const now = { core: md.core.ruler.getRules('').length + 2, @@ -117,7 +117,7 @@ describe('API', function () { assert.deepEqual(was, now) // Enable the same rules back - md.enable([ 'block', 'inline', 'code', 'fence', 'emphasis', 'entity' ]) + md.enable(['block', 'inline', 'code', 'fence', 'emphasis', 'entity']) const back = { core: md.core.ruler.getRules('').length, @@ -132,16 +132,16 @@ describe('API', function () { const md = markdownit() assert.throws(function () { - md.enable([ 'link', 'code', 'invalid' ]) + md.enable(['link', 'code', 'invalid']) }) assert.throws(function () { - md.disable([ 'link', 'code', 'invalid' ]) + md.disable(['link', 'code', 'invalid']) }) assert.doesNotThrow(function () { - md.enable([ 'link', 'code' ]) + md.enable(['link', 'code']) }) assert.doesNotThrow(function () { - md.disable([ 'link', 'code' ]) + md.disable(['link', 'code']) }) }) @@ -198,7 +198,7 @@ describe('Plugins', function () { const pos = state.bMarks[startLine] + state.tShift[startLine] if (state.src.charCodeAt(pos) !== 0x40/* @ */) return false return true - }, { alt: [ 'paragraph' ] }) + }, { alt: ['paragraph'] }) assert.throws(() => md.render('foo\n@bar\nbaz'), /block rule didn't increment state.line/) assert.throws(() => md.render('foo\n\n@bar\n\nbaz'), /block rule didn't increment state.line/) @@ -268,7 +268,7 @@ describe('Misc', function () { it('Should render link target attr', function () { const md = markdownit() .use(forInline, 'target', 'link_open', function (tokens, idx) { - tokens[idx].attrs.push([ 'target', '_blank' ]) + tokens[idx].attrs.push(['target', '_blank']) }) assert.strictEqual(md.render('[foo](bar)'), '

foo

\n') @@ -380,7 +380,7 @@ describe('smartquotes', function () { // all strings have different length to make sure // we didn't accidentally count the wrong one - quotes: [ '[[[', ']]', '(((((', '))))' ] + quotes: ['[[[', ']]', '(((((', '))))'] }) it('Should support multi-character quotes', function () { diff --git a/test/ruler.mjs b/test/ruler.mjs index e649f4f..a261307 100644 --- a/test/ruler.mjs +++ b/test/ruler.mjs @@ -71,10 +71,10 @@ describe('Ruler', function () { ruler.push('test', function foo () {}) ruler.push('test2', function bar () {}) - ruler.disable([ 'test', 'test2' ]) + ruler.disable(['test', 'test2']) rules = ruler.getRules('') assert.strictEqual(rules.length, 0) - ruler.enable([ 'test', 'test2' ]) + ruler.enable(['test', 'test2']) rules = ruler.getRules('') assert.strictEqual(rules.length, 2) }) @@ -97,8 +97,8 @@ describe('Ruler', function () { let rules ruler.push('test', function foo () {}) - ruler.push('test2', function bar () {}, { alt: [ 'alt1' ] }) - ruler.push('test2', function bar () {}, { alt: [ 'alt1', 'alt2' ] }) + ruler.push('test2', function bar () {}, { alt: ['alt1'] }) + ruler.push('test2', function bar () {}, { alt: ['alt1', 'alt2'] }) rules = ruler.getRules('') assert.strictEqual(rules.length, 3) diff --git a/test/token.mjs b/test/token.mjs index 31b3d1f..87c4896 100644 --- a/test/token.mjs +++ b/test/token.mjs @@ -10,8 +10,8 @@ describe('Token', function () { assert.strictEqual(t.attrs, null) assert.equal(t.attrIndex('foo'), -1) - t.attrPush([ 'foo', 'bar' ]) - t.attrPush([ 'baz', 'bad' ]) + t.attrPush(['foo', 'bar']) + t.attrPush(['baz', 'bad']) assert.equal(t.attrIndex('foo'), 0) assert.equal(t.attrIndex('baz'), 1)