Skip to content

Commit

Permalink
馃悰 Report conformance config violations as errors (ampproject#22914)
Browse files Browse the repository at this point in the history
* Report conformance config violations as errors

Re: ampproject#22822 (comment)

Fixes ampproject#22822

* Fix conformance violations

* Temporarily disable Node.p.after ban
  • Loading branch information
jridgewell committed Jun 20, 2019
1 parent 23986bc commit 7c93c79
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 20 deletions.
1 change: 1 addition & 0 deletions build-system/compile/compile.js
Expand Up @@ -371,6 +371,7 @@ function compile(entryModuleFilenames, outputDir, outputFilename, options) {
// it won't do strict type checking if its whitespace only.
compilerOptions.define.push('TYPECHECK_ONLY=true');
compilerOptions.jscomp_error.push(
'conformanceViolations',
'checkTypes',
'accessControls',
'const',
Expand Down
16 changes: 9 additions & 7 deletions build-system/conformance-config.textproto
Expand Up @@ -258,6 +258,7 @@ requirement: {
whitelist: 'src/web-worker/web-worker.js'
# Allowing violations in ads code for now.
# We would have to fix this to property obfuscated the 3p frame code.
whitelist: '3p/iframe-messaging-client.js'
whitelist: 'ads/google/deprecated_doubleclick.js'
whitelist: 'ads/google/imaVideo.js'
}
Expand Down Expand Up @@ -348,10 +349,11 @@ requirement: {
whitelist: 'extensions/amp-date-picker/0.1/dates-list.js'
}

requirement: {
type: BANNED_PROPERTY_CALL
error_message: 'ChildNode.p.after() is unusual. Please use Node.p.insertBefore()'
value: 'Element.prototype.after'
value: 'DocumentType.prototype.after'
value: 'CharacterData.prototype.after'
}
# TODO(rsimha): Reenable when we move RRule to a node module.
# requirement: {
# type: BANNED_PROPERTY_CALL
# error_message: 'ChildNode.p.after() is unusual. Please use Node.p.insertBefore()'
# value: 'Element.prototype.after'
# value: 'DocumentType.prototype.after'
# value: 'CharacterData.prototype.after'
# }
12 changes: 6 additions & 6 deletions extensions/amp-auto-ads/0.1/anchor-ad-strategy.js
Expand Up @@ -88,19 +88,19 @@ export class AnchorAdStrategy {
* @private
*/
isFilledAnchorAdEnabled_() {
return (this.configObj_['optInStatus'] || []).includes(
OptInStatus.OPT_IN_STATUS_ANCHOR_ADS
);
return user()
.assertArray(this.configObj_['optInStatus'] || [])
.includes(OptInStatus.OPT_IN_STATUS_ANCHOR_ADS);
}

/**
* @return {boolean}
* @private
*/
isNoFillAnchorAdEnabled_() {
return (this.configObj_['optInStatus'] || []).includes(
OptInStatus.OPT_IN_STATUS_NO_FILL_ANCHOR_ADS
);
return user()
.assertArray(this.configObj_['optInStatus'] || [])
.includes(OptInStatus.OPT_IN_STATUS_NO_FILL_ANCHOR_ADS);
}

/**
Expand Down
Expand Up @@ -30,9 +30,7 @@ export class AllowedAttributeMutationEntry {
* @return {boolean}
*/
validate(mutationRecord) {
if (mutationRecord['value']) {
return true;
}
return !!mutationRecord['value'];
}

/**
Expand Down
4 changes: 3 additions & 1 deletion extensions/amp-geo/0.1/amp-geo.js
Expand Up @@ -343,7 +343,9 @@ export class AmpGeo extends AMP.BaseElement {
const {classList} = body;
// Always remove the pending class
classesToRemove.push('amp-geo-pending');
classesToRemove.forEach(toRemove => classList.remove(toRemove));
classesToRemove.forEach(toRemove => {
/** @type {!DOMTokenList} */ (classList).remove(toRemove);
});

// add the new classes to <body>
classesToAdd.forEach(toAdd => classList.add(toAdd));
Expand Down
7 changes: 4 additions & 3 deletions extensions/amp-story/1.0/page-advancement.js
Expand Up @@ -541,9 +541,10 @@ class ManualAdvancement extends AdvancementConfig {
*/
isHandledByEmbeddedComponent_(event, pageRect) {
const target = dev().assertElement(event.target);
const inExpandedMode =
this.storeService_.get(StateProperty.INTERACTIVE_COMPONENT_STATE)
.state === EmbeddedComponentState.EXPANDED;
const stored = /** @type {InteractiveComponentDef} */ (this.storeService_.get(
StateProperty.INTERACTIVE_COMPONENT_STATE
));
const inExpandedMode = stored.state === EmbeddedComponentState.EXPANDED;

return (
inExpandedMode ||
Expand Down

0 comments on commit 7c93c79

Please sign in to comment.