Commit aa9ac23e authored by Paul Slaughter's avatar Paul Slaughter

Fix eslint broken for Jest

**What happened?**
Previously we just checked the immediate parent
to see if the module was being included from eslint.
Now we recursively check all the parents.

Also moves this eslint check to it's own config/helper
parent 0b8ad496
/**
* Returns true if the given module is required from eslint
*/
const isESLint = mod => {
let parent = mod.parent;
while (parent) {
if (parent.filename.includes('/eslint')) {
return true;
}
parent = parent.parent;
}
return false;
};
module.exports = isESLint;
const IS_EE = require('./config/helpers/is_ee_env'); const IS_EE = require('./config/helpers/is_ee_env');
const isESLint = require('./config/helpers/is_eslint');
module.exports = path => { module.exports = path => {
const reporters = ['default']; const reporters = ['default'];
...@@ -24,9 +25,7 @@ module.exports = path => { ...@@ -24,9 +25,7 @@ module.exports = path => {
// workaround for eslint-import-resolver-jest only resolving in test files // workaround for eslint-import-resolver-jest only resolving in test files
// see https://github.com/JoinColony/eslint-import-resolver-jest#note // see https://github.com/JoinColony/eslint-import-resolver-jest#note
const { filename: parentModuleName } = module.parent; if (isESLint(module)) {
const isESLint = parentModuleName && parentModuleName.includes('/eslint-import-resolver-jest/');
if (isESLint) {
testMatch = testMatch.map(path => path.replace('_spec.js', '')); testMatch = testMatch.map(path => path.replace('_spec.js', ''));
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment