Skip to content

Commit 8a56437

Browse files
authored
Pretty format (#20352)
* Update prettier flow to include JS * Run prettier * ...run prettier
1 parent ae3db79 commit 8a56437

File tree

333 files changed

+6929
-5375
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

333 files changed

+6929
-5375
lines changed

.eslintrc.js

+12-23
Original file line numberDiff line numberDiff line change
@@ -3,51 +3,40 @@ module.exports = {
33
browser: true,
44
commonjs: true,
55
es2020: true,
6-
node: true
6+
node: true,
77
},
88
parser: '@babel/eslint-parser',
9-
extends: [
10-
'eslint:recommended',
11-
'standard',
12-
'prettier'
13-
],
9+
extends: ['eslint:recommended', 'standard', 'prettier'],
1410
parserOptions: {
1511
ecmaVersion: 11,
1612
requireConfigFile: 'false',
17-
babelOptions: { configFile: './.babelrc' }
13+
babelOptions: { configFile: './.babelrc' },
1814
},
1915
rules: {
2016
'import/no-extraneous-dependencies': ['error', { packageDir: '.' }],
2117
'node/global-require': ['error'],
22-
'import/no-dynamic-require': ['error']
18+
'import/no-dynamic-require': ['error'],
2319
},
2420
overrides: [
2521
{
26-
files: [
27-
'**/tests/**/*.js'
28-
],
22+
files: ['**/tests/**/*.js'],
2923
env: {
30-
jest: true
31-
}
24+
jest: true,
25+
},
3226
},
3327
{
34-
files: [
35-
'**/*.tsx', '**/*.ts'
36-
],
37-
plugins: [
38-
'@typescript-eslint',
39-
'jsx-a11y'
40-
],
28+
files: ['**/*.tsx', '**/*.ts'],
29+
plugins: ['@typescript-eslint', 'jsx-a11y'],
4130
extends: ['plugin:jsx-a11y/recommended'],
4231
parser: '@typescript-eslint/parser',
4332
rules: {
44-
'camelcase': 'off',
33+
camelcase: 'off',
4534
'no-unused-vars': 'off',
4635
'no-undef': 'off',
4736
'no-use-before-define': 'off',
4837
'@typescript-eslint/no-unused-vars': ['error'],
4938
'jsx-a11y/no-onchange': 'off',
50-
}
39+
},
5140
},
52-
]
41+
],
5342
}

.github/actions-scripts/check-for-enterprise-issues-by-label.js

+16-11
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,30 @@
33
import { getOctokit } from '@actions/github'
44
import { setOutput } from '@actions/core'
55

6-
async function run () {
6+
async function run() {
77
const token = process.env.GITHUB_TOKEN
88
const octokit = getOctokit(token)
99
const query = encodeURIComponent('is:open repo:github/docs-internal is:issue')
1010

11-
const deprecationIssues = await octokit.request(`GET /search/issues?q=${query}+label:"enterprise%20deprecation"`)
12-
const releaseIssues = await octokit.request(`GET /search/issues?q=${query}+label:"enterprise%20release"`)
11+
const deprecationIssues = await octokit.request(
12+
`GET /search/issues?q=${query}+label:"enterprise%20deprecation"`
13+
)
14+
const releaseIssues = await octokit.request(
15+
`GET /search/issues?q=${query}+label:"enterprise%20release"`
16+
)
1317
const isDeprecationIssue = deprecationIssues.data.items.length === 0 ? 'false' : 'true'
1418
const isReleaseIssue = releaseIssues.data.items.length === 0 ? 'false' : 'true'
1519
setOutput('deprecationIssue', isDeprecationIssue)
1620
setOutput('releaseIssue', isReleaseIssue)
1721
return `Set outputs deprecationIssue: ${isDeprecationIssue}, releaseIssue: ${isReleaseIssue}`
1822
}
1923

20-
run()
21-
.then(
22-
(response) => { console.log(`Finished running: ${response}`) },
23-
(error) => {
24-
console.log(`#ERROR# ${error}`)
25-
process.exit(1)
26-
}
27-
)
24+
run().then(
25+
(response) => {
26+
console.log(`Finished running: ${response}`)
27+
},
28+
(error) => {
29+
console.log(`#ERROR# ${error}`)
30+
process.exit(1)
31+
}
32+
)

.github/actions-scripts/create-enterprise-issue.js

+43-31
Original file line numberDiff line numberDiff line change
@@ -20,44 +20,46 @@ const numberOfdaysBeforeDeprecationToOpenIssue = 15
2020
// number of days.
2121
//
2222
// When a milestone is within the specified number of days, a new issue is
23-
// created using the templates in
24-
// .github/actions-scripts/enterprise-server-issue-templates.
23+
// created using the templates in
24+
// .github/actions-scripts/enterprise-server-issue-templates.
2525
//
2626
// Release issues are then added to the docs content squad board for triage.
27-
// Deprecations issues are owned by docs engineering and are added to the
27+
// Deprecations issues are owned by docs engineering and are added to the
2828
// docs engineering squad board automatically when the engineering label is added.
2929
//
3030
// [end-readme]
3131

3232
run()
3333

34-
async function run () {
35-
34+
async function run() {
3635
const milestone = process.argv[2]
3736
if (!acceptedMilestones.includes(milestone)) {
38-
console.log('Please specify either \'release\' or \'deprecation\'\n')
37+
console.log("Please specify either 'release' or 'deprecation'\n")
3938
console.log('Example: script/open-enterprise-issue.js release')
4039
process.exit(1)
4140
}
4241

4342
// Milestone-dependent values.
44-
const numberOfdaysBeforeMilestoneToOpenIssue = milestone === 'release'
45-
? numberOfdaysBeforeReleaseToOpenIssue
46-
: numberOfdaysBeforeDeprecationToOpenIssue
43+
const numberOfdaysBeforeMilestoneToOpenIssue =
44+
milestone === 'release'
45+
? numberOfdaysBeforeReleaseToOpenIssue
46+
: numberOfdaysBeforeDeprecationToOpenIssue
4747

48-
const versionNumber = milestone === 'release'
49-
? getNextVersionNumber()
50-
: oldestSupported
48+
const versionNumber = milestone === 'release' ? getNextVersionNumber() : oldestSupported
5149

5250
if (!versionNumber) {
53-
console.log(`Could not find the next version number after ${latest} in enterprise-dates.json. Try running script/udpate-enterprise-dates.js, then rerun this script.`)
51+
console.log(
52+
`Could not find the next version number after ${latest} in enterprise-dates.json. Try running script/udpate-enterprise-dates.js, then rerun this script.`
53+
)
5454
process.exit(0)
5555
}
5656

5757
const datesForVersion = enterpriseDates[versionNumber]
5858

5959
if (!datesForVersion) {
60-
console.log(`Could not find ${versionNumber} in enterprise-dates.json. Try running script/udpate-enterprise-dates.js, then rerun this script.`)
60+
console.log(
61+
`Could not find ${versionNumber} in enterprise-dates.json. Try running script/udpate-enterprise-dates.js, then rerun this script.`
62+
)
6163
process.exit(0)
6264
}
6365

@@ -66,11 +68,19 @@ async function run () {
6668

6769
// If the milestone is more than the specific days away, exit now.
6870
if (daysUntilMilestone > numberOfdaysBeforeMilestoneToOpenIssue) {
69-
console.log(`The ${versionNumber} ${milestone} is not until ${nextMilestoneDate}! An issue will be opened when it is ${numberOfdaysBeforeMilestoneToOpenIssue} days away.`)
71+
console.log(
72+
`The ${versionNumber} ${milestone} is not until ${nextMilestoneDate}! An issue will be opened when it is ${numberOfdaysBeforeMilestoneToOpenIssue} days away.`
73+
)
7074
process.exit(0)
7175
}
7276

73-
const milestoneSteps = fs.readFileSync(path.join(process.cwd(), `.github/actions-scripts/enterprise-server-issue-templates/${milestone}-issue.md`), 'utf8')
77+
const milestoneSteps = fs.readFileSync(
78+
path.join(
79+
process.cwd(),
80+
`.github/actions-scripts/enterprise-server-issue-templates/${milestone}-issue.md`
81+
),
82+
'utf8'
83+
)
7484
const issueLabels = [`enterprise ${milestone}`, `engineering`]
7585
const issueTitle = `[${nextMilestoneDate}] Enterprise Server ${versionNumber} ${milestone} (technical steps)`
7686

@@ -88,61 +98,63 @@ async function run () {
8898
repo: 'docs-internal',
8999
title: issueTitle,
90100
body: issueBody,
91-
labels: issueLabels
101+
labels: issueLabels,
92102
})
93103
if (issue.status === 201) {
94104
// Write the values to disk for use in the workflow.
95-
console.log(`Issue #${issue.data.number} for the ${versionNumber} ${milestone} was opened: ${issue.data.html_url}`)
105+
console.log(
106+
`Issue #${issue.data.number} for the ${versionNumber} ${milestone} was opened: ${issue.data.html_url}`
107+
)
96108
}
97109
} catch (error) {
98110
console.error(`#ERROR# ${error}`)
99111
console.log(`🛑 There was an error creating the issue.`)
100112
process.exit(1)
101113
}
102114

103-
// Add the release issue to the 'Needs triage' column on the
115+
// Add the release issue to the 'Needs triage' column on the
104116
// docs content squad project board:
105117
// https://github.com/orgs/github/projects/1773#column-12198119
106118
// Deprecation issues are owned by docs engineering only and will
107119
// be triaged by adding the engineering label to the issue.
108120
if (milestone === 'release') {
109121
try {
110122
const addCard = await octokit.request('POST /projects/columns/{column_id}/cards', {
111-
column_id: 12198119,
123+
column_id: 12198119,
112124
content_id: issue.data.id,
113125
content_type: 'Issue',
114126
mediaType: {
115-
previews: [
116-
'inertia'
117-
]
118-
}
127+
previews: ['inertia'],
128+
},
119129
})
120130

121131
if (addCard.status === 201) {
122132
// Write the values to disk for use in the workflow.
123-
console.log(`The issue #${issue.data.number} was added to https://github.com/orgs/github/projects/1773#column-12198119.`)
124-
}
125-
} catch(error) {
133+
console.log(
134+
`The issue #${issue.data.number} was added to https://github.com/orgs/github/projects/1773#column-12198119.`
135+
)
136+
}
137+
} catch (error) {
126138
console.error(`#ERROR# ${error}`)
127139
console.log(`🛑 There was an error adding the issue to the project board.`)
128140
process.exit(1)
129141
}
130142
}
131143
}
132144

133-
function getNextVersionNumber () {
145+
function getNextVersionNumber() {
134146
const indexOfLatest = Object.keys(enterpriseDates).indexOf(latest)
135147
const indexOfNext = indexOfLatest + 1
136148
return Object.keys(enterpriseDates)[indexOfNext]
137149
}
138150

139-
function calculateDaysUntilMilestone (nextMilestoneDate) {
151+
function calculateDaysUntilMilestone(nextMilestoneDate) {
140152
const today = new Date().toISOString().slice(0, 10)
141153
const differenceInMilliseconds = getTime(nextMilestoneDate) - getTime(today)
142154
// Return the difference in days
143-
return Math.floor((differenceInMilliseconds) / (1000 * 60 * 60 * 24))
155+
return Math.floor(differenceInMilliseconds / (1000 * 60 * 60 * 24))
144156
}
145157

146-
function getTime (date) {
158+
function getTime(date) {
147159
return new Date(date).getTime()
148160
}

.github/actions-scripts/enterprise-algolia-label.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ if (!(labelsArray && labelsArray.length)) {
2020

2121
// Find the relevant label
2222
const algoliaLabel = labelsArray
23-
.map(label => label.name)
24-
.find(label => label.startsWith(labelText))
23+
.map((label) => label.name)
24+
.find((label) => label.startsWith(labelText))
2525

2626
// Exit early if no relevant label is found
2727
if (!algoliaLabel) {

.github/actions-scripts/openapi-schema-branch.js

+17-13
Original file line numberDiff line numberDiff line change
@@ -7,34 +7,38 @@ import semver from 'semver'
77

88
/*
99
* This script performs two checks to prevent shipping development mode OpenAPI schemas:
10-
* - Ensures the `info.version` property is a semantic version.
11-
* In development mode, the `info.version` property is a string
12-
* containing the `github/github` branch name.
13-
* - Ensures the decorated schema matches the dereferenced schema.
14-
* The workflow that calls this script runs `script/rest/update-files.js`
15-
* with the `--decorate-only` switch then checks to see if files changed.
16-
*
17-
*/
10+
* - Ensures the `info.version` property is a semantic version.
11+
* In development mode, the `info.version` property is a string
12+
* containing the `github/github` branch name.
13+
* - Ensures the decorated schema matches the dereferenced schema.
14+
* The workflow that calls this script runs `script/rest/update-files.js`
15+
* with the `--decorate-only` switch then checks to see if files changed.
16+
*
17+
*/
1818

1919
// Check that the `info.version` property is a semantic version
2020
const dereferencedDir = path.join(process.cwd(), 'lib/rest/static/dereferenced')
2121
const schemas = fs.readdirSync(dereferencedDir)
2222

23-
schemas.forEach(filename => {
23+
schemas.forEach((filename) => {
2424
const schema = JSON.parse(fs.readFileSync(path.join(dereferencedDir, filename)))
2525
if (!semver.valid(schema.info.version)) {
26-
console.log(`🚧⚠️ Your branch contains a development mode OpenAPI schema: ${schema.info.version}. This check is a reminder to not 🚢 OpenAPI files in development mode. 🛑`)
26+
console.log(
27+
`🚧⚠️ Your branch contains a development mode OpenAPI schema: ${schema.info.version}. This check is a reminder to not 🚢 OpenAPI files in development mode. 🛑`
28+
)
2729
process.exit(1)
2830
}
2931
})
3032

3133
// Check that the decorated schema matches the dereferenced schema
3234
const changedFiles = execSync('git diff --name-only HEAD').toString()
3335

34-
if(changedFiles !== '') {
36+
if (changedFiles !== '') {
3537
console.log(`These files were changed:\n${changedFiles}`)
36-
console.log(`🚧⚠️ Your decorated and dereferenced schema files don't match. Ensure you're using decorated and dereferenced schemas from the automatically created pull requests by the 'github-openapi-bot' user. For more information, see 'script/rest/README.md'. 🛑`)
37-
process.exit(1)
38+
console.log(
39+
`🚧⚠️ Your decorated and dereferenced schema files don't match. Ensure you're using decorated and dereferenced schemas from the automatically created pull requests by the 'github-openapi-bot' user. For more information, see 'script/rest/README.md'. 🛑`
40+
)
41+
process.exit(1)
3842
}
3943

4044
// All checks pass, ready to ship

.github/allowed-actions.js

+32-32
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,36 @@
44
// can be added it this list.
55

66
export default [
7-
"actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f", // v2.3.4
8-
"actions/github-script@2b34a689ec86a68d8ab9478298f91d5401337b7d", // v4.0.2
9-
"actions/labeler@5f867a63be70efff62b767459b009290364495eb", // v2.2.0
10-
"actions/setup-node@38d90ce44d5275ad62cc48384b3d8a58c500bb5f", // v2.2.0
11-
"actions/setup-python@dc73133d4da04e56a135ae2246682783cc7c7cb6", // v2.2.2
12-
"actions/stale@9d6f46564a515a9ea11e7762ab3957ee58ca50da", // v3.0.16
13-
"alex-page/github-project-automation-plus@fdb7991b72040d611e1123d2b75ff10eda9372c9",
14-
"andymckay/labeler@22d5392de2b725cea4b284df5824125054049d84",
15-
"crowdin/github-action@fd9429dd63d6c0f8a8cb4b93ad8076990bd6e688",
16-
"crykn/copy_folder_to_another_repo_action@0282e8b9fef06de92ddcae9fe6cb44df6226646c",
17-
"cschleiden/actions-linter@0ff16d6ac5103cca6c92e6cbc922b646baaea5be",
18-
"dawidd6/action-delete-branch@47743101a121ad657031e6704086271ca81b1911",
19-
"docker://chinthakagodawita/autoupdate-action:v1",
20-
"dorny/paths-filter@eb75a1edc117d3756a18ef89958ee59f9500ba58",
21-
"github/codeql-action/analyze@v1",
22-
"github/codeql-action/init@v1",
23-
"juliangruber/approve-pull-request-action@c530832d4d346c597332e20e03605aa94fa150a8",
24-
"juliangruber/find-pull-request-action@db875662766249c049b2dcd85293892d61cb0b51", // v1.5.0
25-
"juliangruber/read-file-action@e0a316da496006ffd19142f0fd594a1783f3b512",
26-
"lee-dohm/close-matching-issues@22002609b2555fe18f52b8e2e7c07cbf5529e8a8",
27-
"lee-dohm/no-response@9bb0a4b5e6a45046f00353d5de7d90fb8bd773bb",
28-
"pascalgn/automerge-action@c9bd1823770819dc8fb8a5db2d11a3a95fbe9b07", // v0.12.0
29-
"peter-evans/create-issue-from-file@b4f9ee0a9d4abbfc6986601d9b1a4f8f8e74c77e",
30-
"peter-evans/create-or-update-comment@5221bf4aa615e5c6e95bb142f9673a9c791be2cd",
31-
"peter-evans/create-pull-request@8c603dbb04b917a9fc2dd991dc54fef54b640b43",
32-
"rachmari/actions-add-new-issue-to-column@1a459ef92308ba7c9c9dc2fcdd72f232495574a9",
33-
"rachmari/labeler@832d42ec5523f3c6d46e8168de71cd54363e3e2e",
34-
"repo-sync/github-sync@3832fe8e2be32372e1b3970bbae8e7079edeec88",
35-
"repo-sync/pull-request@33777245b1aace1a58c87a29c90321aa7a74bd7d",
36-
"someimportantcompany/github-actions-slack-message@0b470c14b39da4260ed9e3f9a4f1298a74ccdefd",
37-
"tjenkinson/gh-action-auto-merge-dependency-updates@4d7756c04d9d999c5968697a621b81c47f533d61",
38-
"EndBug/add-and-commit@b3c7c1e078a023d75fb0bd326e02962575ce0519"
7+
'actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f', // v2.3.4
8+
'actions/github-script@2b34a689ec86a68d8ab9478298f91d5401337b7d', // v4.0.2
9+
'actions/labeler@5f867a63be70efff62b767459b009290364495eb', // v2.2.0
10+
'actions/setup-node@38d90ce44d5275ad62cc48384b3d8a58c500bb5f', // v2.2.0
11+
'actions/setup-python@dc73133d4da04e56a135ae2246682783cc7c7cb6', // v2.2.2
12+
'actions/stale@9d6f46564a515a9ea11e7762ab3957ee58ca50da', // v3.0.16
13+
'alex-page/github-project-automation-plus@fdb7991b72040d611e1123d2b75ff10eda9372c9',
14+
'andymckay/labeler@22d5392de2b725cea4b284df5824125054049d84',
15+
'crowdin/github-action@fd9429dd63d6c0f8a8cb4b93ad8076990bd6e688',
16+
'crykn/copy_folder_to_another_repo_action@0282e8b9fef06de92ddcae9fe6cb44df6226646c',
17+
'cschleiden/actions-linter@0ff16d6ac5103cca6c92e6cbc922b646baaea5be',
18+
'dawidd6/action-delete-branch@47743101a121ad657031e6704086271ca81b1911',
19+
'docker://chinthakagodawita/autoupdate-action:v1',
20+
'dorny/paths-filter@eb75a1edc117d3756a18ef89958ee59f9500ba58',
21+
'github/codeql-action/analyze@v1',
22+
'github/codeql-action/init@v1',
23+
'juliangruber/approve-pull-request-action@c530832d4d346c597332e20e03605aa94fa150a8',
24+
'juliangruber/find-pull-request-action@db875662766249c049b2dcd85293892d61cb0b51', // v1.5.0
25+
'juliangruber/read-file-action@e0a316da496006ffd19142f0fd594a1783f3b512',
26+
'lee-dohm/close-matching-issues@22002609b2555fe18f52b8e2e7c07cbf5529e8a8',
27+
'lee-dohm/no-response@9bb0a4b5e6a45046f00353d5de7d90fb8bd773bb',
28+
'pascalgn/automerge-action@c9bd1823770819dc8fb8a5db2d11a3a95fbe9b07', // v0.12.0
29+
'peter-evans/create-issue-from-file@b4f9ee0a9d4abbfc6986601d9b1a4f8f8e74c77e',
30+
'peter-evans/create-or-update-comment@5221bf4aa615e5c6e95bb142f9673a9c791be2cd',
31+
'peter-evans/create-pull-request@8c603dbb04b917a9fc2dd991dc54fef54b640b43',
32+
'rachmari/actions-add-new-issue-to-column@1a459ef92308ba7c9c9dc2fcdd72f232495574a9',
33+
'rachmari/labeler@832d42ec5523f3c6d46e8168de71cd54363e3e2e',
34+
'repo-sync/github-sync@3832fe8e2be32372e1b3970bbae8e7079edeec88',
35+
'repo-sync/pull-request@33777245b1aace1a58c87a29c90321aa7a74bd7d',
36+
'someimportantcompany/github-actions-slack-message@0b470c14b39da4260ed9e3f9a4f1298a74ccdefd',
37+
'tjenkinson/gh-action-auto-merge-dependency-updates@4d7756c04d9d999c5968697a621b81c47f533d61',
38+
'EndBug/add-and-commit@b3c7c1e078a023d75fb0bd326e02962575ce0519',
3939
]

0 commit comments

Comments
 (0)