Fixed eslint errors.

This commit is contained in:
orangemug 2017-11-08 08:47:36 +00:00
parent e0b7cdf9dd
commit 8234c51412
17 changed files with 127 additions and 65 deletions

View file

@ -67,7 +67,7 @@
"plugins": [ "plugins": [
"react" "react"
], ],
"extend": [ "extends": [
"plugin:react/recommended" "plugin:react/recommended"
], ],
"env": { "env": {

View file

@ -7,6 +7,7 @@ class Button extends React.Component {
onClick: PropTypes.func, onClick: PropTypes.func,
style: PropTypes.object, style: PropTypes.object,
className: PropTypes.string, className: PropTypes.string,
children: PropTypes.node
} }
render() { render() {

View file

@ -9,11 +9,11 @@ class MessagePanel extends React.Component {
render() { render() {
const errors = this.props.errors.map((m, i) => { const errors = this.props.errors.map((m, i) => {
return <p className="maputnik-message-panel-error">{m}</p> return <p key={"error-"+i} className="maputnik-message-panel-error">{m}</p>
}) })
const infos = this.props.infos.map((m, i) => { const infos = this.props.infos.map((m, i) => {
return <p key={i}>{m}</p> return <p key={"info-"+i}>{m}</p>
}) })
return <div className="maputnik-message-panel"> return <div className="maputnik-message-panel">

View file

@ -1,9 +1,16 @@
import React from 'react' import React from 'react'
import PropTypes from 'prop-types'
const ScrollContainer = (props) => { class ScrollContainer extends React.Component {
static propTypes = {
children: PropTypes.node
}
render() {
return <div className="maputnik-scroll-container"> return <div className="maputnik-scroll-container">
{props.children} {this.props.children}
</div> </div>
}
} }
export default ScrollContainer export default ScrollContainer

View file

@ -25,27 +25,46 @@ import OpenModal from './modals/OpenModal'
import style from '../libs/style' import style from '../libs/style'
function IconText(props) { class IconText extends React.Component {
return <span className="maputnik-icon-text">{props.children}</span> static propTypes = {
children: PropTypes.node,
}
render() {
return <span className="maputnik-icon-text">{this.props.children}</span>
}
} }
function ToolbarLink(props) { class ToolbarLink extends React.Component {
static propTypes = {
className: PropTypes.string,
children: PropTypes.node,
}
render() {
return <a return <a
className={classnames('maputnik-toolbar-link', props.className)} className={classnames('maputnik-toolbar-link', this.props.className)}
href={props.href} href={this.props.href}
target={"blank"} target={"blank"}
> >
{props.children} {this.props.children}
</a> </a>
}
} }
function ToolbarAction(props) { class ToolbarAction extends React.Component {
static propTypes = {
children: PropTypes.node
}
render() {
return <a return <a
className='maputnik-toolbar-action' className='maputnik-toolbar-action'
onClick={props.onClick} onClick={this.props.onClick}
> >
{props.children} {this.props.children}
</a> </a>
}
} }
export default class Toolbar extends React.Component { export default class Toolbar extends React.Component {
@ -57,7 +76,8 @@ export default class Toolbar extends React.Component {
onStyleOpen: PropTypes.func.isRequired, onStyleOpen: PropTypes.func.isRequired,
// A dict of source id's and the available source layers // A dict of source id's and the available source layers
sources: PropTypes.object.isRequired, sources: PropTypes.object.isRequired,
onInspectModeToggle: PropTypes.func.isRequired onInspectModeToggle: PropTypes.func.isRequired,
children: PropTypes.node
} }
constructor(props) { constructor(props) {

View file

@ -30,7 +30,7 @@ class ColorField extends React.Component {
//but I am too stupid to get it to work together with fixed position //but I am too stupid to get it to work together with fixed position
//and scrollbars so I have to fallback to JavaScript //and scrollbars so I have to fallback to JavaScript
calcPickerOffset() { calcPickerOffset() {
const elem = this.refs.colorInput const elem = this.colorInput
if(elem) { if(elem) {
const pos = elem.getBoundingClientRect() const pos = elem.getBoundingClientRect()
return { return {
@ -99,7 +99,7 @@ class ColorField extends React.Component {
<div className="maputnik-color-swatch" style={swatchStyle}></div> <div className="maputnik-color-swatch" style={swatchStyle}></div>
<input <input
className="maputnik-color" className="maputnik-color"
ref="colorInput" ref={(input) => this.colorInput = input}
onClick={this.togglePicker.bind(this)} onClick={this.togglePicker.bind(this)}
style={this.props.style} style={this.props.style}
name={this.props.name} name={this.props.name}

View file

@ -302,12 +302,18 @@ export default class FunctionSpecProperty extends React.Component {
} }
} }
function MakeFunctionButtons(props) { class MakeFunctionButtons extends React.Component {
static propTypes = {
fieldSpec: PropTypes.object,
onZoomClick: PropTypes.func,
}
render() {
let makeZoomButton, makeDataButton let makeZoomButton, makeDataButton
if (props.fieldSpec['zoom-function']) { if (this.props.fieldSpec['zoom-function']) {
makeZoomButton = <Button makeZoomButton = <Button
className="maputnik-make-zoom-function" className="maputnik-make-zoom-function"
onClick={props.onZoomClick} onClick={this.props.onZoomClick}
> >
<DocLabel <DocLabel
label={<FunctionIcon />} label={<FunctionIcon />}
@ -316,10 +322,10 @@ function MakeFunctionButtons(props) {
/> />
</Button> </Button>
if (props.fieldSpec['property-function'] && ['piecewise-constant', 'interpolated'].indexOf(props.fieldSpec['function']) !== -1) { if (this.props.fieldSpec['property-function'] && ['piecewise-constant', 'interpolated'].indexOf(this.props.fieldSpec['function']) !== -1) {
makeDataButton = <Button makeDataButton = <Button
className="maputnik-make-data-function" className="maputnik-make-data-function"
onClick={props.onDataClick} onClick={this.props.onDataClick}
> >
<DocLabel <DocLabel
label={<MdInsertChart />} label={<MdInsertChart />}
@ -333,18 +339,25 @@ function MakeFunctionButtons(props) {
else { else {
return null return null
} }
}
} }
function DeleteStopButton(props) { class DeleteStopButton extends React.Component {
static propTypes = {
onClick: PropTypes.func,
}
render() {
return <Button return <Button
className="maputnik-delete-stop" className="maputnik-delete-stop"
onClick={props.onClick} onClick={this.props.onClick}
> >
<DocLabel <DocLabel
label={<DeleteIcon />} label={<DeleteIcon />}
doc={"Remove zoom level stop."} doc={"Remove zoom level stop."}
/> />
</Button> </Button>
}
} }
function labelFromFieldName(fieldName) { function labelFromFieldName(fieldName) {

View file

@ -17,7 +17,7 @@ class AutocompleteInput extends React.Component {
} }
render() { render() {
const AutocompleteMenu = (items, value, style) => <div className={"maputnik-autocomplete-menu"} children={items} /> const AutocompleteMenu = (items, value, style) => <div className={"maputnik-autocomplete-menu"}>{items}</div>
return <Autocomplete return <Autocomplete
wrapperProps={{ wrapperProps={{

View file

@ -13,6 +13,7 @@ class DynamicArrayInput extends React.Component {
type: PropTypes.string, type: PropTypes.string,
default: PropTypes.array, default: PropTypes.array,
onChange: PropTypes.func, onChange: PropTypes.func,
style: PropTypes.object,
} }
changeValue(idx, newValue) { changeValue(idx, newValue) {
@ -84,10 +85,15 @@ class DynamicArrayInput extends React.Component {
} }
} }
function DeleteValueButton(props) { class DeleteValueButton extends React.Component {
static propTypes = {
onClick: PropTypes.func,
}
render() {
return <Button return <Button
className="maputnik-delete-stop" className="maputnik-delete-stop"
onClick={props.onClick} onClick={this.props.onClick}
> >
<DocLabel <DocLabel
label={<DeleteIcon />} label={<DeleteIcon />}
@ -95,5 +101,6 @@ function DeleteValueButton(props) {
/> />
</Button> </Button>
} }
}
export default DynamicArrayInput export default DynamicArrayInput

View file

@ -5,6 +5,7 @@ import AutocompleteInput from './AutocompleteInput'
class FontInput extends React.Component { class FontInput extends React.Component {
static propTypes = { static propTypes = {
value: PropTypes.array.isRequired, value: PropTypes.array.isRequired,
default: PropTypes.array,
fonts: PropTypes.array, fonts: PropTypes.array,
style: PropTypes.object, style: PropTypes.object,
onChange: PropTypes.func.isRequired, onChange: PropTypes.func.isRequired,

View file

@ -14,6 +14,7 @@ class InputBlock extends React.Component {
action: PropTypes.element, action: PropTypes.element,
children: PropTypes.element.isRequired, children: PropTypes.element.isRequired,
style: PropTypes.object, style: PropTypes.object,
onChange: PropTypes.func,
} }
onChange(e) { onChange(e) {

View file

@ -7,6 +7,7 @@ class StringInput extends React.Component {
style: PropTypes.object, style: PropTypes.object,
default: PropTypes.string, default: PropTypes.string,
onChange: PropTypes.func, onChange: PropTypes.func,
multi: PropTypes.bool,
} }
constructor(props) { constructor(props) {

View file

@ -1,4 +1,5 @@
import React from 'react' import React from 'react'
import PropTypes from 'prop-types'
import InputBlock from '../inputs/InputBlock' import InputBlock from '../inputs/InputBlock'
import StringInput from '../inputs/StringInput' import StringInput from '../inputs/StringInput'
import LayerIcon from '../icons/LayerIcon' import LayerIcon from '../icons/LayerIcon'
@ -14,6 +15,10 @@ function groupFeaturesBySourceLayer(features) {
} }
class FeatureLayerPopup extends React.Component { class FeatureLayerPopup extends React.Component {
static propTypes = {
features: PropTypes.array
}
render() { render() {
const sources = groupFeaturesBySourceLayer(this.props.features) const sources = groupFeaturesBySourceLayer(this.props.features)

View file

@ -1,4 +1,5 @@
import React from 'react' import React from 'react'
import PropTypes from 'prop-types'
import InputBlock from '../inputs/InputBlock' import InputBlock from '../inputs/InputBlock'
import StringInput from '../inputs/StringInput' import StringInput from '../inputs/StringInput'
@ -31,6 +32,9 @@ function renderFeature(feature) {
} }
class FeaturePropertyPopup extends React.Component { class FeaturePropertyPopup extends React.Component {
static propTypes = {
features: PropTypes.array
}
render() { render() {
const features = this.props.features const features = this.props.features

View file

@ -69,6 +69,7 @@ class OpenLayers3Map extends React.Component {
onDataChange: PropTypes.func, onDataChange: PropTypes.func,
mapStyle: PropTypes.object.isRequired, mapStyle: PropTypes.object.isRequired,
accessToken: PropTypes.string, accessToken: PropTypes.string,
style: PropTypes.object,
} }
static defaultProps = { static defaultProps = {

View file

@ -8,6 +8,7 @@ class Modal extends React.Component {
isOpen: PropTypes.bool.isRequired, isOpen: PropTypes.bool.isRequired,
title: PropTypes.string.isRequired, title: PropTypes.string.isRequired,
onOpenToggle: PropTypes.func.isRequired, onOpenToggle: PropTypes.func.isRequired,
children: PropTypes.node,
} }
render() { render() {

View file

@ -77,7 +77,7 @@ class OpenModal extends React.Component {
} }
onOpenUrl() { onOpenUrl() {
const url = this.refs.styleUrl.value; const url = this.styleUrlElement.value;
this.onStyleSelect(url); this.onStyleSelect(url);
} }
@ -151,7 +151,7 @@ class OpenModal extends React.Component {
<p> <p>
Load from a URL. Note that the URL must have <a href="https://enable-cors.org" target="_blank" rel="noopener noreferrer">CORS enabled</a>. Load from a URL. Note that the URL must have <a href="https://enable-cors.org" target="_blank" rel="noopener noreferrer">CORS enabled</a>.
</p> </p>
<input type="text" ref="styleUrl" className="maputnik-input" placeholder="Enter URL..."/> <input type="text" ref={(input) => this.styleUrlElement = input} className="maputnik-input" placeholder="Enter URL..."/>
<div> <div>
<Button className="maputnik-big-button" onClick={this.onOpenUrl.bind(this)}>Open URL</Button> <Button className="maputnik-big-button" onClick={this.onOpenUrl.bind(this)}>Open URL</Button>
</div> </div>