diff --git a/bin/run.js b/bin/run.js index 294aa00..ed962fb 100644 --- a/bin/run.js +++ b/bin/run.js @@ -80,13 +80,17 @@ program .option('-r, --rules "rule1, rule2, ..."', 'languagetools rules', '') .option('-l, --language ', 'A language code like en-US, de-DE, fr, or auto to guess the language automatically', 'auto') .option('-f, --file ', 'Destination', '/content/wrong_words.txt') + .option('-i, --ignore ', 'Path to file with ignore contexts', '/content/ignore') .action((dirPath = '/content', filePath, options) => { exec(serverStartCommand, () => setTimeout(async () => { const rules = options.rules.split(',').map((item) => item.trim()).filter((item) => item); const language = options.language; + const ignorePath = options.ignore; const errors = await getErrors(dirPath, language, rules); - writeIgnoreErrorsFile(errors, filePath); + const filtered = filterIgnoredErrors(errors, ignorePath); + + writeIgnoreErrorsFile(filtered, filePath); }, 5000)); }); diff --git a/ignore_dictionary.txt b/ignore_dictionary.txt index ecc47f8..92137b7 100644 --- a/ignore_dictionary.txt +++ b/ignore_dictionary.txt @@ -112,3 +112,5 @@ javascript hexlet linter тернарника +авторизируют +гитхабе diff --git a/src/index.js b/src/index.js index cdec56d..3363f04 100644 --- a/src/index.js +++ b/src/index.js @@ -209,7 +209,7 @@ const formatError = (error, isColored) => { } = error; const fileLineMessage = formatMessage(getLineError(error), isColored && 'blue'); - const contextMessage = formatContextMessage(match.context.text, match.context.offset, match.context.length); + const contextMessage = formatContextMessage(match.context.text, match.context.offset, match.context.length, isColored); const errorMessage = formatMessage(match.message, isColored && 'red'); @@ -249,7 +249,7 @@ const writeIgnoreErrorsFile = (errors, ignoreFilePath) => { const formatedErrors = formatErrors(errors); const result = formatedErrors.join(errorDelimeter); - fs.writeFileSync(ignoreFilePath, result, 'utf-8'); + fs.appendFile(`${ignoreFilePath}${errorDelimeter}`, result, 'utf-8'); }; export {