Skip to content

Commit

Permalink
Lint for stray console.logs (#2643)
Browse files Browse the repository at this point in the history
* lint for stray console.logs

* upgrade oxlint, add oxlint npm run script
  • Loading branch information
david-crespo authored Jan 9, 2025
1 parent 2fa9b42 commit a6f8404
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 43 deletions.
2 changes: 2 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ module.exports = {
'import/no-default-export': 'error',
'import/no-unresolved': 'off', // plugin doesn't know anything
'jsx-a11y/label-has-associated-control': [2, { controlComponents: ['button'] }],
// only worry about console.log
'no-console': ['error', { allow: ['warn', 'error', 'info', 'table'] }],
'no-param-reassign': 'error',
'no-restricted-imports': [
'error',
Expand Down
2 changes: 1 addition & 1 deletion app/api/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ export const wrapQueryClient = <A extends ApiClient>(api: A, queryClient: QueryC
// directly without further processing
throw data
}
console.log(options.explanation)
console.info(options.explanation)
return { type: 'error' as const, data }
}),
...options,
Expand Down
2 changes: 1 addition & 1 deletion app/api/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function handleResult<T>(result: ApiResult<T>): T {
}

function logHeading(s: string) {
console.log(`%c${s}`, 'font-size: 16px; font-weight: bold;')
console.info(`%c${s}`, 'font-size: 16px; font-weight: bold;')
}

if (typeof window !== 'undefined') {
Expand Down
2 changes: 1 addition & 1 deletion app/forms/image-upload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ export function Component() {
.catch((e) => {
// eat a 404 since that's what we want. anything else should still blow up
if (e.statusCode === 404) {
console.log(
console.info(
'/v1/images 404 is expected. It means the image name is not taken.'
)
return null
Expand Down
4 changes: 2 additions & 2 deletions app/msw-mock-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function getChaos() {
const chaos = getChaos()

if (process.env.NODE_ENV !== 'production' && chaos) {
console.log(`
console.info(`
▄████████ ▄█ █▄ ▄████████ ▄██████▄ ▄████████
███ ███ ███ ███ ███ ███ ███ ███ ███ ███
███ █▀ ███ ███ ███ ███ ███ ███ ███ █▀
Expand All @@ -34,7 +34,7 @@ if (process.env.NODE_ENV !== 'production' && chaos) {
███ ███ ███ ███ ███ ███ ▄███ ███ ███
▀█ ███ █▀ ▀██████▀ ████████▀ ██████████
`)
console.log(`Running MSW in CHAOS MODE with ${chaos}% likelihood of random failure`)
console.info(`Running MSW in CHAOS MODE with ${chaos}% likelihood of random failure`)
}

/** Return true for failure with a given likelihood */
Expand Down
72 changes: 36 additions & 36 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"e2e": "playwright test",
"e2ec": "playwright test --project=chrome",
"lint": "eslint --ext .js,.ts,.tsx app test mock-api",
"lint-fast": "npm run lint -- --cache",
"oxlint": "oxlint",
"fmt": "prettier --cache --write . && npm run lint -- --fix",
"openapi-gen-ts": "openapi-gen-ts",
"prettier": "prettier",
Expand Down Expand Up @@ -109,7 +109,7 @@
"ip-num": "^1.5.1",
"jsdom": "^25.0.1",
"msw": "^2.7.0",
"oxlint": "^0.14.1",
"oxlint": "^0.15.5",
"patch-package": "^8.0.0",
"postcss": "^8.4.49",
"postcss-import": "^16.1.0",
Expand Down

0 comments on commit a6f8404

Please sign in to comment.