Skip to content

Commit

Permalink
updating to look nice output
Browse files Browse the repository at this point in the history
  • Loading branch information
VijayKesharwani authored Oct 19, 2023
1 parent 69db0c4 commit 421f3b5
Showing 1 changed file with 19 additions and 30 deletions.
49 changes: 19 additions & 30 deletions lint_function/check-spelling-code.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,23 @@ function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
export default async function (input) {
return new Promise((resolve, reject) => {
dictionary ((err, dict) => {
if (err) {
reject(err);
return;
}
var spell = nspell(dict)
var no_special_characters= input.replace(/[^\w\s]/gi, '')
const words = no_special_characters.split(separatorsRegex);
var errors= words
.filter((word) => !exceptions.includes(word))
.filter((word) => !spell.correct(word))
.filter((word) => !word == '')
.filter((word) => !includesNumber(word));

if (errors.length > 0) {
// Concatenate all spelling mistakes into a single string
const mistakesString = errors.join(', ');
// Print the mistakes
console.log("There was a spelling mistake: " + mistakesString);
resolve([{
message: `Spelling mistakes found: ${mistakesString}`,
}]);
} else {
resolve([{
message: "No spelling mistakes found!",
}]);
}
})
})
dictionary ((err, dict) => {
if (err) {
throw err;
}
var spell = nspell(dict)
var no_special_characters= input.replace(/[^\w\s]/gi, '')
const words = no_special_characters.split(separatorsRegex);
var errors= words
.filter((word) => !exceptions.includes(word))
.filter((word) => !spell.correct(word))
.filter((word) => !word == '')
.filter((word) => !includesNumber(word));

if ((errors.length > 0) && (mistakes[mistakes.length-1] != errors[errors.length-1])) {
mistakes.push(errors);
errors = [];
console.log("There was a spelling mistake: " + mistakes);
}
})
};

0 comments on commit 421f3b5

Please sign in to comment.