Skip to content

Commit a3e8216

Browse files
committed
tools: also lint for console.log in oxlint
1 parent a6f8404 commit a3e8216

File tree

6 files changed

+28
-25
lines changed

6 files changed

+28
-25
lines changed

.oxlintrc.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
"plugins": ["react", "react-hooks", "unicorn", "typescript", "oxc"],
44
"rules": {
55
"react-hooks/exhaustive-deps": "error",
6+
// only worry about console.log
7+
"no-console": ["error", { "allow": ["warn", "error", "info", "table"] }],
68
// turning this off because it's more sensitive than eslint currently
79
// "react-hooks/rules-of-hooks": "error",
810
"no-unused-vars": [
@@ -13,5 +15,6 @@
1315
"caughtErrorsIgnorePattern": "^_"
1416
}
1517
]
16-
}
18+
},
19+
"ignorePatterns": ["dist/", "node_modules/"]
1720
}

tools/deno/api-diff.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Parameters:
3434
`.trim()
3535

3636
function printHelpAndExit(): never {
37-
console.log(HELP)
37+
console.info(HELP)
3838
Deno.exit()
3939
}
4040

@@ -98,7 +98,7 @@ async function genForCommit(commit: string, force: boolean) {
9898
if (force || !alreadyExists) {
9999
await $`rm -rf ${tmpDir}`
100100
await $`mkdir -p ${tmpDir}`
101-
console.log(`Generating for ${commit}...`)
101+
console.info(`Generating for ${commit}...`)
102102
await $`npx @oxide/[email protected] ${specUrl(commit)} ${tmpDir}`
103103
await $`npx prettier --write --log-level error ${tmpDir}`
104104
}

tools/deno/bump-omicron.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ const args = flags.parse(Deno.args, {
6565
})
6666

6767
if (args.help) {
68-
console.log(HELP)
68+
console.info(HELP)
6969
Deno.exit()
7070
}
7171

@@ -103,7 +103,7 @@ const oldCommit = /COMMIT="?([a-f0-9]+)"?/.exec(oldVersionFile)?.[1]
103103
if (!oldCommit) throw Error('Could not parse existing version file')
104104

105105
if (oldCommit === newCommit) {
106-
console.log('Nothing to update: Omicron already has the current commit pinned')
106+
console.info('Nothing to update: Omicron already has the current commit pinned')
107107
Deno.exit()
108108
}
109109

@@ -118,7 +118,7 @@ const changesLine = `https://github.com/oxidecomputer/console/compare/${commitRa
118118
const branchName = 'bump-console-' + newCommit.slice(0, 8)
119119
const prBody = `${changesLine}\n\n${commitsMarkdown}`
120120

121-
console.log(`\n${changesLine}\n\n${commits}\n`)
121+
console.info(`\n${changesLine}\n\n${commits}\n`)
122122

123123
if (args.dryRun) Deno.exit()
124124

@@ -131,15 +131,15 @@ const message =
131131

132132
const prTitle = 'Bump web console' + (message ? ` (${message})` : '')
133133

134-
console.log(`\nPR title: ${prTitle}\n`)
134+
console.info(`\nPR title: ${prTitle}\n`)
135135

136136
const go = await $.confirm({ message: 'Make Omicron PR?', noClear: true })
137137
if (!go) Deno.exit()
138138

139139
if (!$.commandExistsSync('gh')) throw Error(GH_MISSING)
140140

141141
await Deno.writeTextFile(VERSION_FILE, newVersionFile)
142-
console.log('Updated ', VERSION_FILE)
142+
console.info('Updated ', VERSION_FILE)
143143

144144
const consoleDir = Deno.cwd()
145145

@@ -149,28 +149,28 @@ Deno.chdir(OMICRON_DIR)
149149
await $`git checkout main`
150150
await $`git pull`
151151
await $`git checkout -b ${branchName}`
152-
console.log('Created branch', branchName)
152+
console.info('Created branch', branchName)
153153

154154
await $`git add tools/console_version`
155155
await $`git commit -m ${prTitle} -m ${prBody}`
156156
await $`git push --set-upstream origin ${branchName}`
157-
console.log('Committed changes and pushed')
157+
console.info('Committed changes and pushed')
158158

159159
// create PR
160160
const prUrl = await $`gh pr create --title ${prTitle} --body ${prBody}`.text()
161-
console.log('PR created:', prUrl)
161+
console.info('PR created:', prUrl)
162162

163163
// set it to auto merge
164164
const prNum = prUrl.match(/\d+$/)![0]
165165
await $`gh pr merge ${prNum} --auto --squash`
166-
console.log('PR set to auto-merge when CI passes')
166+
console.info('PR set to auto-merge when CI passes')
167167

168168
await $`git checkout main`
169169
await $`git branch -D ${branchName}`
170-
console.log('Checked out omicron main, deleted branch', branchName)
170+
console.info('Checked out omicron main, deleted branch', branchName)
171171

172172
// bump omicron tag in console to current commit
173173
Deno.chdir(consoleDir)
174-
console.log('Bumping omicron tag in console')
174+
console.info('Bumping omicron tag in console')
175175
await $`git tag -f -a omicron -m 'pinned commit on omicron main'`
176176
await $`git push -f origin tag omicron`

tools/deno/deploy-dogfood.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,36 +36,36 @@ const consoleCommit = args._[0]
3636

3737
if (!consoleCommit) {
3838
console.error('Error: Console commit hash is required\n')
39-
console.log(USAGE)
39+
console.info(USAGE)
4040
Deno.exit(1)
4141
}
4242

43-
console.log('Finding nexus zones...')
43+
console.info('Finding nexus zones...')
4444
const zones: string = await $`./tools/dogfood/find-zone.sh nexus`.text()
4545
const gimletNums = zones
4646
.split('\n')
4747
.filter((line) => line.includes('nexus'))
4848
.map((line) => line.trim().split(' ')[0])
4949

50-
console.log(`Found: ${JSON.stringify(gimletNums)}\n`)
50+
console.info(`Found: ${JSON.stringify(gimletNums)}\n`)
5151

5252
const TARBALL_URL = `https://dl.oxide.computer/releases/console/${consoleCommit}.tar.gz`
5353
const TARBALL_FILE = '/tmp/console.tar.gz'
5454

55-
console.log(`Downloading tarball to ${TARBALL_FILE}`)
55+
console.info(`Downloading tarball to ${TARBALL_FILE}`)
5656
await $`curl --show-error --fail --location --output ${TARBALL_FILE} ${TARBALL_URL}`
57-
console.log(`Done downloading.\n`)
57+
console.info(`Done downloading.\n`)
5858

5959
const go = await $.confirm(`Deploy console to gimlets ${JSON.stringify(gimletNums)}?`)
6060
if (!go) {
61-
console.log('Deploy aborted')
61+
console.info('Deploy aborted')
6262
Deno.exit()
6363
}
6464

6565
async function deploy(num: string) {
66-
console.log(`Deploying to gimlet ${num}...`)
66+
console.info(`Deploying to gimlet ${num}...`)
6767
await $`./tools/dogfood/scp-assets.sh gc${num} ${TARBALL_FILE}`
68-
console.log(`Done with gimlet ${num}...`)
68+
console.info(`Done with gimlet ${num}...`)
6969
}
7070

7171
await Promise.all(gimletNums.map(deploy))

tools/deno/mock-serial-console.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ async function serialConsole(req: Request) {
2727
const { socket, response } = Deno.upgradeWebSocket(req)
2828
socket.binaryType = 'arraybuffer'
2929

30-
console.log(`New client connected`)
30+
console.info(`New client connected`)
3131

3232
// send hello as a binary frame for xterm to display
3333
socket.onopen = () => {
@@ -39,7 +39,7 @@ async function serialConsole(req: Request) {
3939
// echo back binary data
4040
socket.onmessage = (m) => socket.send(m.data)
4141

42-
socket.onclose = () => console.log('Connection closed')
42+
socket.onclose = () => console.info('Connection closed')
4343

4444
return response
4545
}

tools/start_mock_api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { handlers } from '../mock-api/msw/handlers'
1212
// TODO: take port argument
1313
createServer(...handlers).listen(12220)
1414

15-
console.log('Mock Nexus API running at http://localhost:12220')
15+
console.info('Mock Nexus API running at http://localhost:12220')
1616

1717
// TODO: request logging. I tried adding this as a full express server with
1818
// logging middleware and it only logged 404s, not good requests

0 commit comments

Comments
 (0)