Skip to content

Commit

Permalink
Create camara-casing-convention.js
Browse files Browse the repository at this point in the history
  • Loading branch information
VijayKesharwani authored Oct 31, 2023
1 parent c1befcb commit 6128afb
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions lint_function/camara-casing-convention.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
function isCamelCase(str) {
// Regular expression to match valid camel case identifiers
const camelCaseRegex = /^[a-z][a-zA-Z0-9]*$/;
return camelCaseRegex.test(str);
}

export default async function (input) {
for (const path in input.paths) {
const pathObject = input.paths[path];
for (const method in pathObject) {
const operation = pathObject[method];
if (operation.operationId) {
if (!isCamelCase(operation.operationId)) {
console.warn(`WARN: Operation ID "${operation.operationId}" in path "${path}" does not follow camel case convention.`);
}
}
}
}
};

0 comments on commit 6128afb

Please sign in to comment.