Skip to content

Commit

Permalink
refactor: Remove unnecessary imports and update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
ngocjohn committed Nov 4, 2024
1 parent 13c3482 commit 29f59e4
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 52 deletions.
5 changes: 2 additions & 3 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
src/localize/*.ts
src/localize/*.js
scripts/*.js
node_modules
dist
10 changes: 5 additions & 5 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import perfectionist from 'eslint-plugin-perfectionist';

export default [
{
files: ['src/**/*.ts'],
languageOptions: {
parser: tsParser,
parserOptions: {
Expand All @@ -23,16 +24,16 @@ export default [
type: 'alphabetical',
order: 'asc',
ignoreCase: true,
internalPattern: ['~/**'],
internalPattern: ['~/**', '^~/.*'],
newlinesBetween: 'always',
maxLineLength: undefined,
groups: [
['external', 'builtin'],
['parent-type', 'sibling-type', 'index-type'],
['parent', 'sibling', 'index'],
'type',
['builtin', 'external'],
'internal-type',
'internal',
['parent-type', 'sibling-type', 'index-type'],
['parent', 'sibling', 'index'],
'object',
'unknown',
],
Expand All @@ -41,6 +42,5 @@ export default [
},
],
},
ignores: ['rollup.config.*'],
},
];
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@
"scripts": {
"dev": "rollup -c --watch --bundleConfigAsCjs",
"build": "npm run lint && npm run rollup",
"lint": "eslint src/**/*.ts --no-warn-ignored",
"lint": "eslint src/**/*.ts ",
"rollup": "rollup -c",
"update-lang": "node scripts/update-languages",
"import-lang": "node scripts/generate-lang-imports.js",
"local-copy": "cp dist/lunar-phase-card.js /Volumes/config/www/dashboard-resources/lunar-phase-card.js"
}
}
}
8 changes: 3 additions & 5 deletions src/components/moon-data.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { LitElement, html, TemplateResult, CSSResultGroup, PropertyValues, unsafeCSS } from 'lit';
import { customElement, state } from 'lit/decorators.js';

import Swiper from 'swiper';
import { Pagination } from 'swiper/modules';
import { MoonData, MoonDataItem } from '../types';
import { Moon } from '../utils/moon';
import swiperStyleCss from 'swiper/swiper-bundle.css';

import mainStyles from '../css/style.css';
import swiperStyleCss from 'swiper/swiper-bundle.css';
import { MoonData, MoonDataItem } from '../types';
import { Moon } from '../utils/moon';

@customElement('lunar-base-data')
export class LunarBaseData extends LitElement {
Expand Down
8 changes: 5 additions & 3 deletions src/components/moon-horizon.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { formatTime, formatDateTime, HomeAssistant } from 'custom-card-helpers';
import { LitElement, html, CSSResultGroup, TemplateResult, css } from 'lit';
import { customElement, state, property } from 'lit/decorators.js';
import { formatTime, formatDateTime, HomeAssistant } from 'custom-card-helpers';

import type { ChartDataset } from 'chart.js/auto';

// Chart.js
import {
Chart,
Expand All @@ -12,12 +15,11 @@ import {
ScaleChartOptions,
} from 'chart.js/auto';
import annotationPlugin from 'chartjs-plugin-annotation';
import type { ChartDataset } from 'chart.js/auto';
Chart.register(annotationPlugin);

import { LunarPhaseCard } from '../lunar-phase-card';
// Local imports
import { Moon } from '../utils/moon';
import { LunarPhaseCard } from '../lunar-phase-card';

// Styles
import styles from '../css/style.css';
Expand Down
9 changes: 4 additions & 5 deletions src/components/moon-phase-calendar.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import { LitElement, html, TemplateResult, CSSResultGroup, css } from 'lit';
import { customElement, state, property } from 'lit/decorators.js';

import { Calendar } from '@fullcalendar/core';
import allLocales from '@fullcalendar/core/locales-all';
import dayGridPlugin from '@fullcalendar/daygrid';
import interactionPlugin from '@fullcalendar/interaction';
import allLocales from '@fullcalendar/core/locales-all';
import { LitElement, html, TemplateResult, CSSResultGroup, css } from 'lit';
import { customElement, state, property } from 'lit/decorators.js';

import { LunarPhaseCard } from '../lunar-phase-card';
import { Moon } from '../utils/moon';

// styles
import styles from '../css/style.css';
import { LunarPhaseCard } from '../lunar-phase-card';

@customElement('moon-phase-calendar')
export class MoonPhaseCalendar extends LitElement {
Expand Down
14 changes: 6 additions & 8 deletions src/editor.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/* @typescript-eslint/no-explicit-any */
import { LitElement, html, TemplateResult, css, CSSResultGroup, PropertyValues } from 'lit';
import { customElement, property, state } from 'lit/decorators.js';

// Custom card helpers
import { fireEvent, LovelaceCardEditor } from 'custom-card-helpers';

import { HomeAssistantExtended as HomeAssistant, LunarPhaseCardConfig, FontCustomStyles, defaultConfig } from './types';

import { languageOptions, localize } from './localize/localize';
import { loadHaComponents, fetchLatestReleaseTag, stickyPreview } from './utils/loader';
import { compareVersions } from './utils/helpers';
import { deepMerge, InitializeDefaultConfig } from './utils/ha-helper';

import { CARD_VERSION, FONTCOLORS, FONTSTYLES, FONTSIZES } from './const';
import editorcss from './css/editor.css';
import { languageOptions, localize } from './localize/localize';
import { HomeAssistantExtended as HomeAssistant, LunarPhaseCardConfig, FontCustomStyles, defaultConfig } from './types';
import { deepMerge, InitializeDefaultConfig } from './utils/ha-helper';
import { compareVersions } from './utils/helpers';
import { loadHaComponents, fetchLatestReleaseTag, stickyPreview } from './utils/loader';

@customElement('lunar-phase-card-editor')
export class LunarPhaseCardEditor extends LitElement implements LovelaceCardEditor {
Expand Down
34 changes: 16 additions & 18 deletions src/lunar-phase-card.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,3 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { LitElement, html, TemplateResult, PropertyValues, CSSResultGroup, nothing } from 'lit';
import { customElement, property, query, state } from 'lit/decorators.js';
import { classMap } from 'lit/directives/class-map.js';
import { LovelaceCardEditor, formatDate, FrontendLocaleData } from 'custom-card-helpers';
import { HomeAssistantExtended as HomeAssistant, LunarPhaseCardConfig, defaultConfig } from './types';
import { BASE_REFRESH_INTERVAL, BACKGROUND, CurrentPage } from './const';
import { localize } from './localize/localize';
import { getDefaultConfig } from './utils/helpers';

import { Moon } from './utils/moon';
import './components/moon-data';
import './components/moon-horizon';
import './components/moon-phase-calendar';
import { LunarBaseData } from './components/moon-data';
import { MoonHorizon } from './components/moon-horizon';

import style from './css/style.css';
import {
mdiCalendarMonthOutline,
mdiCalendarSearch,
Expand All @@ -24,6 +6,22 @@ import {
mdiChevronRight,
mdiRestore,
} from '@mdi/js';
import { LovelaceCardEditor, formatDate, FrontendLocaleData } from 'custom-card-helpers';
import { LitElement, html, TemplateResult, PropertyValues, CSSResultGroup, nothing } from 'lit';
import { customElement, property, query, state } from 'lit/decorators.js';
import { classMap } from 'lit/directives/class-map.js';

import { LunarBaseData } from './components/moon-data';
import { MoonHorizon } from './components/moon-horizon';
import { BASE_REFRESH_INTERVAL, BACKGROUND, CurrentPage } from './const';
import style from './css/style.css';
import './components/moon-data';
import './components/moon-horizon';
import './components/moon-phase-calendar';
import { localize } from './localize/localize';
import { HomeAssistantExtended as HomeAssistant, LunarPhaseCardConfig, defaultConfig } from './types';
import { getDefaultConfig } from './utils/helpers';
import { Moon } from './utils/moon';

@customElement('lunar-phase-card')
export class LunarPhaseCard extends LitElement {
Expand Down
1 change: 1 addition & 0 deletions src/utils/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { FrontendLocaleData, TimeFormat, HomeAssistant } from 'custom-card-helpers';

import { BASE_BACKGROUND_URL } from '../const';
import { MOON_IMAGES } from './moon-pic';

Expand Down
2 changes: 1 addition & 1 deletion src/utils/loader.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { REPOSITORY, BASE_BACKGROUND_URL } from '../const';
import { REPOSITORY } from '../const';

// Hack to load ha-components needed for editor
export const loadHaComponents = () => {
Expand Down
5 changes: 3 additions & 2 deletions src/utils/moon.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import * as SunCalc from '@noim/suncalc3';
import { FrontendLocaleData, formatNumber } from 'custom-card-helpers';

import { localize } from '../localize/localize';
import { LunarPhaseCardConfig, MoonData, MoonDataItem, MoonImage, Location } from '../types';
import { formatRelativeTime, formatedTime, convertKmToMiles } from './helpers';
import { MOON_IMAGES } from '../utils/moon-pic';
import { FrontendLocaleData, formatNumber } from 'custom-card-helpers';
import { formatRelativeTime, formatedTime, convertKmToMiles } from './helpers';

export class Moon {
readonly _date: Date;
Expand Down

0 comments on commit 29f59e4

Please sign in to comment.