Skip to content
Permalink
Browse files

Added prettier, eslint, and reformatted the files

  • Loading branch information
lfre committed Jul 4, 2019
1 parent f0aa630 commit 70e16c3f2960242047a16d667868496476e5c718
Showing with 3,807 additions and 315 deletions.
  1. +15 −0 .eslintrc
  2. +5 −0 .prettierrc
  3. +13 −17 app/configuration.js
  4. +98 −129 app/index.js
  5. +5 −28 app/runner.js
  6. +3 −4 app/status.js
  7. +61 −18 app/util/index.js
  8. +29 −38 lighthouse/index.js
  9. +3,554 −80 package-lock.json
  10. +24 −1 package.json
@@ -0,0 +1,15 @@
{
"extends": [
"airbnb-base",
"prettier"
],
"env": {
"node": true,
"es6": true
},
"rules": {
"no-bitwise": ["error", { "int32Hint": true }],
"camelcase": "off",
"no-param-reassign": "off"
}
}
@@ -0,0 +1,5 @@
{
printWidth: 100,
singleQuote: true,
useTabs: false,
}
@@ -1,7 +1,6 @@
const { homepage } = require('../package.json');
const {
CONFIG_FILE_PATH = '.github/lightkeeper.json',
} = process.env;

const { CONFIG_FILE_PATH = '.github/lightkeeper.json' } = process.env;

class Configuration {
constructor(params, status) {
@@ -15,20 +14,13 @@ class Configuration {
* Gets the configuration file contents from the PR or base branch
*/
async getConfigFile() {
const {
context,
github,
headBranch: ref,
pullNumber: pull_number
} = this.params;
const { context, github, headBranch: ref, pullNumber: pull_number } = this.params;
const { owner, repo } = context.repo();

const { data: prFiles } = await github.pullRequests.listFiles(
context.repo({ pull_number })
);
const { data: prFiles } = await github.pullRequests.listFiles(context.repo({ pull_number }));
const modifiedFiles = prFiles
.filter(file => ['modified', 'added'].includes(file.status))
.map(file => file.filename)
.map(file => file.filename);

// check if the PR has a modified configuration
if (modifiedFiles.includes(CONFIG_FILE_PATH)) {
@@ -37,13 +29,13 @@ class Configuration {
repo,
path: CONFIG_FILE_PATH,
ref
})
});
}
return github.repos.getContents({
owner,
repo,
path: CONFIG_FILE_PATH
})
});
}

/**
@@ -53,7 +45,9 @@ class Configuration {
let configuration = {};
let missingKeys = this.requiredKeys;
try {
const { data: { content } } = await this.getConfigFile();
const {
data: { content }
} = await this.getConfigFile();
configuration = JSON.parse(Buffer.from(content, 'base64').toString());
} catch (error) {
// Exit early if config was not found
@@ -66,7 +60,9 @@ class Configuration {
}
// Check for required keys
if (configuration) {
missingKeys = missingKeys.filter(key => !(configuration[key] && typeof configuration[key] === 'string'));
missingKeys = missingKeys.filter(
key => !(configuration[key] && typeof configuration[key] === 'string')
);
if (missingKeys.length) {
this.status.run({
conclusion: 'action_required',

1 comment on commit 70e16c3

@now

This comment has been minimized.

Please sign in to comment.
You can’t perform that action at this time.