Skip to content

Commit

Permalink
add linting rules and do small related fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Richardsl committed Jul 17, 2022
1 parent fab112a commit 043545b
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 21 deletions.
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = tab
indent_size = 4
Expand Down
3 changes: 2 additions & 1 deletion EXAMPLE_VAULT/.obsidian/community-plugins.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"dataview",
"hot-reload",
"obsidian-metatable",
"heatmap-calendar"
"heatmap-calendar",
"hot-reload"
]
5 changes: 4 additions & 1 deletion esbuild.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ esbuild.build({
'@codemirror/stream-parser',
'@codemirror/text',
'@codemirror/tooltip',
'@codemirror/view',
'@codemirror/view',
'@lezer/common',
'@lezer/highlight',
'@lezer/lr',
...builtins],
format: 'cjs',
watch: !prod,
Expand Down
20 changes: 9 additions & 11 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ interface CalendarData {
interface Entry {
date: string
intensity?: number
color?: string | number
content?: string
color: string
content: string
}
const DEFAULT_SETTINGS: CalendarData = {
year: new Date().getFullYear(),
colors: {
default: ["#c6e48b", "#7bc96f", "#49af5d", "#2e8840", "#196127",],
},
entries: [{ date: "1900-01-01", },],
entries: [{ date: "1900-01-01", color: "#7bc96f", intensity: 5, content: "",},],
showCurrentDayBorder: true,
defaultEntryIntensity: 4,
intensityScaleStart: 1,
Expand Down Expand Up @@ -87,7 +87,7 @@ export default class HeatmapCalendar extends Plugin {

const defaultEntryIntensity = calendarData.defaultEntryIntensity ?? this.settings.defaultEntryIntensity

const intensities = calEntries.filter(e => e.intensity).map(e => e.intensity)
const intensities = calEntries.filter(e => e.intensity).map(e => e.intensity as number)
const minimumIntensity = intensities.length ? Math.min(...intensities) : this.settings.intensityScaleStart
const maximumIntensity = intensities.length ? Math.max(...intensities) : this.settings.intensityScaleEnd
const intensityScaleStart = calendarData.intensityScaleStart ?? minimumIntensity
Expand Down Expand Up @@ -130,24 +130,22 @@ export default class HeatmapCalendar extends Plugin {

for (let day = 1; day <= numberOfDaysInYear; day++) {

const box: Box = {
classNames: [],
}
const box: Box = {}

if (day === todaysDayNumberLocal && showCurrentDayBorder) box.classNames.push("today")
if (day === todaysDayNumberLocal && showCurrentDayBorder) box.classNames?.push("today")

if (mappedEntries[day]) {
box.classNames.push("hasData")
box.classNames?.push("hasData")
const entry = mappedEntries[day]

box.date = entry.date

if (entry.content) box.content = entry.content

const currentDayColors = entry.color ? colors[entry.color] : colors[Object.keys(colors)[0]]
box.backgroundColor = currentDayColors[entry.intensity - 1]
box.backgroundColor = currentDayColors[entry.intensity as number - 1]

} else box.classNames.push("isEmpty")
} else box.classNames?.push("isEmpty")
boxes.push(box)
}

Expand Down
27 changes: 23 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
"builtin-modules": "^3.2.0",
"concurrently": "^7.2.1",
"cpx": "^1.5.0",
"esbuild": "0.13.12",
"obsidian": "^0.12.17",
"tslib": "2.3.1",
"typescript": "4.4.4"
"esbuild": "0.14.49",
"obsidian": "latest",
"tslib": "2.4.0",
"typescript": "4.7.4"
}
}
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"moduleResolution": "node",
"importHelpers": true,
"isolatedModules": true,
"strictNullChecks": true,
"lib": [
"DOM",
"ES5",
Expand Down

0 comments on commit 043545b

Please sign in to comment.