Skip to content

Commit

Permalink
allow hoc and context
Browse files Browse the repository at this point in the history
  • Loading branch information
marcaaron committed Nov 11, 2021
1 parent 991e1c1 commit 4516862
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion eslint-plugin-expensify/prefer-import-module-contents.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,22 @@ function hasPropTypesSpecifier(specifiers) {
return _.some(specifiers, specifier => /proptypes/.test(lodashGet(specifier, 'imported.name', '').toLowerCase()));
}

/**
* @param {String} source
* @returns {Boolean}
*/
function isHigherOrderComponent(source) {
return /with/.test(source.toLowerCase());
}

/**
* @param {String} source
* @returns {Boolean}
*/
function isContextComponent(source) {
return /context/.test(source.toLowerCase());
}

module.exports = {
create: context => ({
ImportDeclaration(node) {
Expand All @@ -36,7 +52,7 @@ module.exports = {
return;
}

if (isFromNodeModules(sourceValue)) {
if (isFromNodeModules(sourceValue) || isHigherOrderComponent(sourceValue) || isContextComponent(sourceValue)) {
return;
}

Expand Down

0 comments on commit 4516862

Please sign in to comment.