Skip to content

Commit

Permalink
Set up Biome ignored rules and warnings + manual fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
watsonbox committed Sep 30, 2024
1 parent b201401 commit 089abd8
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 16 deletions.
15 changes: 14 additions & 1 deletion biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,25 @@
"ignore": ["main.js"]
},
"organizeImports": {
"ignore": ["main.js"],
"enabled": true
},
"linter": {
"ignore": ["main.js"],
"enabled": true,
"rules": {
"recommended": true
"recommended": true,
"suspicious": {
"noExplicitAny": "warn",
"noControlCharactersInRegex": "warn"
},
"style": {
"noNonNullAssertion": "warn"
},
"complexity": {
"useLiteralKeys": "off",
"noForEach": "off"
}
}
},
"javascript": {
Expand Down
2 changes: 1 addition & 1 deletion esbuild.config.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import process from "node:process";
import builtins from "builtin-modules";
import esbuild from "esbuild";
import process from "process";

const banner = `/*
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
Expand Down
6 changes: 3 additions & 3 deletions src/ActivitiesCSVImporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ export class ActivitiesCSVImporter {

return records.map((record: any): Activity => {
const startDateTimestamp = Date.parse(
record["Activity Date"] + ` ${TIME_ZONE}`,
`${record["Activity Date"]} ${TIME_ZONE}`,
);

if (isNaN(startDateTimestamp)) {
if (Number.isNaN(startDateTimestamp)) {
throw new CSVImportError(
`Invalid date: ${record["Activity Date"] + ` ${TIME_ZONE}`}`,
`Invalid date: ${record["Activity Date"]} ${TIME_ZONE}`,
);
}

Expand Down
4 changes: 2 additions & 2 deletions src/ActivitySerializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ export class ActivitySerializer {
} catch (error) {
if (error.toString().includes("File already exists")) {
return false;
} else {
throw error;
}

throw error;
}

return true;
Expand Down
8 changes: 4 additions & 4 deletions src/StravaSync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export default class StravaSync extends Plugin {
} else {
console.error("Unexpected error during CSV import:", error);
new Notice(
`🛑 An unexpected error occurred during import. Check the console for details.`,
"🛑 An unexpected error occurred during import. Check the console for details.",
ERROR_NOTICE_DURATION,
);
}
Expand All @@ -105,14 +105,14 @@ export default class StravaSync extends Plugin {
try {
if (!this.stravaApi.isAuthenticated()) {
new Notice(
`🛑 Please authenticate with Strava first in the plugin settings.`,
"🛑 Please authenticate with Strava first in the plugin settings.",
ERROR_NOTICE_DURATION,
);
return;
}

new Notice(
`🔄 Importing new activities from Strava...`,
"🔄 Importing new activities from Strava...",
SUCCESS_NOTICE_DURATION,
);

Expand All @@ -135,7 +135,7 @@ export default class StravaSync extends Plugin {
} catch (error) {
console.error("Unexpected error during Strava import:", error);
new Notice(
`🛑 An unexpected error occurred during import. Check the console for details.`,
"🛑 An unexpected error occurred during import. Check the console for details.",
ERROR_NOTICE_DURATION,
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/ActivityImporter.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as fs from "fs";
import * as path from "path";
import * as fs from "node:fs";
import * as path from "node:path";
import { ActivityImporter } from "../ActivityImporter";
import { StravaApi } from "../StravaApi";

Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/StravaSync.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as fs from "fs";
import * as path from "path";
import * as fs from "node:fs";
import * as path from "node:path";

import { App, Notice, type PluginManifest, Vault } from "obsidian";
import StravaSync from "../StravaSync";
Expand Down
2 changes: 1 addition & 1 deletion version-bump.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { readFileSync, writeFileSync } from "fs";
import { readFileSync, writeFileSync } from "node:fs";

const targetVersion = process.env.npm_package_version;

Expand Down

0 comments on commit 089abd8

Please sign in to comment.