mirror of
https://github.com/axios/axios.git
synced 2026-04-11 02:11:50 +08:00
style: turn '()=>' into '() =>' (#6324)
Co-authored-by: Jay <jasonsaayman@gmail.com>
This commit is contained in:
parent
f73474d02c
commit
4d06112452
@ -194,7 +194,7 @@ const renderPRsList = async (tag, template, {comments_threshold= 5, awesome_thre
|
||||
for(const merge of release.merges) {
|
||||
const pr = await getIssueById(merge.id);
|
||||
|
||||
if (pr && pr.labels.find(({name})=> name === label)) {
|
||||
if (pr && pr.labels.find(({name}) => name === label)) {
|
||||
const {reactions, body} = pr;
|
||||
prs[pr.number] = pr;
|
||||
pr.isHot = pr.comments > comments_threshold;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import chalk from 'chalk';
|
||||
|
||||
export const colorize = (...colors)=> {
|
||||
export const colorize = (...colors) => {
|
||||
if(!colors.length) {
|
||||
colors = ['green', 'cyan', 'magenta', 'blue', 'yellow', 'red'];
|
||||
}
|
||||
|
||||
@ -120,8 +120,8 @@ const generateFileReport = async (files, historyCount = 3) => {
|
||||
const generateBody = async ({files, template = './templates/pr.hbs'} = {}) => {
|
||||
const data = await generateFileReport(files);
|
||||
|
||||
Handlebars.registerHelper('filesize', (bytes)=> bytes != null ? prettyBytes(bytes) : '<unknown>');
|
||||
Handlebars.registerHelper('percent', (value)=> Number.isFinite(value) ? `${(value * 100).toFixed(1)}%` : `---` );
|
||||
Handlebars.registerHelper('filesize', (bytes) => bytes != null ? prettyBytes(bytes) : '<unknown>');
|
||||
Handlebars.registerHelper('percent', (value) => Number.isFinite(value) ? `${(value * 100).toFixed(1)}%` : `---` );
|
||||
|
||||
return Handlebars.compile(String(await fs.readFile(template)))(data);
|
||||
}
|
||||
|
||||
@ -40,7 +40,7 @@ async function getContributors(user, repo, maxCount = 1) {
|
||||
{ params: { per_page: maxCount } }
|
||||
)).data;
|
||||
|
||||
return Promise.all(contributors.map(async (contributor)=> {
|
||||
return Promise.all(contributors.map(async (contributor) => {
|
||||
return {...contributor, ...(await axios.get(
|
||||
`https://api.github.com/users/${encodeURIComponent(contributor.login)}`
|
||||
)).data};
|
||||
|
||||
@ -44,7 +44,7 @@ const remove = async (file) => {
|
||||
|
||||
describe('module', function () {
|
||||
|
||||
before(async ()=> {
|
||||
before(async () => {
|
||||
console.log('✓ Creating build backup...');
|
||||
await fs.copy('./dist/', BACKUP_PATH);
|
||||
console.log('✓ Exec build script...');
|
||||
@ -149,10 +149,10 @@ describe('module', function () {
|
||||
});
|
||||
|
||||
describe('typings', () => {
|
||||
describe('ESM', ()=> {
|
||||
describe('ESM', () => {
|
||||
const pkgPath = path.join(__dirname, './typings/esm');
|
||||
|
||||
after(async ()=> {
|
||||
after(async () => {
|
||||
await remove(path.join(pkgPath, './node_modules'));
|
||||
});
|
||||
|
||||
@ -166,10 +166,10 @@ describe('module', function () {
|
||||
});
|
||||
});
|
||||
|
||||
describe('CommonJS', ()=> {
|
||||
describe('CommonJS', () => {
|
||||
const pkgPath = path.join(__dirname, './typings/cjs');
|
||||
|
||||
after(async ()=> {
|
||||
after(async () => {
|
||||
await remove(path.join(pkgPath, './node_modules'));
|
||||
});
|
||||
|
||||
|
||||
@ -101,7 +101,7 @@ describe('core::mergeConfig', function() {
|
||||
expect(merged.nestedConfig.propertyOnRequestConfig).toEqual(true);
|
||||
});
|
||||
|
||||
describe('headers', ()=> {
|
||||
describe('headers', () => {
|
||||
it('should allow merging with AxiosHeaders instances', () => {
|
||||
const merged = mergeConfig({
|
||||
headers: new AxiosHeaders({
|
||||
|
||||
@ -133,7 +133,7 @@ describe('headers', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('should allow an AxiosHeaders instance to be used as the value of the headers option', async ()=> {
|
||||
it('should allow an AxiosHeaders instance to be used as the value of the headers option', async () => {
|
||||
const instance = axios.create({
|
||||
headers: new AxiosHeaders({
|
||||
xFoo: 'foo',
|
||||
|
||||
@ -84,7 +84,7 @@ describe('utils::merge', function () {
|
||||
expect(d.a).not.toBe(a);
|
||||
});
|
||||
|
||||
it('should support caseless option', ()=> {
|
||||
it('should support caseless option', () => {
|
||||
const a = {x: 1};
|
||||
const b = {X: 2};
|
||||
const merged = merge.call({caseless: true}, a, b);
|
||||
|
||||
@ -26,12 +26,12 @@ describe('adapters', function () {
|
||||
|
||||
it('should detect adapter unavailable status', function () {
|
||||
adapters.adapters['testadapter'] = null;
|
||||
assert.throws(()=> adapters.getAdapter('testAdapter'), /is not available in the build/)
|
||||
assert.throws(() => adapters.getAdapter('testAdapter'), /is not available in the build/)
|
||||
});
|
||||
|
||||
it('should detect adapter unsupported status', function () {
|
||||
adapters.adapters['testadapter'] = false;
|
||||
assert.throws(()=> adapters.getAdapter('testAdapter'), /is not supported by the environment/)
|
||||
assert.throws(() => adapters.getAdapter('testAdapter'), /is not supported by the environment/)
|
||||
});
|
||||
|
||||
it('should pick suitable adapter from the list', function () {
|
||||
|
||||
@ -66,7 +66,7 @@ function toleranceRange(positive, negative) {
|
||||
const nodeVersion = process.versions.node.split('.').map(v => parseInt(v, 10));
|
||||
const nodeMajorVersion = nodeVersion[0];
|
||||
|
||||
var noop = ()=> {};
|
||||
var noop = () => {};
|
||||
|
||||
describe('supports http with nodejs', function () {
|
||||
afterEach(async function () {
|
||||
@ -541,7 +541,7 @@ describe('supports http with nodejs', function () {
|
||||
});
|
||||
});
|
||||
|
||||
describe('algorithms', ()=> {
|
||||
describe('algorithms', () => {
|
||||
const responseBody ='str';
|
||||
|
||||
for (const [typeName, zipped] of Object.entries({
|
||||
@ -783,7 +783,7 @@ describe('supports http with nodejs', function () {
|
||||
// consume the req stream
|
||||
req.on('data', noop);
|
||||
// and wait for the end before responding, otherwise an ECONNRESET error will be thrown
|
||||
req.on('end', ()=> {
|
||||
req.on('end', () => {
|
||||
res.end('OK');
|
||||
});
|
||||
}).listen(4444, function (err) {
|
||||
@ -1844,7 +1844,7 @@ describe('supports http with nodejs', function () {
|
||||
|
||||
const dataURI = 'data:application/octet-stream;base64,' + buffer.toString('base64');
|
||||
|
||||
axios.get(dataURI).then(({data})=> {
|
||||
axios.get(dataURI).then(({data}) => {
|
||||
assert.deepStrictEqual(data, buffer);
|
||||
done();
|
||||
}).catch(done);
|
||||
@ -1861,7 +1861,7 @@ describe('supports http with nodejs', function () {
|
||||
|
||||
const dataURI = 'data:application/octet-stream;base64,' + buffer.toString('base64');
|
||||
|
||||
axios.get(dataURI, {responseType: 'blob'}).then(async ({data})=> {
|
||||
axios.get(dataURI, {responseType: 'blob'}).then(async ({data}) => {
|
||||
assert.strictEqual(data.type, 'application/octet-stream');
|
||||
assert.deepStrictEqual(await data.text(), '123');
|
||||
done();
|
||||
@ -1873,7 +1873,7 @@ describe('supports http with nodejs', function () {
|
||||
|
||||
const dataURI = 'data:application/octet-stream;base64,' + buffer.toString('base64');
|
||||
|
||||
axios.get(dataURI, {responseType: "text"}).then(({data})=> {
|
||||
axios.get(dataURI, {responseType: "text"}).then(({data}) => {
|
||||
assert.deepStrictEqual(data, '123');
|
||||
done();
|
||||
}).catch(done);
|
||||
@ -1884,7 +1884,7 @@ describe('supports http with nodejs', function () {
|
||||
|
||||
const dataURI = 'data:application/octet-stream;base64,' + buffer.toString('base64');
|
||||
|
||||
axios.get(dataURI, {responseType: "stream"}).then(({data})=> {
|
||||
axios.get(dataURI, {responseType: "stream"}).then(({data}) => {
|
||||
var str = '';
|
||||
|
||||
data.on('data', function(response){
|
||||
@ -2049,7 +2049,7 @@ describe('supports http with nodejs', function () {
|
||||
maxRedirects: 0
|
||||
});
|
||||
|
||||
samples.slice(skip).forEach(({rate, progress}, i, _samples)=> {
|
||||
samples.slice(skip).forEach(({rate, progress}, i, _samples) => {
|
||||
assert.ok(compareValues(rate, configRate),
|
||||
`Rate sample at index ${i} is out of the expected range (${rate} / ${configRate}) [${
|
||||
_samples.map(({rate}) => rate).join(', ')
|
||||
@ -2097,7 +2097,7 @@ describe('supports http with nodejs', function () {
|
||||
maxRedirects: 0
|
||||
});
|
||||
|
||||
samples.slice(skip).forEach(({rate, progress}, i, _samples)=> {
|
||||
samples.slice(skip).forEach(({rate, progress}, i, _samples) => {
|
||||
assert.ok(compareValues(rate, configRate),
|
||||
`Rate sample at index ${i} is out of the expected range (${rate} / ${configRate}) [${
|
||||
_samples.map(({rate}) => rate).join(', ')
|
||||
|
||||
@ -168,12 +168,12 @@ describe('AxiosHeaders', function () {
|
||||
|
||||
headers.set('foo', 'bar=value1');
|
||||
|
||||
assert.strictEqual(headers.has('foo', (value, header, headers)=> {
|
||||
assert.strictEqual(headers.has('foo', (value, header, headers) => {
|
||||
assert.strictEqual(value, 'bar=value1');
|
||||
assert.strictEqual(header, 'foo');
|
||||
return true;
|
||||
}), true);
|
||||
assert.strictEqual(headers.has('foo', ()=> false), false);
|
||||
assert.strictEqual(headers.has('foo', () => false), false);
|
||||
});
|
||||
|
||||
it('should support string pattern', function () {
|
||||
@ -246,7 +246,7 @@ describe('AxiosHeaders', function () {
|
||||
|
||||
headers.set('foo', 'bar=value1');
|
||||
|
||||
headers.delete('foo', (value, header)=> {
|
||||
headers.delete('foo', (value, header) => {
|
||||
assert.strictEqual(value, 'bar=value1');
|
||||
assert.strictEqual(header, 'foo');
|
||||
return false;
|
||||
@ -254,7 +254,7 @@ describe('AxiosHeaders', function () {
|
||||
|
||||
assert.strictEqual(headers.has('foo'), true);
|
||||
|
||||
assert.strictEqual(headers.delete('foo', ()=> true), true);
|
||||
assert.strictEqual(headers.delete('foo', () => true), true);
|
||||
|
||||
assert.strictEqual(headers.has('foo'), false);
|
||||
});
|
||||
@ -277,7 +277,7 @@ describe('AxiosHeaders', function () {
|
||||
});
|
||||
});
|
||||
|
||||
describe('clear', ()=> {
|
||||
describe('clear', () => {
|
||||
it('should clear all headers', () => {
|
||||
const headers = new AxiosHeaders({x: 1, y:2});
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user