Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
85 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// eslint-disable-next-line | ||
export const DEFAULT_Components_SET = new Set([ | ||
'View', | ||
'ScrollView', | ||
'Swiper', | ||
'MovableView', | ||
'CoverView', | ||
'Icon', | ||
'Text', | ||
'RichText', | ||
'Progress', | ||
'Button', | ||
'Checkbox', | ||
'Form', | ||
'Input', | ||
'Label', | ||
'Picker', | ||
'PickerView', | ||
'Radio', | ||
'RadioGroup', | ||
'CheckboxGroup', | ||
'Slider', | ||
'Switch', | ||
'Textarea', | ||
'Navigator', | ||
'Audio', | ||
'Image', | ||
'Video', | ||
'Camera', | ||
'LivePlayer', | ||
'LivePusher', | ||
'Map', | ||
'Canvas', | ||
'OpenData', | ||
'WebView', | ||
'SwiperItem' | ||
]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
packages/eslint-plugin-taro/rules/custom/no-jsx-in-props.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
const { buildDocsMeta } = require('../../utils/utils') | ||
|
||
const ERROR_MESSAGE = '不允许在 JSX 参数(props)中传入 JSX 元素' | ||
|
||
module.exports = { | ||
meta: { | ||
docs: buildDocsMeta(ERROR_MESSAGE, 'no-jsx-in-props') | ||
}, | ||
|
||
create (context) { | ||
return { | ||
JSXElement (node) { | ||
const parents = context.getAncestors(node) | ||
const jsxAttr = parents.find(p => p.type === 'JSXAttribute') | ||
if (jsxAttr) { | ||
context.report({ | ||
message: ERROR_MESSAGE, | ||
node: jsxAttr | ||
}) | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
function docsUrl (rule) { | ||
return 'https://github.com/NervJS/taro/tree/master/packages/eslint-plugin-taro/docs/' + rule + '.md' | ||
} | ||
|
||
function buildDocsMeta (description, rule) { | ||
return { | ||
description: '[Taro] ' + description, | ||
category: 'Taro', | ||
recommended: true, | ||
url: docsUrl(rule) | ||
} | ||
} | ||
|
||
module.exports = { | ||
docsUrl, | ||
buildDocsMeta | ||
} |