From f23b914bd629e9dc29afd865517626f04e57b490 Mon Sep 17 00:00:00 2001 From: Sebastian Benz Date: Thu, 17 Dec 2020 14:09:28 +0100 Subject: [PATCH] Improve viewport check (#1116) * warn instead of fail on tap delay * add viewport check to websites and stories * improve wording * update test --- packages/linter/src/index.ts | 2 ++ packages/linter/src/rules/ViewportDisablesTapDelay.ts | 6 ++++-- packages/linter/tests/local.test.ts | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/linter/src/index.ts b/packages/linter/src/index.ts index 2338cf51a..b263688e9 100644 --- a/packages/linter/src/index.ts +++ b/packages/linter/src/index.ts @@ -116,6 +116,7 @@ function testsForMode(type: LintMode) { AmpImgAmpPixelPreferred, EndpointsAreAccessibleFromOrigin, EndpointsAreAccessibleFromCache, + ViewportDisablesTapDelay, ]); tests.set( LintMode.AmpStory, @@ -131,6 +132,7 @@ function testsForMode(type: LintMode) { VideosHaveAltText, VideosAreSubtitled, TitleMeetsLengthCriteria, + ViewportDisablesTapDelay, ]) ); tests.set( diff --git a/packages/linter/src/rules/ViewportDisablesTapDelay.ts b/packages/linter/src/rules/ViewportDisablesTapDelay.ts index 8c08d8b84..1fe88c39b 100644 --- a/packages/linter/src/rules/ViewportDisablesTapDelay.ts +++ b/packages/linter/src/rules/ViewportDisablesTapDelay.ts @@ -8,7 +8,9 @@ export class ViewportDisablesTapDelay extends Rule { return this.pass(); } return viewport.attribs.content !== "width=device-width" - ? this.fail(`Viewport width not set to device width`) + ? this.warn( + `Viewport width is not set to device width: ''` + ) : this.pass(); } meta() { @@ -16,7 +18,7 @@ export class ViewportDisablesTapDelay extends Rule { url: "https://developers.google.com/web/updates/2013/12/300ms-tap-delay-gone-away", title: - "Set viewport width to the same as the device to disable touch delay causing FID.", + "Set viewport width to match the device to disable touch delay causing FID.", info: "", }; } diff --git a/packages/linter/tests/local.test.ts b/packages/linter/tests/local.test.ts index a4890831b..b4a4257ef 100644 --- a/packages/linter/tests/local.test.ts +++ b/packages/linter/tests/local.test.ts @@ -610,7 +610,7 @@ describe(ViewportDisablesTapDelay.name, () => { }); it(`${ViewportDisablesTapDelay.name} - Viewport causes Tap Delay`, async () => { - return assertFail( + return assertWarn( runLocalTest( ViewportDisablesTapDelay, `${__dirname}/local/ViewportDisablesTapDelay-2/source.html`