diff --git a/.eslintrc b/.eslintrc index 1366696..9e75c7b 100644 --- a/.eslintrc +++ b/.eslintrc @@ -8,40 +8,109 @@ plugins: rules: block-scoped-var: 2 brace-style: [ 2, '1tbs', { allowSingleLine: true } ] - camelcase: 0 - consistent-return: 2 + comma-spacing: 2 + comma-style: 2 consistent-this: [ 2, self ] - curly: [ 2, all ] - default-case: 2 + consistent-return: 2 + curly: 2 + # default-case: 2 + dot-notation: 2 eol-last: 2 eqeqeq: 2 guard-for-in: 2 handle-callback-err: 2 - key-spacing: 0 max-depth: [ 1, 6 ] max-nested-callbacks: [ 1, 4 ] # string can exceed 80 chars, but should not overflow github website :) max-len: [ 2, 120, 1000 ] + new-cap: 2 + new-parens: 2 no-alert: 2 + no-array-constructor: 2 no-bitwise: 2 + no-caller: 2 + no-catch-shadow: 2 no-comma-dangle: 2 - no-console: 2 + no-cond-assign: 2 + no-console: 1 + no-constant-condition: 2 + no-control-regex: 2 + no-debugger: 2 + no-delete-var: 2 + no-dupe-keys: 2 no-div-regex: 2 + no-empty: 2 + no-empty-class: 2 + no-empty-label: 2 no-else-return: 2 no-eq-null: 2 + no-ex-assign: 2 + no-extend-native: 2 + no-extra-bind: 2 + no-extra-boolean-cast: 2 + no-extra-semi: 2 + no-extra-strict: 2 + no-eval: 2 no-floating-decimal: 2 + no-func-assign: 2 + no-implied-eval: 2 + no-inner-declarations: 2 + no-invalid-regexp: 2 + no-irregular-whitespace: 2 + no-label-var: 2 + no-labels: 2 + no-lone-blocks: 2 no-lonely-if: 2 - no-multi-spaces: 0 - no-process-exit: 0 + no-loop-func: 2 + no-mixed-requires: 2 + no-mixed-spaces-and-tabs: 2 + no-multi-str: 2 + no-native-reassign: 2 + no-negated-in-lhs: 2 + no-new: 2 + no-new-func: 2 + no-new-object: 2 + no-new-require: 2 + no-new-wrappers: 2 + no-obj-calls: 2 + no-octal: 2 + no-octal-escape: 2 + no-path-concat: 2 + no-redeclare: 2 + no-regex-spaces: 2 + no-reserved-keys: 2 + no-return-assign: 2 + no-script-url: 2 + no-sequences: 2 + no-shadow: 2 + no-shadow-restricted-names: 2 + no-space-before-semi: 2 + no-sparse-arrays: 2 no-trailing-spaces: 2 - no-underscore-dangle: 0 + no-undef: 2 + no-undef-init: 2 + no-undefined: 2 + no-unreachable: 2 + no-unused-expressions: 2 + no-unused-vars: 2 + no-use-before-define: 2 + no-with: 2 + no-wrap-func: 2 quotes: [ 2, single, avoid-escape ] radix: 2 - space-after-keywords: [ 2, always ] # Fixed in master - space-in-brackets: [ 1, always, { propertyName: false } ] - - # temporary - no-func-assign: 0 + semi: 2 + space-after-keywords: [ 2, always, , { "checkFunctionKeyword": true } ] + space-before-blocks: 2 + space-in-brackets: [ 2, always, { propertyName: false } ] + space-in-parens: [ 2, never ] + space-infix-ops: 2 + space-return-throw-case: 2 + space-unary-ops: 2 + spaced-line-comment: [ 2, always, { exceptions: [ '/' ] } ] + strict: 2 + use-isnan: 2 + yoda: 2 + valid-typeof: 2 # # Our custom rules diff --git a/Makefile b/Makefile index 17bc0ca..224e7ce 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,7 @@ demo: lint rm -rf demo/sample.json lint: - eslint ./ + eslint --reset ./ test: lint NODE_ENV=test mocha -R spec diff --git a/benchmark/profile.js b/benchmark/profile.js index 7dd9bba..878e24b 100755 --- a/benchmark/profile.js +++ b/benchmark/profile.js @@ -12,7 +12,7 @@ var md = new Remarkable({ typographer: false }); -//var data = fs.readFileSync(path.join(__dirname, '/samples/lorem1.txt'), 'utf8'); +// var data = fs.readFileSync(path.join(__dirname, '/samples/lorem1.txt'), 'utf8'); var data = fs.readFileSync(path.join(__dirname, '../test/fixtures/commonmark/spec.txt'), 'utf8'); for (var i = 0; i < 20; i++) { diff --git a/bin/remarkable.js b/bin/remarkable.js index 88921f5..c9c6811 100755 --- a/bin/remarkable.js +++ b/bin/remarkable.js @@ -47,16 +47,16 @@ function readFile(filename, encoding, callback) { //////////////////////////////////////////////////////////////////////////////// -readFile(options.file, 'utf8', function (error, input) { +readFile(options.file, 'utf8', function (err, input) { var output, md; - if (error) { - if (error.code === 'ENOENT') { + if (err) { + if (err.code === 'ENOENT') { console.error('File not found: ' + options.file); process.exit(2); } - console.error(error.stack || error.message || String(error)); + console.error(err.stack || err.message || String(err)); process.exit(1); } @@ -71,8 +71,8 @@ readFile(options.file, 'utf8', function (error, input) { try { output = md.render(input); - } catch (error) { - console.error(error.stack || error.message || String(error)); + } catch (e) { + console.error(e.stack || e.message || String(e)); process.exit(1); } diff --git a/lib/rules_block/heading.js b/lib/rules_block/heading.js index f2d175d..f5ef6a2 100644 --- a/lib/rules_block/heading.js +++ b/lib/rules_block/heading.js @@ -28,8 +28,8 @@ module.exports = function heading(state, startLine, endLine, silent) { // Let's cut tails like ' ### ' from the end of string - max = state.skipCharsBack(max, 0x20/* space */, pos); - tmp = state.skipCharsBack(max, 0x23/* # */, pos); + max = state.skipCharsBack(max, 0x20, pos); // space + tmp = state.skipCharsBack(max, 0x23, pos); // # if (tmp > pos && state.src.charCodeAt(tmp - 1) === 0x20/* space */) { max = tmp; } diff --git a/lib/rules_block/list.js b/lib/rules_block/list.js index 23e4e1b..65b653b 100644 --- a/lib/rules_block/list.js +++ b/lib/rules_block/list.js @@ -182,8 +182,6 @@ module.exports = function list(state, startLine, endLine, silent) { level: state.level++ }); - //nextLine++; - oldIndent = state.blkIndent; oldTight = state.tight; oldTShift = state.tShift[startLine]; diff --git a/lib/rules_core/abbr.js b/lib/rules_core/abbr.js index 235d9f9..624cc9d 100644 --- a/lib/rules_core/abbr.js +++ b/lib/rules_core/abbr.js @@ -32,7 +32,7 @@ function parseAbbr(str, parserInline, options, env) { title = str.slice(labelEnd + 2, pos).trim(); if (title.length === 0) { return -1; } if (!env.abbreviations) { env.abbreviations = {}; } - if (env.abbreviations[':' + label] === undefined) { + if (typeof env.abbreviations[':' + label] === 'undefined') { env.abbreviations[':' + label] = title; } diff --git a/lib/rules_core/references.js b/lib/rules_core/references.js index df76185..5ab6f05 100644 --- a/lib/rules_core/references.js +++ b/lib/rules_core/references.js @@ -58,7 +58,7 @@ function parseReference(str, parser, options, env) { if (pos < max && state.src.charCodeAt(pos) !== 0x0A) { return -1; } label = normalizeReference(str.slice(1, labelEnd)); - if (env.references[':' + label] === undefined) { + if (typeof env.references[':' + label] === 'undefined') { env.references[':' + label] = { title: title, href: href }; } diff --git a/lib/rules_inline/backticks.js b/lib/rules_inline/backticks.js index 394bfa6..fff04f5 100644 --- a/lib/rules_inline/backticks.js +++ b/lib/rules_inline/backticks.js @@ -29,7 +29,7 @@ module.exports = function backticks(state, silent) { state.push({ type: 'code', content: state.src.slice(pos, matchStart) - .replace(/[ \n]+/g,' ') + .replace(/[ \n]+/g, ' ') .trim(), block: false, level: state.level diff --git a/lib/rules_inline/del.js b/lib/rules_inline/del.js index 1258e56..0af767c 100644 --- a/lib/rules_inline/del.js +++ b/lib/rules_inline/del.js @@ -50,7 +50,7 @@ module.exports = function del(state, silent) { stack++; } // else { // // standalone ' ~~ ' indented with spaces - //} + // } if (stack <= 0) { found = true; break; diff --git a/lib/rules_inline/footnote_ref.js b/lib/rules_inline/footnote_ref.js index e79f9d5..f0ab553 100644 --- a/lib/rules_inline/footnote_ref.js +++ b/lib/rules_inline/footnote_ref.js @@ -32,7 +32,7 @@ module.exports = function footnote_ref(state, silent) { pos++; label = state.src.slice(start + 2, pos - 1); - if (state.env.footnotes.refs[':' + label] === undefined) { return false; } + if (typeof state.env.footnotes.refs[':' + label] === 'undefined') { return false; } if (!silent) { if (!state.env.footnotes.list) { state.env.footnotes.list = []; } diff --git a/lib/rules_inline/ins.js b/lib/rules_inline/ins.js index 46bc888..2a55981 100644 --- a/lib/rules_inline/ins.js +++ b/lib/rules_inline/ins.js @@ -50,7 +50,7 @@ module.exports = function ins(state, silent) { stack++; } // else { // // standalone ' ++ ' indented with spaces - //} + // } if (stack <= 0) { found = true; break; diff --git a/lib/rules_inline/mark.js b/lib/rules_inline/mark.js index c367229..d154ba4 100644 --- a/lib/rules_inline/mark.js +++ b/lib/rules_inline/mark.js @@ -50,7 +50,7 @@ module.exports = function del(state, silent) { stack++; } // else { // // standalone ' == ' indented with spaces - //} + // } if (stack <= 0) { found = true; break; diff --git a/package.json b/package.json index 6dac0e5..bf0148b 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "browserify": "*", "commonmark": "0.12.0", "coveralls": "^2.11.2", - "eslint": "0.9.1", + "eslint": "0.10.1", "eslint-plugin-nodeca": "^1.0.0", "istanbul": "*", "jade": "^1.6.0",