From fa2f47b317e677adb82a14a57ea6398558b6ace7 Mon Sep 17 00:00:00 2001 From: fent <933490+fent@users.noreply.github.com> Date: Fri, 18 Dec 2020 11:50:14 -0700 Subject: [PATCH] fix: don't use reserved keywords closes #834 --- .eslintrc.json | 5 ++++- lib/utils.js | 6 +++--- test/utils-test.js | 10 +++++----- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index c1a904c4..215a35d5 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,7 +1,10 @@ { "extends": "eslint:recommended", "parserOptions": { - "ecmaVersion": 2017 + "ecmaVersion": 2017, + "ecmaFeatures": { + "impliedStrict": true + } }, "env": { "es6": true, diff --git a/lib/utils.js b/lib/utils.js index f17179c8..3d2ae843 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -140,16 +140,16 @@ exports.deprecate = (obj, prop, value, oldPath, newPath) => { // Check for updates. -const package = require('../package.json'); +const pkg = require('../package.json'); exports.lastUpdateCheck = 0; exports.checkForUpdates = () => { - if (!process.env.YTDL_NO_UPDATE && !package.version.startsWith('0.0.0-') && + if (!process.env.YTDL_NO_UPDATE && !pkg.version.startsWith('0.0.0-') && Date.now() - exports.lastUpdateCheck >= 1000 * 60 * 60 * 12) { exports.lastUpdateCheck = Date.now(); return miniget('https://api.github.com/repos/fent/node-ytdl-core/releases/latest', { headers: { 'User-Agent': 'ytdl-core' }, }).text().then(response => { - if (JSON.parse(response).tag_name !== `v${package.version}`) { + if (JSON.parse(response).tag_name !== `v${pkg.version}`) { console.warn('\x1b[33mWARNING:\x1B[0m ytdl-core is out of date! Update with "npm install ytdl-core@latest".'); } }); diff --git a/test/utils-test.js b/test/utils-test.js index 6dd50c9a..70cc5537 100644 --- a/test/utils-test.js +++ b/test/utils-test.js @@ -106,11 +106,11 @@ describe('utils.checkForUpdates', () => { describe('Already on latest', () => { it('Does not warn the console', async() => { - const package = require('../package.json'); - sinon.replace(package, 'version', 'v1.0.0'); + const pkg = require('../package.json'); + sinon.replace(pkg, 'version', 'v1.0.0'); const scope = nock('https://api.github.com') .get('/repos/fent/node-ytdl-core/releases/latest') - .reply(200, { tag_name: `v${package.version}` }); + .reply(200, { tag_name: `v${pkg.version}` }); const warnSpy = sinon.spy(); sinon.replace(console, 'warn', warnSpy); sinon.replace(Date, 'now', sinon.stub().returns(Infinity)); @@ -122,8 +122,8 @@ describe('utils.checkForUpdates', () => { describe('When there is a new update', () => { it('Warns the console about the update', async() => { - const package = require('../package.json'); - sinon.replace(package, 'version', 'v1.0.0'); + const pkg = require('../package.json'); + sinon.replace(pkg, 'version', 'v1.0.0'); const scope = nock('https://api.github.com') .get('/repos/fent/node-ytdl-core/releases/latest') .reply(200, { tag_name: 'vInfinity.0.0' });