mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-23 01:06:35 +00:00
Enforce prettier for TypeScript (#1860)
This commit is contained in:
parent
741c0c08b9
commit
17b4f873e7
@ -140,6 +140,7 @@
|
|||||||
"tslint": "^5.11.0",
|
"tslint": "^5.11.0",
|
||||||
"tslint-config-prettier": "^1.15.0",
|
"tslint-config-prettier": "^1.15.0",
|
||||||
"tslint-eslint-rules": "^5.4.0",
|
"tslint-eslint-rules": "^5.4.0",
|
||||||
|
"tslint-plugin-prettier": "^2.0.0",
|
||||||
"typescript": "3.1.3",
|
"typescript": "3.1.3",
|
||||||
"wct-browser-legacy": "^1.0.1",
|
"wct-browser-legacy": "^1.0.1",
|
||||||
"web-component-tester": "^6.8.0",
|
"web-component-tester": "^6.8.0",
|
||||||
@ -168,7 +169,7 @@
|
|||||||
},
|
},
|
||||||
"lint-staged": {
|
"lint-staged": {
|
||||||
"linters": {
|
"linters": {
|
||||||
"*.{js,json,css,md}": [
|
"*.{js,ts,json,css,md}": [
|
||||||
"prettier --write",
|
"prettier --write",
|
||||||
"git add"
|
"git add"
|
||||||
]
|
]
|
||||||
|
@ -19,7 +19,7 @@ class HuiConditionalCard extends HTMLElement implements LovelaceCard {
|
|||||||
protected card?: LovelaceCard;
|
protected card?: LovelaceCard;
|
||||||
|
|
||||||
public setConfig(config) {
|
public setConfig(config) {
|
||||||
if(
|
if (
|
||||||
!config.card ||
|
!config.card ||
|
||||||
!config.conditions ||
|
!config.conditions ||
|
||||||
!Array.isArray(config.conditions) ||
|
!Array.isArray(config.conditions) ||
|
||||||
@ -37,22 +37,28 @@ class HuiConditionalCard extends HTMLElement implements LovelaceCard {
|
|||||||
}
|
}
|
||||||
|
|
||||||
set hass(hass: HomeAssistant) {
|
set hass(hass: HomeAssistant) {
|
||||||
const visible = this.config &&
|
const visible =
|
||||||
|
this.config &&
|
||||||
this.config.conditions.every((c) => {
|
this.config.conditions.every((c) => {
|
||||||
if (!(c.entity in hass.states)) { return false; }
|
if (!(c.entity in hass.states)) {
|
||||||
if (c.state) { return hass.states[c.entity].state === c.state; }
|
return false;
|
||||||
return hass.states[c.entity].state !== c.state_not;
|
}
|
||||||
});
|
if (c.state) {
|
||||||
|
return hass.states[c.entity].state === c.state;
|
||||||
|
}
|
||||||
|
return hass.states[c.entity].state !== c.state_not;
|
||||||
|
});
|
||||||
|
|
||||||
if (visible && this.card) { this.card.hass = hass; }
|
if (visible && this.card) {
|
||||||
|
this.card.hass = hass;
|
||||||
|
}
|
||||||
|
|
||||||
this.style.setProperty("display", visible? "" : "none");
|
this.style.setProperty("display", visible ? "" : "none");
|
||||||
}
|
}
|
||||||
|
|
||||||
public getCardSize() {
|
public getCardSize() {
|
||||||
return computeCardSize(this.card);
|
return computeCardSize(this.card);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
|
@ -11,8 +11,7 @@ interface Config extends LovelaceConfig {
|
|||||||
title?: string;
|
title?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class HuiMarkdownCard extends LitElement
|
export class HuiMarkdownCard extends LitElement implements LovelaceCard {
|
||||||
implements LovelaceCard {
|
|
||||||
protected config?: Config;
|
protected config?: Config;
|
||||||
|
|
||||||
static get properties() {
|
static get properties() {
|
||||||
|
@ -1,6 +1,12 @@
|
|||||||
{
|
{
|
||||||
"extends": ["tslint:latest", "tslint-eslint-rules", "tslint-config-prettier"],
|
"extends": [
|
||||||
|
"tslint-plugin-prettier",
|
||||||
|
"tslint:latest",
|
||||||
|
"tslint-eslint-rules",
|
||||||
|
"tslint-config-prettier"
|
||||||
|
],
|
||||||
"rules": {
|
"rules": {
|
||||||
|
"prettier": true,
|
||||||
"interface-name": false,
|
"interface-name": false,
|
||||||
"no-submodule-imports": false,
|
"no-submodule-imports": false,
|
||||||
"ordered-imports": false,
|
"ordered-imports": false,
|
||||||
|
28
yarn.lock
28
yarn.lock
@ -6291,6 +6291,14 @@ eslint-plugin-import@^2.14.0:
|
|||||||
read-pkg-up "^2.0.0"
|
read-pkg-up "^2.0.0"
|
||||||
resolve "^1.6.0"
|
resolve "^1.6.0"
|
||||||
|
|
||||||
|
eslint-plugin-prettier@^2.2.0:
|
||||||
|
version "2.7.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-2.7.0.tgz#b4312dcf2c1d965379d7f9d5b5f8aaadc6a45904"
|
||||||
|
integrity sha512-CStQYJgALoQBw3FsBzH0VOVDRnJ/ZimUlpLm226U8qgqYJfPOY/CPK6wyRInMxh73HSKg5wyRwdS4BVYYHwokA==
|
||||||
|
dependencies:
|
||||||
|
fast-diff "^1.1.1"
|
||||||
|
jest-docblock "^21.0.0"
|
||||||
|
|
||||||
eslint-plugin-prettier@^3.0.0:
|
eslint-plugin-prettier@^3.0.0:
|
||||||
version "3.0.0"
|
version "3.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-3.0.0.tgz#f6b823e065f8c36529918cdb766d7a0e975ec30c"
|
resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-3.0.0.tgz#f6b823e065f8c36529918cdb766d7a0e975ec30c"
|
||||||
@ -6764,6 +6772,11 @@ fast-deep-equal@^2.0.1:
|
|||||||
resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz#7b05218ddf9667bf7f370bf7fdb2cb15fdd0aa49"
|
resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz#7b05218ddf9667bf7f370bf7fdb2cb15fdd0aa49"
|
||||||
integrity sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=
|
integrity sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=
|
||||||
|
|
||||||
|
fast-diff@^1.1.1:
|
||||||
|
version "1.2.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/fast-diff/-/fast-diff-1.2.0.tgz#73ee11982d86caaf7959828d519cfe927fac5f03"
|
||||||
|
integrity sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w==
|
||||||
|
|
||||||
fast-diff@^1.1.2:
|
fast-diff@^1.1.2:
|
||||||
version "1.1.2"
|
version "1.1.2"
|
||||||
resolved "https://registry.yarnpkg.com/fast-diff/-/fast-diff-1.1.2.tgz#4b62c42b8e03de3f848460b639079920695d0154"
|
resolved "https://registry.yarnpkg.com/fast-diff/-/fast-diff-1.1.2.tgz#4b62c42b8e03de3f848460b639079920695d0154"
|
||||||
@ -9056,6 +9069,11 @@ isurl@^1.0.0-alpha5:
|
|||||||
has-to-string-tag-x "^1.2.0"
|
has-to-string-tag-x "^1.2.0"
|
||||||
is-object "^1.0.1"
|
is-object "^1.0.1"
|
||||||
|
|
||||||
|
jest-docblock@^21.0.0:
|
||||||
|
version "21.2.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/jest-docblock/-/jest-docblock-21.2.0.tgz#51529c3b30d5fd159da60c27ceedc195faf8d414"
|
||||||
|
integrity sha512-5IZ7sY9dBAYSV+YjQ0Ovb540Ku7AO9Z5o2Cg789xj167iQuZ2cG+z0f3Uct6WeYLbU6aQiM2pCs7sZ+4dotydw==
|
||||||
|
|
||||||
jest-get-type@^22.1.0:
|
jest-get-type@^22.1.0:
|
||||||
version "22.4.3"
|
version "22.4.3"
|
||||||
resolved "https://registry.yarnpkg.com/jest-get-type/-/jest-get-type-22.4.3.tgz#e3a8504d8479342dd4420236b322869f18900ce4"
|
resolved "https://registry.yarnpkg.com/jest-get-type/-/jest-get-type-22.4.3.tgz#e3a8504d8479342dd4420236b322869f18900ce4"
|
||||||
@ -14235,7 +14253,7 @@ tslib@1.9.0:
|
|||||||
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.0.tgz#e37a86fda8cbbaf23a057f473c9f4dc64e5fc2e8"
|
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.0.tgz#e37a86fda8cbbaf23a057f473c9f4dc64e5fc2e8"
|
||||||
integrity sha512-f/qGG2tUkrISBlQZEjEqoZ3B2+npJjIf04H1wuAv9iA8i04Icp+61KRXxFdha22670NJopsZCIjhC3SnjPRKrQ==
|
integrity sha512-f/qGG2tUkrISBlQZEjEqoZ3B2+npJjIf04H1wuAv9iA8i04Icp+61KRXxFdha22670NJopsZCIjhC3SnjPRKrQ==
|
||||||
|
|
||||||
tslib@^1.8.0, tslib@^1.8.1, tslib@^1.9.0:
|
tslib@^1.7.1, tslib@^1.8.0, tslib@^1.8.1, tslib@^1.9.0:
|
||||||
version "1.9.3"
|
version "1.9.3"
|
||||||
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.3.tgz#d7e4dd79245d85428c4d7e4822a79917954ca286"
|
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.3.tgz#d7e4dd79245d85428c4d7e4822a79917954ca286"
|
||||||
integrity sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==
|
integrity sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==
|
||||||
@ -14254,6 +14272,14 @@ tslint-eslint-rules@^5.4.0:
|
|||||||
tslib "1.9.0"
|
tslib "1.9.0"
|
||||||
tsutils "^3.0.0"
|
tsutils "^3.0.0"
|
||||||
|
|
||||||
|
tslint-plugin-prettier@^2.0.0:
|
||||||
|
version "2.0.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/tslint-plugin-prettier/-/tslint-plugin-prettier-2.0.0.tgz#ade328b26c71f37418d4d01187dca232a7447b49"
|
||||||
|
integrity sha512-nA8yM+1tS9dylirSajTxxFV6jCQrIMQ0Ykl//jjRgqmwwmGp3hqodG+rtr16S/OUwyQBfoFScFDK7nuHYPd4Gw==
|
||||||
|
dependencies:
|
||||||
|
eslint-plugin-prettier "^2.2.0"
|
||||||
|
tslib "^1.7.1"
|
||||||
|
|
||||||
tslint@^5.11.0:
|
tslint@^5.11.0:
|
||||||
version "5.11.0"
|
version "5.11.0"
|
||||||
resolved "https://registry.yarnpkg.com/tslint/-/tslint-5.11.0.tgz#98f30c02eae3cde7006201e4c33cb08b48581eed"
|
resolved "https://registry.yarnpkg.com/tslint/-/tslint-5.11.0.tgz#98f30c02eae3cde7006201e4c33cb08b48581eed"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user