Skip to content

Commit

Permalink
fix(*): fix linter/flow errors
Browse files Browse the repository at this point in the history
  • Loading branch information
CharlesMangwa committed Jan 18, 2018
1 parent 0b1cf88 commit a6edc8c
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"parser": "babel-eslint",
"extends": [
"airbnb",
"prettier",
"plugin:flowtype/recommended",
"plugin:react/recommended"
],
Expand All @@ -19,6 +18,7 @@
}
},
"rules": {
"brace-style": ["error", "stroustrup"],
"function-paren-newline": 0,
"import/extensions": 0,
"import/no-unresolved": 0,
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,9 @@ When those 3 criteria are fulfilled, we can validate the **Rendering** column. F
| ------ | ------ | ------ | ------ |
| `blockQuote` | `<View>` | ❌ | Also `blockQuoteBar` (`<View>`) and `blockQuoteText` (`<Text>`) |
| `br` | `<Text>` | ❌ | - |
| `del` | `<Text>` | ❌ | - |
| `del` | `<Text>` | ❌ | - |
| `em` | `<Text>` | ❌ | - |
| `hr` | `<View>` | ❌ | - |
| `hr` | `<View>` | ❌ | - |
| `heading` | `<Text>` | ❌ | Also `heading1` through `heading6` |
| `image` | `<Image>` | ❌ | ou can use `resizeMode` in `<Markdown />` styles prop to set a `resizeMode` |
| `inlineCode` | `<Text>` | ❌ | - |
Expand Down
44 changes: 20 additions & 24 deletions src/rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,15 @@ export default styles => ({
},
},
br: {
react: (node, output, state) => (
react: (node, output, state) =>
createElement(
Text,
{
key: state.key,
style: styles.br,
},
'\n\n',
)
),
),
},
codeBlock: {
react: (node, output, state) => {
Expand Down Expand Up @@ -110,19 +109,17 @@ export default styles => ({
},
},
hr: {
react: (node, output, state) => (
createElement(View, { key: state.key, style: styles.hr })
),
react: (node, output, state) =>
createElement(View, { key: state.key, style: styles.hr }),
},
image: {
react: (node, output, state) => (
react: (node, output, state) =>
createElement(Image, {
key: state.key,
resizeMode: styles.resizeMode ? styles.resizeMode : 'contain',
source: { uri: node.target },
style: node.target.match(/youtu|vimeo/) ? styles.video : styles.image,
})
),
}),
},
inlineCode: {
react: (node, output, state) => {
Expand All @@ -140,7 +137,7 @@ export default styles => ({
link: {
react: (node, output, state) => {
state.withinText = true
const openUrl = url => {
const openUrl = (url) => {
Linking.openURL(url).catch(error =>
console.warn('An error occurred: ', error),
)
Expand All @@ -166,7 +163,8 @@ export default styles => ({
{ key: state.key, style: styles.listItemNumber },
`${i + 1} . `,
)
} else {
}
else {
bullet = createElement(
Text,
{ key: state.key, style: styles.listItemBullet },
Expand All @@ -193,28 +191,26 @@ export default styles => ({
},
},
newline: {
react: (node, output, state) => (
react: (node, output, state) =>
createElement(
Text,
{
key: state.key,
style: styles.newline,
},
'\n',
)
),
),
},
paragraph: {
react: (node, output, state) => (
react: (node, output, state) =>
createElement(
View,
{
key: state.key,
style: styles.paragraph,
},
output(node.content, state),
)
),
),
},
strong: {
react: (node, output, state) => {
Expand All @@ -231,30 +227,30 @@ export default styles => ({
},
table: {
react: (node, output, state) => {
const headers = _.map(node.header, (content, i) => (
const headers = _.map(node.header, (content, i) =>
createElement(
Text,
{
style: styles.tableHeaderCell,
key: i,
},
output(content, state),
)
))
),
)

const header = createElement(View, { style: styles.tableHeader }, headers)

const rows = _.map(node.cells, (row, r) => {
const cells = _.map(row, (content, c) => (
const cells = _.map(row, (content, c) =>
createElement(
View,
{
key: c,
style: styles.tableRowCell,
},
output(content, state),
)
))
),
)
const rowStyles = [styles.tableRow]
node.cells.length - 1 === r ? rowStyles.push(styles.tableRowLast) : null
return createElement(View, { key: r, style: rowStyles }, cells)
Expand Down Expand Up @@ -304,7 +300,7 @@ export default styles => ({
url: {
react: (node, output, state) => {
state.withinText = true
const openURL = url => {
const openURL = (url) => {
Linking.openURL(url).catch(error =>
console.warn('An error occurred: ', error),
)
Expand Down
2 changes: 1 addition & 1 deletion src/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ const styles: Object = {
view: {
minWidth: 1,
minHeight: 1,
}
},
}

export default styles

0 comments on commit a6edc8c

Please sign in to comment.