Skip to content

Commit

Permalink
refactor: #158 fix eslint rule "no-unused-vars" (#170)
Browse files Browse the repository at this point in the history
* removed tslint

* add eslint

* add default config

* setup default config and npm run command

* add command to node.js.yml

* set rules to support current codebase

* remove unused tslint.json

* include sample files in eslint command

* remove rule no-explicit-any

* specify type for timer

* remove any from filterKeys

* explictly declare that error can be Error, String but still accept any from the end users

* specify types in the sync worker

* improve the IndexableError type

* explain why any is allowed in CustomData

* remove no-this-alias from eslint config

* convert to arrow function to preserve this reference

* use arrow functions to remove the need of a this alias

* define httpoptions object instead of using this alias

* setup no-unused-vars lint rule

* remove unused var

* fixed lib/raygun.batch.ts

* fix lib/raygun.offline.ts

* cleanup lib/raygun.sync.transport.ts

* fix lib/raygun.transport.ts

* fix lib/raygun.ts

* fix @typescript-eslint/no-unused-vars

* fixs in test files

* update package lock in sample

* cleanup eslint config
  • Loading branch information
miquelbeltran committed May 6, 2024
1 parent 2157e34 commit 4cc4d4f
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 16 deletions.
9 changes: 8 additions & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,15 @@ export default tseslint.config(
...tseslint.configs.recommended,
{
rules: {
// Unused vars reported as error
"@typescript-eslint/no-unused-vars": [
"error",
{
// Do not report unused function arguments
"args": "none",
}
],
// TODO: Remove ignored rules and fix the code
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-var-requires": "off",
"no-undef": "off",
"no-unreachable": "off",
Expand Down
1 change: 0 additions & 1 deletion examples/express-sample/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ var raygunClient = new raygun.Client().init({

var express = require('express');
var path = require('path');
var favicon = require('serve-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
Expand Down
3 changes: 1 addition & 2 deletions lib/raygun.batch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import type { IncomingMessage } from "http";
import {
callVariadicCallback,
Callback,
Message,
HTTPOptions,
SendOptions,
} from "./types";
Expand Down Expand Up @@ -65,7 +64,7 @@ export class RaygunBatchTransport {
}

private onIncomingMessage(messageAndCallback: MessageAndCallback) {
const { serializedMessage, callback } = messageAndCallback;
const { serializedMessage} = messageAndCallback;
const messageLength = Buffer.byteLength(serializedMessage, "utf-8");

if (messageLength >= MAX_BATCH_INNER_SIZE_BYTES) {
Expand Down
1 change: 0 additions & 1 deletion lib/raygun.offline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

import fs from "fs";
import path from "path";
import * as raygunTransport from "./raygun.transport";
import {
MessageTransport,
IOfflineStorage,
Expand Down
4 changes: 1 addition & 3 deletions lib/raygun.sync.transport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
import { spawnSync } from "child_process";
import { SendOptionsWithoutCB } from "./types";

const debug = require("debug")("raygun");

const requestProcessSource = require.resolve("./raygun.sync.worker");

function syncRequest(httpOptions: SendOptionsWithoutCB) {
Expand All @@ -25,7 +23,7 @@ function syncRequest(httpOptions: SendOptionsWithoutCB) {

export function send(options: SendOptionsWithoutCB) {
try {
const request = syncRequest(options);
syncRequest(options);
} catch (e) {
console.log(
`Raygun: error ${e} occurred while attempting to send error with message: ${options.message}`
Expand Down
2 changes: 0 additions & 2 deletions lib/raygun.transport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ import {
SendOptions,
} from "./types";

const debug = require("debug")("raygun");

const API_HOST = "api.raygun.io";
const DEFAULT_ENDPOINT = "/entries";
const BATCH_ENDPOINT = "/entries/bulk";
Expand Down
2 changes: 1 addition & 1 deletion lib/raygun.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ class Raygun {
}

private reportUncaughtExceptions() {
const [major, minor, patch, ...rest] = process.versions.node
const [major, minor] = process.versions.node
.split(".")
.map((part) => parseInt(part, 10));

Expand Down
6 changes: 2 additions & 4 deletions test/raygun_express_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ var express = require("express");
var test = require("tap").test;

const { MAX_BATCH_SIZE_BYTES } = require("../lib/raygun.batch.ts");
var { listen, request, makeClientWithMockServer, sleep } = require("./utils");

var API_KEY = "apikey";
var { listen, request, makeClientWithMockServer } = require("./utils");

test("reporting express errors", async function (t) {
const app = express();
Expand Down Expand Up @@ -48,7 +46,7 @@ test("batch reporting errors", async function (t) {
client.send(new Error("c"));

try {
const message = await nextBatchRequest({ maxWait: 2000 });
await nextBatchRequest({ maxWait: 2000 });
} catch (e) {
throw e;
} finally {
Expand Down
2 changes: 1 addition & 1 deletion test/raygun_offline_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const { promisify } = require("util");

const test = require("tap").test;

const { listen, request, makeClientWithMockServer, sleep } = require("./utils");
const { makeClientWithMockServer } = require("./utils");

test("offline message storage and sending", async function (t) {
const cachePath = fs.mkdtempSync(path.join(os.tmpdir(), "raygun4node-test"));
Expand Down

0 comments on commit 4cc4d4f

Please sign in to comment.