Skip to content

Commit

Permalink
lint: lint fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dntzhang committed Aug 8, 2023
1 parent 80b5136 commit debaa81
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 24 deletions.
3 changes: 1 addition & 2 deletions packages/omi/src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ export const ASYNC_RENDER = 3
export const ATTR_KEY = 'prevProps'

// DOM properties that should NOT have "px" added when numeric
export const IS_NON_DIMENSIONAL =
/acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i
export const IS_NON_DIMENSIONAL = /acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i
6 changes: 3 additions & 3 deletions packages/omi/src/define.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ export function define(name, ctor, config) {

for (let key in config) {
if (typeof config[key] === 'function') {
Ele.prototype[key] = function () {
Ele.prototype[key] = function() {
return config[key].apply(this, arguments)
}
}
}

storeHelpers.forEach((func) => {
storeHelpers.forEach(func => {
if (config[func] && config[func] !== 'function') {
Ele.prototype[func] = function () {
Ele.prototype[func] = function() {
return config[func]
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/omi/src/h.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export function h(nodeName, attributes) {
nodeName,
children,
attributes: attributes == null ? undefined : attributes,
key: attributes == null ? undefined : attributes.key,
key: attributes == null ? undefined : attributes.key
}

// if a "vnode hook" is defined, pass every created VNode to it
Expand Down
4 changes: 2 additions & 2 deletions packages/omi/src/omi.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const omi = {
get,
set,
bind,
unbind,
unbind
}

options.root.Omi = omi
Expand Down Expand Up @@ -79,5 +79,5 @@ export {
get,
set,
bind,
unbind,
unbind
}
4 changes: 2 additions & 2 deletions packages/omi/src/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function getGlobal() {
self ||
window ||
global ||
(function () {
(function() {
return this
})()
)
Expand All @@ -24,5 +24,5 @@ function getGlobal() {
export default {
store: null,
root: getGlobal(),
mapping: {},
mapping: {}
}
2 changes: 1 addition & 1 deletion packages/omi/src/tag.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { define } from './define'

export function tag(name) {
return function (target) {
return function(target) {
define(name, target)
}
}
13 changes: 8 additions & 5 deletions packages/omi/src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* this.constructor so that the native HTMLElement constructor can access the
* current under-construction element's definition.
*/
;(function () {
;(function() {
if (
// No Reflect, no classes, no need for shim because native custom elements
// require ES2015 classes or Reflect.
Expand Down Expand Up @@ -85,7 +85,10 @@ export function isArray(obj) {
export function pathToArr(path) {
if (typeof path !== 'string' || !path) return []
// return path.split(/\.|\[|\]/).filter(name => !!name)
return path.replace(/]/g, '').replace(/\[/g, '.').split('.')
return path
.replace(/]/g, '')
.replace(/\[/g, '.')
.split('.')
}

const hyphenateRE = /\B([A-Z])/g
Expand All @@ -95,15 +98,15 @@ export function hyphenate(str) {

export function capitalize(name) {
return name
.replace(/\-(\w)/g, function (all, letter) {
.replace(/\-(\w)/g, function(all, letter) {
return letter.toUpperCase()
})
.replace(/^\S/, (s) => s.toUpperCase())
.replace(/^\S/, s => s.toUpperCase())
}

export function getValByPath(path, current) {
const arr = pathToArr(path)
arr.forEach((prop) => {
arr.forEach(prop => {
current = current[prop]
})
return current
Expand Down
16 changes: 8 additions & 8 deletions packages/omi/src/we-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default class WeElement extends HTMLElement {
p = p.parentNode || p.host
}
if (provide) {
this.inject.forEach((injectKey) => {
this.inject.forEach(injectKey => {
this.injection[injectKey] = provide[injectKey]
})
} else {
Expand All @@ -54,7 +54,7 @@ export default class WeElement extends HTMLElement {
} else {
if (!this.shadowRoot) {
shadowRoot = this.attachShadow({
mode: 'open',
mode: 'open'
})
} else {
shadowRoot = this.shadowRoot
Expand All @@ -78,7 +78,7 @@ export default class WeElement extends HTMLElement {
shadowRoot.adoptedStyleSheets = [styleSheet]
} else if (Object.prototype.toString.call(css) === '[object Array]') {
const styleSheets = []
css.forEach((styleSheet) => {
css.forEach(styleSheet => {
if (typeof styleSheet === 'string') {
const adoptedStyleSheet = new CSSStyleSheet()
adoptedStyleSheet.replaceSync(styleSheet)
Expand Down Expand Up @@ -124,7 +124,7 @@ export default class WeElement extends HTMLElement {
}

if (isArray(this.rootNode)) {
this.rootNode.forEach(function (item) {
this.rootNode.forEach(function(item) {
shadowRoot.appendChild(item)
})
} else {
Expand Down Expand Up @@ -175,7 +175,7 @@ export default class WeElement extends HTMLElement {
}

updateProps(obj) {
Object.keys(obj).forEach((key) => {
Object.keys(obj).forEach(key => {
this.props[key] = obj[key]
if (this.prevProps) {
this.prevProps[key] = obj[key]
Expand Down Expand Up @@ -223,7 +223,7 @@ export default class WeElement extends HTMLElement {
ele.props['css'] = ele.getAttribute('css')
const attrs = this.constructor.propTypes
if (!attrs) return
Object.keys(attrs).forEach((key) => {
Object.keys(attrs).forEach(key => {
const type = attrs[key]
const val = ele.getAttribute(hyphenate(key))
if (val !== null) {
Expand Down Expand Up @@ -274,13 +274,13 @@ export default class WeElement extends HTMLElement {
if (handler) {
handler(
new CustomEvent(name, {
detail: data,
detail: data
})
)
} else {
this.dispatchEvent(
new CustomEvent(name, {
detail: data,
detail: data
})
)
}
Expand Down

0 comments on commit debaa81

Please sign in to comment.