Skip to content

Commit

Permalink
Create camara-language-avoid-telco.js
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-murray authored Oct 10, 2024
1 parent ca586dd commit 8aafec6
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions lint_function/camara-language-avoid-telco.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// CAMARA Project - support function for Spectral linter
// 31.01.2024 - initial version

const replacements = [
{ original: 'UE', recommended: 'device' },
{ original: 'MSISDN', recommended: 'phone number' },
{ original: 'mobile network', recommended: 'network' }
];

export default async function (input) {
const errors = [];
const suggestions = [];

// Iterate over properties of the input object
for (const path in input) {
const value = input[path];

// Check if the value is a string
if (typeof value === 'string') {
for (const replacement of replacements) {
const original = replacement.original;
const recommended = replacement.recommended;

// Use a regular expression to match 'original' as a standalone word
const regex = new RegExp(`\\b${original}\\b`, 'g');

// Check if 'original' exists in the value
if (regex.test(value)) {
errors.push(replacement);
suggestions.push(` Telco-specific terminology found in input: Consider replacing '${original}' with '${recommended}'.`);
}
}
}
}

// Check if any word from 'replacements' is in the suggestions
if (errors.length > 0) {
console.log(`Hint camara-language-avoid-telco ` + suggestions.join(', '));
}
};

0 comments on commit 8aafec6

Please sign in to comment.