From a98199599ab9ac98241db6b2f501036f9aa00f67 Mon Sep 17 00:00:00 2001 From: Jori Lallo Date: Wed, 10 May 2017 00:02:11 -0700 Subject: [PATCH] Fixed linting errors and warnings --- frontend/components/Document/Document.js | 4 +- .../DocumentPreview/DocumentPreview.js | 5 +-- .../components/MoreIcon/MoreIcon.js | 10 ++++- frontend/components/Layout/Layout.js | 4 +- .../Layout/components/Title/Title.js | 27 ++++++------ .../Layout/components/Title/Title.scss | 7 --- .../Layout/components/Title/index.js | 1 + frontend/components/Tree/Node.js | 3 +- frontend/components/Tree/UiTree.js | 6 +-- .../DocumentScene/DocumentSceneStore.js | 2 +- .../components/Sidebar/Sidebar.js | 1 - frontend/scenes/Home/animation.js | 44 ------------------- frontend/scenes/Search/Search.js | 11 +++-- frontend/scenes/Settings/SettingsStore.js | 2 +- frontend/utils/emojify.js | 3 +- 15 files changed, 42 insertions(+), 88 deletions(-) delete mode 100644 frontend/components/Layout/components/Title/Title.scss delete mode 100644 frontend/scenes/Home/animation.js diff --git a/frontend/components/Document/Document.js b/frontend/components/Document/Document.js index fbe505d8..eaf68c1a 100644 --- a/frontend/components/Document/Document.js +++ b/frontend/components/Document/Document.js @@ -2,11 +2,13 @@ import React from 'react'; import { toJS } from 'mobx'; import { observer } from 'mobx-react'; -import type { Document as DocumentType } from 'types'; + import PublishingInfo from '../PublishingInfo'; import styles from './Document.scss'; import DocumentHtml from './components/DocumentHtml'; +import type { Document as DocumentType } from 'types'; + @observer class Document extends React.Component { props: { document: DocumentType, diff --git a/frontend/components/DocumentPreview/DocumentPreview.js b/frontend/components/DocumentPreview/DocumentPreview.js index a609800d..96a309c3 100644 --- a/frontend/components/DocumentPreview/DocumentPreview.js +++ b/frontend/components/DocumentPreview/DocumentPreview.js @@ -1,12 +1,11 @@ import React from 'react'; import { toJS } from 'mobx'; - import { Link } from 'react-router'; -import PublishingInfo from 'components/PublishingInfo'; - import styles from './DocumentPreview.scss'; +import PublishingInfo from 'components/PublishingInfo'; + class Document extends React.Component { static propTypes = { document: React.PropTypes.object.isRequired, diff --git a/frontend/components/DropdownMenu/components/MoreIcon/MoreIcon.js b/frontend/components/DropdownMenu/components/MoreIcon/MoreIcon.js index ab1a2ed3..18d271d3 100644 --- a/frontend/components/DropdownMenu/components/MoreIcon/MoreIcon.js +++ b/frontend/components/DropdownMenu/components/MoreIcon/MoreIcon.js @@ -2,8 +2,14 @@ import React from 'react'; import styles from './MoreIcon.scss'; -const MoreIcon = props => { - return ; +const MoreIcon = () => { + return ( + More + ); }; export default MoreIcon; diff --git a/frontend/components/Layout/Layout.js b/frontend/components/Layout/Layout.js index 8238d40f..afa7c8d8 100644 --- a/frontend/components/Layout/Layout.js +++ b/frontend/components/Layout/Layout.js @@ -5,11 +5,11 @@ import styled from 'styled-components'; import { observer, inject } from 'mobx-react'; import keydown from 'react-keydown'; import _ from 'lodash'; +import { Flex } from 'reflexbox'; import DropdownMenu, { MenuItem } from 'components/DropdownMenu'; -import { Flex } from 'reflexbox'; + import LoadingIndicator from 'components/LoadingIndicator'; -import Alert from 'components/Alert'; import styles from './Layout.scss'; import classNames from 'classnames/bind'; diff --git a/frontend/components/Layout/components/Title/Title.js b/frontend/components/Layout/components/Title/Title.js index 7dea7d38..9b3fcb21 100644 --- a/frontend/components/Layout/components/Title/Title.js +++ b/frontend/components/Layout/components/Title/Title.js @@ -1,16 +1,16 @@ +// @flow import React from 'react'; import _ from 'lodash'; +import styled from 'styled-components'; -import styles from './Title.scss'; -import classNames from 'classnames/bind'; -const cx = classNames.bind(styles); +type Props = { + children: string, + truncate?: number, + placeholder: string, +}; class Title extends React.Component { - static propTypes = { - children: React.PropTypes.string, - truncate: React.PropTypes.number, - placeholder: React.PropTypes.string, - }; + props: Props; render() { let title; @@ -29,15 +29,16 @@ class Title extends React.Component { return ( {title &&  / } - + {title} - + ); } } +const TitleText = styled.span` + opacity: ${props => (props.untitled ? 0.5 : 1)}; +`; + export default Title; diff --git a/frontend/components/Layout/components/Title/Title.scss b/frontend/components/Layout/components/Title/Title.scss deleted file mode 100644 index 6a51ea94..00000000 --- a/frontend/components/Layout/components/Title/Title.scss +++ /dev/null @@ -1,7 +0,0 @@ -.title { - -} - -.untitled { - color: #ccc; -} \ No newline at end of file diff --git a/frontend/components/Layout/components/Title/index.js b/frontend/components/Layout/components/Title/index.js index 8b8e12dd..8dffbce8 100644 --- a/frontend/components/Layout/components/Title/index.js +++ b/frontend/components/Layout/components/Title/index.js @@ -1,2 +1,3 @@ +// @flow import Title from './Title'; export default Title; diff --git a/frontend/components/Tree/Node.js b/frontend/components/Tree/Node.js index 92c91a77..5eacd6f7 100644 --- a/frontend/components/Tree/Node.js +++ b/frontend/components/Tree/Node.js @@ -25,7 +25,7 @@ class Node extends React.Component { }} onClick={this.handleCollapse} > - + Expand ); } @@ -82,7 +82,6 @@ class Node extends React.Component { }; render() { - const tree = this.props.tree; const index = this.props.index; const dragging = this.props.dragging; const node = index.node; diff --git a/frontend/components/Tree/UiTree.js b/frontend/components/Tree/UiTree.js index 4b9a9dc5..40aedc69 100644 --- a/frontend/components/Tree/UiTree.js +++ b/frontend/components/Tree/UiTree.js @@ -4,7 +4,7 @@ const Node = require('./Node'); import styles from './Tree.scss'; -module.exports = React.createClass({ +export default React.createClass({ displayName: 'UITree', propTypes: { @@ -175,14 +175,14 @@ module.exports = React.createClass({ } else if (diffY > dragging.h) { // down if (index.next) { - var below = tree.getIndex(index.next); + let below = tree.getIndex(index.next); if (below.children && below.children.length && !below.node.collapsed) { newIndex = tree.move(index.id, index.next, 'prepend'); } else { newIndex = tree.move(index.id, index.next, 'after'); } } else { - var below = tree.getNodeByTop(index.top + index.height); + let below = tree.getNodeByTop(index.top + index.height); if (below && below.parent !== index.id) { if (below.children && below.children.length) { newIndex = tree.move(index.id, below.id, 'prepend'); diff --git a/frontend/scenes/DocumentScene/DocumentSceneStore.js b/frontend/scenes/DocumentScene/DocumentSceneStore.js index 220cd02f..d0f419bc 100644 --- a/frontend/scenes/DocumentScene/DocumentSceneStore.js +++ b/frontend/scenes/DocumentScene/DocumentSceneStore.js @@ -1,4 +1,5 @@ import _ from 'lodash'; +import { browserHistory } from 'react-router'; import { observable, action, @@ -8,7 +9,6 @@ import { autorunAsync, } from 'mobx'; import { client } from 'utils/ApiClient'; -import { browserHistory } from 'react-router'; const DOCUMENT_PREFERENCES = 'DOCUMENT_PREFERENCES'; diff --git a/frontend/scenes/DocumentScene/components/Sidebar/Sidebar.js b/frontend/scenes/DocumentScene/components/Sidebar/Sidebar.js index 46828f58..624c05fe 100644 --- a/frontend/scenes/DocumentScene/components/Sidebar/Sidebar.js +++ b/frontend/scenes/DocumentScene/components/Sidebar/Sidebar.js @@ -1,6 +1,5 @@ import React, { PropTypes } from 'react'; import { observer } from 'mobx-react'; -import { Link } from 'react-router'; import { Flex } from 'reflexbox'; import Tree from 'components/Tree'; diff --git a/frontend/scenes/Home/animation.js b/frontend/scenes/Home/animation.js deleted file mode 100644 index 1223bc5f..00000000 --- a/frontend/scenes/Home/animation.js +++ /dev/null @@ -1,44 +0,0 @@ -import React from 'react'; -import { Frame } from 'react-keyframes'; - -const frames = []; -const p = node => frames.push(node); -const E = props => { - return ( - - {props.children} - - ); -}; - -const line1 =

Hi there,

; -const line2 =

We're excited to share what we’re building.

; -const line3 =

We **love** Markdown,

; -const line4 =

but we also get that it's not for everyone.

; -const line5 =

Together with you,

; -const line6 =

we want to build the best place to

; -const line7 =

share ideas,

; -const line8 =

tell stories,

; -const line9 =

and build knowledge.

; -const line10 =

We're just getting started.

; -const line11 =

Welcome to Atlas.

; - -p( - - {line1} - {line2} - {line3} - {line4} - {line5} - {line6} - {line7} - {line8} - {line9} - {line10} - {line11} - -); - -// Hmms leaving this here for now, would be nice to something - -export default frames; diff --git a/frontend/scenes/Search/Search.js b/frontend/scenes/Search/Search.js index e5ed8afd..f3d9570f 100644 --- a/frontend/scenes/Search/Search.js +++ b/frontend/scenes/Search/Search.js @@ -1,17 +1,16 @@ import React, { PropTypes } from 'react'; import { observer } from 'mobx-react'; import _ from 'lodash'; - import { Flex } from 'reflexbox'; + +import SearchField from './components/SearchField'; +import styles from './Search.scss'; +import SearchStore from './SearchStore'; + import Layout, { Title } from 'components/Layout'; import CenteredContent from 'components/CenteredContent'; -import SearchField from './components/SearchField'; import DocumentPreview from 'components/DocumentPreview'; -import styles from './Search.scss'; - -import SearchStore from './SearchStore'; - @observer class Search extends React.Component { static propTypes = { route: PropTypes.object.isRequired, diff --git a/frontend/scenes/Settings/SettingsStore.js b/frontend/scenes/Settings/SettingsStore.js index abb94184..6ede16b9 100644 --- a/frontend/scenes/Settings/SettingsStore.js +++ b/frontend/scenes/Settings/SettingsStore.js @@ -1,4 +1,4 @@ -import { observable, action, runInAction, toJS } from 'mobx'; +import { observable, action, runInAction } from 'mobx'; import { client } from 'utils/ApiClient'; class SearchStore { diff --git a/frontend/utils/emojify.js b/frontend/utils/emojify.js index 4ed97796..5491663c 100644 --- a/frontend/utils/emojify.js +++ b/frontend/utils/emojify.js @@ -1,9 +1,8 @@ import emojiMapping from './emoji-mapping.json'; -const EMOJI_REGEX = /:([A-Za-z0-9_\-\+]+?):/gm; +const EMOJI_REGEX = /:([A-Za-z0-9_\-+]+?):/gm; const emojify = (text = '') => { - const emojis = text.match(EMOJI_REGEX) || []; let emojifiedText = text; emojifiedText = text.replace(EMOJI_REGEX, (match, p1, offset, string) => {