Skip to content

Commit

Permalink
update prettier formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbenz committed May 11, 2021
1 parent 9966ad8 commit 29c006a
Show file tree
Hide file tree
Showing 17 changed files with 58 additions and 56 deletions.
7 changes: 2 additions & 5 deletions gulpfile.js/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,8 @@ const {join} = require('path');
const {sh} = require('@lib/utils/sh.js');
const mri = require('mri');
const {existsSync} = require('fs');
const {
ROOT,
THUMBOR_ROOT,
PIXI_CLOUD_ROOT,
} = require('@lib/utils/project').paths;
const {ROOT, THUMBOR_ROOT, PIXI_CLOUD_ROOT} =
require('@lib/utils/project').paths;

const PREFIX = 'amp-dev';
const PACKAGER_PREFIX = PREFIX + '-packager';
Expand Down
3 changes: 2 additions & 1 deletion gulpfile.js/import/importRoadmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ const ROADMAP_DIRECTORY_PATH = utils.project.absolute('pages/shared/data');
const ALLOWED_ISSUE_TYPES = ['Type: Status Update', 'Status Update'];

// RegEx to extract date from issue title
const STATUS_UPDATE_REGEX = /(\d\d\d\d)-(0?[1-9]|1[012])-(0?[1-9]|[12]\d|3[01])/;
const STATUS_UPDATE_REGEX =
/(\d\d\d\d)-(0?[1-9]|1[012])-(0?[1-9]|[12]\d|3[01])/;
// Match any amp-component tag. Eg. <amp-img>
const AMP_COMPONENT_REGEX = /\s(<amp-\S*>)/g;
// Group markdown text into text blocks starting with h1 - h3
Expand Down
4 changes: 2 additions & 2 deletions pixi/backend/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ const cheerio = require('cheerio');
const log = require('@lib/utils/log')('Pixi API');
const fetch = require('node-fetch');
const RateLimitedFetch = require('@lib/utils/rateLimitedFetch');
const GA_TRACKING_ID = require('../../platform/config/shared.json')
.gaTrackingId;
const GA_TRACKING_ID =
require('../../platform/config/shared.json').gaTrackingId;
const {API_ENDPOINT_TOOLBOX_PAGE_EXPERIENCE} = require('../config').production;

const rateLimitedFetch = new RateLimitedFetch({
Expand Down
18 changes: 7 additions & 11 deletions pixi/src/Cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,13 @@ export default class PageExperienceCli {

const recommendations = await recommendationsPromise;

const [
{pageExperience},
linter,
mobileFriendliness,
safeBrowsing,
] = await Promise.all([
pageExperiencePromise,
linterPromise,
mobileFriendlinessPromise,
safeBrowsingPromise,
]);
const [{pageExperience}, linter, mobileFriendliness, safeBrowsing] =
await Promise.all([
pageExperiencePromise,
linterPromise,
mobileFriendlinessPromise,
safeBrowsingPromise,
]);

const hasPageExperience = pageExperience !== undefined;
const hasFieldData =
Expand Down
3 changes: 2 additions & 1 deletion pixi/src/ui/InputBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
import i18n from './I18n.js';

/* eslint-disable max-len */
const URL_VALIDATION_REGEX = /^(?:https?:\/\/)?[\w.-]+(?:\.[\w.-]+)+[\w._~:/?#\[\]@!$%&'()*+,;=-]+$/gm;
const URL_VALIDATION_REGEX =
/^(?:https?:\/\/)?[\w.-]+(?:\.[\w.-]+)+[\w._~:/?#\[\]@!$%&'()*+,;=-]+$/gm;

export default class InputBar {
constructor(doc, callback) {
Expand Down
18 changes: 7 additions & 11 deletions pixi/src/utils/issueUrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,13 @@ export default async function getIssueUrl(
mobileFriendlinessPromise,
safeBrowsingPromise
) {
const [
{pageExperience},
linter,
mobileFriendliness,
safeBrowsing,
] = await Promise.all([
pageExperiencePromise,
linterPromise,
mobileFriendlinessPromise,
safeBrowsingPromise,
]);
const [{pageExperience}, linter, mobileFriendliness, safeBrowsing] =
await Promise.all([
pageExperiencePromise,
linterPromise,
mobileFriendlinessPromise,
safeBrowsingPromise,
]);
const hasPageExperience = pageExperience !== undefined;
const hasFieldData =
hasPageExperience && pageExperience.source === 'fieldData';
Expand Down
3 changes: 2 additions & 1 deletion platform/lib/common/samples.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ const EXAMPLE_SITEMAP_PATH = path.join(
project.paths.STATICS_DEST,
'/samples/samples.json'
);
const EXAMPLE_COMPONENT_PATTERN = /^(?:https?:\/\/[^/]+)?(?:\/[^/]+)?\/documentation\/examples\/components\/(amp-[^/]+)\/?/;
const EXAMPLE_COMPONENT_PATTERN =
/^(?:https?:\/\/[^/]+)?(?:\/[^/]+)?\/documentation\/examples\/components\/(amp-[^/]+)\/?/;

function getExamplePreviewUrl(exampleUrl) {
let path = url.parse(exampleUrl).pathname;
Expand Down
6 changes: 4 additions & 2 deletions platform/lib/format-transform/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,14 @@ describe('formatTransform', () => {
});

it('removes @formats', () => {
const input = s(`<html ⚡><head><style amp-custom>body{color:red}</style></head>
const input =
s(`<html ⚡><head><style amp-custom>body{color:red}</style></head>
<!-- comment @formats(websites) -->
<body>
</body>
</html>`);
const want = s(`<html ⚡><head><style amp-custom>body{color:red}</style></head>
const want =
s(`<html ⚡><head><style amp-custom>body{color:red}</style></head>
<!-- comment -->
<body>
</body>
Expand Down
12 changes: 8 additions & 4 deletions platform/lib/pipeline/markdownDocument.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ const SlugGenerator = require('@lib/utils/slugGenerator');
const TOC_MARKER = '[TOC]';

// This expression matches a {% raw %}...{% endraw %} block
const JINJA2_RAW_BLOCK = /\{%\s*raw\s*%\}(?:(?!\{%\s*endraw\s*%\})[\s\S])*\{%\s*endraw\s*%\}/;
const JINJA2_RAW_BLOCK =
/\{%\s*raw\s*%\}(?:(?!\{%\s*endraw\s*%\})[\s\S])*\{%\s*endraw\s*%\}/;

// This expression matches source code blocks. fenced blocks are converted to this syntax
const SOURCECODE_BLOCK = /\[\s*sourcecode[^\]]*\][\s\S]*?\[\s*\/\s*sourcecode\s*\]/;
const SOURCECODE_BLOCK =
/\[\s*sourcecode[^\]]*\][\s\S]*?\[\s*\/\s*sourcecode\s*\]/;

// we search for ALL code blocks, and at the same time for raw blocks
// to ensure we do not match something that belongs to different code blocks
Expand Down Expand Up @@ -74,7 +76,8 @@ const RELATIVE_LINK_PATTERN = new RegExp(
);

// This pattern will find the text for markdown titles skipping explicit anchors.
const TITLE_ANCHOR_PATTERN = /^(#+)[ \t]+(.*?)(<a[ \t]+name=[^>]*><\/a>)?((?:.(?!<a[ \t]+name))*?)$/gm;
const TITLE_ANCHOR_PATTERN =
/^(#+)[ \t]+(.*?)(<a[ \t]+name=[^>]*><\/a>)?((?:.(?!<a[ \t]+name))*?)$/gm;

// Matches a block of frontmatter delimited by ---
const FRONTMATTER_PATTERN = /^---\r?\n.*\r?\n---\r?\n/ms;
Expand Down Expand Up @@ -327,7 +330,8 @@ class MarkdownDocument {
* @return {String} The rewritten input
*/
static rewriteCalloutToTip(contents) {
const CALLOUT_PATTERN = /{% call callout\('.*?', type='(.*?)'\) %}(.*?){% endcall %}/gs;
const CALLOUT_PATTERN =
/{% call callout\('.*?', type='(.*?)'\) %}(.*?){% endcall %}/gs;
const AVAILABLE_CALLOUT_TYPES = {
'note': 'note',
'read': 'read-on',
Expand Down
3 changes: 2 additions & 1 deletion platform/lib/routers/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ const RESPONSE_MAX_AGE = {
autosuggest: 86400, // 24 hours
};

const COMPONENT_REFERENCE_DOC_PATTERN = /^(?:https?:\/\/[^/]+)?(?:\/[^/]+)?\/documentation\/components\/(amp-[^/]+)/;
const COMPONENT_REFERENCE_DOC_PATTERN =
/^(?:https?:\/\/[^/]+)?(?:\/[^/]+)?\/documentation\/components\/(amp-[^/]+)/;

// use the twitter title if available since it does not contain the site name
const TITLE_META_TAG = 'twitter:title';
Expand Down
3 changes: 2 additions & 1 deletion platform/lib/samples/CodeSection.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ renderer.paragraph = function (text) {
return '<p class="mb2 px1">' + text + '</p>';
};

const encodedTemplateRegexp = /\[\[\s*<.*?>([A-Za-z]*?)\s*(<.*?>)?(\.[A-Za-z]*)?\s*<\/span>\s*\]\]/g;
const encodedTemplateRegexp =
/\[\[\s*<.*?>([A-Za-z]*?)\s*(<.*?>)?(\.[A-Za-z]*)?\s*<\/span>\s*\]\]/g;

const hintStartPlaceholder = 'START_HINT';
const hintStartRegexp = new RegExp(
Expand Down
10 changes: 8 additions & 2 deletions platform/lib/samples/DocumentParser.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,14 @@ describe('DocumentParser', () => {
});

it('marks sections in body', () => {
const sections = parse(HEAD, HEAD_END, BODY, COMMENT, TAG, BODY_END)
.sections;
const sections = parse(
HEAD,
HEAD_END,
BODY,
COMMENT,
TAG,
BODY_END
).sections;
expect(sections[0].inBody).toBe(false);
expect(sections[1].inBody).toBe(true);
});
Expand Down
5 changes: 2 additions & 3 deletions platform/lib/tools/componentReferenceLinker.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,8 @@ class ComponentReferenceLinker {
_createTablePlaceholder(component) {
const placeholder = `<!--${this._hash(component)}-->`;
if (!this._tablePlaceholders[placeholder]) {
this._tablePlaceholders[placeholder] = this._tableComponentPath(
component
);
this._tablePlaceholders[placeholder] =
this._tableComponentPath(component);
}
return placeholder;
}
Expand Down
3 changes: 2 additions & 1 deletion platform/lib/tools/growReferenceChecker.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ const LOOKUP_TABLE = {
};
/* eslint-enable max-len */
// The following paths are skipped when checked for existance
const IGNORED_PATH_PATTERNS = /\/content\/amp-dev\/documentation\/components\/reference\/.*?|\/boilerplate|\/content\/amp-dev\/community\/working-groups\/.*?/g;
const IGNORED_PATH_PATTERNS =
/\/content\/amp-dev\/documentation\/components\/reference\/.*?|\/boilerplate|\/content\/amp-dev\/community\/working-groups\/.*?/g;

// The list of imported docs. Here we do not check anchors.
const IMPORTED_DOCS = require(__dirname +
Expand Down
6 changes: 2 additions & 4 deletions platform/lib/utils/HeadDedupTransformer.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@
* limitations under the License.
*/

const {
remove,
firstChildByTag,
} = require('@ampproject/toolbox-optimizer').NodeUtils;
const {remove, firstChildByTag} =
require('@ampproject/toolbox-optimizer').NodeUtils;
const TAGS_TO_DEDUP = {
meta: {
name: 'viewport',
Expand Down
7 changes: 2 additions & 5 deletions platform/lib/utils/cssTransformer.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
const {
nextNode,
hasAttribute,
firstChildByTag,
} = require('@ampproject/toolbox-optimizer').NodeUtils;
const {nextNode, hasAttribute, firstChildByTag} =
require('@ampproject/toolbox-optimizer').NodeUtils;
const rcs = require('rcs-core');

/* Class names which are safe to rewrite in the context of amp.dev */
Expand Down
3 changes: 2 additions & 1 deletion playground/src/importer/importer.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ import * as Runtimes from '../runtime/runtimes.js';
export const EVENT_REQUEST_URL_CONTENT = 'event-request-url-content';

/* eslint-disable max-len */
const URL_VALIDATION_REGEX = /^(?:http(s)?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]+$/gm;
const URL_VALIDATION_REGEX =
/^(?:http(s)?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]+$/gm;

export function createImport() {
const target = document.getElementById('import-view');
Expand Down

0 comments on commit 29c006a

Please sign in to comment.