lint: clean and update some rules
This commit is contained in:
parent
eab793a022
commit
bb77ada35e
15 changed files with 49 additions and 61 deletions
|
|
@ -27,13 +27,6 @@
|
|||
"args": "none"
|
||||
}
|
||||
],
|
||||
"arrow-spacing": [
|
||||
"error",
|
||||
{
|
||||
"before": false,
|
||||
"after": false
|
||||
}
|
||||
],
|
||||
"space-before-function-paren": [
|
||||
"error",
|
||||
"never"
|
||||
|
|
@ -45,7 +38,8 @@
|
|||
"SwitchCase": 1,
|
||||
"ObjectExpression": 1,
|
||||
"ArrayExpression": 1,
|
||||
"MemberExpression": 1
|
||||
"MemberExpression": "off",
|
||||
"ignoredNodes": ["ConditionalExpression"]
|
||||
}
|
||||
],
|
||||
"linebreak-style": [
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ function updateWidget(widget, options={}) {
|
|||
!propNames.some(n => !widget.constructor.dynamicProps.includes(n))
|
||||
) {
|
||||
|
||||
var edited = widget.updateProps(options.changedProps, null) || widget
|
||||
var edited = widget.updateProps(options.changedProps, null) || widget
|
||||
|
||||
if (
|
||||
// if prop/osc listeners have changed (@{} / OSC{})
|
||||
|
|
|
|||
|
|
@ -2,12 +2,12 @@ module.exports = {
|
|||
|
||||
diff: require('jsondiffpatch'),
|
||||
|
||||
diffToWidget: function(widget, diff) {
|
||||
diffToWidget: function(widget, diff) {
|
||||
|
||||
// traverse a diff patch and the associated widget
|
||||
// to return the first node (widget and sub-patch) with actual changes
|
||||
|
||||
var children = diff.tabs ||diff.widgets
|
||||
var children = diff.tabs || diff.widgets
|
||||
|
||||
if (children) {
|
||||
var childrenKeys = Object.keys(children),
|
||||
|
|
|
|||
|
|
@ -142,8 +142,7 @@ module.exports = function editField(editor, widget, propName, defaultValue){
|
|||
|
||||
|
||||
list.addEventListener('click', (e)=>{
|
||||
// e.stopPropagation()
|
||||
var change
|
||||
|
||||
switch (e.target.getAttribute('data-action')) {
|
||||
|
||||
case 'select':
|
||||
|
|
|
|||
|
|
@ -138,8 +138,8 @@ var Editor = class Editor {
|
|||
if (!this.selectedWidgets.length) return
|
||||
if (e.target.classList.contains('no-keybinding')) return
|
||||
|
||||
var curWidget = this.selectedWidgets[0],
|
||||
toSelect
|
||||
var curWidget = this.selectedWidgets[0]
|
||||
|
||||
if (curWidget.parent !== widgetManager) {
|
||||
this.select(curWidget.parent.children)
|
||||
}
|
||||
|
|
@ -158,7 +158,7 @@ var Editor = class Editor {
|
|||
|
||||
} else if (e.key === 'ArrowDown') {
|
||||
|
||||
var toSelectList = [...curWidget.children]
|
||||
let toSelectList = [...curWidget.children]
|
||||
|
||||
if (toSelectList && toSelectList.length) {
|
||||
toSelectList.sort((a,b) => a.container.offsetLeft>b.container.offsetLeft)
|
||||
|
|
@ -170,8 +170,11 @@ var Editor = class Editor {
|
|||
|
||||
}
|
||||
else if((e.key == 'ArrowLeft') || (e.key == 'ArrowRight')){
|
||||
|
||||
if (curWidget.parent === widgetManager) return
|
||||
var toSelectList = [...curWidget.parent.children]
|
||||
|
||||
let toSelectList = [...curWidget.parent.children]
|
||||
|
||||
if (toSelectList && toSelectList.length) {
|
||||
toSelectList.sort((a,b) => a.container.offsetLeft > b.container.offsetLeft)
|
||||
var idx = toSelectList.indexOf(curWidget)
|
||||
|
|
@ -575,7 +578,7 @@ var Editor = class Editor {
|
|||
minTop = Infinity,
|
||||
minLeft = Infinity
|
||||
|
||||
for (var i in pastedData) {
|
||||
for (let i in pastedData) {
|
||||
if (increment) pastedData[i] = incrementWidget(pastedData[i])
|
||||
if (!isNaN(pastedData[i]).top && pastedData[i].top < minTop) {
|
||||
minTop = pastedData[i].top
|
||||
|
|
@ -596,7 +599,7 @@ var Editor = class Editor {
|
|||
data[0].widgets = data[0].widgets.concat(pastedData)
|
||||
|
||||
var indexes = {addedIndexes: []}
|
||||
for (var i = 0; i < pastedData.length; i++) {
|
||||
for (let i = 0; i < pastedData.length; i++) {
|
||||
indexes.addedIndexes.push(data[0].widgets.length - 1 - i )
|
||||
}
|
||||
updateWidget(this.selectedWidgets[0], indexes)
|
||||
|
|
@ -812,13 +815,13 @@ var Editor = class Editor {
|
|||
|
||||
updateWidgetFromPatch(patch, indexes) {
|
||||
|
||||
var [widget, patch] = diffToWidget(widgetManager.getWidgetById('root')[0], patch[0]),
|
||||
var [widget, subpatch] = diffToWidget(widgetManager.getWidgetById('root')[0], patch[0]),
|
||||
options = {}
|
||||
|
||||
if (indexes) {
|
||||
options = {...indexes}
|
||||
} else {
|
||||
options.changedProps = Object.keys(patch)
|
||||
options.changedProps = Object.keys(subpatch)
|
||||
options.reuseChildren = false
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ class SelectArea {
|
|||
this.curX = 0
|
||||
this.curY = 0
|
||||
|
||||
this.rectCoords = [0, 0, 0, 0]
|
||||
this.rectSize = [0, 0]
|
||||
this.rectCoords = [0, 0, 0, 0]
|
||||
this.rectSize = [0, 0]
|
||||
this.elements = []
|
||||
|
||||
this.rect = DOM.create('<div class="select-area hidden"></div>')
|
||||
|
|
@ -44,7 +44,7 @@ class SelectArea {
|
|||
if (!this.down) return
|
||||
this.down = false
|
||||
|
||||
if (this.rectSize[0] > 0 && this.rectSize[1] > 0) {
|
||||
if (this.rectSize[0] > 0 && this.rectSize[1] > 0) {
|
||||
this.callback(this.getElements())
|
||||
this.rect.classList.add('hidden')
|
||||
}
|
||||
|
|
@ -62,7 +62,7 @@ class SelectArea {
|
|||
w = x1 - x0,
|
||||
h = y1 - y0
|
||||
|
||||
if (w < 1 || h < 1) {
|
||||
if (w < 1 || h < 1) {
|
||||
this.rect.classList.add('hidden')
|
||||
} else {
|
||||
this.rect.classList.remove('hidden')
|
||||
|
|
@ -95,8 +95,8 @@ class SelectArea {
|
|||
})
|
||||
|
||||
// slower implementation...
|
||||
// for (var x = x0; x <= x1; x += 10) {
|
||||
// for (var y = y0; y <= y1; y += 10) {
|
||||
// for (var x = x0; x <= x1; x += 10) {
|
||||
// for (var y = y0; y <= y1; y += 10) {
|
||||
// var el = document.elementFromPoint(x, y)
|
||||
// if (elements.indexOf(el) < 0) elements.push(el)
|
||||
// }
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ module.exports = {
|
|||
|
||||
window.location.search = search
|
||||
|
||||
} catch(e) {
|
||||
} catch(e) {
|
||||
|
||||
window.location.href = window.location.href
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ var Parser = class Parser {
|
|||
reCreateOptions,
|
||||
children,
|
||||
index
|
||||
} = options
|
||||
} = options
|
||||
|
||||
if (!Array.isArray(data)) data = [data]
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
var Widget = require('./widget'),
|
||||
widgetManager = require('../../managers/widgets')
|
||||
|
||||
var Widget = require('./widget')
|
||||
|
||||
class Container extends Widget {
|
||||
|
||||
|
|
|
|||
|
|
@ -193,7 +193,7 @@ class Widget extends EventEmitter {
|
|||
|
||||
}
|
||||
|
||||
getAllChildren() {
|
||||
getAllChildren() {
|
||||
|
||||
var children = []
|
||||
for (var i = 0; i < this.children.length; i++) {
|
||||
|
|
@ -312,7 +312,7 @@ class Widget extends EventEmitter {
|
|||
widgetManager.on('widget-created', this.linkedCreatedCallback, {context: this})
|
||||
widgetManager.on('prop-changed', this.linkedPropChangedCallback, {context: this})
|
||||
|
||||
} else if (this.linkedCreatedCallback && !Object.keys(this.linkedPropsValue).length) {
|
||||
} else if (this.linkedCreatedCallback && !Object.keys(this.linkedPropsValue).length) {
|
||||
|
||||
widgetManager.removeEventContext('widget-created', this.linkedCreatedCallback, {context: this})
|
||||
widgetManager.removeEventContext('prop-changed', this.linkedPropChangedCallback, {context: this})
|
||||
|
|
@ -327,7 +327,7 @@ class Widget extends EventEmitter {
|
|||
|
||||
widgetManager.on('change', this.linkedValueChangedCallback, {context: this})
|
||||
|
||||
} else if (this.linkedPropsValueCallback && !Object.keys(this.linkedPropsValue).length) {
|
||||
} else if (this.linkedPropsValueCallback && !Object.keys(this.linkedPropsValue).length) {
|
||||
|
||||
widgetManager.removeEventContext('change', this.linkedValueChangedCallback, {context: this})
|
||||
|
||||
|
|
@ -354,7 +354,7 @@ class Widget extends EventEmitter {
|
|||
if (this.nestedLinkedProps[id]) {
|
||||
this.updateLinkedPropsWithNesting(id)
|
||||
}
|
||||
|
||||
|
||||
if (linkedProps[id]) {
|
||||
this.updateProps(linkedProps[id], widget, options, changedProps)
|
||||
}
|
||||
|
|
@ -380,7 +380,7 @@ class Widget extends EventEmitter {
|
|||
|
||||
for (var linksStores of [this.linkedPropsValue, this.linkedProps]) {
|
||||
for (let id in linksStores) {
|
||||
if (linksStores[id].includes(prop)) {
|
||||
if (linksStores[id].includes(prop)) {
|
||||
linksStores[id].splice(linksStores[id].indexOf(prop), 1)
|
||||
if (!linksStores[id].length) delete linksStores[id]
|
||||
}
|
||||
|
|
@ -671,7 +671,7 @@ class Widget extends EventEmitter {
|
|||
|
||||
case 'label':
|
||||
this.setContainerStyles(['label'])
|
||||
if (oldPropValue === false || this.getProp('label') === false) {
|
||||
if (oldPropValue === false || this.getProp('label') === false) {
|
||||
resize.check(this.container)
|
||||
}
|
||||
return
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ class Clone extends Container {
|
|||
|
||||
if (!this.cloneTarget) return
|
||||
|
||||
if (e.widget === this.cloneTarget || this.cloneTarget.contains(e.widget)) {
|
||||
if (e.widget === this.cloneTarget || this.cloneTarget.contains(e.widget)) {
|
||||
|
||||
this.updateClone()
|
||||
|
||||
|
|
@ -90,36 +90,31 @@ class Clone extends Container {
|
|||
// attempt to acquire a cloneTarget if 'widget-created' event has not been catched
|
||||
// (the target might have been created before the clone itself)
|
||||
|
||||
const widgets = widgetManager.getWidgetById(this.getProp('widgetId'))
|
||||
var widgets = widgetManager.getWidgetById(this.getProp('widgetId'))
|
||||
.filter(el=>this.isValidCloneTarget(el))
|
||||
|
||||
if (widgets.length === 0) return null
|
||||
if (widgets.length === 1) {
|
||||
return widgets[0]
|
||||
}
|
||||
}
|
||||
|
||||
// when duplicating clones pointing to an object with a static id,
|
||||
// each clone will recreate an object with the same id internally
|
||||
// we try to get the original one if there is more than 2 clone pointing to the same id (avoiding cloning the clone)
|
||||
|
||||
function isCreatedByAClone(wi){
|
||||
const parent = wi.parent
|
||||
var parent = wi.parent
|
||||
return parent && parent.getProp('type') === 'clone'
|
||||
}
|
||||
|
||||
var target = widgets[0]
|
||||
for (const w of widgets) {
|
||||
for (var w of widgets) {
|
||||
if (!isCreatedByAClone(w)) {
|
||||
target = w
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// we may want to remove this warning
|
||||
// if (isCreatedByAClone(this.cloneTarget)) {
|
||||
// console.warn('no deduped clone found : ',this.getProp('widgetId'))
|
||||
// }
|
||||
|
||||
return target
|
||||
|
||||
}
|
||||
|
|
@ -136,12 +131,13 @@ class Clone extends Container {
|
|||
|
||||
this.cloneLock = true
|
||||
|
||||
var data = {...deepCopy(this.cloneTarget.props), ...this.getProp('props')},
|
||||
clone = parser.parse({
|
||||
data: data,
|
||||
parentNode: this.widget,
|
||||
parent: this
|
||||
})
|
||||
var data = {...deepCopy(this.cloneTarget.props), ...this.getProp('props')}
|
||||
|
||||
parser.parse({
|
||||
data: data,
|
||||
parentNode: this.widget,
|
||||
parent: this
|
||||
})
|
||||
|
||||
this.updateContainer(!init)
|
||||
|
||||
|
|
@ -201,7 +197,7 @@ class Clone extends Container {
|
|||
var data = {...deepCopy(this.cloneTarget.props), ...this.getProp('props')},
|
||||
clone = this.children[0]
|
||||
|
||||
var delta = diff.diff(clone.props, data) || {},
|
||||
var delta = diff.diff(clone.props, data) || {},
|
||||
[widget, patch] = diffToWidget(clone, delta),
|
||||
changedProps = Object.keys(patch)
|
||||
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ class Panel extends Container {
|
|||
|
||||
this.wrapper = this.widget.appendChild(DOM.create('<div class="tabs-wrapper"></div>'))
|
||||
|
||||
this.children = options.children || new Array(this.getProp('tabs').length)
|
||||
this.children = options.children || new Array(this.getProp('tabs').length)
|
||||
for (let i = 0; i < this.children.length; i++) {
|
||||
if (this.children[i]) {
|
||||
this.wrapper.appendChild(this.children[i].container)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
var _matrix_base = require('./_matrix_base'),
|
||||
parser = require('../../parser'),
|
||||
widgetManager = require('../../managers/widgets')
|
||||
parser = require('../../parser')
|
||||
|
||||
class Matrix extends _matrix_base {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
var _matrix_base = require('./_matrix_base'),
|
||||
parser = require('../../parser'),
|
||||
widgetManager = require('../../managers/widgets')
|
||||
parser = require('../../parser')
|
||||
|
||||
module.exports = class Multifader extends _matrix_base {
|
||||
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ module.exports = class _switchers_base extends Widget {
|
|||
|
||||
for (var i in widgets) {
|
||||
|
||||
if (widgets[i].contains(widget) || widgets[i] === widget) return true
|
||||
if (widgets[i].contains(widget) || widgets[i] === widget) return true
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue