Skip to content

Commit 89929da

Browse files
committed
style: automatic fixes for new ESLint rules
Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
1 parent 753fe88 commit 89929da

6 files changed

+15
-15
lines changed

combine.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export default function combineOpenapi(openapiDocs) {
5858
}
5959

6060
for (const [pathStr, pathObj] of Object.entries(paths)) {
61-
if (hasOwnProperty.call(combinedPaths, pathStr)) {
61+
if (Object.hasOwn(combinedPaths, pathStr)) {
6262
throw new Error(`Duplicate path ${pathStr}`);
6363
}
6464

index.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function visit(transformer, method, propName, propValue) {
3838
return method.call(transformer, propValue);
3939
} catch (err) {
4040
handlingException = true;
41-
if (!hasOwnProperty.call(err, 'transformPath')) {
41+
if (!Object.hasOwn(err, 'transformPath')) {
4242
err.transformPath = [...transformer.transformPath];
4343
err.message +=
4444
` (while transforming ${toJsonPointer(err.transformPath)})`;
@@ -318,7 +318,7 @@ export default class ProcoreApiDocToOpenApiTransformer {
318318
parentObjectSchema.properties = parentProperties;
319319
}
320320

321-
if (hasOwnProperty.call(parentProperties, name)) {
321+
if (Object.hasOwn(parentProperties, name)) {
322322
throw new Error(`duplicate property ${name} for parameter`);
323323
}
324324

@@ -347,7 +347,7 @@ export default class ProcoreApiDocToOpenApiTransformer {
347347
parentObjectSchema.patternProperties = patternProperties;
348348
}
349349

350-
if (hasOwnProperty.call(patternProperties, pattern)) {
350+
if (Object.hasOwn(patternProperties, pattern)) {
351351
throw new Error(
352352
`duplicate patternProperty ${pattern} for parameter ${name}`,
353353
);
@@ -391,7 +391,7 @@ export default class ProcoreApiDocToOpenApiTransformer {
391391
);
392392
}
393393

394-
if (hasOwnProperty.call(propertiesByName, field)) {
394+
if (Object.hasOwn(propertiesByName, field)) {
395395
throw new Error(
396396
`Duplicate field '${field}' in schema properties`,
397397
);
@@ -494,7 +494,7 @@ export default class ProcoreApiDocToOpenApiTransformer {
494494
this.warn('Invalid status:', status);
495495
}
496496

497-
if (hasOwnProperty.call(responseByStatus, status)) {
497+
if (Object.hasOwn(responseByStatus, status)) {
498498
throw new Error(`Multiple responses for status ${status}`);
499499
}
500500

lib/doc-bugs-transformer.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function applyToPath(transform, obj, propPath, i) {
1212
}
1313

1414
const propName = propPath[i];
15-
if (!hasOwnProperty.call(obj, propName)) {
15+
if (!Object.hasOwn(obj, propName)) {
1616
this.warn('Expected %s on %o', propName, obj);
1717
return obj;
1818
}

lib/error-response-transformer.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -165,13 +165,13 @@ const ubiquitousResponses = {
165165

166166
function isResponseEqual(response1, response2) {
167167
let response1NoDesc = response1;
168-
if (hasOwnProperty.call(response1, 'description')) {
168+
if (Object.hasOwn(response1, 'description')) {
169169
const { description, ...noDesc } = response1;
170170
response1NoDesc = noDesc;
171171
}
172172

173173
let response2NoDesc = response2;
174-
if (hasOwnProperty.call(response2, 'description')) {
174+
if (Object.hasOwn(response2, 'description')) {
175175
const { description, ...noDesc } = response2;
176176
response2NoDesc = noDesc;
177177
}
@@ -182,21 +182,21 @@ function isResponseEqual(response1, response2) {
182182
function addComponentsResponses(responses) {
183183
if (responses === undefined) {
184184
// Deep clone componentsResponses as new components.responses
185-
return JSON.parse(JSON.stringify(componentsResponses));
185+
return structuredClone(componentsResponses);
186186
}
187187

188188
// Merge componentsResponses into components.responses
189189
const newResponses = { ...responses };
190190
for (const [responseName, response] of Object.keys(componentsResponses)) {
191-
if (hasOwnProperty.call(responses, responseName)) {
191+
if (Object.hasOwn(responses, responseName)) {
192192
const oldResponse = responses[responseName];
193193
if (!isDeepStrictEqual(response, oldResponse)) {
194194
throw new Error(
195195
`components.responses.${responseName} already exists`,
196196
);
197197
}
198198
} else {
199-
newResponses[responseName] = JSON.parse(JSON.stringify(response));
199+
newResponses[responseName] = structuredClone(response);
200200
}
201201
}
202202

lib/multipart-transformer.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ export default class MultipartTransformer extends OpenApiTransformerBase {
173173
return requestBody;
174174
}
175175

176-
const schemaMulti = JSON.parse(JSON.stringify(schema));
176+
const schemaMulti = structuredClone(schema);
177177
for (const multipartPropPath of multipartPropPaths) {
178178
const multipartSchema = get(schema, multipartPropPath, 0);
179179
if (multipartSchema.type === 'string') {

make-filter.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export default function makeEndpointFilter(
1818
includeBetaPrograms,
1919
) {
2020
const minIndex = supportLevels.indexOf(minSupportLevel);
21-
if (minIndex < 0) {
21+
if (minIndex === -1) {
2222
throw new RangeError(`Unrecognized minSupportLevel '${minSupportLevel}'`);
2323
}
2424

@@ -42,7 +42,7 @@ export default function makeEndpointFilter(
4242
}
4343

4444
const supportIndex = supportLevels.indexOf(supportLevel);
45-
if (supportIndex < 0) {
45+
if (supportIndex === -1) {
4646
this.warn('Unrecognized support_level:', supportLevel);
4747
}
4848

0 commit comments

Comments
 (0)