Browse Source

standard: init vars in separate declaration

pull/979/head
Vitaly Puzrin 1 year ago
parent
commit
9e7378775f
  1. 1
      .eslintrc.yml
  2. 4
      lib/common/utils.mjs
  3. 4
      lib/rules_block/table.mjs
  4. 12
      lib/rules_core/replacements.mjs
  5. 4
      lib/rules_inline/fragments_join.mjs
  6. 11
      lib/rules_inline/image.mjs
  7. 13
      lib/rules_inline/link.mjs
  8. 4
      lib/token.mjs
  9. 5
      support/specsplit.mjs
  10. 12
      test/misc.mjs

1
.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 ]

4
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)
}

4
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)
}

12
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)) {

4
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

11
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

13
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 }

4
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)

5
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') {

12
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)

Loading…
Cancel
Save