-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: enable biome recommended linter rules #9848
Conversation
204c92d
to
3e5fb88
Compare
packages/browser-integration-tests/suites/replay/bufferMode/test.ts
Outdated
Show resolved
Hide resolved
3e5fb88
to
44f5bda
Compare
size-limit report 📦
|
48f2fc5
to
0f9a3ca
Compare
0f9a3ca
to
d4d1ab2
Compare
@@ -236,8 +236,8 @@ function _enhanceEventWithInitialFrame(event: Event, url: any, line: any, column | |||
// event.exception.values[0].stacktrace.frames | |||
const ev0sf = (ev0s.frames = ev0s.frames || []); | |||
|
|||
const colno = isNaN(parseInt(column, 10)) ? undefined : column; | |||
const lineno = isNaN(parseInt(line, 10)) ? undefined : line; | |||
const colno = Number.isNaN(parseInt(column, 10)) ? undefined : column; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Number.isNaN
is not supported by IE11 😬 so we need to remove that rule and revert these, sadly, at least until V8!
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
fill(xhr, prop, function (original: WrappedFunction): () => any { | ||
fill(this, prop, (original: WrappedFunction): (() => any) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not 100% sure if it is safe to replace these with anonymous functions - we should just double check, I remember seeing some comments somewhere that in some cases this may be tricky.
@@ -1,5 +1,5 @@ | |||
// biome-ignore format: Disabled due to trailing comma not working in IE10/11 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to exclude this file, as this is specifically copy-pasted from the sentry repo (where the loader actually lives), and should be exactly the same as there!
@@ -416,7 +416,7 @@ export function applyDebugMetadata(resource_paths: ReadonlyArray<string>): Debug | |||
*/ | |||
export function isValidSampleRate(rate: unknown): boolean { | |||
// we need to check NaN explicitly because it's of type 'number' and therefore wouldn't get caught by this typecheck | |||
if ((typeof rate !== 'number' && typeof rate !== 'boolean') || (typeof rate === 'number' && isNaN(rate))) { | |||
if ((typeof rate !== 'number' && typeof rate !== 'boolean') || (typeof rate === 'number' && Number.isNaN(rate))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IE 11 :(
@@ -107,7 +107,7 @@ function createIndexedDbStore(options: BrowserOfflineTransportOptions): OfflineS | |||
|
|||
// Lazily create the store only when it's needed | |||
function getStore(): Store { | |||
if (store == undefined) { | |||
if (store === undefined) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
l: can we just make this:
if (store === undefined) { | |
if (!store) { |
@@ -103,7 +103,7 @@ export function sampleTransaction<T extends Transaction>( | |||
function isValidSampleRate(rate: unknown): boolean { | |||
// we need to check NaN explicitly because it's of type 'number' and therefore wouldn't get caught by this typecheck | |||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | |||
if (isNaN(rate) || !(typeof rate === 'number' || typeof rate === 'boolean')) { | |||
if (Number.isNaN(rate) || !(typeof rate === 'number' || typeof rate === 'boolean')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IE 11 :(
@@ -19,5 +19,3 @@ assert.match(buildStdout, /● \/client-component\/parameter\/\[parameter\]/); | |||
assert.match(buildStdout, /λ \/server-component/); | |||
assert.match(buildStdout, /λ \/server-component\/parameter\/\[\.\.\.parameters\]/); | |||
assert.match(buildStdout, /λ \/server-component\/parameter\/\[parameter\]/); | |||
|
|||
export {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is needed for build reasons 🤔
@@ -39,7 +39,7 @@ function isSentryInitialized() { | |||
} | |||
|
|||
function areSentryOptionsDefined(params) { | |||
if (params == undefined) return false; | |||
if (params === undefined) return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (params === undefined) return false; | |
if (!params) return false; |
@@ -17,7 +17,7 @@ var fdeb = new u8([ | |||
// code length index map |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a built file, we need to exclude this.
@@ -5,7 +5,7 @@ import type { Span, SpanContext } from '@sentry/types'; | |||
* Checks if a given value is a valid measurement value. | |||
*/ | |||
export function isMeasurementValue(value: unknown): value is number { | |||
return typeof value === 'number' && isFinite(value); | |||
return typeof value === 'number' && Number.isFinite(value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IE 11 :(
@@ -175,7 +175,7 @@ export function extractNetworkProtocol(nextHopProtocol: string): { name: string; | |||
break; | |||
} | |||
// h2, h3 etc. | |||
if (!isNaN(Number(char))) { | |||
if (!Number.isNaN(Number(char))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IE 11 :(
@@ -9,7 +9,7 @@ import { truncate } from './string'; | |||
export function applyAggregateErrorsToEvent( | |||
exceptionFromErrorImplementation: (stackParser: StackParser, ex: Error) => Exception, | |||
parser: StackParser, | |||
maxValueLimit: number = 250, | |||
maxValueLimit: number | undefined = 250, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why this change? 🤔
@@ -107,7 +107,7 @@ function validateDsn(dsn: DsnComponents): boolean { | |||
return false; | |||
} | |||
|
|||
if (port && isNaN(parseInt(port, 10))) { | |||
if (port && Number.isNaN(parseInt(port, 10))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IE11 :(
* @param wat A value to be checked. | ||
* @returns A boolean representing the result. | ||
*/ | ||
export function isNaN(wat: unknown): boolean { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we can get rid of this, as this is exported and thus public API.
major: isNaN(major) ? undefined : major, | ||
minor: isNaN(minor) ? undefined : minor, | ||
patch: isNaN(patch) ? undefined : patch, | ||
major: Number.isNaN(major) ? undefined : major, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IE11 :(
memo: MemoFunc = memoBuilder(), | ||
): Primitive | ObjOrArray<unknown> { | ||
const [memoize, unmemoize] = memo; | ||
|
||
// Get the simple cases out of the way first | ||
if ( | ||
value == null || // this matches null and undefined -> eqeq not eqeqeq | ||
(['number', 'boolean', 'string'].includes(typeof value) && !isNaN(value)) | ||
(['number', 'boolean', 'string'].includes(typeof value) && !Number.isNaN(value)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I wont repeat this anymore, but for everything that's not node only we can't use Number.isNaN
😅
I'll keep this PR open, and revisit it when we start working on v8. @mydea |
Please review with caution and make sure you go through all lines.
Found several bugs on Biome:
useStringLiterals
produce false recommendations biomejs/biome#1192noUselessElse
recommendation is wrong biomejs/biome#1191I think we should enable some of these rules after this PR is merged: