Skip to content

Commit

Permalink
eslint & CS update
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitaly Puzrin committed Jul 8, 2017
1 parent d87c338 commit 561891c
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 24 deletions.
15 changes: 7 additions & 8 deletions lib/js-yaml/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ function fromDecimalCode(c) {
}

function simpleEscapeSequence(c) {
/* eslint-disable indent */
return (c === 0x30/* 0 */) ? '\x00' :
(c === 0x61/* a */) ? '\x07' :
(c === 0x62/* b */) ? '\x08' :
Expand All @@ -112,8 +113,10 @@ function charFromCodepoint(c) {
}
// Encode UTF-16 surrogate pair
// https://en.wikipedia.org/wiki/UTF-16#Code_points_U.2B010000_to_U.2B10FFFF
return String.fromCharCode(((c - 0x010000) >> 10) + 0xD800,
((c - 0x010000) & 0x03FF) + 0xDC00);
return String.fromCharCode(
((c - 0x010000) >> 10) + 0xD800,
((c - 0x010000) & 0x03FF) + 0xDC00
);
}

var simpleEscapeCheck = new Array(256); // integer, for fast access
Expand Down Expand Up @@ -245,9 +248,7 @@ function captureSegment(state, start, end, checkJson) {
_result = state.input.slice(start, end);

if (checkJson) {
for (_position = 0, _length = _result.length;
_position < _length;
_position += 1) {
for (_position = 0, _length = _result.length; _position < _length; _position += 1) {
_character = _result.charCodeAt(_position);
if (!(_character === 0x09 ||
(0x20 <= _character && _character <= 0x10FFFF))) {
Expand Down Expand Up @@ -1365,9 +1366,7 @@ function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact

if (state.tag !== null && state.tag !== '!') {
if (state.tag === '?') {
for (typeIndex = 0, typeQuantity = state.implicitTypes.length;
typeIndex < typeQuantity;
typeIndex += 1) {
for (typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) {
type = state.implicitTypes[typeIndex];

// Implicit resolving is not allowed for non-scalar types, and '?'
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"benchmark": "^2.1.4",
"browserify": "^14.3.0",
"codemirror": "^5.13.4",
"eslint": "^3.10.0",
"eslint": "^4.1.1",
"istanbul": "^0.4.5",
"mocha": "^3.3.0",
"uglify-js": "^3.0.1"
Expand Down
6 changes: 4 additions & 2 deletions test/issues/0085.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ test('Dumper should take into account booleans syntax from YAML 1.0/1.1', functi
DEPRECATED_BOOLEANS_SYNTAX.forEach(function (string) {
var dump = yaml.dump(string).trim();

assert(((dump === "'" + string + "'") || (dump === '"' + string + '"')),
('"' + string + '" string is dumped without quoting; actual dump: ' + dump));
assert(
((dump === "'" + string + "'") || (dump === '"' + string + '"')),
('"' + string + '" string is dumped without quoting; actual dump: ' + dump)
);
});
});

4 changes: 2 additions & 2 deletions test/issues/0217.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ test('Folding Javascript functions preserves content', function () {

assertFunctionPreserved(fnRot13,
[ 'nggnpxngqnja', 'orjnergurvqrfbsznepu' ],
[ 'attackatdawn', 'bewaretheidesofmarch' ]
, 'ROT13');
[ 'attackatdawn', 'bewaretheidesofmarch' ],
'ROT13');
});

test('Folding long regular expressions preserves content', function () {
Expand Down
6 changes: 4 additions & 2 deletions test/issues/0266.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ test('Dumper should not take into account booleans syntax from YAML 1.0/1.1 in n
DEPRECATED_BOOLEANS_SYNTAX.forEach(function (string) {
var dump = yaml.dump(string, { noCompatMode: true }).trim();

assert((dump === string),
('"' + string + '" string is not dumped as-is; actual dump: ' + dump));
assert(
(dump === string),
('"' + string + '" string is not dumped as-is; actual dump: ' + dump)
);
});
});
18 changes: 9 additions & 9 deletions test/units/dump-scalar-styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,16 +197,16 @@ suite('Scalar style dump:', function () {

var indeed = repeat('word. ', 31) + '\n' +
[ 2, 3, 5, 7, 11, 13, 17 ]
.map(function (n) { return repeat(' ', n); })
.join('\n');
.map(function (n) { return repeat(' ', n); })
.join('\n');
assert.strictEqual(dump(indeed),
'>-\n' + indent(
'word. word. word. word. word. word. word. word. word. word. word. word. word.\n' +
'word. word. word. word. word. word. word. word. word. word. word. word. word.\n' +
'word. word. word. word. word. \n' +
[ 2, 3, 5, 7, 11, 13, 17 ]
.map(function (n) { return repeat(' ', n); })
.join('\n') + '\n'));
'>-\n' + indent(
'word. word. word. word. word. word. word. word. word. word. word. word. word.\n' +
'word. word. word. word. word. word. word. word. word. word. word. word. word.\n' +
'word. word. word. word. word. \n' +
[ 2, 3, 5, 7, 11, 13, 17 ]
.map(function (n) { return repeat(' ', n); })
.join('\n') + '\n'));
});

var story = 'Call me Ishmael. Some years ago—never mind how long precisely—'
Expand Down

0 comments on commit 561891c

Please sign in to comment.