Fixed linting errors and warnings

This commit is contained in:
Jori Lallo
2017-05-10 00:02:11 -07:00
parent eb8d2631fb
commit a98199599a
15 changed files with 42 additions and 88 deletions

View File

@ -2,11 +2,13 @@
import React from 'react'; import React from 'react';
import { toJS } from 'mobx'; import { toJS } from 'mobx';
import { observer } from 'mobx-react'; import { observer } from 'mobx-react';
import type { Document as DocumentType } from 'types';
import PublishingInfo from '../PublishingInfo'; import PublishingInfo from '../PublishingInfo';
import styles from './Document.scss'; import styles from './Document.scss';
import DocumentHtml from './components/DocumentHtml'; import DocumentHtml from './components/DocumentHtml';
import type { Document as DocumentType } from 'types';
@observer class Document extends React.Component { @observer class Document extends React.Component {
props: { props: {
document: DocumentType, document: DocumentType,

View File

@ -1,12 +1,11 @@
import React from 'react'; import React from 'react';
import { toJS } from 'mobx'; import { toJS } from 'mobx';
import { Link } from 'react-router'; import { Link } from 'react-router';
import PublishingInfo from 'components/PublishingInfo';
import styles from './DocumentPreview.scss'; import styles from './DocumentPreview.scss';
import PublishingInfo from 'components/PublishingInfo';
class Document extends React.Component { class Document extends React.Component {
static propTypes = { static propTypes = {
document: React.PropTypes.object.isRequired, document: React.PropTypes.object.isRequired,

View File

@ -2,8 +2,14 @@ import React from 'react';
import styles from './MoreIcon.scss'; import styles from './MoreIcon.scss';
const MoreIcon = props => { const MoreIcon = () => {
return <img src={require('./assets/more.svg')} className={styles.icon} />; return (
<img
alt="More"
src={require('./assets/more.svg')}
className={styles.icon}
/>
);
}; };
export default MoreIcon; export default MoreIcon;

View File

@ -5,11 +5,11 @@ import styled from 'styled-components';
import { observer, inject } from 'mobx-react'; import { observer, inject } from 'mobx-react';
import keydown from 'react-keydown'; import keydown from 'react-keydown';
import _ from 'lodash'; import _ from 'lodash';
import { Flex } from 'reflexbox';
import DropdownMenu, { MenuItem } from 'components/DropdownMenu'; import DropdownMenu, { MenuItem } from 'components/DropdownMenu';
import { Flex } from 'reflexbox';
import LoadingIndicator from 'components/LoadingIndicator'; import LoadingIndicator from 'components/LoadingIndicator';
import Alert from 'components/Alert';
import styles from './Layout.scss'; import styles from './Layout.scss';
import classNames from 'classnames/bind'; import classNames from 'classnames/bind';

View File

@ -1,16 +1,16 @@
// @flow
import React from 'react'; import React from 'react';
import _ from 'lodash'; import _ from 'lodash';
import styled from 'styled-components';
import styles from './Title.scss'; type Props = {
import classNames from 'classnames/bind'; children: string,
const cx = classNames.bind(styles); truncate?: number,
placeholder: string,
};
class Title extends React.Component { class Title extends React.Component {
static propTypes = { props: Props;
children: React.PropTypes.string,
truncate: React.PropTypes.number,
placeholder: React.PropTypes.string,
};
render() { render() {
let title; let title;
@ -29,15 +29,16 @@ class Title extends React.Component {
return ( return (
<span> <span>
{title && <span>&nbsp;/&nbsp;</span>} {title && <span>&nbsp;/&nbsp;</span>}
<span <TitleText title={this.props.children} untitled={usePlaceholder}>
title={this.props.children}
className={cx(styles.title, { untitled: usePlaceholder })}
>
{title} {title}
</span> </TitleText>
</span> </span>
); );
} }
} }
const TitleText = styled.span`
opacity: ${props => (props.untitled ? 0.5 : 1)};
`;
export default Title; export default Title;

View File

@ -1,7 +0,0 @@
.title {
}
.untitled {
color: #ccc;
}

View File

@ -1,2 +1,3 @@
// @flow
import Title from './Title'; import Title from './Title';
export default Title; export default Title;

View File

@ -25,7 +25,7 @@ class Node extends React.Component {
}} }}
onClick={this.handleCollapse} onClick={this.handleCollapse}
> >
<img src={require('./assets/chevron.svg')} /> <img alt="Expand" src={require('./assets/chevron.svg')} />
</span> </span>
); );
} }
@ -82,7 +82,6 @@ class Node extends React.Component {
}; };
render() { render() {
const tree = this.props.tree;
const index = this.props.index; const index = this.props.index;
const dragging = this.props.dragging; const dragging = this.props.dragging;
const node = index.node; const node = index.node;

View File

@ -4,7 +4,7 @@ const Node = require('./Node');
import styles from './Tree.scss'; import styles from './Tree.scss';
module.exports = React.createClass({ export default React.createClass({
displayName: 'UITree', displayName: 'UITree',
propTypes: { propTypes: {
@ -175,14 +175,14 @@ module.exports = React.createClass({
} else if (diffY > dragging.h) { } else if (diffY > dragging.h) {
// down // down
if (index.next) { if (index.next) {
var below = tree.getIndex(index.next); let below = tree.getIndex(index.next);
if (below.children && below.children.length && !below.node.collapsed) { if (below.children && below.children.length && !below.node.collapsed) {
newIndex = tree.move(index.id, index.next, 'prepend'); newIndex = tree.move(index.id, index.next, 'prepend');
} else { } else {
newIndex = tree.move(index.id, index.next, 'after'); newIndex = tree.move(index.id, index.next, 'after');
} }
} else { } 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 && below.parent !== index.id) {
if (below.children && below.children.length) { if (below.children && below.children.length) {
newIndex = tree.move(index.id, below.id, 'prepend'); newIndex = tree.move(index.id, below.id, 'prepend');

View File

@ -1,4 +1,5 @@
import _ from 'lodash'; import _ from 'lodash';
import { browserHistory } from 'react-router';
import { import {
observable, observable,
action, action,
@ -8,7 +9,6 @@ import {
autorunAsync, autorunAsync,
} from 'mobx'; } from 'mobx';
import { client } from 'utils/ApiClient'; import { client } from 'utils/ApiClient';
import { browserHistory } from 'react-router';
const DOCUMENT_PREFERENCES = 'DOCUMENT_PREFERENCES'; const DOCUMENT_PREFERENCES = 'DOCUMENT_PREFERENCES';

View File

@ -1,6 +1,5 @@
import React, { PropTypes } from 'react'; import React, { PropTypes } from 'react';
import { observer } from 'mobx-react'; import { observer } from 'mobx-react';
import { Link } from 'react-router';
import { Flex } from 'reflexbox'; import { Flex } from 'reflexbox';
import Tree from 'components/Tree'; import Tree from 'components/Tree';

View File

@ -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 (
<Frame duration={props.duration || 300} component="div">
{props.children}
</Frame>
);
};
const line1 = <p>Hi there,</p>;
const line2 = <p>We're excited to share what were building.</p>;
const line3 = <p>We <strong>**love**</strong> Markdown,</p>;
const line4 = <p>but we also get that it's not for everyone.</p>;
const line5 = <p>Together with you,</p>;
const line6 = <p>we want to build the best place to</p>;
const line7 = <p>share ideas,</p>;
const line8 = <p>tell stories,</p>;
const line9 = <p>and build knowledge.</p>;
const line10 = <p>We're just getting started.</p>;
const line11 = <p>Welcome to Atlas.</p>;
p(
<E>
{line1}
{line2}
{line3}
{line4}
{line5}
{line6}
{line7}
{line8}
{line9}
{line10}
{line11}
</E>
);
// Hmms leaving this here for now, would be nice to something
export default frames;

View File

@ -1,17 +1,16 @@
import React, { PropTypes } from 'react'; import React, { PropTypes } from 'react';
import { observer } from 'mobx-react'; import { observer } from 'mobx-react';
import _ from 'lodash'; import _ from 'lodash';
import { Flex } from 'reflexbox'; 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 Layout, { Title } from 'components/Layout';
import CenteredContent from 'components/CenteredContent'; import CenteredContent from 'components/CenteredContent';
import SearchField from './components/SearchField';
import DocumentPreview from 'components/DocumentPreview'; import DocumentPreview from 'components/DocumentPreview';
import styles from './Search.scss';
import SearchStore from './SearchStore';
@observer class Search extends React.Component { @observer class Search extends React.Component {
static propTypes = { static propTypes = {
route: PropTypes.object.isRequired, route: PropTypes.object.isRequired,

View File

@ -1,4 +1,4 @@
import { observable, action, runInAction, toJS } from 'mobx'; import { observable, action, runInAction } from 'mobx';
import { client } from 'utils/ApiClient'; import { client } from 'utils/ApiClient';
class SearchStore { class SearchStore {

View File

@ -1,9 +1,8 @@
import emojiMapping from './emoji-mapping.json'; 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 emojify = (text = '') => {
const emojis = text.match(EMOJI_REGEX) || [];
let emojifiedText = text; let emojifiedText = text;
emojifiedText = text.replace(EMOJI_REGEX, (match, p1, offset, string) => { emojifiedText = text.replace(EMOJI_REGEX, (match, p1, offset, string) => {