Skip to content

Commit

Permalink
Apply stylistic changes
Browse files Browse the repository at this point in the history
Co-authored-by: Barthélemy Laurans <barthelemy.laurans.external@salomon.com>
  • Loading branch information
schorfES and Barthélemy Laurans committed Oct 15, 2024
1 parent 3faec2d commit e2ace5a
Showing 1 changed file with 9 additions and 19 deletions.
28 changes: 9 additions & 19 deletions src/Validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit e2ace5a

Please sign in to comment.