Browse Source

updated eslint to 9.1 & did appropriate changes in sources

pull/14/head
Vitaly Puzrin 10 years ago
parent
commit
220efa32e8
  1. 4
      .eslintrc
  2. 6
      lib/linkifier.js
  3. 26
      lib/parser_block.js
  4. 41
      lib/parser_inline.js
  5. 4
      lib/renderer.js
  6. 1
      lib/rules_inline/autolink.js
  7. 2
      lib/rules_inline/backticks.js
  8. 2
      lib/rules_inline/escape.js
  9. 2
      lib/rules_inline/newline.js
  10. 2
      lib/rules_inline/text.js
  11. 6
      lib/typographer.js
  12. 2
      package.json

4
.eslintrc

@ -17,6 +17,7 @@ rules:
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 :)
@ -30,13 +31,14 @@ rules:
no-eq-null: 2
no-floating-decimal: 2
no-lonely-if: 2
no-multi-spaces: 0
no-process-exit: 0
no-trailing-spaces: 2
no-underscore-dangle: 0
quotes: [ 2, single, avoid-escape ]
radix: 2
space-after-keywords: [ 2, always ] # Fixed in master
space-in-brackets: [ 1, always ]
space-in-brackets: [ 1, always, { propertyName: false } ]
# temporary
no-func-assign: 0

6
lib/linkifier.js

@ -7,7 +7,7 @@ var assign = require('./common/utils').assign;
var Ruler = require('./ruler');
var rules = [
var _rules = [
require('./rules_text/linkify')
];
@ -19,8 +19,8 @@ function Linkifier() {
this.ruler = new Ruler(this.rulesUpdate.bind(this));
for (var i = 0; i < rules.length; i++) {
this.ruler.after(rules[i]);
for (var i = 0; i < _rules.length; i++) {
this.ruler.after(_rules[i]);
}
}

26
lib/parser_block.js

@ -8,19 +8,19 @@ var Ruler = require('./ruler');
var State = require('./rules_block/state_block');
var rules = [];
var _rules = [];
// `list` should be after `hr`, but before `heading`
rules.push([ require('./rules_block/code') ]);
rules.push([ require('./rules_block/fences'), 'paragraph', 'blockquote', 'list' ]);
rules.push([ require('./rules_block/blockquote'), 'paragraph', 'blockquote', 'list' ]);
rules.push([ require('./rules_block/hr'), 'paragraph', 'blockquote', 'list' ]);
rules.push([ require('./rules_block/list'), 'paragraph', 'blockquote' ]);
rules.push([ require('./rules_block/heading'), 'paragraph', 'blockquote' ]);
rules.push([ require('./rules_block/lheading') ]);
rules.push([ require('./rules_block/htmlblock'), 'paragraph', 'blockquote' ]);
rules.push([ require('./rules_block/table'), 'paragraph' ]);
rules.push([ require('./rules_block/paragraph') ]);
_rules.push([ require('./rules_block/code') ]);
_rules.push([ require('./rules_block/fences'), 'paragraph', 'blockquote', 'list' ]);
_rules.push([ require('./rules_block/blockquote'), 'paragraph', 'blockquote', 'list' ]);
_rules.push([ require('./rules_block/hr'), 'paragraph', 'blockquote', 'list' ]);
_rules.push([ require('./rules_block/list'), 'paragraph', 'blockquote' ]);
_rules.push([ require('./rules_block/heading'), 'paragraph', 'blockquote' ]);
_rules.push([ require('./rules_block/lheading') ]);
_rules.push([ require('./rules_block/htmlblock'), 'paragraph', 'blockquote' ]);
_rules.push([ require('./rules_block/table'), 'paragraph' ]);
_rules.push([ require('./rules_block/paragraph') ]);
// Block Parser class
@ -33,8 +33,8 @@ function ParserBlock() {
this.ruler = new Ruler(this.rulesUpdate.bind(this));
for (var i = 0; i < rules.length; i++) {
this.ruler.after(rules[i][0], rules[i].slice(1));
for (var i = 0; i < _rules.length; i++) {
this.ruler.after(_rules[i][0], _rules[i].slice(1));
}
}

41
lib/parser_inline.js

@ -9,22 +9,21 @@ var StateInline = require('./rules_inline/state_inline');
////////////////////////////////////////////////////////////////////////////////
// Parser rules
var rules = [];
// Pure text
rules.push(require('./rules_inline/text'));
rules.push(require('./rules_inline/newline'));
rules.push(require('./rules_inline/escape'));
rules.push(require('./rules_inline/backticks'));
rules.push(require('./rules_inline/del'));
rules.push(require('./rules_inline/ins'));
rules.push(require('./rules_inline/mark'));
rules.push(require('./rules_inline/emphasis'));
rules.push(require('./rules_inline/links'));
rules.push(require('./rules_inline/autolink'));
rules.push(require('./rules_inline/htmltag'));
rules.push(require('./rules_inline/entity'));
var _rules = [];
_rules.push(require('./rules_inline/text'));
_rules.push(require('./rules_inline/newline'));
_rules.push(require('./rules_inline/escape'));
_rules.push(require('./rules_inline/backticks'));
_rules.push(require('./rules_inline/del'));
_rules.push(require('./rules_inline/ins'));
_rules.push(require('./rules_inline/mark'));
_rules.push(require('./rules_inline/emphasis'));
_rules.push(require('./rules_inline/links'));
_rules.push(require('./rules_inline/autolink'));
_rules.push(require('./rules_inline/htmltag'));
_rules.push(require('./rules_inline/entity'));
var BAD_PROTOCOLS = [ 'vbscript', 'javascript', 'file' ];
@ -58,8 +57,8 @@ function ParserInline() {
this.ruler = new Ruler(this.rulesUpdate.bind(this));
for (var i = 0; i < rules.length; i++) {
this.ruler.after(rules[i]);
for (var i = 0; i < _rules.length; i++) {
this.ruler.after(_rules[i]);
}
}
@ -74,7 +73,6 @@ ParserInline.prototype.rulesUpdate = function () {
//
ParserInline.prototype.skipToken = function (state) {
var i, cached_pos, pos = state.pos,
rules = this._rules,
len = this._rules.length;
if ((cached_pos = state.cacheGet(pos)) > 0) {
@ -83,7 +81,7 @@ ParserInline.prototype.skipToken = function (state) {
}
for (i = 0; i < len; i++) {
if (rules[i](state, true)) {
if (this._rules[i](state, true)) {
state.cacheSet(pos, state.pos);
return;
}
@ -98,7 +96,6 @@ ParserInline.prototype.skipToken = function (state) {
//
ParserInline.prototype.tokenize = function (state) {
var ok, i,
rules = this._rules,
len = this._rules.length,
end = state.posMax;
@ -112,7 +109,7 @@ ParserInline.prototype.tokenize = function (state) {
// - return true
for (i = 0; i < len; i++) {
ok = rules[i](state, false);
ok = this._rules[i](state, false);
if (ok) { break; }
}

4
lib/renderer.js

@ -282,13 +282,13 @@ Renderer.prototype.renderInline = function (tokens, options) {
Renderer.prototype.render = function (tokens, options) {
var i, len,
result = '',
rules = this.rules;
_rules = this.rules;
for (i = 0, len = tokens.length; i < len; i++) {
if (tokens[i].type === 'inline') {
result += this.renderInline(tokens[i].children, options);
} else {
result += rules[tokens[i].type](tokens, i, options);
result += _rules[tokens[i].type](tokens, i, options);
}
}

1
lib/rules_inline/autolink.js

@ -1,5 +1,6 @@
// Process autolinks '<protocol:...>'
'use strict';
var url_schemas = require('../common/url_schemas');

2
lib/rules_inline/backticks.js

@ -1,5 +1,7 @@
// Parse backticks
'use strict';
module.exports = function backticks(state, silent) {
var start, max, marker, matchStart, matchEnd,
pos = state.pos,

2
lib/rules_inline/escape.js

@ -1,5 +1,7 @@
// Proceess escaped chars and hardbreaks
'use strict';
var ESCAPED = [];
for (var i = 0; i < 256; i++) { ESCAPED.push(0); }

2
lib/rules_inline/newline.js

@ -1,5 +1,7 @@
// Proceess '\n'
'use strict';
module.exports = function newline(state, silent) {
var pmax, max, pos = state.pos;

2
lib/rules_inline/text.js

@ -1,6 +1,8 @@
// Skip text characters for text token, place those to pendibg buffer
// and increment current pos
'use strict';
module.exports = function text(state, silent) {
var str = state.src.slice(state.pos),
next = str.search(state.parser.textMatch);

6
lib/typographer.js

@ -11,7 +11,7 @@ var assign = require('./common/utils').assign;
var Ruler = require('./ruler');
var rules = [
var _rules = [
require('./rules_text/replace'),
require('./rules_text/smartquotes')
];
@ -24,8 +24,8 @@ function Typographer() {
this.ruler = new Ruler(this.rulesUpdate.bind(this));
for (var i = 0; i < rules.length; i++) {
this.ruler.after(rules[i]);
for (var i = 0; i < _rules.length; i++) {
this.ruler.after(_rules[i]);
}
}

2
package.json

@ -27,7 +27,7 @@
"autoprefixer-stylus": "^0.3.0",
"benchmark": "^1.0.0",
"browserify": "*",
"eslint": "0.8.0",
"eslint": "0.9.1",
"eslint-plugin-nodeca": "^1.0.0",
"istanbul": "*",
"jade": "^1.6.0",

Loading…
Cancel
Save