Skip to content

Commit dafe953

Browse files
prettier fix
1 parent 81a2d23 commit dafe953

File tree

5 files changed

+22
-25
lines changed

5 files changed

+22
-25
lines changed

tools/spectral/ipa/__tests__/eachPathAlternatesBetweenResourceNameAndPathParam.test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ testRule('xgen-IPA-102-path-alternate-resource-name-path-param', [
3232
},
3333
'/api/atlas/v2': {
3434
post: {},
35-
}
35+
},
3636
},
3737
},
3838
errors: [],
@@ -67,7 +67,7 @@ testRule('xgen-IPA-102-path-alternate-resource-name-path-param', [
6767
},
6868
'/api/atlas/v2/unauth': {
6969
post: {},
70-
}
70+
},
7171
},
7272
},
7373
errors: [],
@@ -99,7 +99,7 @@ testRule('xgen-IPA-102-path-alternate-resource-name-path-param', [
9999
'/api/atlas/v2/{pathParam1}/{pathParam2}': {
100100
post: {},
101101
get: {},
102-
}
102+
},
103103
},
104104
},
105105
errors: [
@@ -139,7 +139,7 @@ testRule('xgen-IPA-102-path-alternate-resource-name-path-param', [
139139
path: ['paths', '/api/atlas/v2/{pathParam1}/{pathParam2}'],
140140
severity: DiagnosticSeverity.Warning,
141141
},
142-
]
142+
],
143143
},
144144
{
145145
name: 'invalid paths - api/atlas/v2/unauth',
@@ -168,7 +168,7 @@ testRule('xgen-IPA-102-path-alternate-resource-name-path-param', [
168168
'/api/atlas/v2/unauth/{pathParam1}/{pathParam2}': {
169169
post: {},
170170
get: {},
171-
}
171+
},
172172
},
173173
},
174174
errors: [

tools/spectral/ipa/rulesets/IPA-102.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ functions:
66

77
rules:
88
xgen-IPA-102-path-alternate-resource-name-path-param:
9-
description: "Paths should alternate between resource names and path params. http://go/ipa/102"
10-
message: "{{error}} http://go/ipa/102"
9+
description: 'Paths should alternate between resource names and path params. http://go/ipa/102'
10+
message: '{{error}} http://go/ipa/102'
1111
severity: warn
12-
given: "$.paths"
12+
given: '$.paths'
1313
then:
14-
field: "@key"
15-
function: "eachPathAlternatesBetweenResourceNameAndPathParam"
14+
field: '@key'
15+
function: 'eachPathAlternatesBetweenResourceNameAndPathParam'

tools/spectral/ipa/rulesets/IPA-104.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ functions:
66

77
rules:
88
xgen-IPA-104-resource-has-GET:
9-
description: "APIs must provide a get method for resources. http://go/ipa/104"
10-
message: "{{error}} http://go/ipa/104"
9+
description: 'APIs must provide a get method for resources. http://go/ipa/104'
10+
message: '{{error}} http://go/ipa/104'
1111
severity: warn
12-
given: "$.paths"
12+
given: '$.paths'
1313
then:
14-
field: "@key"
15-
function: "eachResourceHasGetMethod"
14+
field: '@key'
15+
function: 'eachResourceHasGetMethod'

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

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { isPathParam } from './utils/pathUtils';
22

33
const ERROR_MESSAGE = 'API paths must alternate between resource name and path params.';
44
const ERROR_RESULT = [{ message: ERROR_MESSAGE }];
5-
const AUTH_PREFIX = "/api/atlas/v2";
6-
const UNAUTH_PREFIX = "/api/atlas/v2/unauth"
5+
const AUTH_PREFIX = '/api/atlas/v2';
6+
const UNAUTH_PREFIX = '/api/atlas/v2/unauth';
77

88
const getPrefix = (path) => {
99
if (path.includes(UNAUTH_PREFIX)) return UNAUTH_PREFIX;
@@ -14,9 +14,7 @@ const getPrefix = (path) => {
1414
const validatePathStructure = (elements) => {
1515
return elements.every((element, index) => {
1616
const isEvenIndex = index % 2 === 0;
17-
return isEvenIndex
18-
? !isPathParam(element)
19-
: isPathParam(element);
17+
return isEvenIndex ? !isPathParam(element) : isPathParam(element);
2018
});
2119
};
2220

@@ -26,12 +24,11 @@ export default (input, _0, _1) => {
2624
if (!prefix) return [];
2725

2826
let suffixWithLeadingSlash = input.slice(prefix.length);
29-
if(suffixWithLeadingSlash.length === 0) {
27+
if (suffixWithLeadingSlash.length === 0) {
3028
return [];
3129
}
3230

3331
let suffix = suffixWithLeadingSlash.slice(1);
34-
let elements = suffix.split("/");
32+
let elements = suffix.split('/');
3533
return validatePathStructure(elements) ? [] : ERROR_RESULT;
36-
37-
}
34+
};

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ export function isPathParam(str) {
22
const pathParamRegEx = new RegExp(`^{[a-z][a-zA-Z0-9]*}$`);
33
const pathParamWithCustomMethodRegEx = new RegExp(`^{[a-z][a-zA-Z0-9]*}:[a-z][a-zA-Z0-9]*$`);
44
return pathParamRegEx.test(str) || pathParamWithCustomMethodRegEx.test(str);
5-
}
5+
}

0 commit comments

Comments
 (0)