Skip to content

Commit 5de9f6f

Browse files
committed
style(prettier): update eslint-config-prettier to v7.0.0
Closes #1827
1 parent 4e8dceb commit 5de9f6f

21 files changed

+195
-319
lines changed

Diff for: package-lock.json

+4-15
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
"cross-env": "=7.0.3",
7777
"eslint": "=7.15.0",
7878
"eslint-config-airbnb-base": "=14.2.1",
79-
"eslint-config-prettier": "=6.15.0",
79+
"eslint-config-prettier": "=7.0.0",
8080
"eslint-plugin-import": "=2.22.1",
8181
"eslint-plugin-prettier": "=3.2.0",
8282
"expect": "=26.6.2",

Diff for: src/execute/index.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ import oas3BuildRequest from './oas3/build-request';
1212
import swagger2BuildRequest from './swagger2/build-request';
1313
import { getOperationRaw, legacyIdFromPathMethod, isOAS3 } from '../helpers';
1414

15-
const arrayOrEmpty = (ar) => {
16-
return Array.isArray(ar) ? ar : [];
17-
};
15+
const arrayOrEmpty = (ar) => (Array.isArray(ar) ? ar : []);
1816

1917
const OperationNotFoundError = createError(
2018
'OperationNotFoundError',
@@ -24,9 +22,7 @@ const OperationNotFoundError = createError(
2422
}
2523
);
2624

27-
const findParametersWithName = (name, parameters) => {
28-
return parameters.filter((p) => p.name === name);
29-
};
25+
const findParametersWithName = (name, parameters) => parameters.filter((p) => p.name === name);
3026

3127
// removes parameters that have duplicate 'in' and 'name' properties
3228
const deduplicateParameters = (parameters) => {

Diff for: src/execute/oas3/style-serializer.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
const { Buffer } = require('buffer');
22

33
const isRfc3986Reserved = (char) => ":/?#[]@!$&'()*+,;=".indexOf(char) > -1;
4-
const isRrc3986Unreserved = (char) => {
5-
return /^[a-z0-9\-._~]+$/i.test(char);
6-
};
4+
const isRrc3986Unreserved = (char) => /^[a-z0-9\-._~]+$/i.test(char);
75

86
export function encodeDisallowedCharacters(str, { escape } = {}, parse) {
97
if (typeof str === 'number') {

Diff for: src/helpers.js

+4-7
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ import isObject from 'lodash/isObject';
22
import startsWith from 'lodash/startsWith';
33

44
const toLower = (str) => String.prototype.toLowerCase.call(str);
5-
const escapeString = (str) => {
6-
return str.replace(/[^\w]/gi, '_');
7-
};
5+
const escapeString = (str) => str.replace(/[^\w]/gi, '_');
86

97
// Spec version detection
108
export function isOAS3(spec) {
@@ -209,14 +207,13 @@ export function normalizeSwagger(parsedSpec) {
209207
} else if (inheritName === 'parameters') {
210208
// eslint-disable-next-line no-restricted-syntax
211209
for (const param of inherits[inheritName]) {
212-
const exists = operation[inheritName].some((opParam) => {
213-
return (
210+
const exists = operation[inheritName].some(
211+
(opParam) =>
214212
(opParam.name && opParam.name === param.name) ||
215213
(opParam.$ref && opParam.$ref === param.$ref) ||
216214
(opParam.$$ref && opParam.$$ref === param.$$ref) ||
217215
opParam === param
218-
);
219-
});
216+
);
220217

221218
if (!exists) {
222219
operation[inheritName].push(param);

Diff for: src/interfaces.js

+3-6
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ import { eachOperation, opId } from './helpers';
44

55
const nullFn = () => null;
66

7-
const normalizeArray = (arg) => {
8-
return Array.isArray(arg) ? arg : [arg];
9-
};
7+
const normalizeArray = (arg) => (Array.isArray(arg) ? arg : [arg]);
108

119
// To allow stubbing of functions
1210
export const self = {
@@ -16,8 +14,8 @@ export const self = {
1614

1715
// Make an execute, bound to arguments defined in mapTagOperation's callback (cb)
1816
export function makeExecute(swaggerJs = {}) {
19-
return ({ pathName, method, operationId }) => (parameters, opts = {}) => {
20-
return swaggerJs.execute({
17+
return ({ pathName, method, operationId }) => (parameters, opts = {}) =>
18+
swaggerJs.execute({
2119
spec: swaggerJs.spec,
2220
...pick(swaggerJs, 'requestInterceptor', 'responseInterceptor', 'userFetch'),
2321
pathName,
@@ -26,7 +24,6 @@ export function makeExecute(swaggerJs = {}) {
2624
operationId,
2725
...opts,
2826
});
29-
};
3027
}
3128

3229
// Creates an interface with tags+operations = execute

Diff for: src/internal/form-data-monkey-patch.js

+4-16
Original file line numberDiff line numberDiff line change
@@ -36,35 +36,23 @@ export const patch = (FormData) => {
3636
set(field, value) {
3737
const newEntry = createEntry(field, value);
3838

39-
this.entryList = this.entryList.filter((entry) => {
40-
return entry.name !== field;
41-
});
39+
this.entryList = this.entryList.filter((entry) => entry.name !== field);
4240

4341
this.entryList.push(newEntry);
4442
}
4543

4644
get(field) {
47-
const foundEntry = this.entryList.find((entry) => {
48-
return entry.name === field;
49-
});
45+
const foundEntry = this.entryList.find((entry) => entry.name === field);
5046

5147
return foundEntry === undefined ? null : foundEntry;
5248
}
5349

5450
getAll(field) {
55-
return this.entryList
56-
.filter((entry) => {
57-
return entry.name === field;
58-
})
59-
.map((entry) => {
60-
return entry.value;
61-
});
51+
return this.entryList.filter((entry) => entry.name === field).map((entry) => entry.value);
6252
}
6353

6454
has(field) {
65-
return this.entryList.some((entry) => {
66-
return entry.name === field;
67-
});
55+
return this.entryList.some((entry) => entry.name === field);
6856
}
6957
}
7058

Diff for: src/resolver.js

+3-6
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ export function makeFetchJSON(http, opts = {}) {
77
const { requestInterceptor, responseInterceptor } = opts;
88
// Set credentials with 'http.withCredentials' value
99
const credentials = http.withCredentials ? 'include' : 'same-origin';
10-
return (docPath) => {
11-
return http({
10+
return (docPath) =>
11+
http({
1212
url: docPath,
1313
loadSpec: true,
1414
requestInterceptor,
@@ -17,10 +17,7 @@ export function makeFetchJSON(http, opts = {}) {
1717
Accept: ACCEPT_HEADER_VALUE_FOR_DOCUMENTS,
1818
},
1919
credentials,
20-
}).then((res) => {
21-
return res.body;
22-
});
23-
};
20+
}).then((res) => res.body);
2421
}
2522

2623
// Wipe out the http cache

Diff for: src/specmap/index.js

+4-8
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,7 @@ class SpecMap {
9999
return true;
100100
}
101101

102-
return path.every((val, i) => {
103-
return val === tested[i];
104-
});
102+
return path.every((val, i) => val === tested[i]);
105103
};
106104

107105
return function* generator(patches, specmap) {
@@ -350,11 +348,9 @@ class SpecMap {
350348
const promises = this.promisedPatches.map((p) => p.value);
351349

352350
// Waits for all to settle instead of Promise.all which stops on rejection
353-
return Promise.all(
354-
promises.map((promise) => {
355-
return promise.then(noop, noop);
356-
})
357-
).then(() => this.dispatch());
351+
return Promise.all(promises.map((promise) => promise.then(noop, noop))).then(() =>
352+
this.dispatch()
353+
);
358354
}
359355

360356
// Ok, run the plugin

Diff for: src/specmap/lib/all-of.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,8 @@ export default {
6767
const collapsedFullPath = fullPath.slice(0, -1);
6868

6969
const absoluteRefPatches = generateAbsoluteRefPatches(toMerge, collapsedFullPath, {
70-
getBaseUrlForNodePath: (nodePath) => {
71-
return specmap.getContext([...fullPath, i, ...nodePath]).baseDoc;
72-
},
70+
getBaseUrlForNodePath: (nodePath) =>
71+
specmap.getContext([...fullPath, i, ...nodePath]).baseDoc,
7372
specmap,
7473
});
7574

Diff for: src/specmap/lib/index.js

+13-24
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,11 @@ function normalizeJSONPath(path) {
130130
}
131131

132132
return `/${path
133-
.map((item) => {
134-
// eslint-disable-line prefer-template
135-
return (item + '').replace(/~/g, '~0').replace(/\//g, '~1'); // eslint-disable-line prefer-template
136-
})
133+
.map(
134+
(item) =>
135+
// eslint-disable-line prefer-template
136+
(item + '').replace(/~/g, '~0').replace(/\//g, '~1') // eslint-disable-line prefer-template
137+
)
137138
.join('/')}`;
138139
}
139140

@@ -211,9 +212,9 @@ function forEachNewPrimitive(mutations, fn) {
211212

212213
function forEachNewPatch(mutations, fn, callback) {
213214
const res =
214-
mutations.filter(isAdditiveMutation).map((mutation) => {
215-
return fn(mutation.value, callback, mutation.path);
216-
}) || [];
215+
mutations
216+
.filter(isAdditiveMutation)
217+
.map((mutation) => fn(mutation.value, callback, mutation.path)) || [];
217218
const flat = flatten(res);
218219
const clean = cleanArray(flat);
219220
return clean;
@@ -223,15 +224,11 @@ function forEachPrimitive(obj, fn, basePath) {
223224
basePath = basePath || [];
224225

225226
if (Array.isArray(obj)) {
226-
return obj.map((val, key) => {
227-
return forEachPrimitive(val, fn, basePath.concat(key));
228-
});
227+
return obj.map((val, key) => forEachPrimitive(val, fn, basePath.concat(key)));
229228
}
230229

231230
if (isObject(obj)) {
232-
return Object.keys(obj).map((key) => {
233-
return forEachPrimitive(obj[key], fn, basePath.concat(key));
234-
});
231+
return Object.keys(obj).map((key) => forEachPrimitive(obj[key], fn, basePath.concat(key)));
235232
}
236233

237234
return fn(obj, basePath[basePath.length - 1], basePath);
@@ -249,16 +246,12 @@ function forEach(obj, fn, basePath) {
249246
}
250247

251248
if (Array.isArray(obj)) {
252-
const arrayResults = obj.map((val, key) => {
253-
return forEach(val, fn, basePath.concat(key));
254-
});
249+
const arrayResults = obj.map((val, key) => forEach(val, fn, basePath.concat(key)));
255250
if (arrayResults) {
256251
results = results.concat(arrayResults);
257252
}
258253
} else if (isObject(obj)) {
259-
const moreResults = Object.keys(obj).map((key) => {
260-
return forEach(obj[key], fn, basePath.concat(key));
261-
});
254+
const moreResults = Object.keys(obj).map((key) => forEach(obj[key], fn, basePath.concat(key)));
262255
if (moreResults) {
263256
results = results.concat(moreResults);
264257
}
@@ -308,11 +301,7 @@ function normalizeArray(arr) {
308301
}
309302

310303
function flatten(arr) {
311-
return [].concat(
312-
...arr.map((val) => {
313-
return Array.isArray(val) ? flatten(val) : val;
314-
})
315-
);
304+
return [].concat(...arr.map((val) => (Array.isArray(val) ? flatten(val) : val)));
316305
}
317306

318307
function cleanArray(arr) {

Diff for: src/specmap/lib/refs.js

+4-8
Original file line numberDiff line numberDiff line change
@@ -517,12 +517,11 @@ function pointerAlreadyInPath(pointer, basePath, parent, specmap) {
517517
currPath = `${currPath}/${escapeJsonPointerToken(token)}`;
518518
return (
519519
refs[currPath] &&
520-
refs[currPath].some((ref) => {
521-
return (
520+
refs[currPath].some(
521+
(ref) =>
522522
pointerIsAParent(ref, fullyQualifiedPointer) ||
523523
pointerIsAParent(fullyQualifiedPointer, ref)
524-
);
525-
})
524+
)
526525
);
527526
});
528527
if (hasIndirectCycle) {
@@ -551,10 +550,7 @@ function patchValueAlreadyInPath(root, patch) {
551550
function pointToAncestor(obj) {
552551
return (
553552
lib.isObject(obj) &&
554-
(ancestors.indexOf(obj) >= 0 ||
555-
Object.keys(obj).some((k) => {
556-
return pointToAncestor(obj[k]);
557-
}))
553+
(ancestors.indexOf(obj) >= 0 || Object.keys(obj).some((k) => pointToAncestor(obj[k])))
558554
);
559555
}
560556
}

Diff for: test/client.js

+6-8
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,8 @@ describe('http', () => {
169169
/**
170170
* See https://github.com/swagger-api/swagger-js/issues/1277
171171
*/
172-
test('should return a helpful error when the connection is refused', () => {
173-
return Swagger('http://localhost:1/untouchable.yaml')
172+
test('should return a helpful error when the connection is refused', () =>
173+
Swagger('http://localhost:1/untouchable.yaml')
174174
.then(() => {
175175
throw new Error('Expected an error.');
176176
})
@@ -179,8 +179,7 @@ describe('http', () => {
179179
'request to http://localhost:1/untouchable.yaml failed, reason: connect ECONNREFUSED 127.0.0.1:1'
180180
);
181181
expect(error.name).toEqual('FetchError');
182-
});
183-
});
182+
}));
184183

185184
/**
186185
* See https://github.com/swagger-api/swagger-js/issues/1002
@@ -253,8 +252,8 @@ describe('http', () => {
253252
}
254253
});
255254

256-
test('should err gracefully when requesting https from an http server', () => {
257-
return Swagger({
255+
test('should err gracefully when requesting https from an http server', () =>
256+
Swagger({
258257
url: 'http://localhost:8000/petstore.json',
259258
requestInterceptor: (req) => {
260259
const u = url.parse(req.url);
@@ -266,8 +265,7 @@ describe('http', () => {
266265
expect(err.message).toMatch(
267266
/^request to https:\/\/localhost:8000\/petstore\.json failed, reason: (socket hang up|write EPROTO)/
268267
);
269-
});
270-
});
268+
}));
271269

272270
test('should use requestInterceptor for resolving nested $refs', () => {
273271
const requestInterceptor = jest.fn();

Diff for: test/helpers.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,10 @@ describe('helpers', () => {
1717
expect(id).toEqual('get_one');
1818
});
1919
test('should handle strange paths/methods correctly when in v2 mode', () => {
20-
const fn = (path, method) => {
21-
return idFromPathMethod(path, method, {
20+
const fn = (path, method) =>
21+
idFromPathMethod(path, method, {
2222
v2OperationIdCompatibilityMode: true,
2323
});
24-
};
2524
// https://github.com/swagger-api/swagger-js/issues/1269#issue-309070070
2625
expect(fn('/foo/{bar}/baz', 'get')).toEqual('get_foo_bar_baz');
2726

0 commit comments

Comments
 (0)