Skip to content

Commit

Permalink
feat: docs
Browse files Browse the repository at this point in the history
  • Loading branch information
pagnkelly committed Mar 24, 2023
1 parent fa6e19e commit 3bdc0f6
Show file tree
Hide file tree
Showing 9 changed files with 143 additions and 11 deletions.
4 changes: 4 additions & 0 deletions docs/.vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ const sidebarCategories = [
{
title: 'Essential',
categoryIds: ['mpx-essential']
},
{
title: 'Composition-api-essential',
categoryIds: ['composition-api-essential']
}
]

Expand Down
44 changes: 44 additions & 0 deletions docs/rules/no-deprecated-lifecycle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
pageClass: rule-details
sidebarDepth: 0
title: mpx/no-deprecated-lifecycle
description: pageShow/pageHide废弃的生命周期
---
# mpx/no-deprecated-lifecycle
> pageShow/pageHide废弃的生命周期
- :gear: 这条规则包含在`"plugin:mpx/composition-api-essential"`

## :book: 规则详情

mpx升级2.8版本之后,pageShow/pageHide将废弃

<eslint-code-block :rules="{'mpx/no-deprecated-lifecycle': ['error']}">

```vue
<script>
/* ✓ GOOD */
createComponent({
pageLifetimes: {
show() {},
hide() {}
}
})
/* ✗ BAD */
createComponent({
pageShow () {},
pageHide () {}
})
</script>
```

</eslint-code-block>

## :wrench: 选项


## :mag: 具体实现

- [规则](https://github.com/mpx-ecology/eslint-plugin-mpx/blob/master/lib/rules/no-deprecated-lifecycle.js)
- [测试](https://github.com/mpx-ecology/eslint-plugin-mpx/blob/master/tests/lib/rules/no-deprecated-lifecycle.js)
37 changes: 37 additions & 0 deletions docs/rules/no-deprecated-mpx-createfunction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
pageClass: rule-details
sidebarDepth: 0
title: mpx/no-deprecated-mpx-createfunction
description: mpx.create调用方式已经被废弃
---
# mpx/no-deprecated-mpx-createfunction
> mpx.create调用方式已经被废弃
- :gear: 这条规则包含在`"plugin:composition-api-essential"`

## :book: 规则详情

mpx升级2.8版本之后,mpx.create*调用方式已经被废弃

<eslint-code-block :rules="{'mpx/no-deprecated-mpx-createfunction': ['error']}">

```vue
<script>
import { createComponent } from '@mpxjs/core'
/* ✓ GOOD */
createComponent({})
/* ✗ BAD */
mpx.createComponent({})
</script>
```

</eslint-code-block>

## :wrench: 选项


## :mag: 具体实现

- [规则](https://github.com/mpx-ecology/eslint-plugin-mpx/blob/master/lib/rules/no-deprecated-mpx-createfunction.js)
- [测试](https://github.com/mpx-ecology/eslint-plugin-mpx/blob/master/tests/lib/rules/no-deprecated-mpx-createfunction.js)
41 changes: 41 additions & 0 deletions docs/rules/no-deprecated-watch-second-param.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
pageClass: rule-details
sidebarDepth: 0
title: mpx/no-deprecated-watch-second-param
description: watch第二个参数统一为函数,不再提供对象方式
---
# mpx/no-deprecated-watch-second-param
> watch第二个参数统一为函数,不再提供对象方式
- :gear: 这条规则包含在`"plugin:mpx/composition-api-essential"`

## :book: 规则详情

mpx升级2.8版本之后,watch第二个参数统一为函数,不再提供对象方式

<eslint-code-block :rules="{'mpx/no-deprecated-watch-second-param': ['error']}">

```vue
<script setup>
import { ref, watch } from '@mpxjs/core'
const refValue = ref('')
/* ✓ GOOD */
watch(refValue, () => {})
const handler = () => {}
watch(refValue, handler)
watch(refValue, () => {}, { immediate: true })
/* ✗ BAD */
watch(refValue, { handler() {} })
</script>
```

</eslint-code-block>

## :wrench: 选项


## :mag: 具体实现

- [规则](https://github.com/mpx-ecology/eslint-plugin-mpx/blob/master/lib/rules/no-deprecated-watch-second-param.js)
- [测试](https://github.com/mpx-ecology/eslint-plugin-mpx/blob/master/tests/lib/rules/no-deprecated-watch-second-param.js)
5 changes: 4 additions & 1 deletion lib/configs/composition-api-essential.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ module.exports = {
'mpx/valid-wx-elif': 'error',
'mpx/valid-wx-model': 'error',
// 'mpx/script-setup-uses-vars': 'error',
'mpx/valid-setup-define-expose': 'error'
'mpx/valid-setup-define-expose': 'error',
'mpx/no-deprecated-mpx-createfunction': 'error',
'mpx/no-deprecated-watch-second-param': 'error',
'mpx/no-deprecated-lifecycle': 'error'
}
}
3 changes: 2 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ module.exports = {
'valid-component-range': require('./rules/valid-component-range'),
'valid-setup-define-expose': require('./rules/valid-setup-define-expose'),
'no-deprecated-lifecycle': require('./rules/no-deprecated-lifecycle'),
'no-deprecated-mpx-createfunction': require('./rules/no-deprecated-mpx-createfunction')
'no-deprecated-mpx-createfunction': require('./rules/no-deprecated-mpx-createfunction'),
'no-deprecated-watch-second-param': require('./rules/no-deprecated-watch-second-param')
},
configs: {
base: require('./configs/base'),
Expand Down
7 changes: 4 additions & 3 deletions lib/rules/no-deprecated-mpx-createfunction.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports = {
meta: {
type: 'problem',
docs: {
description: 'mpx.create调用方式已经被废弃',
description: 'mpx.create*调用方式已经被废弃',
categories: ['composition-api-essential'],
url: 'https://mpx-ecology.github.io/eslint-plugin-mpx/rules/no-deprecated-mpx-createfunction'
},
Expand All @@ -22,9 +22,10 @@ module.exports = {
/** @param {import("mpx-eslint-parser/ast").ESLintStatement} node */
ExpressionStatement(node) {
if (
node.expression?.callee?.object &&
node.expression.callee &&
node.expression.callee.object &&
node.expression.callee.object.name === 'mpx' &&
node.expression?.callee?.property &&
node.expression.callee.property &&
[
'createApp',
'createStore',
Expand Down
8 changes: 5 additions & 3 deletions lib/rules/no-deprecated-watch-second-param.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ module.exports = {
/** @param {import("mpx-eslint-parser/ast").ESLintStatement} node */
ExpressionStatement(node) {
if (
node.expression?.type === 'CallExpression' &&
node.expression?.callee?.name === 'watch' &&
node.expression?.arguments?.[1]?.type === 'ObjectExpression'
node.expression &&
node.expression.type === 'CallExpression' &&
node.expression.callee.name === 'watch' &&
node.expression.arguments[1] &&
node.expression.arguments[1].type === 'ObjectExpression'
) {
context.report({
node,
Expand Down
5 changes: 2 additions & 3 deletions lib/rules/valid-setup-define-expose.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function handleProperties(properties, exposeSet, scriptVariableNames) {
/**
* @param {String} name - 展开节点
* @param {Set<String>} exposeSet 存储定义的expose变量
* @param {Object} scriptVariableNames 用于解析定义的展开的expose变量
* @param {any} scriptVariableNames 用于解析定义的展开的expose变量
*/
function handleIdentifier(name, exposeSet, scriptVariableNames) {
const props = scriptVariableNames[name]
Expand All @@ -77,10 +77,9 @@ module.exports = {
docs: {
description:
'prevent `<script setup>` variables used in `<template>` to be marked as unused', // eslint-disable-line eslint-plugin/require-meta-docs-description
categories: undefined,
categories: ['composition-api-essential'],
url: 'https://eslint.vuejs.org/rules/script-setup-uses-vars.html'
},
categories: ['composition-api-essential'],
schema: [],
messages: {
unexpected: "The variable '{{name}}' isn't expose in setup scripts."
Expand Down

0 comments on commit 3bdc0f6

Please sign in to comment.