-
Notifications
You must be signed in to change notification settings - Fork 244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/linter optimizer checks #901
Conversation
I wonder if we should somehow add the recommendation to the linter rule (for example in the info field). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅ Few nits. But otherwise looks good.
|
||
export class IsTransformedAmp extends Rule { | ||
run({ $ }: Context) { | ||
const isTransformed = $("html[transformed='self;v=1']").length > 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checking for the presence of transformed
is enough. The content might change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
|
||
export class ModuleRuntimeUsed extends Rule { | ||
run({ $ }: Context) { | ||
const isTransformed = $("html[transformed='self;v=1']").length > 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might make sense to extract this into a helper method. We'll need it more often.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
return this.pass(); | ||
} | ||
const isModuleVersion = | ||
$("script[type='module'][src='https://cdn.ampproject.org/v0.mjs']") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just check for /v0.mjs
to support runtime self-hosting in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
return isModuleVersion | ||
? this.pass() | ||
: this.warn( | ||
"The Java Script module version of the AMP Runtime is not used" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/Java Script/JavaScript
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Build failure is unrelated |
Implementing linter page experience checks for