Skip to content

Commit

Permalink
Update check-telco-specific-terms.js
Browse files Browse the repository at this point in the history
  • Loading branch information
VijayKesharwani authored Oct 27, 2023
1 parent 37f2b16 commit 2266b98
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions lint_function/check-telco-specific-terms.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,38 @@
export default async function (input) {
const errors = [];
const suggestions = [];
let mobileNetworkFound = false;
let msisdnFound = false;
const replacements = [
{ original: 'mobile network', recommended: 'network' },
{ original: 'MSISDN', recommended: 'phone number' }
];

const termFlags = {}; // Store flags for each replacement term

// Initialize flags to false for all replacement terms
replacements.forEach(replacement => {
termFlags[replacement.original] = false;
});

// 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') {
if (value.includes('mobile network') && !mobileNetworkFound) {
errors.push({ original: 'mobile network', recommended: 'network' });
suggestions.push(`Consider replacing 'mobile network' with 'network'.`);
mobileNetworkFound = true;
}
for (const replacement of replacements) {
const original = replacement.original;

if (value.includes('MSISDN') && !msisdnFound) {
errors.push({ original: 'MSISDN', recommended: 'phone number' });
suggestions.push(`Consider replacing 'MSISDN' with 'phone number'.`);
msisdnFound = true;
// Check if the term is not flagged and exists in the value
if (!termFlags[original] && value.includes(original)) {
errors.push(replacement);
suggestions.push(`Consider replacing '${original}' with '${replacement.recommended}'.`);
termFlags[original] = true; // Set the flag to true
}
}
}
}

// Check if any word from 'replacements' is in the suggestions
// Check if any words from 'replacements' are in the suggestions
if (errors.length > 0) {
console.log('Hint: Telco-specific terminology found in input: ' + suggestions.join(', '));
}
Expand Down

0 comments on commit 2266b98

Please sign in to comment.