{"action":"created","comment":{"url":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/comments/62536492","id":62536492,"diff_hunk":"@@ -0,0 +1,70 @@\n+/**\n+ * @license\n+ * Copyright 2016 Google Inc. All rights reserved.\n+ *\n+ * Licensed under the Apache License, Version 2.0 (the \"License\");\n+ * you may not use this file except in compliance with the License.\n+ * You may obtain a copy of the License at\n+ *\n+ *     http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ */\n+\n+'use strict';\n+\n+class Formatter {\n+  static get SUPPORTED_FORMATS() {\n+    // Get the available formatters if they don't already exist.\n+    if (!this._formatters) {\n+      this._getFormatters();\n+    }\n+\n+    // From the formatters we can establish a master list of supported format names.\n+    if (!this._supportedFormatsNames) {\n+      this._generateSupportedFormats();\n+    }\n+\n+    return this._supportedFormatsNames;\n+  }\n+\n+  static _getFormatters() {\n+    this._formatters = {\n+      accessibility: require('./accessibility')\n+    };\n+  }\n+\n+  static _generateSupportedFormats() {\n+    const formatNames = Object.keys(this._formatters);\n+    this._supportedFormatsNames = formatNames.reduce((prev, format) => {\n+      prev[format.toUpperCase()] = format;\n+      return prev;\n+    }, {});\n+  }\n+\n+  static getByName(name) {\n+    if (!this._formatters) {\n+      this._getFormatters();\n+    }\n+\n+    if (!this._formatters[name]) {\n+      throw new Error(`Unknown formatter: ${name}`);\n+    }\n+\n+    return this._formatters[name];\n+  }\n+\n+  static getPrettyFormatter() {","path":"formatters/formatter.js","position":61,"original_position":61,"commit_id":"de4ae8cd82c68e6263cac8923cea7803af54499f","original_commit_id":"0629e10ec8331502f655bc92fdcd0de075ff556b","user":{"login":"paullewis","id":617438,"avatar_url":"https://avatars.githubusercontent.com/u/617438?v=3","gravatar_id":"","url":"https://api.github.com/users/paullewis","html_url":"https://github.com/paullewis","followers_url":"https://api.github.com/users/paullewis/followers","following_url":"https://api.github.com/users/paullewis/following{/other_user}","gists_url":"https://api.github.com/users/paullewis/gists{/gist_id}","starred_url":"https://api.github.com/users/paullewis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paullewis/subscriptions","organizations_url":"https://api.github.com/users/paullewis/orgs","repos_url":"https://api.github.com/users/paullewis/repos","events_url":"https://api.github.com/users/paullewis/events{/privacy}","received_events_url":"https://api.github.com/users/paullewis/received_events","type":"User","site_admin":false},"body":"@paulirish The formatter matches the internal type, e.g. 'critical-render-path', 'accessibility', 'security'... it's essentially the formatter to use. Even if we 1:1 it, we'd still hard code the ReportGenerator to request HTML, and the CLI to request pretty, so I dunno we'd get much benefit.","created_at":"2016-05-09T17:18:29Z","updated_at":"2016-05-09T17:18:29Z","html_url":"https://github.com/GoogleChrome/lighthouse/pull/301#discussion_r62536492","pull_request_url":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/301","_links":{"self":{"href":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/comments/62536492"},"html":{"href":"https://github.com/GoogleChrome/lighthouse/pull/301#discussion_r62536492"},"pull_request":{"href":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/301"}}},"pull_request":{"url":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/301","id":69326640,"html_url":"https://github.com/GoogleChrome/lighthouse/pull/301","diff_url":"https://github.com/GoogleChrome/lighthouse/pull/301.diff","patch_url":"https://github.com/GoogleChrome/lighthouse/pull/301.patch","issue_url":"https://api.github.com/repos/GoogleChrome/lighthouse/issues/301","number":301,"state":"open","locked":false,"title":"Adds formatters for pretty and report outputs","user":{"login":"paullewis","id":617438,"avatar_url":"https://avatars.githubusercontent.com/u/617438?v=3","gravatar_id":"","url":"https://api.github.com/users/paullewis","html_url":"https://github.com/paullewis","followers_url":"https://api.github.com/users/paullewis/followers","following_url":"https://api.github.com/users/paullewis/following{/other_user}","gists_url":"https://api.github.com/users/paullewis/gists{/gist_id}","starred_url":"https://api.github.com/users/paullewis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paullewis/subscriptions","organizations_url":"https://api.github.com/users/paullewis/orgs","repos_url":"https://api.github.com/users/paullewis/repos","events_url":"https://api.github.com/users/paullewis/events{/privacy}","received_events_url":"https://api.github.com/users/paullewis/received_events","type":"User","site_admin":false},"body":"Works with a11y audit atm, but this change will allow support for CRP etc.","created_at":"2016-05-09T10:46:15Z","updated_at":"2016-05-09T17:18:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"64886ea0a269138acaf4c47084dcf482126959e0","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/301/commits","review_comments_url":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/301/comments","review_comment_url":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/comments{/number}","comments_url":"https://api.github.com/repos/GoogleChrome/lighthouse/issues/301/comments","statuses_url":"https://api.github.com/repos/GoogleChrome/lighthouse/statuses/de4ae8cd82c68e6263cac8923cea7803af54499f","head":{"label":"paullewis:formatters","ref":"formatters","sha":"de4ae8cd82c68e6263cac8923cea7803af54499f","user":{"login":"paullewis","id":617438,"avatar_url":"https://avatars.githubusercontent.com/u/617438?v=3","gravatar_id":"","url":"https://api.github.com/users/paullewis","html_url":"https://github.com/paullewis","followers_url":"https://api.github.com/users/paullewis/followers","following_url":"https://api.github.com/users/paullewis/following{/other_user}","gists_url":"https://api.github.com/users/paullewis/gists{/gist_id}","starred_url":"https://api.github.com/users/paullewis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paullewis/subscriptions","organizations_url":"https://api.github.com/users/paullewis/orgs","repos_url":"https://api.github.com/users/paullewis/repos","events_url":"https://api.github.com/users/paullewis/events{/privacy}","received_events_url":"https://api.github.com/users/paullewis/received_events","type":"User","site_admin":false},"repo":{"id":54384726,"name":"lighthouse","full_name":"paullewis/lighthouse","owner":{"login":"paullewis","id":617438,"avatar_url":"https://avatars.githubusercontent.com/u/617438?v=3","gravatar_id":"","url":"https://api.github.com/users/paullewis","html_url":"https://github.com/paullewis","followers_url":"https://api.github.com/users/paullewis/followers","following_url":"https://api.github.com/users/paullewis/following{/other_user}","gists_url":"https://api.github.com/users/paullewis/gists{/gist_id}","starred_url":"https://api.github.com/users/paullewis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paullewis/subscriptions","organizations_url":"https://api.github.com/users/paullewis/orgs","repos_url":"https://api.github.com/users/paullewis/repos","events_url":"https://api.github.com/users/paullewis/events{/privacy}","received_events_url":"https://api.github.com/users/paullewis/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/paullewis/lighthouse","description":null,"fork":true,"url":"https://api.github.com/repos/paullewis/lighthouse","forks_url":"https://api.github.com/repos/paullewis/lighthouse/forks","keys_url":"https://api.github.com/repos/paullewis/lighthouse/keys{/key_id}","collaborators_url":"https://api.github.com/repos/paullewis/lighthouse/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/paullewis/lighthouse/teams","hooks_url":"https://api.github.com/repos/paullewis/lighthouse/hooks","issue_events_url":"https://api.github.com/repos/paullewis/lighthouse/issues/events{/number}","events_url":"https://api.github.com/repos/paullewis/lighthouse/events","assignees_url":"https://api.github.com/repos/paullewis/lighthouse/assignees{/user}","branches_url":"https://api.github.com/repos/paullewis/lighthouse/branches{/branch}","tags_url":"https://api.github.com/repos/paullewis/lighthouse/tags","blobs_url":"https://api.github.com/repos/paullewis/lighthouse/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/paullewis/lighthouse/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/paullewis/lighthouse/git/refs{/sha}","trees_url":"https://api.github.com/repos/paullewis/lighthouse/git/trees{/sha}","statuses_url":"https://api.github.com/repos/paullewis/lighthouse/statuses/{sha}","languages_url":"https://api.github.com/repos/paullewis/lighthouse/languages","stargazers_url":"https://api.github.com/repos/paullewis/lighthouse/stargazers","contributors_url":"https://api.github.com/repos/paullewis/lighthouse/contributors","subscribers_url":"https://api.github.com/repos/paullewis/lighthouse/subscribers","subscription_url":"https://api.github.com/repos/paullewis/lighthouse/subscription","commits_url":"https://api.github.com/repos/paullewis/lighthouse/commits{/sha}","git_commits_url":"https://api.github.com/repos/paullewis/lighthouse/git/commits{/sha}","comments_url":"https://api.github.com/repos/paullewis/lighthouse/comments{/number}","issue_comment_url":"https://api.github.com/repos/paullewis/lighthouse/issues/comments{/number}","contents_url":"https://api.github.com/repos/paullewis/lighthouse/contents/{+path}","compare_url":"https://api.github.com/repos/paullewis/lighthouse/compare/{base}...{head}","merges_url":"https://api.github.com/repos/paullewis/lighthouse/merges","archive_url":"https://api.github.com/repos/paullewis/lighthouse/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/paullewis/lighthouse/downloads","issues_url":"https://api.github.com/repos/paullewis/lighthouse/issues{/number}","pulls_url":"https://api.github.com/repos/paullewis/lighthouse/pulls{/number}","milestones_url":"https://api.github.com/repos/paullewis/lighthouse/milestones{/number}","notifications_url":"https://api.github.com/repos/paullewis/lighthouse/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/paullewis/lighthouse/labels{/name}","releases_url":"https://api.github.com/repos/paullewis/lighthouse/releases{/id}","deployments_url":"https://api.github.com/repos/paullewis/lighthouse/deployments","created_at":"2016-03-21T11:54:00Z","updated_at":"2016-03-21T11:54:01Z","pushed_at":"2016-05-09T17:15:50Z","git_url":"git://github.com/paullewis/lighthouse.git","ssh_url":"git@github.com:paullewis/lighthouse.git","clone_url":"https://github.com/paullewis/lighthouse.git","svn_url":"https://github.com/paullewis/lighthouse","homepage":null,"size":5742,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"base":{"label":"GoogleChrome:master","ref":"master","sha":"e2d7163345e980fd5802d284b41760f2e98c3db7","user":{"login":"GoogleChrome","id":1778935,"avatar_url":"https://avatars.githubusercontent.com/u/1778935?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleChrome","html_url":"https://github.com/GoogleChrome","followers_url":"https://api.github.com/users/GoogleChrome/followers","following_url":"https://api.github.com/users/GoogleChrome/following{/other_user}","gists_url":"https://api.github.com/users/GoogleChrome/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleChrome/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleChrome/subscriptions","organizations_url":"https://api.github.com/users/GoogleChrome/orgs","repos_url":"https://api.github.com/users/GoogleChrome/repos","events_url":"https://api.github.com/users/GoogleChrome/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleChrome/received_events","type":"Organization","site_admin":false},"repo":{"id":53370988,"name":"lighthouse","full_name":"GoogleChrome/lighthouse","owner":{"login":"GoogleChrome","id":1778935,"avatar_url":"https://avatars.githubusercontent.com/u/1778935?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleChrome","html_url":"https://github.com/GoogleChrome","followers_url":"https://api.github.com/users/GoogleChrome/followers","following_url":"https://api.github.com/users/GoogleChrome/following{/other_user}","gists_url":"https://api.github.com/users/GoogleChrome/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleChrome/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleChrome/subscriptions","organizations_url":"https://api.github.com/users/GoogleChrome/orgs","repos_url":"https://api.github.com/users/GoogleChrome/repos","events_url":"https://api.github.com/users/GoogleChrome/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleChrome/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/GoogleChrome/lighthouse","description":null,"fork":false,"url":"https://api.github.com/repos/GoogleChrome/lighthouse","forks_url":"https://api.github.com/repos/GoogleChrome/lighthouse/forks","keys_url":"https://api.github.com/repos/GoogleChrome/lighthouse/keys{/key_id}","collaborators_url":"https://api.github.com/repos/GoogleChrome/lighthouse/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/GoogleChrome/lighthouse/teams","hooks_url":"https://api.github.com/repos/GoogleChrome/lighthouse/hooks","issue_events_url":"https://api.github.com/repos/GoogleChrome/lighthouse/issues/events{/number}","events_url":"https://api.github.com/repos/GoogleChrome/lighthouse/events","assignees_url":"https://api.github.com/repos/GoogleChrome/lighthouse/assignees{/user}","branches_url":"https://api.github.com/repos/GoogleChrome/lighthouse/branches{/branch}","tags_url":"https://api.github.com/repos/GoogleChrome/lighthouse/tags","blobs_url":"https://api.github.com/repos/GoogleChrome/lighthouse/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/GoogleChrome/lighthouse/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/GoogleChrome/lighthouse/git/refs{/sha}","trees_url":"https://api.github.com/repos/GoogleChrome/lighthouse/git/trees{/sha}","statuses_url":"https://api.github.com/repos/GoogleChrome/lighthouse/statuses/{sha}","languages_url":"https://api.github.com/repos/GoogleChrome/lighthouse/languages","stargazers_url":"https://api.github.com/repos/GoogleChrome/lighthouse/stargazers","contributors_url":"https://api.github.com/repos/GoogleChrome/lighthouse/contributors","subscribers_url":"https://api.github.com/repos/GoogleChrome/lighthouse/subscribers","subscription_url":"https://api.github.com/repos/GoogleChrome/lighthouse/subscription","commits_url":"https://api.github.com/repos/GoogleChrome/lighthouse/commits{/sha}","git_commits_url":"https://api.github.com/repos/GoogleChrome/lighthouse/git/commits{/sha}","comments_url":"https://api.github.com/repos/GoogleChrome/lighthouse/comments{/number}","issue_comment_url":"https://api.github.com/repos/GoogleChrome/lighthouse/issues/comments{/number}","contents_url":"https://api.github.com/repos/GoogleChrome/lighthouse/contents/{+path}","compare_url":"https://api.github.com/repos/GoogleChrome/lighthouse/compare/{base}...{head}","merges_url":"https://api.github.com/repos/GoogleChrome/lighthouse/merges","archive_url":"https://api.github.com/repos/GoogleChrome/lighthouse/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/GoogleChrome/lighthouse/downloads","issues_url":"https://api.github.com/repos/GoogleChrome/lighthouse/issues{/number}","pulls_url":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls{/number}","milestones_url":"https://api.github.com/repos/GoogleChrome/lighthouse/milestones{/number}","notifications_url":"https://api.github.com/repos/GoogleChrome/lighthouse/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/GoogleChrome/lighthouse/labels{/name}","releases_url":"https://api.github.com/repos/GoogleChrome/lighthouse/releases{/id}","deployments_url":"https://api.github.com/repos/GoogleChrome/lighthouse/deployments","created_at":"2016-03-08T01:03:11Z","updated_at":"2016-05-07T07:18:30Z","pushed_at":"2016-05-09T17:15:51Z","git_url":"git://github.com/GoogleChrome/lighthouse.git","ssh_url":"git@github.com:GoogleChrome/lighthouse.git","clone_url":"https://github.com/GoogleChrome/lighthouse.git","svn_url":"https://github.com/GoogleChrome/lighthouse","homepage":null,"size":5939,"stargazers_count":90,"watchers_count":90,"language":"JavaScript","has_issues":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":16,"mirror_url":null,"open_issues_count":34,"forks":16,"open_issues":34,"watchers":90,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/301"},"html":{"href":"https://github.com/GoogleChrome/lighthouse/pull/301"},"issue":{"href":"https://api.github.com/repos/GoogleChrome/lighthouse/issues/301"},"comments":{"href":"https://api.github.com/repos/GoogleChrome/lighthouse/issues/301/comments"},"review_comments":{"href":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/301/comments"},"review_comment":{"href":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/301/commits"},"statuses":{"href":"https://api.github.com/repos/GoogleChrome/lighthouse/statuses/de4ae8cd82c68e6263cac8923cea7803af54499f"}}}}