Skip to content

Commit b02053b

Browse files
address the comments
1 parent 7e76feb commit b02053b

File tree

4 files changed

+10
-13
lines changed

4 files changed

+10
-13
lines changed

eslint.config.mjs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ export default [
2525
ecmaVersion: 2022,
2626
sourceType: 'module',
2727
},
28+
rules: {
29+
'no-extra-boolean-cast': ['warn',
30+
{
31+
enforceForLogicalOperands: true,
32+
}]
33+
},
2834
},
2935
{
3036
ignores: ['node-modules'],

tools/spectral/ipa/rulesets/functions/IPA110CollectionsRequestIncludeCountNotRequired.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,12 @@ export default (input, _, { path, documentInventory }) => {
2525
return;
2626
}
2727

28-
const parameters = input.parameters;
29-
if (!parameters) {
30-
return;
31-
}
32-
33-
const includeCountParam = parameters.find((p) => p.name === 'includeCount' && p.in === 'query');
34-
28+
const includeCountParam = input?.parameters?.find((p) => p.name === 'includeCount' && p.in === 'query');
3529
if (!includeCountParam) {
3630
return;
3731
}
3832

39-
if (includeCountParam.required === true) {
33+
if (includeCountParam.required) {
4034
return collectAndReturnViolation(path, RULE_NAME, ERROR_MESSAGE);
4135
}
4236

tools/spectral/ipa/rulesets/functions/IPA110CollectionsResponseDefineLinksArray.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,7 @@ export default (input, _, { path, documentInventory }) => {
5050

5151
function checkViolationsAndReturnErrors(listResponseSchema, oas, path) {
5252
try {
53-
const hasLinksArray =
54-
listResponseSchema.properties &&
55-
listResponseSchema.properties.links &&
56-
listResponseSchema.properties.links.type === 'array';
53+
const hasLinksArray = listResponseSchema.properties?.links?.type === 'array';
5754

5855
if (!hasLinksArray) {
5956
return [

tools/spectral/ipa/rulesets/functions/utils/schemaUtils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* @returns true if schema object returns results property (pagination), false otherwise
55
*/
66
export function schemaIsPaginated(schema) {
7-
const hasResultsArray = schema.properties && schema.properties.results && schema.properties.results.type === 'array';
7+
const hasResultsArray = schema.properties?.results?.type === 'array';
88

99
return hasResultsArray;
1010
}

0 commit comments

Comments
 (0)