mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 15:18:08 +02:00
Enable ESLint rules that no longer need to be disabled on a directory/file-basis
Given that browsers/environments without native support for both arrow functions and object shorthand properties are no longer supported in PDF.js, please refer to the compatibility information below, we can now enable a fair number of ESLint rules and also simplify/remove some `.eslintrc` files. With the exception of the `no-alert` cases, all code changes were made automatically by using `gulp lint --fix`. - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions#browser_compatibility - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Object_initializer#browser_compatibility
This commit is contained in:
parent
2cba290361
commit
4db7330677
25 changed files with 76 additions and 110 deletions
|
@ -7,8 +7,4 @@
|
|||
"node": true,
|
||||
"jasmine": true,
|
||||
},
|
||||
|
||||
"rules": {
|
||||
"no-restricted-globals": "off",
|
||||
},
|
||||
}
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/* eslint-disable object-shorthand */
|
||||
|
||||
"use strict";
|
||||
|
||||
|
@ -110,17 +109,17 @@ function createExtensionGlobal() {
|
|||
};
|
||||
var headers = {};
|
||||
return {
|
||||
open: function (method, url) {
|
||||
open(method, url) {
|
||||
assert.equal(invoked.open, false);
|
||||
invoked.open = true;
|
||||
assert.equal(method, "POST");
|
||||
assert.equal(url, LOG_URL);
|
||||
},
|
||||
setRequestHeader: function (k, v) {
|
||||
setRequestHeader(k, v) {
|
||||
assert.equal(invoked.open, true);
|
||||
headers[k] = String(v);
|
||||
},
|
||||
send: function (body) {
|
||||
send(body) {
|
||||
assert.equal(invoked.open, true);
|
||||
assert.equal(invoked.send, false);
|
||||
invoked.send = true;
|
||||
|
@ -138,7 +137,7 @@ function createExtensionGlobal() {
|
|||
};
|
||||
window.Date = {
|
||||
test_now_value: Date.now(),
|
||||
now: function () {
|
||||
now() {
|
||||
return window.Date.test_now_value;
|
||||
},
|
||||
};
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/* eslint-disable object-shorthand */
|
||||
|
||||
"use strict";
|
||||
|
||||
|
@ -133,7 +132,7 @@ function downloadManifestFiles(manifest, callback) {
|
|||
var linkfile = file + ".link";
|
||||
var url = fs.readFileSync(linkfile).toString();
|
||||
url = url.replace(/\s+$/, "");
|
||||
return { file: file, url: url };
|
||||
return { file, url };
|
||||
});
|
||||
|
||||
var i = 0;
|
||||
|
|
11
test/test.js
11
test/test.js
|
@ -13,7 +13,6 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/* eslint-disable object-shorthand */
|
||||
|
||||
"use strict";
|
||||
|
||||
|
@ -646,15 +645,15 @@ function refTestPostHandler(req, res) {
|
|||
}
|
||||
|
||||
taskResults[round][page] = {
|
||||
failure: failure,
|
||||
snapshot: snapshot,
|
||||
failure,
|
||||
snapshot,
|
||||
};
|
||||
if (stats) {
|
||||
stats.push({
|
||||
browser: browser,
|
||||
browser,
|
||||
pdf: id,
|
||||
page: page,
|
||||
round: round,
|
||||
page,
|
||||
round,
|
||||
stats: data.stats,
|
||||
});
|
||||
}
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/* eslint-disable object-shorthand */
|
||||
|
||||
"use strict";
|
||||
|
||||
|
@ -53,7 +52,7 @@ function WebServer() {
|
|||
};
|
||||
}
|
||||
WebServer.prototype = {
|
||||
start: function (callback) {
|
||||
start(callback) {
|
||||
this._ensureNonZeroPort();
|
||||
this.server = http.createServer(this._handler.bind(this));
|
||||
this.server.listen(this.port, this.host, callback);
|
||||
|
@ -61,11 +60,11 @@ WebServer.prototype = {
|
|||
"Server running at http://" + this.host + ":" + this.port + "/"
|
||||
);
|
||||
},
|
||||
stop: function (callback) {
|
||||
stop(callback) {
|
||||
this.server.close(callback);
|
||||
this.server = null;
|
||||
},
|
||||
_ensureNonZeroPort: function () {
|
||||
_ensureNonZeroPort() {
|
||||
if (!this.port) {
|
||||
// If port is 0, a random port will be chosen instead. Do not set a host
|
||||
// name to make sure that the port is synchronously set by .listen().
|
||||
|
@ -78,7 +77,7 @@ WebServer.prototype = {
|
|||
server.close();
|
||||
}
|
||||
},
|
||||
_handler: function (req, res) {
|
||||
_handler(req, res) {
|
||||
var url = req.url.replace(/\/\//g, "/");
|
||||
var urlParts = /([^?]*)((?:\?(.*))?)/.exec(url);
|
||||
try {
|
||||
|
@ -312,7 +311,7 @@ WebServer.prototype = {
|
|||
function serveRequestedFileRange(reqFilePath, start, end) {
|
||||
var stream = fs.createReadStream(reqFilePath, {
|
||||
flags: "rs",
|
||||
start: start,
|
||||
start,
|
||||
end: end - 1,
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue