Skip to content

Commit

Permalink
refactor(components-rn): 用 typescript 重写组件
Browse files Browse the repository at this point in the history
  • Loading branch information
Manjiz committed Apr 19, 2019
1 parent 0d80849 commit 8f8b003
Show file tree
Hide file tree
Showing 83 changed files with 1,520 additions and 2,136 deletions.
8 changes: 6 additions & 2 deletions packages/taro-components-rn/.eslintignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
coverage/
regions.js
regions.object.js
regionsFormatter.js
setupTests.js
gulpfile.js
dist/
example/
App.js
backupcode/
__tests__/
TCRNExample/
16 changes: 13 additions & 3 deletions packages/taro-components-rn/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
module.exports = {
root: true,
extends: ['standard', 'plugin:react/recommended', 'plugin:jest/recommended', 'plugin:flowtype/recommended'],
plugins: ['flowtype'],
parser: 'babel-eslint',
extends: [
'standard',
'plugin:react/recommended',
'plugin:jest/recommended',
// 'plugin:@typescript-eslint/recommended'
],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
env: {
'node': true,
'jest': true,
},
settings: {
react: {
version: 'detect'
}
},
rules: {
'comma-dangle': [2, 'only-multiline']
}
Expand Down
18 changes: 0 additions & 18 deletions packages/taro-components-rn/.flowconfig

This file was deleted.

6 changes: 0 additions & 6 deletions packages/taro-components-rn/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,3 @@ npm run android
- [ ] camera
- 其他
- [ ] tabbar

## 开发者日志

- 2018-06-14:`sdkmanager "system-images;android-28;default;x86_64" --proxy_host=mirrors.zzu.edu.cn --proxy_port=80 --proxy=http --no_https` 即将开始安卓的测试。
- 2018-06-13:换了新 MAC,测试用的 react-native-app 创建的 AwesomeProject 竟然跑不起来,这段时间应该有更新了,折腾半天,发现 package.json 有个 eject 命令,而且相比在原来的文件少了 ios 和 android 等目录,取而代之的是一个 .expo 文件夹,果然执行 eject 命令后,就可以正常跑起来了。
- 2018-04: [flow type annotation for children react elements](https://stackoverflow.com/a/42887802)
13 changes: 5 additions & 8 deletions packages/taro-components-rn/TCRNExample/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
*/

import React, {Component} from 'react';
import { Platform, StyleSheet } from 'react-native';
import { StyleSheet } from 'react-native';
import { Provider, ScrollView, View, Text, Button } from '../dist'
import EXButton from './example/EXButton'
import EXCheckbox from './example/EXCheckbox'
import EXIcon from './example/EXIcon'
import EXImage from './example/EXImage'
import EXTextinput from './example/EXTextinput'
import EXSwiper from './example/EXSwiper'
import EXSwitch from './example/EXSwitch'
import EXSlider from './example/EXSlider'
import EXRadio from './example/EXRadio'
Expand All @@ -26,13 +27,6 @@ import EXForm from './example/EXForm'
// import EXMap from './example/EXMap'
import EXWebView from './example/EXWebView'

const instructions = Platform.select({
ios: 'Press Cmd+R to reload,\n' + 'Cmd+D or shake for dev menu',
android:
'Double tap R on your keyboard to reload,\n' +
'Shake or press menu button for dev menu',
});

type Props = {};
export default class App extends Component<Props> {
state = {
Expand Down Expand Up @@ -144,6 +138,9 @@ export default class App extends Component<Props> {
<Text>Slider</Text>
<EXSlider />

<Text>Swiper</Text>
<EXSwiper />

<Text>Switch</Text>
<EXSwitch />

Expand Down
22 changes: 2 additions & 20 deletions packages/taro-components-rn/gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,10 @@
const { src, dest, parallel, watch } = require('gulp')
const flowRemoveTypes = require('gulp-flow-remove-types')
const babel = require('gulp-babel')
const ts = require('gulp-typescript')

const tsProject = ts.createProject('tsconfig.json')
const distPath = 'dist'

const compatibleJsFiles = 'src/**/*.js'
const staticFiles = 'src/**/*.png'

function scripts () {
return src([compatibleJsFiles])
.pipe(flowRemoveTypes({
pretty: true
}))
.pipe(babel({
presets: ['module:metro-react-native-babel-preset']
}))
.pipe(dest(distPath))
}

function typescripts () {
return tsProject
.src()
Expand All @@ -33,11 +18,8 @@ function typescripts () {
}

function images () {
return src([staticFiles])
return src(['src/**/*.png'])
.pipe(dest(distPath))
}

// watch(compatibleJsFiles, scripts)
// watch(staticFiles, images)

exports.default = parallel(scripts, typescripts, images)
exports.default = parallel(typescripts, images)
16 changes: 5 additions & 11 deletions packages/taro-components-rn/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
"scripts": {
"build": "rm -rf ./dist && gulp",
"tsc-watch": "tsc --watch",
"flow": "flow",
"flow-stop": "flow stop",
"lint": "eslint .",
"prepare": "npm run build",
"test-update": "jest --updateSnapshot"
Expand All @@ -16,9 +14,7 @@
"dist"
],
"pre-commit": [
"lint",
"flow",
"flow-stop"
"lint"
],
"author": "",
"license": "MIT",
Expand All @@ -44,26 +40,24 @@
"@babel/plugin-transform-modules-commonjs": "^7.2.0",
"@babel/preset-env": "^7.3.4",
"@types/react": "^16.7.5",
"@types/react-dom": "^16.8.4",
"@types/react-native": "^0.57.8",
"@typescript-eslint/eslint-plugin": "^1.6.0",
"babel-eslint": "^10.0.1",
"babel-jest": "^22.4.3",
"babel-preset-flow": "^6.23.0",
"babel-preset-react-native": "^4.0.1",
"enzyme": "^3.3.0",
"enzyme-adapter-react-16": "^1.1.1",
"eslint": "^4.19.1",
"eslint-config-standard": "^11.0.0",
"eslint-plugin-flowtype": "^2.46.1",
"eslint": "5.16.0",
"eslint-config-standard": "12.0.0",
"eslint-plugin-import": "^2.9.0",
"eslint-plugin-jest": "^21.15.0",
"eslint-plugin-node": "^6.0.1",
"eslint-plugin-promise": "^3.7.0",
"eslint-plugin-react": "^7.7.0",
"eslint-plugin-standard": "^3.0.1",
"flow-bin": "^0.69.0",
"gulp": "^4.0.0",
"gulp-babel": "^8.0.0",
"gulp-flow-remove-types": "^1.0.0",
"gulp-typescript": "^5.0.1",
"jest": "^22.4.3",
"jest-environment-node": "^23.2.0",
Expand Down
94 changes: 0 additions & 94 deletions packages/taro-components-rn/src/assets/weui.js

This file was deleted.

Loading

0 comments on commit 8f8b003

Please sign in to comment.