mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-22 00:36:34 +00:00
Fix eslint import extension (#682)
* Fix eslint import extension * Update eslint hound * Enable no unresolved for normal usage
This commit is contained in:
parent
5f5a62d094
commit
28457747e7
@ -46,6 +46,8 @@
|
|||||||
"no-restricted-globals": 0,
|
"no-restricted-globals": 0,
|
||||||
"prefer-promise-reject-errors": 0,
|
"prefer-promise-reject-errors": 0,
|
||||||
"import/prefer-default-export": 0,
|
"import/prefer-default-export": 0,
|
||||||
|
"import/no-unresolved": 0,
|
||||||
|
"import/extensions": [2, "ignorePackages"],
|
||||||
"react/jsx-no-bind": [2, { "ignoreRefs": true }],
|
"react/jsx-no-bind": [2, { "ignoreRefs": true }],
|
||||||
"react/jsx-no-duplicate-props": 2,
|
"react/jsx-no-duplicate-props": 2,
|
||||||
"react/self-closing-comp": 2,
|
"react/self-closing-comp": 2,
|
||||||
|
@ -6,5 +6,8 @@
|
|||||||
],
|
],
|
||||||
"env": {
|
"env": {
|
||||||
"browser": true
|
"browser": true
|
||||||
|
},
|
||||||
|
"rules": {
|
||||||
|
"import/no-unresolved": 2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { h, render } from 'preact';
|
import { h, render } from 'preact';
|
||||||
import Automation from './automation';
|
import Automation from './automation.js';
|
||||||
|
|
||||||
window.AutomationEditor = function (mountEl, props, mergeEl) {
|
window.AutomationEditor = function (mountEl, props, mergeEl) {
|
||||||
return render(h(Automation, props), mountEl, mergeEl);
|
return render(h(Automation, props), mountEl, mergeEl);
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { h, Component } from 'preact';
|
import { h, Component } from 'preact';
|
||||||
|
|
||||||
import Trigger from './trigger';
|
import Trigger from './trigger/index.js';
|
||||||
import Condition from '../common/component/condition';
|
import Condition from '../common/component/condition/index.js';
|
||||||
import Script from '../common/component/script';
|
import Script from '../common/component/script/index.js';
|
||||||
|
|
||||||
export default class Automation extends Component {
|
export default class Automation extends Component {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
import { h, Component } from 'preact';
|
import { h, Component } from 'preact';
|
||||||
|
|
||||||
import JSONTextArea from '../../common/component/json_textarea';
|
import JSONTextArea from '../../common/component/json_textarea.js';
|
||||||
|
import { onChangeEvent } from '../../common/util/event.js';
|
||||||
import { onChangeEvent } from '../../common/util/event';
|
|
||||||
|
|
||||||
export default class EventTrigger extends Component {
|
export default class EventTrigger extends Component {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { h, Component } from 'preact';
|
import { h, Component } from 'preact';
|
||||||
|
|
||||||
import TriggerRow from './trigger_row';
|
import TriggerRow from './trigger_row.js';
|
||||||
import StateTrigger from './state';
|
import StateTrigger from './state.js';
|
||||||
|
|
||||||
export default class Trigger extends Component {
|
export default class Trigger extends Component {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { h, Component } from 'preact';
|
import { h, Component } from 'preact';
|
||||||
|
|
||||||
import { onChangeEvent } from '../../common/util/event';
|
import { onChangeEvent } from '../../common/util/event.js';
|
||||||
|
|
||||||
export default class MQTTTrigger extends Component {
|
export default class MQTTTrigger extends Component {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { h, Component } from 'preact';
|
import { h, Component } from 'preact';
|
||||||
|
|
||||||
import { onChangeEvent } from '../../common/util/event';
|
import { onChangeEvent } from '../../common/util/event.js';
|
||||||
|
|
||||||
export default class NumericStateTrigger extends Component {
|
export default class NumericStateTrigger extends Component {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { h, Component } from 'preact';
|
import { h, Component } from 'preact';
|
||||||
|
|
||||||
import { onChangeEvent } from '../../common/util/event';
|
import { onChangeEvent } from '../../common/util/event.js';
|
||||||
|
|
||||||
export default class StateTrigger extends Component {
|
export default class StateTrigger extends Component {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { h, Component } from 'preact';
|
import { h, Component } from 'preact';
|
||||||
|
|
||||||
import { onChangeEvent } from '../../common/util/event';
|
import { onChangeEvent } from '../../common/util/event.js';
|
||||||
|
|
||||||
export default class SunTrigger extends Component {
|
export default class SunTrigger extends Component {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { h, Component } from 'preact';
|
import { h, Component } from 'preact';
|
||||||
|
|
||||||
import { onChangeEvent } from '../../common/util/event';
|
import { onChangeEvent } from '../../common/util/event.js';
|
||||||
|
|
||||||
export default class TemplateTrigger extends Component {
|
export default class TemplateTrigger extends Component {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { h, Component } from 'preact';
|
import { h, Component } from 'preact';
|
||||||
|
|
||||||
import { onChangeEvent } from '../../common/util/event';
|
import { onChangeEvent } from '../../common/util/event.js';
|
||||||
|
|
||||||
export default class TimeTrigger extends Component {
|
export default class TimeTrigger extends Component {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
import { h, Component } from 'preact';
|
import { h, Component } from 'preact';
|
||||||
|
|
||||||
import EventTrigger from './event';
|
import EventTrigger from './event.js';
|
||||||
import HassTrigger from './homeassistant';
|
import HassTrigger from './homeassistant.js';
|
||||||
import MQTTTrigger from './mqtt';
|
import MQTTTrigger from './mqtt.js';
|
||||||
import NumericStateTrigger from './numeric_state';
|
import NumericStateTrigger from './numeric_state.js';
|
||||||
import StateTrigger from './state';
|
import StateTrigger from './state.js';
|
||||||
import SunTrigger from './sun';
|
import SunTrigger from './sun.js';
|
||||||
import TemplateTrigger from './template';
|
import TemplateTrigger from './template.js';
|
||||||
import TimeTrigger from './time';
|
import TimeTrigger from './time.js';
|
||||||
import ZoneTrigger from './zone';
|
import ZoneTrigger from './zone.js';
|
||||||
|
|
||||||
const TYPES = {
|
const TYPES = {
|
||||||
event: EventTrigger,
|
event: EventTrigger,
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { h, Component } from 'preact';
|
import { h, Component } from 'preact';
|
||||||
|
|
||||||
import TriggerEdit from './trigger_edit';
|
import TriggerEdit from './trigger_edit.js';
|
||||||
|
|
||||||
export default class TriggerRow extends Component {
|
export default class TriggerRow extends Component {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { h, Component } from 'preact';
|
import { h, Component } from 'preact';
|
||||||
|
|
||||||
import { onChangeEvent } from '../../common/util/event';
|
import { onChangeEvent } from '../../common/util/event.js';
|
||||||
|
|
||||||
export default class ZoneTrigger extends Component {
|
export default class ZoneTrigger extends Component {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import { h, Component } from 'preact';
|
import { h, Component } from 'preact';
|
||||||
|
|
||||||
import NumericStateCondition from './numeric_state';
|
import NumericStateCondition from './numeric_state.js';
|
||||||
import StateCondition from './state';
|
import StateCondition from './state.js';
|
||||||
import SunCondition from './sun';
|
import SunCondition from './sun.js';
|
||||||
import TemplateCondition from './template';
|
import TemplateCondition from './template.js';
|
||||||
import TimeCondition from './time';
|
import TimeCondition from './time.js';
|
||||||
import ZoneCondition from './zone';
|
import ZoneCondition from './zone.js';
|
||||||
|
|
||||||
const TYPES = {
|
const TYPES = {
|
||||||
state: StateCondition,
|
state: StateCondition,
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { h, Component } from 'preact';
|
import { h, Component } from 'preact';
|
||||||
|
|
||||||
import ConditionEdit from './condition_edit';
|
import ConditionEdit from './condition_edit.js';
|
||||||
|
|
||||||
export default class ConditionRow extends Component {
|
export default class ConditionRow extends Component {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { h, Component } from 'preact';
|
import { h, Component } from 'preact';
|
||||||
|
|
||||||
import ConditionRow from './condition_row';
|
import ConditionRow from './condition_row.js';
|
||||||
|
|
||||||
export default class Condition extends Component {
|
export default class Condition extends Component {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { h, Component } from 'preact';
|
import { h, Component } from 'preact';
|
||||||
|
|
||||||
import { onChangeEvent } from '../../util/event';
|
import { onChangeEvent } from '../../util/event.js';
|
||||||
|
|
||||||
export default class NumericStateCondition extends Component {
|
export default class NumericStateCondition extends Component {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { h, Component } from 'preact';
|
import { h, Component } from 'preact';
|
||||||
|
|
||||||
import { onChangeEvent } from '../../util/event';
|
import { onChangeEvent } from '../../util/event.js';
|
||||||
|
|
||||||
export default class StateCondition extends Component {
|
export default class StateCondition extends Component {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { h, Component } from 'preact';
|
import { h, Component } from 'preact';
|
||||||
|
|
||||||
import { onChangeEvent } from '../../util/event';
|
import { onChangeEvent } from '../../util/event.js';
|
||||||
|
|
||||||
export default class SunCondition extends Component {
|
export default class SunCondition extends Component {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { h, Component } from 'preact';
|
import { h, Component } from 'preact';
|
||||||
|
|
||||||
import { onChangeEvent } from '../../util/event';
|
import { onChangeEvent } from '../../util/event.js';
|
||||||
|
|
||||||
export default class TemplateCondition extends Component {
|
export default class TemplateCondition extends Component {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { h, Component } from 'preact';
|
import { h, Component } from 'preact';
|
||||||
|
|
||||||
import { onChangeEvent } from '../../util/event';
|
import { onChangeEvent } from '../../util/event.js';
|
||||||
|
|
||||||
export default class TimeCondition extends Component {
|
export default class TimeCondition extends Component {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { h, Component } from 'preact';
|
import { h, Component } from 'preact';
|
||||||
|
|
||||||
import { onChangeEvent } from '../../util/event';
|
import { onChangeEvent } from '../../util/event.js';
|
||||||
|
|
||||||
export default class ZoneCondition extends Component {
|
export default class ZoneCondition extends Component {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
import { h, Component } from 'preact';
|
import { h, Component } from 'preact';
|
||||||
|
|
||||||
import CallServiceAction from './call_service';
|
import CallServiceAction from './call_service.js';
|
||||||
import ConditionAction from './condition';
|
import ConditionAction from './condition.js';
|
||||||
import DelayAction from './delay';
|
import DelayAction from './delay.js';
|
||||||
import EventAction from './event';
|
import EventAction from './event.js';
|
||||||
import WaitAction from './wait';
|
import WaitAction from './wait.js';
|
||||||
|
|
||||||
const TYPES = {
|
const TYPES = {
|
||||||
'Call Service': CallServiceAction,
|
'Call Service': CallServiceAction,
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { h, Component } from 'preact';
|
import { h, Component } from 'preact';
|
||||||
|
|
||||||
import ActionEdit from './action_edit';
|
import ActionEdit from './action_edit.js';
|
||||||
|
|
||||||
export default class Action extends Component {
|
export default class Action extends Component {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { h, Component } from 'preact';
|
import { h, Component } from 'preact';
|
||||||
|
|
||||||
import JSONTextArea from '../json_textarea';
|
import JSONTextArea from '../json_textarea.js';
|
||||||
import { onChangeEvent } from '../../util/event';
|
import { onChangeEvent } from '../../util/event.js';
|
||||||
|
|
||||||
export default class CallServiceAction extends Component {
|
export default class CallServiceAction extends Component {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { h, Component } from 'preact';
|
import { h, Component } from 'preact';
|
||||||
|
|
||||||
import StateCondition from '../condition/state';
|
import StateCondition from '../condition/state.js';
|
||||||
import ConditionEdit from '../condition/condition_edit';
|
import ConditionEdit from '../condition/condition_edit.js';
|
||||||
|
|
||||||
export default class ConditionAction extends Component {
|
export default class ConditionAction extends Component {
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { h, Component } from 'preact';
|
import { h, Component } from 'preact';
|
||||||
import { onChangeEvent } from '../../util/event';
|
import { onChangeEvent } from '../../util/event.js';
|
||||||
|
|
||||||
export default class DelayAction extends Component {
|
export default class DelayAction extends Component {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { h, Component } from 'preact';
|
import { h, Component } from 'preact';
|
||||||
|
|
||||||
import JSONTextArea from '../json_textarea';
|
import JSONTextArea from '../json_textarea.js';
|
||||||
import { onChangeEvent } from '../../util/event';
|
import { onChangeEvent } from '../../util/event.js';
|
||||||
|
|
||||||
export default class EventAction extends Component {
|
export default class EventAction extends Component {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { h, Component } from 'preact';
|
import { h, Component } from 'preact';
|
||||||
|
|
||||||
import ActionRow from './action_row';
|
import ActionRow from './action_row.js';
|
||||||
|
|
||||||
export default class Script extends Component {
|
export default class Script extends Component {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { h, Component } from 'preact';
|
import { h, Component } from 'preact';
|
||||||
import { onChangeEvent } from '../../util/event';
|
import { onChangeEvent } from '../../util/event.js';
|
||||||
|
|
||||||
export default class WaitAction extends Component {
|
export default class WaitAction extends Component {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -1,7 +1,3 @@
|
|||||||
export default function computeDomain(stateObj) {
|
export default function computeDomain(entityId) {
|
||||||
if (!stateObj._domain) {
|
return entityId.substr(0, entityId.indexOf('.'));
|
||||||
stateObj._domain = stateObj.entity_id.substr(0, stateObj.entity_id.indexOf('.'));
|
|
||||||
}
|
|
||||||
|
|
||||||
return stateObj._domain;
|
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import computeDomain from './compute_domain';
|
import computeStateDomain from './compute_state_domain.js';
|
||||||
import formatDateTime from './format_date_time';
|
import formatDateTime from './format_date_time.js';
|
||||||
import formatDate from './format_date';
|
import formatDate from './format_date.js';
|
||||||
import formatTime from './format_time';
|
import formatTime from './format_time.js';
|
||||||
|
|
||||||
export default function computeStateDisplay(haLocalize, stateObj, language) {
|
export default function computeStateDisplay(haLocalize, stateObj, language) {
|
||||||
if (!stateObj._stateDisplay) {
|
if (!stateObj._stateDisplay) {
|
||||||
const domain = computeDomain(stateObj);
|
const domain = computeStateDomain(stateObj);
|
||||||
if (domain === 'binary_sensor') {
|
if (domain === 'binary_sensor') {
|
||||||
// Try device class translation, then default binary sensor translation
|
// Try device class translation, then default binary sensor translation
|
||||||
if (stateObj.attributes.device_class) {
|
if (stateObj.attributes.device_class) {
|
||||||
|
9
js/common/util/compute_state_domain.js
Normal file
9
js/common/util/compute_state_domain.js
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import computeDomain from './compute_domain.js';
|
||||||
|
|
||||||
|
export default function computeStateDomain(stateObj) {
|
||||||
|
if (!stateObj._domain) {
|
||||||
|
stateObj._domain = computeDomain(stateObj.entity_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
return stateObj._domain;
|
||||||
|
}
|
@ -1,5 +1,5 @@
|
|||||||
import { h, render } from 'preact';
|
import { h, render } from 'preact';
|
||||||
import Script from './script';
|
import Script from './script.js';
|
||||||
|
|
||||||
window.ScriptEditor = function (mountEl, props, mergeEl) {
|
window.ScriptEditor = function (mountEl, props, mergeEl) {
|
||||||
return render(h(Script, props), mountEl, mergeEl);
|
return render(h(Script, props), mountEl, mergeEl);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { h, Component } from 'preact';
|
import { h, Component } from 'preact';
|
||||||
|
|
||||||
import Script from '../common/component/script';
|
import Script from '../common/component/script/index.js';
|
||||||
|
|
||||||
export default class ScriptEditor extends Component {
|
export default class ScriptEditor extends Component {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
14
js/util.js
14
js/util.js
@ -6,12 +6,12 @@
|
|||||||
* import these functions where we need them.
|
* import these functions where we need them.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import attributeClassNames from './common/util/attribute_class_names';
|
import attributeClassNames from './common/util/attribute_class_names.js';
|
||||||
import computeDomain from './common/util/compute_domain';
|
import computeStateDomain from './common/util/compute_state_domain.js';
|
||||||
import computeStateDisplay from './common/util/compute_state_display';
|
import computeStateDisplay from './common/util/compute_state_display.js';
|
||||||
import formatDate from './common/util/format_date';
|
import formatDate from './common/util/format_date.js';
|
||||||
import formatDateTime from './common/util/format_date_time';
|
import formatDateTime from './common/util/format_date_time.js';
|
||||||
import formatTime from './common/util/format_time';
|
import formatTime from './common/util/format_time.js';
|
||||||
|
|
||||||
window.hassUtil = window.hassUtil || {};
|
window.hassUtil = window.hassUtil || {};
|
||||||
|
|
||||||
@ -21,7 +21,7 @@ const language = navigator.languages ?
|
|||||||
window.fecha.masks.haDateTime = window.fecha.masks.shortTime + ' ' + window.fecha.masks.mediumDate;
|
window.fecha.masks.haDateTime = window.fecha.masks.shortTime + ' ' + window.fecha.masks.mediumDate;
|
||||||
|
|
||||||
window.hassUtil.attributeClassNames = attributeClassNames;
|
window.hassUtil.attributeClassNames = attributeClassNames;
|
||||||
window.hassUtil.computeDomain = computeDomain;
|
window.hassUtil.computeDomain = computeStateDomain;
|
||||||
window.hassUtil.computeStateDisplay = computeStateDisplay;
|
window.hassUtil.computeStateDisplay = computeStateDisplay;
|
||||||
window.hassUtil.formatDate = dateObj => formatDate(dateObj, language);
|
window.hassUtil.formatDate = dateObj => formatDate(dateObj, language);
|
||||||
window.hassUtil.formatDateTime = dateObj => formatDateTime(dateObj, language);
|
window.hassUtil.formatDateTime = dateObj => formatDateTime(dateObj, language);
|
||||||
|
@ -3,10 +3,10 @@ import computeDomain from '../../../js/common/util/compute_domain';
|
|||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
|
|
||||||
describe('computeDomain', () => {
|
describe('computeDomain', () => {
|
||||||
it('Detects sensor domain', () => {
|
it('Returns domains', () => {
|
||||||
const stateObj = {
|
assert.equal(computeDomain('sensor.bla'), 'sensor');
|
||||||
entity_id: 'sensor.test',
|
assert.equal(computeDomain('switch.bla'), 'switch');
|
||||||
};
|
assert.equal(computeDomain('light.bla'), 'light');
|
||||||
assert.strictEqual(computeDomain(stateObj), 'sensor');
|
assert.equal(computeDomain('persistent_notification.bla'), 'persistent_notification');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
12
test-mocha/common/util/compute_state_domain.js
Normal file
12
test-mocha/common/util/compute_state_domain.js
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import computeStateDomain from '../../../js/common/util/compute_state_domain.js';
|
||||||
|
|
||||||
|
const assert = require('assert');
|
||||||
|
|
||||||
|
describe('computeStateDomain', () => {
|
||||||
|
it('Detects sensor domain', () => {
|
||||||
|
const stateObj = {
|
||||||
|
entity_id: 'sensor.test',
|
||||||
|
};
|
||||||
|
assert.strictEqual(computeStateDomain(stateObj), 'sensor');
|
||||||
|
});
|
||||||
|
});
|
Loading…
x
Reference in New Issue
Block a user