1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-21 07:38:07 +02:00

Adjust the brace-style ESLint rule to disallow single lines (and also enable no-iterator)

See http://eslint.org/docs/rules/brace-style.
Having the opening/closing braces on the same line can often make the code slightly more difficult to read, in particular for `if`/`else if` statements, compared to using new lines.

This patch also, for consistency with `mozilla-central`, enables the [`no-iterator`](http://eslint.org/docs/rules/no-iterator) rule. Note that this rule didn't require a single code change.
This commit is contained in:
Jonas Jenwald 2017-02-03 12:58:08 +01:00
parent 92e5fb099e
commit bc736fdc7d
18 changed files with 129 additions and 46 deletions

View file

@ -84,7 +84,9 @@ function createExtensionGlobal() {
// Network-related mocks.
window.Request = {};
window.Request.prototype = {
get mode() { throw new TypeError('Illegal invocation'); },
get mode() {
throw new TypeError('Illegal invocation');
},
};
window.fetch = function(url, options) {
assert.equal(url, LOG_URL);
@ -339,7 +341,9 @@ var tests = [
var window = createExtensionGlobal();
var didWarn = false;
window.console = {};
window.console.warn = function() { didWarn = true; };
window.console.warn = function() {
didWarn = true;
};
window.chrome.runtime.id = 'abcdefghijklmnopabcdefghijklmnop';
telemetryScript.runInNewContext(window);
assert.deepEqual(window.test_requests, []);
@ -373,7 +377,9 @@ var tests = [
function test_fetch_mode_not_supported() {
var window = createExtensionGlobal();
delete window.Request.prototype.mode;
window.fetch = function() { throw new Error('Unexpected call to fetch!'); };
window.fetch = function() {
throw new Error('Unexpected call to fetch!');
};
telemetryScript.runInNewContext(window);
assert.deepEqual(window.test_requests, [{
'Deduplication-Id': '4242424242',

View file

@ -67,7 +67,9 @@ function initializePDFJS(callback) {
// Runner Parameters
var queryString = new jasmine.QueryString({
getWindowLocation: function() { return window.location; }
getWindowLocation: function() {
return window.location;
}
});
var catchingExceptions = queryString.getParam('catch');
@ -101,7 +103,9 @@ function initializePDFJS(callback) {
addToExistingQueryString: function(key, value) {
return queryString.fullStringWithNewParam(key, value);
},
getContainer: function() { return document.body; },
getContainer: function() {
return document.body;
},
createElement: function() {
return document.createElement.apply(document, arguments);
},
@ -122,7 +126,9 @@ function initializePDFJS(callback) {
// Filter which specs will be run by matching the start of the full name
// against the `spec` query param.
var specFilter = new jasmine.HtmlSpecFilter({
filterString: function() { return queryString.getParam('spec'); }
filterString: function() {
return queryString.getParam('spec');
}
});
env.specFilter = function(spec) {

View file

@ -66,7 +66,9 @@ function flatten(stats) {
});
// Use only overall results if not grouped by 'stat'
if (options.groupBy.indexOf('stat') < 0) {
rows = rows.filter(function(s) { return s.stat === 'Overall'; });
rows = rows.filter(function(s) {
return s.stat === 'Overall';
});
}
return rows;
}
@ -129,7 +131,9 @@ function stat(baseline, current) {
}
var i, row, rows = [];
// collect rows and measure column widths
var width = labels.map(function(s) { return s.length; });
var width = labels.map(function(s) {
return s.length;
});
rows.push(labels);
for (var k = 0; k < keys.length; k++) {
var key = keys[k];
@ -157,7 +161,9 @@ function stat(baseline, current) {
}
// add horizontal line
var hline = width.map(function(w) { return new Array(w + 1).join('-'); });
var hline = width.map(function(w) {
return new Array(w + 1).join('-');
});
rows.splice(1, 0, hline);
// print output

View file

@ -1092,8 +1092,12 @@ describe('api', function() {
var xhr = new XMLHttpRequest(pdfPath);
xhr.open('GET', pdfPath);
xhr.responseType = 'arraybuffer';
xhr.onload = function () { resolve(new Uint8Array(xhr.response)); };
xhr.onerror = function () { reject(new Error('PDF is not loaded')); };
xhr.onload = function () {
resolve(new Uint8Array(xhr.response));
};
xhr.onerror = function () {
reject(new Error('PDF is not loaded'));
};
xhr.send();
});
return loadPromise;

View file

@ -211,8 +211,9 @@ describe('cmap', function() {
expect(cmap instanceof IdentityCMap).toEqual(true);
expect(cmap.vertical).toEqual(false);
expect(cmap.length).toEqual(0x10000);
expect(function() { return cmap.isIdentityCMap; }).toThrow(
new Error('should not access .isIdentityCMap'));
expect(function() {
return cmap.isIdentityCMap;
}).toThrow(new Error('should not access .isIdentityCMap'));
done();
}).catch(function (reason) {
done.fail(reason);

View file

@ -124,8 +124,9 @@ describe('function', function() {
expect(program).toMatchArray(expectedProgram);
});
it('handles missing brackets', function() {
expect(function() { parse('{'); }).toThrow(
new Error('Unexpected symbol: found undefined expected 1.'));
expect(function() {
parse('{');
}).toThrow(new Error('Unexpected symbol: found undefined expected 1.'));
});
it('handles junk after the end', function() {
var number = 3.3;

View file

@ -83,7 +83,9 @@ function initializePDFJS(callback) {
// Runner Parameters
var queryString = new jasmine.QueryString({
getWindowLocation: function() { return window.location; }
getWindowLocation: function() {
return window.location;
}
});
var catchingExceptions = queryString.getParam('catch');
@ -117,7 +119,9 @@ function initializePDFJS(callback) {
addToExistingQueryString: function(key, value) {
return queryString.fullStringWithNewParam(key, value);
},
getContainer: function() { return document.body; },
getContainer: function() {
return document.body;
},
createElement: function() {
return document.createElement.apply(document, arguments);
},
@ -138,7 +142,9 @@ function initializePDFJS(callback) {
// Filter which specs will be run by matching the start of the full name
// against the `spec` query param.
var specFilter = new jasmine.HtmlSpecFilter({
filterString: function() { return queryString.getParam('spec'); }
filterString: function() {
return queryString.getParam('spec');
}
});
env.specFilter = function(spec) {