Skip to content

Commit

Permalink
Fix some more JS issues
Browse files Browse the repository at this point in the history
- uninitialized vars
- use of == and !=
- throwing string literal
- not using shorthand property
- not using dot notation
- unused variables/statements
- coercion shorthands
- useless template literals
- function keyword with callback
- logical operators instead of chains
- use of `javascript:` url
  • Loading branch information
lemonyte committed May 12, 2024
1 parent 38fef99 commit 763c171
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 78 deletions.
6 changes: 3 additions & 3 deletions static/d3-timeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ export const timeline = () => {
d.forEach((datum, index) => {
datum.times.forEach((time, j) => {
if (index === 0 && j === 0) {
originTime = time.startingTime; // store the timestamp that will serve as origin
const originTime = time.startingTime; // store the timestamp that will serve as origin
time.startingTime = 0; // set the origin
time.endingTime = time.endingTime - originTime; // store the relative time (millis)
} else {
Expand Down Expand Up @@ -461,7 +461,7 @@ export const timeline = () => {
// set bounding rectangle height
d3.select(gParent._groups[0][0]).attr("height", height);
} else {
throw "height of the timeline is not set";
throw new Error("height of the timeline is not set");
}
} else {
if (!height) {
Expand All @@ -477,7 +477,7 @@ export const timeline = () => {
try {
width = gParentItem.attr("width");
if (!width) {
throw "width of the timeline is not set. As of Firefox 27, timeline().with(x) needs to be explicitly set in order to render";
throw new Error("width of the timeline is not set. As of Firefox 27, timeline().with(x) needs to be explicitly set in order to render");
}
} catch (err) {
console.log(err);
Expand Down
Loading

0 comments on commit 763c171

Please sign in to comment.