Skip to content

Commit

Permalink
Update packages/kbn-eslint-plugin-eslint/rules/module_migration.js
Browse files Browse the repository at this point in the history
Co-authored-by: Spencer <[email protected]>
  • Loading branch information
thompsongl and Spencer authored Jul 6, 2021
1 parent 8bdfd6b commit cc91272
Showing 1 changed file with 11 additions and 21 deletions.
32 changes: 11 additions & 21 deletions packages/kbn-eslint-plugin-eslint/rules/module_migration.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,30 +101,20 @@ module.exports = {
],
},
create: (context) => {
const _mappings = context.options[0];
const filename = path.relative(KIBANA_ROOT, context.getFilename());

const mappings = _mappings.filter((mapping) => {
if (mapping.include || mapping.exclude) {
if (mapping.include) {
let include = false;
mapping.include.forEach((rgx) => {
if (rgx.test(filename)) {
include = true;
}
});
return include;
}
if (mapping.exclude) {
let include = true;
mapping.exclude.forEach((rgx) => {
if (rgx.test(filename)) {
include = false;
}
});
return include;
}
const mappings = context.options[0].filter((mapping) => {
// exclude mapping rule if it is explicitly excluded from this file
if (mapping.exclude && mapping.exclude.some((p) => p.test(filename))) {
return false;
}

// if this mapping rule is only included in specific files, optionally include it
if (mapping.include) {
return mapping.include.some((p) => p.test(filename));
}

// include all mapping rules by default
return true;
});

Expand Down

0 comments on commit cc91272

Please sign in to comment.