From e2ace5a79ed6c8f082586d6d986520ce0eb341a4 Mon Sep 17 00:00:00 2001 From: Norman Rusch Date: Fri, 11 Oct 2024 09:38:17 +0200 Subject: [PATCH] Apply stylistic changes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Barthélemy Laurans --- src/Validator.js | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/src/Validator.js b/src/Validator.js index 8701755..b885c28 100644 --- a/src/Validator.js +++ b/src/Validator.js @@ -256,27 +256,17 @@ class Validator { // Merge editorconfig values into the correct settings names: for (key in config) { if (typeof MAPPINGS[key] === 'object') { - // Disable the setting for "unset" values from editorconfig. - // See: Issue #47 - if (config[key] === 'unset') { - this._settings[MAPPINGS[key].name] = false; - continue; - } - - // Disable the setting for invalid types from editorconfig. - // See: Issue #47 - if (!MAPPINGS[key].types.includes(typeof config[key])) { - this._settings[MAPPINGS[key].name] = false; - continue; - } - - // Disable the setting for invalid string values from editorconfig - // by testing against a regular expression. + // Handle "unset" special value given by editorconfig file + // and consider not to parse invalid types and value. // See: Issue #47 if ( - typeof config[key] === 'string' && - MAPPINGS[key].regexp instanceof RegExp && - !MAPPINGS[key].regexp.test(config[key]) + config[key] === 'unset' || + !MAPPINGS[key].types.includes(typeof config[key]) || + ( + typeof config[key] === 'string' && + MAPPINGS[key].regexp instanceof RegExp && + !MAPPINGS[key].regexp.test(config[key]) + ) ) { this._settings[MAPPINGS[key].name] = false; continue;