Prebid.js icon indicating copy to clipboard operation
Prebid.js copied to clipboard

Build system: do not allow cross-module imports

Open dgirardi opened this issue 3 years ago • 5 comments

Type of change

  • [x] Build related changes

Description of change

This updates the validate-imports eslint plugin to fix an edge case where cross-module imports would sometimes be allowed if the imported module is a directory.

dgirardi avatar Apr 18 '22 18:04 dgirardi

These adapters now fail the lint check because they import {createEidsArray} from 'userId/eids.js':

/home/circleci/Prebid.js/modules/adagioBidAdapter.js
  30:1  error  import "./userId/eids.js": importing from modules is not allowed  prebid/validate-imports

/home/circleci/Prebid.js/modules/adyoulikeBidAdapter.js
  4:1  error  import "./userId/eids.js": importing from modules is not allowed  prebid/validate-imports

/home/circleci/Prebid.js/modules/bluebillywigBidAdapter.js
  7:1  error  import "./userId/eids.js": importing from modules is not allowed  prebid/validate-imports

/home/circleci/Prebid.js/modules/connectadBidAdapter.js
  5:1  error  import "./userId/eids.js": importing from modules is not allowed  prebid/validate-imports

/home/circleci/Prebid.js/modules/impactifyBidAdapter.js
  5:1  error  import "./userId/eids.js": importing from modules is not allowed  prebid/validate-imports

/home/circleci/Prebid.js/modules/improvedigitalBidAdapter.js
  9:1  error  import "./userId/eids.js": importing from modules is not allowed  prebid/validate-imports

/home/circleci/Prebid.js/modules/mediakeysBidAdapter.js
  25:1  error  import "./userId/eids.js": importing from modules is not allowed  prebid/validate-imports

/home/circleci/Prebid.js/modules/onetagBidAdapter.js
  9:1  error  import "./userId/eids.js": importing from modules is not allowed  prebid/validate-imports

/home/circleci/Prebid.js/modules/sharethroughBidAdapter.js
  5:1  error  import "./userId/eids.js": importing from modules is not allowed  prebid/validate-imports

/home/circleci/Prebid.js/modules/smartadserverBidAdapter.js
  4:1  error  import "./userId/eids.js": importing from modules is not allowed  prebid/validate-imports

/home/circleci/Prebid.js/modules/sortableBidAdapter.js
  5:1  error  import "./userId/eids.js": importing from modules is not allowed  prebid/validate-imports

/home/circleci/Prebid.js/modules/sovrnBidAdapter.js
  4:1  error  import "./userId/eids.js": importing from modules is not allowed  prebid/validate-imports

/home/circleci/Prebid.js/modules/ttdBidAdapter.js
  3:1  error  import "./userId/eids.js": importing from modules is not allowed  prebid/validate-imports

/home/circleci/Prebid.js/modules/yieldmoBidAdapter.js
  20:1  error  import "./userId/eids.js": importing from modules is not allowed  prebid/validate-imports

so there's more work involved in fixing that - keeping this in draft for now.

dgirardi avatar Apr 18 '22 19:04 dgirardi

so can createEidsArray return empty from core and userid can overwrite it?

patmmccann avatar Apr 25 '22 18:04 patmmccann

@patmmccann adapters are supposed to take ids from the request, e.g. bid.userIdsAsEids. What must have happened is that one of them accidentally imported that and then others followed suit.

The effect of this is that every one of those adapters will have that logic duplicated in their module file.

dgirardi avatar Apr 25 '22 18:04 dgirardi

this was the original intention of the validate-imports plugin so the change looks good to me as soon as the adapters are updated.

snapwich avatar Jun 08 '22 16:06 snapwich

@caseywhitmire https://github.com/prebid/Prebid.js/blob/2ee4d3f21f5767734222d0298d3b538e6cc3c859/modules/userId/index.js#L497 does the same conversion most of the adapters that fail the lint check do; could you help us by cleaning that up in a pr to dgirardi:better-validate-imports so we can get this pr knocked out?

patmmccann avatar Aug 11 '22 12:08 patmmccann

linking #8539 for possible enforcement

patmmccann avatar Jan 11 '23 18:01 patmmccann