Skip to content
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

refactor: #158 remove no-this-alias ignore eslint rule #160

Merged
merged 23 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
1b86912
removed tslint
miquelbeltran Apr 24, 2024
2594236
add eslint
miquelbeltran Apr 24, 2024
0a8f09d
add default config
miquelbeltran Apr 24, 2024
e05676e
setup default config and npm run command
miquelbeltran Apr 24, 2024
efb470f
add command to node.js.yml
miquelbeltran Apr 24, 2024
930758a
set rules to support current codebase
miquelbeltran Apr 24, 2024
7c144e1
remove unused tslint.json
miquelbeltran Apr 24, 2024
81e4cae
include sample files in eslint command
miquelbeltran Apr 24, 2024
c7bdcc7
remove rule no-explicit-any
miquelbeltran Apr 25, 2024
abdd156
specify type for timer
miquelbeltran Apr 25, 2024
44adb8f
remove any from filterKeys
miquelbeltran Apr 25, 2024
284f95b
explictly declare that error can be Error, String but still accept an…
miquelbeltran Apr 25, 2024
28c3bbf
specify types in the sync worker
miquelbeltran Apr 25, 2024
a0df356
improve the IndexableError type
miquelbeltran Apr 25, 2024
57cffc7
explain why any is allowed in CustomData
miquelbeltran Apr 25, 2024
4bcc97b
remove no-this-alias from eslint config
miquelbeltran Apr 25, 2024
6dc0bc0
convert to arrow function to preserve this reference
miquelbeltran Apr 25, 2024
aa0f0a7
use arrow functions to remove the need of a this alias
miquelbeltran Apr 25, 2024
8eb988d
define httpoptions object instead of using this alias
miquelbeltran Apr 25, 2024
68c932b
Merge branch 'develop' into 158-eslint-fixes
miquelbeltran Apr 29, 2024
5ad42ce
update package lock in sample
miquelbeltran Apr 29, 2024
5eda8d9
Merge branch '158-eslint-fixes' into 158-no-this-alias
miquelbeltran Apr 29, 2024
d7e3172
Merge branch 'develop' into 158-no-this-alias
miquelbeltran May 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export default tseslint.config(
{
rules: {
// TODO: Remove ignored rules and fix the code
"@typescript-eslint/no-this-alias": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-var-requires": "off",
"no-undef": "off",
Expand Down
24 changes: 9 additions & 15 deletions lib/raygun.offline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,12 @@ export class OfflineStorage implements IOfflineStorage {
}

private _sendAndDelete(item: string) {
const storage = this;

fs.readFile(path.join(this.cachePath, item), "utf8", function (
fs.readFile(path.join(this.cachePath, item), "utf8", (
err,
cacheContents
) {
storage.transport.send(cacheContents);
fs.unlink(path.join(storage.cachePath, item), () => {});
) => {
this.transport.send(cacheContents);
fs.unlink(path.join(this.cachePath, item), () => {});
});
}

Expand All @@ -60,18 +58,16 @@ export class OfflineStorage implements IOfflineStorage {
}

save(transportItem: string, callback: (err: Error | null) => void) {
const storage = this;

const filename = path.join(storage.cachePath, Date.now() + ".json");
const filename = path.join(this.cachePath, Date.now() + ".json");

fs.readdir(storage.cachePath, function (err, files) {
fs.readdir(this.cachePath, (err, files) => {
if (err) {
console.log("[Raygun] Error reading cache folder");
console.log(err);
return callback(err);
}

if (files.length > storage.cacheLimit) {
if (files.length > this.cacheLimit) {
console.log("[Raygun] Error cache reached limit");
return callback(null);
}
Expand All @@ -97,9 +93,7 @@ export class OfflineStorage implements IOfflineStorage {
}

send(callback: (error: Error | null, items?: string[]) => void) {
const storage = this;

storage.retrieve(function (err, items) {
this.retrieve((err, items) => {
if (err) {
console.log("[Raygun] Error reading cache folder");
console.log(err);
Expand All @@ -113,7 +107,7 @@ export class OfflineStorage implements IOfflineStorage {
}

for (let i = 0; i < items.length; i++) {
storage._sendAndDelete(items[i]);
this._sendAndDelete(items[i]);
}

callback(err, items);
Expand Down
20 changes: 9 additions & 11 deletions lib/raygun.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,8 @@ class Raygun {
return;
}

const client = this;

process.on("uncaughtExceptionMonitor", function (e) {
client.sendSync(e);
process.on("uncaughtExceptionMonitor", (e) => {
this.sendSync(e);
});
}

Expand Down Expand Up @@ -397,19 +395,19 @@ class Raygun {

private offlineTransport(): MessageTransport {
const transport = this.transport();
const client = this;
const httpOptions = {
host: this._host,
port: this._port,
useSSL: this._useSSL || false,
apiKey: this._apiKey || "",
}

return {
send(message: string) {
transport.send({
message,
callback: () => {},
http: {
host: client._host,
port: client._port,
useSSL: !!client._useSSL,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_useSSL was doing this double negation (!!) to convert any null values into false, so I changed that to _useSSL || false as it looks more clear.

apiKey: client._apiKey || "",
},
http: httpOptions,
});
},
};
Expand Down