From 6ebd851d279cfb618a01531eba033d3e2aa35cf5 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sun, 16 Feb 2020 12:21:40 +0100 Subject: [PATCH] Enable the `no-buffer-constructor` ESLint rule According to https://nodejs.org/api/buffer.html#buffer_class_buffer: `new Buffer(...)` is deprecated in up-to-date versions of Node.js, hence you want to prevent it from being accidentally used. Please see https://eslint.org/docs/rules/no-buffer-constructor for additional information. --- .eslintrc | 3 +++ src/display/svg.js | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.eslintrc b/.eslintrc index 187da5ad6..81858f150 100644 --- a/.eslintrc +++ b/.eslintrc @@ -127,6 +127,9 @@ "args": "none", }], + // Node.js and CommonJS + "no-buffer-constructor": "error", + // Stylistic Issues "lines-between-class-members": ["error", "always"], "max-len": ["error", { diff --git a/src/display/svg.js b/src/display/svg.js index 745d66f8c..de720fd4f 100644 --- a/src/display/svg.js +++ b/src/display/svg.js @@ -145,7 +145,7 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) { input = literals; } else { // eslint-disable-next-line no-undef - input = new Buffer(literals); + input = Buffer.from(literals); } const output = __non_webpack_require__("zlib").deflateSync(input, { level: 9,