Skip to content

Gulp Dep Check: fail on unused entries#26981

Merged
samouri merged 6 commits intoampproject:masterfrom
samouri:clean-dep-check
Feb 26, 2020
Merged

Gulp Dep Check: fail on unused entries#26981
samouri merged 6 commits intoampproject:masterfrom
samouri:clean-dep-check

Conversation

@samouri
Copy link
Copy Markdown
Member

@samouri samouri commented Feb 26, 2020

summary
We have have a presubmit check called check-deps that ensures modules only depend on those that they should. While it does its job well, there is an issue facing it now where unused rule-exceptions are allowed to stay. This means that it is all too easy to have the file grow indefinitely.

This Pull Request adds in the a new type of error for allowlisted entries that are unused. It also removes all the currently unused rule-exceptions.

Interestingly enough, this check can help prevent us from making errors during refactors. Specifically I noticed that our DOMPurify code was refactored/moved around but the checks were never updated to the new filepaths.

question
Who should we bring in to verify that each of these removals from the dep config actually make sense and are not errors. I happened to be able to catch the DOMPurify mistake because I had context there, but I'm worried refactors could have caused some of these other unused exceptions (and they just need their paths updated)
answer: a rule with 100% unused rules would have been a clear sign of this mistake. purify was the only case.

cc @ampproject/wg-infra

@samouri samouri requested a review from rsimha February 26, 2020 17:22
@samouri samouri self-assigned this Feb 26, 2020
Copy link
Copy Markdown
Contributor

@rsimha rsimha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really cool PR. Thanks for doing this!

Who should we bring in to verify that each of these removals from the dep config actually make sense and are not errors. I happened to be able to catch the DOMPurify mistake because I had context there, but I'm worried refactors could have caused some of these other unused exceptions (and they just need their paths updated)

With your refactor, gulp dep-check should be self-checking in this regard. If there are missing entries or unnecessary entries, the check should fail on Travis.

Comment on lines +448 to +455
/** DO NOT ADD TO allowlist */
'ads/ix.js->ads/google/doubleclick.js',
'ads/imonomy.js->ads/google/doubleclick.js',
'ads/navegg.js->ads/google/doubleclick.js',
/** DO NOT ADD TO WHITELIST */
/** DO NOT ADD TO allowlist */
'ads/openx.js->ads/google/doubleclick.js',
'ads/pulsepoint.js->ads/google/doubleclick.js',
/** DO NOT ADD TO WHITELIST */
/** DO NOT ADD TO allowlist */
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These three should probably be all caps.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah darn i missed this. tiny followup incoming!

@samouri samouri merged commit 93f439b into ampproject:master Feb 26, 2020
@samouri samouri deleted the clean-dep-check branch February 26, 2020 22:04
robinvanopstal added a commit to jungvonmatt/amphtml that referenced this pull request Feb 27, 2020
* master: (54 commits)
  inabox-resources: Minor test improvement (ampproject#26916)
  DocInfo: replace metaTags with viewport in API (ampproject#26687)
  🐛 SwG now uses AMP sendBeacon interface (ampproject#26970)
  🏗 Allow array destructuring on preact hooks (ampproject#26901)
  Gulp Dep Check: fail on unused entries (ampproject#26981)
  Update no-import lint rule to forbid sub-paths (ampproject#26531)
  🐛 amp-ad type blade - fix bladeOnLoad callback (ampproject#26627)
  📖 Clarify when max-age is required (ampproject#26956)
  ♻️ Consolidate players as .i-amphtml-media-component (ampproject#26967)
  Add Preact Enzyme tests (ampproject#26529)
  Fixes `update_tests` flag on `gulp validator` (ampproject#26965)
  📦 Update dependency google-closure-library to v20200224 (ampproject#26986)
  🏗 Transform aliased configured components (ampproject#26541)
  ✨ InaboxResources: Observe intersections for some elements' viewportCallbacks (ampproject#26942)
  variable substitutions: Support allowlist lookup in AmpDocShadow (ampproject#26731)
  cl/297197875 Revision bump for ampproject#26877 (ampproject#26982)
  Json fix (ampproject#26971)
  📦 Update dependency mocha to v7.1.0 (ampproject#26976)
  Add documentation for amp-access-scroll (ampproject#26782)
  make controls always shown in amp for email (ampproject#25714)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants