Skip to content

Commit d3510fd

Browse files
committed
chore: autoformatted after changed eslint config in github#664
Mostly, the changes in github#664 relaxes the eslint rules, but that PR also removes the space before the parentheses in function definitions. The formatting was done with the vscode js/ts formatter `vscode.typescript-language-features`, and since this also does the same change it is now consistent across the whole codebase. Other than removing the space-before-function-paren, some files with inconsistent indentation and/or trailing spaces has been updated.
1 parent 60f8fd3 commit d3510fd

38 files changed

+623
-624
lines changed

index.js

+21-21
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ let deploymentConfig
1313
module.exports = (robot, { getRouter }, Settings = require('./lib/settings')) => {
1414
let appName = 'safe-settings'
1515
let appSlug = 'safe-settings'
16-
async function syncAllSettings (nop, context, repo = context.repo(), ref) {
16+
async function syncAllSettings(nop, context, repo = context.repo(), ref) {
1717
try {
1818
deploymentConfig = await loadYamlFileSystem()
1919
robot.log.debug(`deploymentConfig is ${JSON.stringify(deploymentConfig)}`)
@@ -42,7 +42,7 @@ module.exports = (robot, { getRouter }, Settings = require('./lib/settings')) =>
4242
}
4343
}
4444

45-
async function syncSubOrgSettings (nop, context, suborg, repo = context.repo(), ref) {
45+
async function syncSubOrgSettings(nop, context, suborg, repo = context.repo(), ref) {
4646
try {
4747
deploymentConfig = await loadYamlFileSystem()
4848
robot.log.debug(`deploymentConfig is ${JSON.stringify(deploymentConfig)}`)
@@ -67,7 +67,7 @@ module.exports = (robot, { getRouter }, Settings = require('./lib/settings')) =>
6767
}
6868
}
6969

70-
async function syncSettings (nop, context, repo = context.repo(), ref) {
70+
async function syncSettings(nop, context, repo = context.repo(), ref) {
7171
try {
7272
deploymentConfig = await loadYamlFileSystem()
7373
robot.log.debug(`deploymentConfig is ${JSON.stringify(deploymentConfig)}`)
@@ -92,7 +92,7 @@ module.exports = (robot, { getRouter }, Settings = require('./lib/settings')) =>
9292
}
9393
}
9494

95-
async function renameSync (nop, context, repo = context.repo(), rename, ref) {
95+
async function renameSync(nop, context, repo = context.repo(), rename, ref) {
9696
try {
9797
deploymentConfig = await loadYamlFileSystem()
9898
robot.log.debug(`deploymentConfig is ${JSON.stringify(deploymentConfig)}`)
@@ -101,7 +101,7 @@ module.exports = (robot, { getRouter }, Settings = require('./lib/settings')) =>
101101
const config = Object.assign({}, deploymentConfig, runtimeConfig)
102102
const renameConfig = Object.assign({}, config, rename)
103103
robot.log.debug(`config for ref ${ref} is ${JSON.stringify(config)}`)
104-
return Settings.sync(nop, context, repo, renameConfig, ref )
104+
return Settings.sync(nop, context, repo, renameConfig, ref)
105105
} catch (e) {
106106
if (nop) {
107107
let filename = env.SETTINGS_FILE_PATH
@@ -123,7 +123,7 @@ module.exports = (robot, { getRouter }, Settings = require('./lib/settings')) =>
123123
*
124124
* @return The parsed YAML file
125125
*/
126-
async function loadYamlFileSystem () {
126+
async function loadYamlFileSystem() {
127127
if (deploymentConfig === undefined) {
128128
const deploymentConfigPath = env.DEPLOYMENT_CONFIG_FILE
129129
if (fs.existsSync(deploymentConfigPath)) {
@@ -135,7 +135,7 @@ module.exports = (robot, { getRouter }, Settings = require('./lib/settings')) =>
135135
return deploymentConfig
136136
}
137137

138-
function getAllChangedSubOrgConfigs (payload) {
138+
function getAllChangedSubOrgConfigs(payload) {
139139
const settingPattern = new Glob(`${env.CONFIG_PATH}/suborgs/*.yml`)
140140
// Changes will be an array of files that were added
141141
const added = payload.commits.map(c => {
@@ -159,7 +159,7 @@ module.exports = (robot, { getRouter }, Settings = require('./lib/settings')) =>
159159
return configs
160160
}
161161

162-
function getAllChangedRepoConfigs (payload, owner) {
162+
function getAllChangedRepoConfigs(payload, owner) {
163163
const settingPattern = new Glob(`${env.CONFIG_PATH}/repos/*.yml`)
164164
// Changes will be an array of files that were added
165165
const added = payload.commits.map(c => {
@@ -182,7 +182,7 @@ module.exports = (robot, { getRouter }, Settings = require('./lib/settings')) =>
182182
return configs
183183
}
184184

185-
function getChangedRepoConfigName (glob, files, owner) {
185+
function getChangedRepoConfigName(glob, files, owner) {
186186
const modifiedFiles = files.filter(s => {
187187
robot.log.debug(JSON.stringify(s))
188188
return (s.search(glob) >= 0)
@@ -193,7 +193,7 @@ module.exports = (robot, { getRouter }, Settings = require('./lib/settings')) =>
193193
})
194194
}
195195

196-
function getChangedSubOrgConfigName (glob, files) {
196+
function getChangedSubOrgConfigName(glob, files) {
197197
const modifiedFiles = files.filter(s => {
198198
robot.log.debug(JSON.stringify(s))
199199
return (s.search(glob) >= 0)
@@ -205,7 +205,7 @@ module.exports = (robot, { getRouter }, Settings = require('./lib/settings')) =>
205205
})
206206
}
207207

208-
async function createCheckRun (context, pull_request, head_sha, head_branch) {
208+
async function createCheckRun(context, pull_request, head_sha, head_branch) {
209209
const { payload } = context
210210
// robot.log.debug(`Check suite was requested! for ${context.repo()} ${pull_request.number} ${head_sha} ${head_branch}`)
211211
const res = await context.octokit.checks.create({
@@ -234,7 +234,7 @@ module.exports = (robot, { getRouter }, Settings = require('./lib/settings')) =>
234234
}
235235

236236

237-
async function syncInstallation () {
237+
async function syncInstallation() {
238238
robot.log.trace('Fetching installations')
239239
const github = await robot.auth()
240240

@@ -395,7 +395,7 @@ module.exports = (robot, { getRouter }, Settings = require('./lib/settings')) =>
395395
})
396396

397397
robot.on('repository.renamed', async context => {
398-
if (env.BLOCK_REPO_RENAME_BY_HUMAN!== 'true') {
398+
if (env.BLOCK_REPO_RENAME_BY_HUMAN !== 'true') {
399399
robot.log.debug(`"env.BLOCK_REPO_RENAME_BY_HUMAN" is 'false' by default. Repo rename is not managed by Safe-settings. Continue with the default behavior.`)
400400
return
401401
}
@@ -414,7 +414,7 @@ module.exports = (robot, { getRouter }, Settings = require('./lib/settings')) =>
414414
const newPath = `.github/repos/${payload.repository.name}.yml`
415415
robot.log.debug(oldPath)
416416
try {
417-
const repofile = await context.octokit.request('GET /repos/{owner}/{repo}/contents/{path}', {
417+
const repofile = await context.octokit.request('GET /repos/{owner}/{repo}/contents/{path}', {
418418
owner: payload.repository.owner.login,
419419
repo: env.ADMIN_REPO,
420420
path: oldPath,
@@ -443,7 +443,7 @@ module.exports = (robot, { getRouter }, Settings = require('./lib/settings')) =>
443443
owner: payload.repository.owner.login,
444444
repo: env.ADMIN_REPO,
445445
path: newPath,
446-
name: `${payload.repository.name}.yml`,
446+
name: `${payload.repository.name}.yml`,
447447
content: content,
448448
message: `Repo Renamed and safe-settings renamed the file from ${payload.changes.repository.name.from} to ${payload.repository.name}`,
449449
sha: repofile.data.sha,
@@ -455,21 +455,21 @@ module.exports = (robot, { getRouter }, Settings = require('./lib/settings')) =>
455455
} else {
456456
robot.log.error(error)
457457
}
458-
}
458+
}
459459

460460
} catch (error) {
461461
if (error.status === 404) {
462462
//nop
463-
} else {
463+
} else {
464464
robot.log.error(error)
465465
}
466-
}
466+
}
467467
return
468468
} else {
469469
robot.log.debug('Repository Edited by a Human')
470470
// Create a repository config to reset the name back to the previous name
471-
const rename = {repository: { name: payload.changes.repository.name.from, oldname: payload.repository.name}}
472-
const repo = {repo: payload.changes.repository.name.from, owner: payload.repository.owner.login}
471+
const rename = { repository: { name: payload.changes.repository.name.from, oldname: payload.repository.name } }
472+
const repo = { repo: payload.changes.repository.name.from, owner: payload.repository.owner.login }
473473
return renameSync(false, context, repo, rename)
474474
}
475475
})
@@ -663,7 +663,7 @@ module.exports = (robot, { getRouter }, Settings = require('./lib/settings')) =>
663663
syncInstallation()
664664
})
665665
}
666-
666+
667667
// Get info about the app
668668
info()
669669

lib/commentmessage.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module.exports = `* Run on: \` <%= new Date() %> \`
55
### Breakdown of changes
66
| Repo <% Object.keys(it.changes).forEach(plugin => { %> | <%= plugin %> settings <% }) %> |
77
| -- <% Object.keys(it.changes).forEach(plugin => { -%> | -- <% }) %>
8-
|
8+
|
99
<% Object.keys(it.reposProcessed).forEach( repo => { -%>
1010
| <%= repo -%>
1111
<%- Object.keys(it.changes).forEach(plugin => { -%>
@@ -22,7 +22,7 @@ module.exports = `* Run on: \` <%= new Date() %> \`
2222
\`None\`
2323
<% } else { %>
2424
<% Object.keys(it.errors).forEach(repo => { %>
25-
<%_= repo %>:
25+
<%_= repo %>:
2626
<% it.errors[repo].forEach(plugin => { %>
2727
* <%= plugin.msg %>
2828
<% }) %>

lib/configManager.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const yaml = require('js-yaml')
33
const env = require('./env')
44

55
module.exports = class ConfigManager {
6-
constructor (context, ref) {
6+
constructor(context, ref) {
77
this.context = context
88
this.ref = ref
99
this.log = context.log
@@ -15,7 +15,7 @@ module.exports = class ConfigManager {
1515
* @param params Params to fetch the file with
1616
* @return The parsed YAML file
1717
*/
18-
async loadYaml (filePath) {
18+
async loadYaml(filePath) {
1919
try {
2020
const repo = { owner: this.context.repo().owner, repo: env.ADMIN_REPO }
2121
const params = Object.assign(repo, { path: filePath, ref: this.ref })
@@ -50,7 +50,7 @@ module.exports = class ConfigManager {
5050
* @param params Params to fetch the file with
5151
* @return The parsed YAML file
5252
*/
53-
async loadGlobalSettingsYaml () {
53+
async loadGlobalSettingsYaml() {
5454
const CONFIG_PATH = env.CONFIG_PATH
5555
const filePath = path.posix.join(CONFIG_PATH, env.SETTINGS_FILE_PATH)
5656
return this.loadYaml(filePath)

lib/deploymentConfig.js

+34-34
Original file line numberDiff line numberDiff line change
@@ -8,46 +8,46 @@ const env = require('./env')
88
* The settings are loaded from the deployment-settings.yml file during initialization and stored as static properties.
99
*/
1010
class DeploymentConfig {
11-
//static config
12-
static configvalidators = {}
13-
static overridevalidators = {}
11+
//static config
12+
static configvalidators = {}
13+
static overridevalidators = {}
1414

15-
static {
16-
const deploymentConfigPath = process.env.DEPLOYMENT_CONFIG_FILE ? process.env.DEPLOYMENT_CONFIG_FILE : 'deployment-settings.yml'
17-
if (fs.existsSync(deploymentConfigPath)) {
18-
this.config = yaml.load(fs.readFileSync(deploymentConfigPath))
19-
} else {
20-
this.config = { restrictedRepos: ['admin', '.github', 'safe-settings'] }
21-
}
22-
23-
const overridevalidators = this.config.overridevalidators
24-
if (this.isIterable(overridevalidators)) {
25-
for (const validator of overridevalidators) {
26-
// eslint-disable-next-line no-new-func
27-
const f = new Function('baseconfig', 'overrideconfig', 'githubContext', validator.script)
28-
this.overridevalidators[validator.plugin] = { canOverride: f, error: validator.error }
29-
}
30-
}
31-
const configvalidators = this.config.configvalidators
32-
if (this.isIterable(configvalidators)) {
33-
for (const validator of configvalidators) {
34-
// eslint-disable-next-line no-new-func
35-
const f = new Function('baseconfig', 'githubContext', validator.script)
36-
this.configvalidators[validator.plugin] = { isValid: f, error: validator.error }
37-
}
38-
}
15+
static {
16+
const deploymentConfigPath = process.env.DEPLOYMENT_CONFIG_FILE ? process.env.DEPLOYMENT_CONFIG_FILE : 'deployment-settings.yml'
17+
if (fs.existsSync(deploymentConfigPath)) {
18+
this.config = yaml.load(fs.readFileSync(deploymentConfigPath))
19+
} else {
20+
this.config = { restrictedRepos: ['admin', '.github', 'safe-settings'] }
3921
}
4022

41-
static isIterable (obj) {
42-
// checks for null and undefined
43-
if (obj == null) {
44-
return false
45-
}
46-
return typeof obj[Symbol.iterator] === 'function'
23+
const overridevalidators = this.config.overridevalidators
24+
if (this.isIterable(overridevalidators)) {
25+
for (const validator of overridevalidators) {
26+
// eslint-disable-next-line no-new-func
27+
const f = new Function('baseconfig', 'overrideconfig', 'githubContext', validator.script)
28+
this.overridevalidators[validator.plugin] = { canOverride: f, error: validator.error }
29+
}
30+
}
31+
const configvalidators = this.config.configvalidators
32+
if (this.isIterable(configvalidators)) {
33+
for (const validator of configvalidators) {
34+
// eslint-disable-next-line no-new-func
35+
const f = new Function('baseconfig', 'githubContext', validator.script)
36+
this.configvalidators[validator.plugin] = { isValid: f, error: validator.error }
4737
}
38+
}
39+
}
4840

49-
constructor (nop, context, repo, config, ref, suborg) {
41+
static isIterable(obj) {
42+
// checks for null and undefined
43+
if (obj == null) {
44+
return false
5045
}
46+
return typeof obj[Symbol.iterator] === 'function'
47+
}
48+
49+
constructor(nop, context, repo, config, ref, suborg) {
50+
}
5151
}
5252
DeploymentConfig.FILE_NAME = `${env.CONFIG_PATH}/settings.yml`
5353

lib/error.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
module.exports = `Run on: \`<%= new Date().toISOString() %>\`
22
33
#### Breakdown of Errors
4-
| Owner| Repo | Plugin | Error
5-
| --- | --- | --- | ---
4+
| Owner| Repo | Plugin | Error
5+
| --- | --- | --- | ---
66
<% it.forEach( error => { -%>
77
<%= error.owner %> | <%= error.repo %> | <%= error.plugin %> | <%= error.msg %>
88

lib/glob.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
class Glob {
2-
constructor (glob) {
2+
constructor(glob) {
33
this.glob = glob
44

55
// If not a glob pattern then just match the string.
@@ -11,7 +11,7 @@ class Glob {
1111
this.regexp = new RegExp(`^${this.regexptText}$`, 'u')
1212
}
1313

14-
globize (glob) {
14+
globize(glob) {
1515
return glob
1616
.replace(/\\/g, '\\\\') // escape backslashes
1717
.replace(/\//g, '\\/') // escape forward slashes
@@ -21,23 +21,23 @@ class Glob {
2121
.replace(/\*/g, '([^\\/]*)') // match any character except /
2222
}
2323

24-
toString () {
24+
toString() {
2525
return this.glob
2626
}
2727

28-
[Symbol.search] (s) {
28+
[Symbol.search](s) {
2929
return s.search(this.regexp)
3030
}
3131

32-
[Symbol.match] (s) {
32+
[Symbol.match](s) {
3333
return s.match(this.regexp)
3434
}
3535

36-
[Symbol.replace] (s, replacement) {
36+
[Symbol.replace](s, replacement) {
3737
return s.replace(this.regexp, replacement)
3838
}
3939

40-
[Symbol.replaceAll] (s, replacement) {
40+
[Symbol.replaceAll](s, replacement) {
4141
return s.replaceAll(this.regexp, replacement)
4242
}
4343
}

lib/mergeArrayBy.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
const merge = require('deepmerge')
44

5-
function findMatchingIndex (properties, sourceItem, target) {
5+
function findMatchingIndex(properties, sourceItem, target) {
66
const hasAnyProperty = item => properties.some(prop => Object.prototype.hasOwnProperty.call(item, prop))
77
if (hasAnyProperty(sourceItem)) {
88
return target
@@ -11,7 +11,7 @@ function findMatchingIndex (properties, sourceItem, target) {
1111
}
1212
}
1313

14-
function mergeBy (key, configvalidator, overridevalidator, properties, target, source, options, githubContext) {
14+
function mergeBy(key, configvalidator, overridevalidator, properties, target, source, options, githubContext) {
1515
const destination = target.slice()
1616
source.forEach(sourceItem => {
1717
const matchingIndex = findMatchingIndex(properties, sourceItem, target)

0 commit comments

Comments
 (0)