mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 15:18:08 +02:00
Use the ESLint no-restricted-syntax
rule to ensure that assert
is always called with two arguments
Having `assert` calls without a message string isn't very helpful when debugging, and it turns out that it's easy enough to make use of ESLint to enforce better `assert` call-sites. In a couple of cases the `assert` calls were changed to "regular" throwing of errors instead, since that seemed more appropriate. Please find additional details about the ESLint rule at https://eslint.org/docs/rules/no-restricted-syntax
This commit is contained in:
parent
491904d30a
commit
e1f340a0c2
14 changed files with 73 additions and 22 deletions
|
@ -21,8 +21,7 @@ import { setPDFNetworkStreamFactory } from "../../src/display/api.js";
|
|||
// Ensure that this script only runs in Node.js environments.
|
||||
if (!isNodeJS) {
|
||||
throw new Error(
|
||||
"The `gulp unittestcli` command can only be used in " +
|
||||
"Node.js environments."
|
||||
"The `gulp unittestcli` command can only be used in Node.js environments."
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -92,8 +92,7 @@ function initializePDFJS(callback) {
|
|||
|
||||
if (isNodeJS) {
|
||||
throw new Error(
|
||||
"The `gulp unittest` command cannot be used in " +
|
||||
"Node.js environments."
|
||||
"The `gulp unittest` command cannot be used in Node.js environments."
|
||||
);
|
||||
}
|
||||
// Set the network stream factory for unit-tests.
|
||||
|
|
|
@ -14,12 +14,16 @@
|
|||
*/
|
||||
/* globals __non_webpack_require__ */
|
||||
|
||||
import { AbortException, assert } from "../../src/shared/util.js";
|
||||
import { AbortException } from "../../src/shared/util.js";
|
||||
import { isNodeJS } from "../../src/shared/is_node.js";
|
||||
import { PDFNodeStream } from "../../src/display/node_stream.js";
|
||||
|
||||
// Make sure that we only running this script is Node.js environments.
|
||||
assert(isNodeJS);
|
||||
// Ensure that these test only runs in Node.js environments.
|
||||
if (!isNodeJS) {
|
||||
throw new Error(
|
||||
'The "node_stream" unit-tests can only be run in Node.js environments.'
|
||||
);
|
||||
}
|
||||
|
||||
const path = __non_webpack_require__("path");
|
||||
const url = __non_webpack_require__("url");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue