Skip to content

Commit

Permalink
feat: enable biome recommended linter rules
Browse files Browse the repository at this point in the history
  • Loading branch information
anonrig committed Dec 14, 2023
1 parent 56845fb commit d4d1ab2
Show file tree
Hide file tree
Showing 336 changed files with 1,617 additions and 1,690 deletions.
4 changes: 4 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ module.exports = {
rules: {
// Disabled because it's included with Biome's linter
'no-control-regex': 'off',
'no-param-reassign': 'off',
'prefer-const': 'off',
'@typescript-eslint/ban-types': 'off',
'react-hooks/exhaustive-deps': 'off',
},
},
{
Expand Down
2 changes: 1 addition & 1 deletion .size-limit.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module.exports = [
import: '{ init, Replay, BrowserTracing }',
gzip: true,
limit: '75 KB',
modifyWebpackConfig: function (config) {
modifyWebpackConfig: config => {
const webpack = require('webpack');
config.plugins.push(
new webpack.DefinePlugin({
Expand Down
57 changes: 50 additions & 7 deletions biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,60 @@
"linter": {
"enabled": true,
"rules": {
"recommended": false,
"recommended": true,
"a11y": {
"all": false
},
"complexity": {
"noForEach": "off",
"noUselessConstructor": "off",
"noStaticOnlyClass": "off",
"useOptionalChain": "off",
"useLiteralKeys": "off"
},
"correctness": {
"all": false,
"noUnusedVariables": "error",
"noPrecisionLoss": "error"
"noEmptyPattern": "off",
"noInnerDeclarations": "off",
"noVoidTypeReturn": "off",
"noEmptyCharacterClassInRegex": "off"
},
"performance": {
"noDelete": "off"
},
"security": {
"all": true
},
"style": {
"noArguments": "off",
"noCommaOperator": "off",
"noNonNullAssertion": "off",
"noUselessElse": "off",
"useTemplate": "off",
"noVar": "off",
"useSingleVarDeclarator": "off",
"useDefaultParameterLast": "off",
"useExponentiationOperator": "off"
},
"suspicious": {
"all": false,
"noControlCharactersInRegex": "error"
"noDebugger": "off",
"noDoubleEquals": "off",
"noExplicitAny": "off",
"noRedeclare": "off",
"noAssignInExpressions": "off",
"noConfusingVoidType": "off",
"noPrototypeBuiltins": "off",
"noShadowRestrictedNames": "off",
"noControlCharactersInRegex": "off"
}
},
"ignore": [".vscode/*", "**/*.json"]
"ignore": [
".vscode/*",
"**/*.json",
"**/*.min.js",
"packages/browser-integration-tests/fixtures/loader.js",
"packages/browser/test/integration/polyfills/*.js",
"packages/replay-worker/examples/worker.js"
]
},
"files": {
"ignoreUnknown": true
Expand All @@ -44,6 +86,7 @@
]
},
"javascript": {
"globals": ["expect", "describe", "test", "it", "beforeEach", "afterEach", "beforeAll", "afterAll"],
"formatter": {
"enabled": true,
"quoteStyle": "single",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"codecov": "codecov",
"fix": "run-s fix:lerna fix:biome",
"fix:lerna": "lerna run fix",
"fix:biome": "biome check --apply-unsafe .",
"fix:biome": "biome check --apply .",
"changelog": "ts-node ./scripts/get-commit-list.ts",
"link:yarn": "lerna exec yarn link",
"lint": "run-s lint:lerna lint:biome",
Expand Down
9 changes: 5 additions & 4 deletions packages/angular/src/tracing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ let stashedStartTransactionOnLocationChange: boolean;
*/
export function routingInstrumentation(
customStartTransaction: (context: TransactionContext) => Transaction | undefined,
startTransactionOnPageLoad: boolean = true,
startTransactionOnLocationChange: boolean = true,
startTransactionOnPageLoad = true,
startTransactionOnLocationChange = true,
): void {
instrumentationInitialized = true;
stashedStartTransaction = customStartTransaction;
Expand Down Expand Up @@ -260,7 +260,8 @@ export function TraceClassDecorator(): ClassDecorator {
* Decorator function that can be used to capture a single lifecycle methods of the component.
*/
export function TraceMethodDecorator(): MethodDecorator {
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type, @typescript-eslint/ban-types
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
// biome-ignore lint/complexity/noBannedTypes: Disable
return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {
const originalMethod = descriptor.value;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down Expand Up @@ -300,7 +301,7 @@ export function getParameterizedRouteFromSnapshot(route?: ActivatedRouteSnapshot
let currentRoute = route && route.firstChild;
while (currentRoute) {
const path = currentRoute && currentRoute.routeConfig && currentRoute.routeConfig.path;
if (path === null || path === undefined) {
if (path == null) {
break;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
new Promise(function (resolve, reject) {
new Promise((resolve, reject) => {
reject('this is unhandled');
});
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Sentry.onLoad(function () {
Sentry.onLoad(() => {
// You _have_ to call Sentry.init() before calling Sentry.captureException() in Sentry.onLoad()!
Sentry.init();
Sentry.captureException('Test exception');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
window._testBaseTimestamp = performance.timeOrigin / 1000;

Sentry.onLoad(function () {
Sentry.onLoad(() => {
Sentry.init({
integrations: [
// Without this syntax, this will be re-written by the test framework
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
window.__sentryOnLoad = 0;

setTimeout(() => {
Sentry.onLoad(function () {
Sentry.onLoad(() => {
window.__hadSentry = window.sentryIsLoaded();

Sentry.init({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class CustomIntegration {
setupOnce() {}
}

Sentry.onLoad(function () {
Sentry.onLoad(() => {
Sentry.init({
integrations: [new CustomIntegration()],
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class CustomIntegration {
setupOnce() {}
}

Sentry.onLoad(function () {
Sentry.onLoad(() => {
Sentry.init({
integrations: integrations => [new CustomIntegration()].concat(integrations),
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Sentry.onLoad(function () {
Sentry.onLoad(() => {
Sentry.init({
integrations: [
// Without this syntax, this will be re-written by the test framework
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Sentry.onLoad(function () {
Sentry.onLoad(() => {
Sentry.init({});
});
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Sentry.forceLoad();

setTimeout(() => {
Sentry.onLoad(function () {
Sentry.onLoad(() => {
Sentry.captureException('Test exception');
});
}, 200);
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
window._testBaseTimestamp = performance.timeOrigin / 1000;

Sentry.onLoad(function () {
Sentry.onLoad(() => {
Sentry.init({});
});
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Sentry.onLoad(function () {
Sentry.onLoad(() => {
Sentry.init({});
});
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Sentry.onLoad(function () {
Sentry.onLoad(() => {
// this should be called _after_ window.sentryOnLoad
Sentry.captureException(`Test exception: ${Sentry.getCurrentHub().getClient().getOptions().tracesSampleRate}`);
});
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,14 @@ ${changedPaths.join('\n')}
console.log('');
console.log('');

console.error(`⚠️ Some tests failed.`);
console.error('⚠️ Some tests failed.');
console.error(error);
process.exit(1);
}

console.log('');
console.log('');
console.log(`☑️ All tests passed.`);
console.log('☑️ All tests passed.');
}

function getTestPaths(): string[] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const xhr = new XMLHttpRequest();
xhr.open('GET', 'http://localhost:7654/foo');
xhr.send();

xhr.addEventListener('readystatechange', function () {
xhr.addEventListener('readystatechange', () => {
if (xhr.readyState === 4) {
Sentry.captureException('test error');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ xhr.setRequestHeader('Accept', 'application/json');
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.send('{"my":"body"}');

xhr.addEventListener('readystatechange', function () {
xhr.addEventListener('readystatechange', () => {
if (xhr.readyState === 4) {
Sentry.captureException('test error');
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
window.addEventListener('error', function (event) {
window.addEventListener('error', event => {
Sentry.captureException(event);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class EventHandlerClass {

const objectListener = new EventHandlerClass();

window.attachListeners = function () {
window.attachListeners = () => {
window.addEventListener('click', functionListener);
window.addEventListener('click', objectListener);
};
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ sentryTest(
sentryTest.skip();
}

let errorEventId: string = 'invalid_id';
let errorEventId = 'invalid_id';

const reqPromise0 = waitForReplayRequest(page, 0);
const reqPromise1 = waitForReplayRequest(page, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ sentryTest('captures text request body', async ({ getLocalTestPath, page, browse
xhr.open('POST', 'http://localhost:7654/foo');
xhr.send('input body');

xhr.addEventListener('readystatechange', function () {
xhr.addEventListener('readystatechange', () => {
if (xhr.readyState === 4) {
// @ts-expect-error Sentry is a global
setTimeout(() => Sentry.captureException('test error', 0));
Expand Down Expand Up @@ -122,7 +122,7 @@ sentryTest('captures JSON request body', async ({ getLocalTestPath, page, browse
xhr.open('POST', 'http://localhost:7654/foo');
xhr.send('{"foo":"bar"}');

xhr.addEventListener('readystatechange', function () {
xhr.addEventListener('readystatechange', () => {
if (xhr.readyState === 4) {
// @ts-expect-error Sentry is a global
setTimeout(() => Sentry.captureException('test error', 0));
Expand Down Expand Up @@ -207,7 +207,7 @@ sentryTest('captures non-text request body', async ({ getLocalTestPath, page, br
xhr.open('POST', 'http://localhost:7654/foo');
xhr.send(body);

xhr.addEventListener('readystatechange', function () {
xhr.addEventListener('readystatechange', () => {
if (xhr.readyState === 4) {
// @ts-expect-error Sentry is a global
setTimeout(() => Sentry.captureException('test error', 0));
Expand Down Expand Up @@ -288,7 +288,7 @@ sentryTest('captures text request body when matching relative URL', async ({ get
xhr.open('POST', '/foo');
xhr.send('input body');

xhr.addEventListener('readystatechange', function () {
xhr.addEventListener('readystatechange', () => {
if (xhr.readyState === 4) {
// @ts-expect-error Sentry is a global
setTimeout(() => Sentry.captureException('test error', 0));
Expand Down Expand Up @@ -369,7 +369,7 @@ sentryTest('does not capture request body when URL does not match', async ({ get
xhr.open('POST', 'http://localhost:7654/bar');
xhr.send('input body');

xhr.addEventListener('readystatechange', function () {
xhr.addEventListener('readystatechange', () => {
if (xhr.readyState === 4) {
// @ts-expect-error Sentry is a global
setTimeout(() => Sentry.captureException('test error', 0));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ sentryTest('captures request headers', async ({ getLocalTestPath, page, browserN
xhr.setRequestHeader('X-Test-Header', 'test-value');
xhr.send();

xhr.addEventListener('readystatechange', function () {
xhr.addEventListener('readystatechange', () => {
if (xhr.readyState === 4) {
// @ts-expect-error Sentry is a global
setTimeout(() => Sentry.captureException('test error', 0));
Expand Down Expand Up @@ -132,7 +132,7 @@ sentryTest(
xhr.setRequestHeader('X-Test-Header', 'test-value');
xhr.send();

xhr.addEventListener('readystatechange', function () {
xhr.addEventListener('readystatechange', () => {
if (xhr.readyState === 4) {
// @ts-expect-error Sentry is a global
setTimeout(() => Sentry.captureException('test error', 0));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ sentryTest('captures request body size when body is sent', async ({ getLocalTest
xhr.open('POST', 'http://localhost:7654/foo');
xhr.send('{"foo":"bar"}');

xhr.addEventListener('readystatechange', function () {
xhr.addEventListener('readystatechange', () => {
if (xhr.readyState === 4) {
// @ts-expect-error Sentry is a global
setTimeout(() => Sentry.captureException('test error', 0));
Expand Down Expand Up @@ -132,7 +132,7 @@ sentryTest('captures request size from non-text request body', async ({ getLocal
xhr.open('POST', 'http://localhost:7654/foo');
xhr.send(blob);

xhr.addEventListener('readystatechange', function () {
xhr.addEventListener('readystatechange', () => {
if (xhr.readyState === 4) {
// @ts-expect-error Sentry is a global
setTimeout(() => Sentry.captureException('test error', 0));
Expand Down
Loading

0 comments on commit d4d1ab2

Please sign in to comment.