Skip to content

Commit

Permalink
feat(apidom-ls): make variable names explicit
Browse files Browse the repository at this point in the history
  • Loading branch information
kowalczyk-krzysztof committed Dec 15, 2023
1 parent 9d61642 commit 169f0d6
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions packages/apidom-ls/src/services/validation/linter-functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1017,26 +1017,24 @@ export const standardLinterfunctions: FunctionItem[] = [
}

const parameterElements: Element[] = [];

const isParameterPolymorphicCheck = (el: Element): boolean => el.element === 'parameter';
const isParameterElement = (el: Element): boolean => el.element === 'parameter';

pathItemElement.forEach((el) => {
if (el.element === 'parameters') {
const parametersObject = pathItemElement.get('parameters');
if (isArrayElement(parametersObject)) {
parametersObject.forEach((parameter) => {
if (isParameterPolymorphicCheck(parameter)) {
const pathItemParameterElements = pathItemElement.get('parameters');
if (isArrayElement(pathItemParameterElements)) {
pathItemParameterElements.forEach((parameter) => {
if (isParameterElement(parameter)) {
parameterElements.push(parameter);
}
});
}
}
if (el.element === 'operation') {
// @ts-ignore
const parameters = el.get('parameters');
if (isArrayElement(parameters)) {
parameters.forEach((parameter) => {
if (isParameterPolymorphicCheck(parameter)) {
const operationParameterElements = (el as ObjectElement).get('parameters');
if (isArrayElement(operationParameterElements)) {
operationParameterElements.forEach((parameter) => {
if (isParameterElement(parameter)) {
parameterElements.push(parameter);
}
});
Expand All @@ -1045,13 +1043,12 @@ export const standardLinterfunctions: FunctionItem[] = [
});

const allowedLocation = ['path', 'query'];
const pathTemplateResolveParams: { [key: string]: string } = {};
const pathTemplateResolveParams: { [key: string]: 'placeholder' } = {};

parameterElements.forEach((parameter) => {
// @ts-ignore
if (allowedLocation.includes(toValue(parameter.in))) {
// @ts-ignore
pathTemplateResolveParams[toValue(parameter.name) as string] = 'placeholder';
if (allowedLocation.includes(toValue((parameter as ObjectElement).get('in')))) {
pathTemplateResolveParams[toValue((parameter as ObjectElement).get('name'))] =
'placeholder';
}
});

Expand Down

0 comments on commit 169f0d6

Please sign in to comment.