From 76326165f62b4b1f3dabe1f5252a8a54d97793f3 Mon Sep 17 00:00:00 2001 From: Justin Dhillon Date: Tue, 26 Mar 2024 17:07:16 -0700 Subject: [PATCH] fix: remove useless code --- bin/GithubAPI.js | 9 +++------ bin/contributors.js | 3 +-- bin/pr.js | 2 +- dist/axios.js | 2 +- examples/get/server.js | 2 +- examples/post/server.js | 2 +- examples/postMultipartFormData/server.js | 4 ++-- examples/upload/server.js | 2 +- gulpfile.js | 2 +- test/specs/basicAuth.spec.js | 4 ++-- test/specs/defaults.spec.js | 1 - test/specs/headers.spec.js | 2 -- test/specs/interceptors.spec.js | 2 +- test/specs/options.spec.js | 2 -- test/specs/progress.spec.js | 4 ++-- test/specs/xsrf.spec.js | 2 +- test/unit/core/AxiosHeaders.js | 2 +- 17 files changed, 19 insertions(+), 28 deletions(-) diff --git a/bin/GithubAPI.js b/bin/GithubAPI.js index 296f7f6d47..f3e84a5261 100644 --- a/bin/GithubAPI.js +++ b/bin/GithubAPI.js @@ -50,9 +50,7 @@ export default class GithubAPI { async isCollaborator(user) { try { return (await this.axios.get(`/collaborators/${user}`)).status === 204; - } catch (e) { - - } + } catch {} } async deleteLabel(issue, label) { @@ -102,8 +100,7 @@ export default class GithubAPI { static async getTagRef(tag) { try { return (await exec(`git show-ref --tags "refs/tags/${tag}"`)).stdout.split(' ')[0]; - } catch (e) { - } + } catch {} } static async getLatestTag() { @@ -111,7 +108,7 @@ export default class GithubAPI { const {stdout} = await exec(`git for-each-ref refs/tags --sort=-taggerdate --format='%(refname)' --count=1`); return stdout.split('/').pop(); - } catch (e) {} + } catch {} } static normalizeTag(tag){ diff --git a/bin/contributors.js b/bin/contributors.js index 03f3217fd6..52c4d8c6f5 100644 --- a/bin/contributors.js +++ b/bin/contributors.js @@ -229,8 +229,7 @@ const renderPRsList = async (tag, template, {comments_threshold= 5, awesome_thre const getTagRef = async (tag) => { try { return (await exec(`git show-ref --tags "refs/tags/${tag}"`)).stdout.split(' ')[0]; - } catch(e) { - } + } catch {} } export { diff --git a/bin/pr.js b/bin/pr.js index 4a6db09923..3fdfb6fab7 100644 --- a/bin/pr.js +++ b/bin/pr.js @@ -66,7 +66,7 @@ const generateBody = async ({files, template = './templates/pr.hbs'} = {}) => { return Handlebars.compile(String(await fs.readFile(template)))(data); } -console.log(await generateBody({ +console.log(generateBody({ files: { 'Browser build (UMD)' : './dist/axios.min.js', 'Browser build (ESM)' : './dist/esm/axios.min.js', diff --git a/dist/axios.js b/dist/axios.js index 2649e27701..52ef888922 100644 --- a/dist/axios.js +++ b/dist/axios.js @@ -3005,7 +3005,7 @@ } }, _callee, this, [[0, 6]]); })); - function request(_x, _x2) { + function request() { return _request2.apply(this, arguments); } return request; diff --git a/examples/get/server.js b/examples/get/server.js index 8a3622f5c7..d894fcb9a1 100644 --- a/examples/get/server.js +++ b/examples/get/server.js @@ -31,4 +31,4 @@ export default function (req, res) { }); res.write(JSON.stringify(people)); res.end(); -}; +} diff --git a/examples/post/server.js b/examples/post/server.js index 1cb9c45fa6..f3d3d3bdf4 100644 --- a/examples/post/server.js +++ b/examples/post/server.js @@ -13,4 +13,4 @@ export default function (req, res) { res.write(JSON.stringify(data)); res.end(); }); -}; +} diff --git a/examples/postMultipartFormData/server.js b/examples/postMultipartFormData/server.js index 9db463ea2c..9803735f0d 100644 --- a/examples/postMultipartFormData/server.js +++ b/examples/postMultipartFormData/server.js @@ -1,6 +1,6 @@ export default function (req, res) { - req.on('data', function (chunk) { + req.on('data', function () { }); req.on('end', function () { @@ -10,4 +10,4 @@ export default function (req, res) { }); res.end(); }); -}; +} diff --git a/examples/upload/server.js b/examples/upload/server.js index 3d365be98b..348becf11f 100644 --- a/examples/upload/server.js +++ b/examples/upload/server.js @@ -10,4 +10,4 @@ export default function (req, res) { res.writeHead(200); res.end(); }); -}; +} diff --git a/gulpfile.js b/gulpfile.js index 2e1858197e..168288a5cd 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -59,7 +59,7 @@ const packageJSON = gulp.task('package', async function () { .filter( ({type, contributions}) => type.toLowerCase() === 'user' && contributions >= CONTRIBUTION_THRESHOLD ) - .map(({login, name, url}) => `${name || login} (https://github.com/${login})`); + .map(({login, name}) => `${name || login} (https://github.com/${login})`); await fs.writeFile('package.json', JSON.stringify(npm, null, 2)); } catch (err) { diff --git a/test/specs/basicAuth.spec.js b/test/specs/basicAuth.spec.js index d453f83a0d..4df29a13d9 100644 --- a/test/specs/basicAuth.spec.js +++ b/test/specs/basicAuth.spec.js @@ -2,7 +2,7 @@ import axios from "../../index"; function validateInvalidCharacterError(error) { expect(/character/i.test(error.message)).toEqual(true); -}; +} describe('basicAuth', function () { // Validate an invalid character error @@ -67,7 +67,7 @@ describe('basicAuth', function () { username: 'Aladßç£☃din', password: 'open sesame' } - }).then(function (response) { + }).then(function () { done(new Error('Should not succeed to make a HTTP Basic auth request with non-latin1 chars in credentials.')); }).catch(function (error) { validateInvalidCharacterError(error); diff --git a/test/specs/defaults.spec.js b/test/specs/defaults.spec.js index 1c5abf371e..9fb96a36ee 100644 --- a/test/specs/defaults.spec.js +++ b/test/specs/defaults.spec.js @@ -1,5 +1,4 @@ import defaults from '../../lib/defaults'; -import utils from '../../lib/utils'; import AxiosHeaders from '../../lib/core/AxiosHeaders'; describe('defaults', function () { diff --git a/test/specs/headers.spec.js b/test/specs/headers.spec.js index ffc725d5ff..47bc57b307 100644 --- a/test/specs/headers.spec.js +++ b/test/specs/headers.spec.js @@ -1,5 +1,3 @@ -import assert from "assert"; - const {AxiosHeaders} = axios; function testHeaderValue(headers, key, val) { diff --git a/test/specs/interceptors.spec.js b/test/specs/interceptors.spec.js index d08bcba31a..89422f900b 100644 --- a/test/specs/interceptors.spec.js +++ b/test/specs/interceptors.spec.js @@ -414,7 +414,7 @@ describe('interceptors', function () { describe('and when the fulfillment-interceptor throws', function () { function fireRequestCatchAndExpect(expectation) { - axios('/foo').catch(function(data) { + axios('/foo').catch(function() { // dont handle result }); getAjaxRequest().then(function (request) { diff --git a/test/specs/options.spec.js b/test/specs/options.spec.js index 9879fdc885..f2e589b4da 100644 --- a/test/specs/options.spec.js +++ b/test/specs/options.spec.js @@ -1,5 +1,3 @@ -import AxiosHeaders from "../../lib/core/AxiosHeaders.js"; - describe('options', function () { beforeEach(function () { jasmine.Ajax.install(); diff --git a/test/specs/progress.spec.js b/test/specs/progress.spec.js index 9d7cb49030..1db1307550 100644 --- a/test/specs/progress.spec.js +++ b/test/specs/progress.spec.js @@ -27,7 +27,7 @@ describe('progress events', function () { axios('/foo', { onUploadProgress: progressSpy } ); - getAjaxRequest().then(function (request) { + getAjaxRequest().then(function () { // Jasmine AJAX doesn't trigger upload events. Waiting for upstream fix // expect(progressSpy).toHaveBeenCalled(); done(); @@ -80,7 +80,7 @@ describe('progress events', function () { instance.get('/foo'); - getAjaxRequest().then(function (request) { + getAjaxRequest().then(function () { // expect(progressSpy).toHaveBeenCalled(); done(); }); diff --git a/test/specs/xsrf.spec.js b/test/specs/xsrf.spec.js index b05f70e378..4f143e2af6 100644 --- a/test/specs/xsrf.spec.js +++ b/test/specs/xsrf.spec.js @@ -50,7 +50,7 @@ describe('xsrf', function () { xsrfCookieName: null }); - getAjaxRequest().then(function (request) { + getAjaxRequest().then(function () { expect(cookies.read).not.toHaveBeenCalled(); done(); }); diff --git a/test/unit/core/AxiosHeaders.js b/test/unit/core/AxiosHeaders.js index bc751233c6..aa97c36b89 100644 --- a/test/unit/core/AxiosHeaders.js +++ b/test/unit/core/AxiosHeaders.js @@ -138,7 +138,7 @@ describe('AxiosHeaders', function () { headers.set('foo', 'bar=value1'); - assert.strictEqual(headers.has('foo', (value, header, headers)=> { + assert.strictEqual(headers.has('foo', (value, header)=> { assert.strictEqual(value, 'bar=value1'); assert.strictEqual(header, 'foo'); return true;