Skip to content

Commit

Permalink
refactor: Update ESLint configuration and linting script
Browse files Browse the repository at this point in the history
  • Loading branch information
ngocjohn committed Oct 20, 2024
1 parent e6ed004 commit 2fe9c32
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 44 deletions.
35 changes: 0 additions & 35 deletions .eslintrc.cjs

This file was deleted.

45 changes: 45 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import typescriptEslintRecommended from '@typescript-eslint/eslint-plugin';
import tsParser from '@typescript-eslint/parser';
import perfectionist from 'eslint-plugin-perfectionist';

export default [
{
languageOptions: {
parser: tsParser,
parserOptions: {
ecmaVersion: 2020,
sourceType: 'module',
},
},
plugins: {
'@typescript-eslint': typescriptEslintRecommended,
perfectionist,
},
rules: {
// Perfectionist sort-imports rule
'perfectionist/sort-imports': [
'error',
{
type: 'alphabetical',
order: 'asc',
ignoreCase: true,
internalPattern: ['~/**'],
newlinesBetween: 'always',
maxLineLength: undefined,
groups: [
'type',
['builtin', 'external'],
'internal-type',
'internal',
['parent-type', 'sibling-type', 'index-type'],
['parent', 'sibling', 'index'],
'object',
'unknown',
],
customGroups: { type: {}, value: {} },
environment: 'node',
},
],
},
},
];
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@
"scripts": {
"dev": "rollup -c --watch",
"build": "npm run import-lang && npm run lint && npm run rollup",
"lint": "eslint src/*.ts --fix",
"lint": "eslint src/**/*.ts --fix --quiet",
"rollup": "rollup -c",
"update-lang": "node scripts/update-languages",
"import-lang": "node scripts/generate-lang-imports.js",
"start:hass": "docker run --rm -p8123:8123 -v ${HOME}/Documents/GitHub/custom-cards-project/.hass_dev:/config homeassistant/home-assistant:beta"
}
}
}
9 changes: 2 additions & 7 deletions src/vehicle-info-card.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { mdiChevronLeft, mdiChevronRight, mdiClose } from '@mdi/js';
import {
fireEvent,
formatDateTime,
formatNumber,
forwardHaptic,
hasConfigOrEntityChanged,
LovelaceCardConfig,
Expand All @@ -13,13 +13,10 @@ import {
import { LitElement, html, TemplateResult, PropertyValues, CSSResultGroup, nothing } from 'lit';
import { styleMap } from 'lit-html/directives/style-map.js';
import { customElement, property, state, query } from 'lit/decorators.js';
import { classMap } from 'lit/directives/class-map.js';

import './components/cards';
import { VehicleButtons } from './components/cards';

import { CardItem, cardTypes } from './const/data-keys';

import * as IMG from './const/imgconst';
import * as StateMapping from './const/state-mapping';
import { localize } from './localize/localize';
Expand All @@ -40,7 +37,6 @@ import { handleCardFirstUpdated, getCarEntity, handleCardSwipe, convertMinutes,
import { getAddedButton, getDefaultButton, createCardElement, createCustomButtons } from './utils/ha-helpers';

import styles from './css/styles.css';
import { mdiChevronLeft, mdiChevronRight, mdiClose } from '@mdi/js';

@customElement('vehicle-info-card')
export class VehicleCard extends LitElement implements LovelaceCard {
Expand Down Expand Up @@ -636,7 +632,7 @@ export class VehicleCard extends LitElement implements LovelaceCard {
private _renderButtons(): TemplateResult {
if (!this.config.show_buttons) return html``;
if (!this._buttonReady) return html``;
const notHidden = Object.entries(this.buttonCards).filter(([_, value]) => !value.button.hidden);
const notHidden = Object.entries(this.buttonCards).filter(([, value]) => !value.button.hidden);
const buttonCards = Object.fromEntries(notHidden);
const config = this.config;
return html`
Expand Down Expand Up @@ -1519,7 +1515,6 @@ export class VehicleCard extends LitElement implements LovelaceCard {
};

public getErrorNotify(cardType: string): boolean {
const lang = this.userLang;
const { vehicleEntities } = this;
switch (cardType) {
case 'vehicleCards':
Expand Down

0 comments on commit 2fe9c32

Please sign in to comment.