Skip to content

Commit

Permalink
cell: add lint:should-be-in-group
Browse files Browse the repository at this point in the history
  • Loading branch information
airyland committed Sep 11, 2017
1 parent 828132f commit c568800
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/components/cell/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,17 @@
import InlineDesc from '../inline-desc'
import { go } from '../../libs/router'
import props from './props'
import shouldBeInGroup from '../../lints/shouleBeInGroup' // env:development
export default {
name: 'cell',
mounted () {
if (process.env.NODE_ENV === 'development') {
this.$nextTick(() => {
shouldBeInGroup(this)
})
}
},
components: {
InlineDesc
},
Expand Down
9 changes: 9 additions & 0 deletions src/lints/shouleBeInGroup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export default function (vm, name) {
if (process.env.NODE_ENV === 'development') {
const parentName = vm.$parent ? vm.$parent.$options.name : ''
const parentNode = vm.$el.parentNode
if (parentName !== 'group' && !/weui-cells/.test(parentNode.className)) {
console.error(`[VUX] ${vm.$options.name} 组件应该作为 Group 子元素使用`, vm.$el)
}
}
}

0 comments on commit c568800

Please sign in to comment.