chore: fix miscellaneous errors from linters (#1555)

This commit is contained in:
Caleb
2018-07-31 15:03:46 -06:00
committed by Shawn Erquhart
parent d5f59de2d2
commit 5a27fb8b9d
35 changed files with 75 additions and 85 deletions

View File

@ -86,7 +86,7 @@ export function validateConfig(config) {
throw new Error("Error in configuration file: Your `backend.name` must be a string. Check your config.yml file.");
}
if (!config.get('media_folder')) {
throw new Error("Error in configuration file: A `media_folder` wasn\'t found. Check your config.yml file.");
throw new Error("Error in configuration file: A `media_folder` wasn't found. Check your config.yml file.");
}
if (typeof config.get('media_folder') !== 'string') {
throw new Error("Error in configuration file: Your `media_folder` must be a string. Check your config.yml file.");
@ -99,7 +99,7 @@ export function validateConfig(config) {
throw new Error("Error in configuration file: Your `slug.clean_accents` must be a boolean. Check your config.yml file.");
}
if (!config.get('collections')) {
throw new Error("Error in configuration file: A `collections` wasn\'t found. Check your config.yml file.");
throw new Error("Error in configuration file: A `collections` wasn't found. Check your config.yml file.");
}
const collections = config.get('collections');
if (!List.isList(collections) || collections.isEmpty() || !collections.first()) {

View File

@ -45,7 +45,7 @@ const slugFormatter = (collection, entryData, slugConfig) => {
throw new Error("Collection must have a field name that is a valid entry identifier");
}
const slug = template.replace(/\{\{([^\}]+)\}\}/g, (_, field) => {
const slug = template.replace(/\{\{([^}]+)\}\}/g, (_, field) => {
switch (field) {
case "year":
return date.getFullYear();
@ -85,7 +85,7 @@ const commitMessageTemplates = Map({
const commitMessageFormatter = (type, config, { slug, path, collection }) => {
const templates = commitMessageTemplates.merge(config.getIn(['backend', 'commit_messages'], Map()));
const messageTemplate = templates.get(type);
return messageTemplate.replace(/\{\{([^\}]+)\}\}/g, (_, variable) => {
return messageTemplate.replace(/\{\{([^}]+)\}\}/g, (_, variable) => {
switch (variable) {
case 'slug':
return slug;

View File

@ -7,8 +7,10 @@ const NotFoundContainer = styled.div`
margin: ${lengths.pageMargin};
`;
export default () => (
const NotFoundPage = () => (
<NotFoundContainer>
<h2>Not Found</h2>
</NotFoundContainer>
);
export default NotFoundPage;

View File

@ -186,7 +186,7 @@ class EditorInterface extends Component {
fieldsErrors={fieldsErrors}
onChange={onChange}
onValidate={onValidate}
ref={c => this.controlPaneRef = c} // eslint-disable-line
ref={c => this.controlPaneRef = c}
/>
</ControlPaneContainer>
);

View File

@ -120,7 +120,7 @@ export default class PreviewPane extends React.Component {
const widgets = nestedFields && Map(nestedFields.map((f, i) => [f.get('name'), <div key={i}>{this.getWidget(f, val, this.props)}</div>]));
return Map({ data: val, widgets });
});
};
}
return Map({
data: value,

View File

@ -57,12 +57,12 @@ export default class ScrollSync extends Component {
addEvents = (node, group) => {
/* For some reason element.addEventListener doesnt work with document.body */
node.onscroll = this.handlePaneScroll.bind(this, node, group) // eslint-disable-line
node.onscroll = this.handlePaneScroll.bind(this, node, group)
}
removeEvents = (node) => {
/* For some reason element.removeEventListener doesnt work with document.body */
node.onscroll = null // eslint-disable-line
node.onscroll = null
}
findPane = (node, group) => {
@ -108,10 +108,10 @@ export default class ScrollSync extends Component {
const paneWidth = pane.scrollWidth - clientWidth
/* Adjust the scrollTop position of it accordingly */
if (vertical && scrollTopOffset > 0) {
pane.scrollTop = proportional ? (paneHeight * scrollTop) / scrollTopOffset : scrollTop // eslint-disable-line
pane.scrollTop = proportional ? (paneHeight * scrollTop) / scrollTopOffset : scrollTop
}
if (horizontal && scrollLeftOffset > 0) {
pane.scrollLeft = proportional ? (paneWidth * scrollLeft) / scrollLeftOffset : scrollLeft // eslint-disable-line
pane.scrollLeft = proportional ? (paneWidth * scrollLeft) / scrollLeftOffset : scrollLeft
}
/* Re-attach event listeners after we're done scrolling */
window.requestAnimationFrame(() => {

View File

@ -373,4 +373,4 @@ export default class EditorToolbar extends React.Component {
</ToolbarContainer>
);
}
};
}

View File

@ -48,11 +48,11 @@ function mergeProps(stateProps, dispatchProps, ownProps) {
export default function withWorkflow(Editor) {
return connect(mapStateToProps, null, mergeProps)(
class extends React.Component {
class WorkflowEditor extends React.Component {
render() {
return <Editor {...this.props} />;
}
}
);
};
}

View File

@ -209,4 +209,4 @@ Please drag the card to the "Ready" column to enable publishing.`
}
}
export default HTML5DragDrop(WorkflowList); // eslint-disable-line
export default HTML5DragDrop(WorkflowList);

View File

@ -1,6 +1,5 @@
import React from 'react';
/* eslint-disable */
export const IDENTIFIER_FIELDS = ['title', 'path'];
export const INFERABLE_FIELDS = {
@ -8,7 +7,7 @@ export const INFERABLE_FIELDS = {
type: 'string',
secondaryTypes: [],
synonyms: ['title', 'name', 'label', 'headline', 'header'],
defaultPreview: value => <h1>{ value }</h1>,
defaultPreview: value => <h1>{ value }</h1>, // eslint-disable-line react/display-name
fallbackToFirstField: true,
showError: true,
},
@ -16,7 +15,7 @@ export const INFERABLE_FIELDS = {
type: 'string',
secondaryTypes: [],
synonyms: ['short_title', 'shortTitle', 'short'],
defaultPreview: value => <h2>{ value }</h2>,
defaultPreview: value => <h2>{ value }</h2>, // eslint-disable-line react/display-name
fallbackToFirstField: false,
showError: false,
},
@ -24,7 +23,7 @@ export const INFERABLE_FIELDS = {
type: 'string',
secondaryTypes: [],
synonyms: ['author', 'name', 'by', 'byline', 'owner'],
defaultPreview: value => <strong>{ value }</strong>,
defaultPreview: value => <strong>{ value }</strong>, // eslint-disable-line react/display-name
fallbackToFirstField: false,
showError: false,
},

View File

@ -3,7 +3,7 @@ import { createEntry } from 'ValueObjects/Entry';
import { selectEntrySlug } from 'Reducers/collections';
function getSlug(path) {
return path.split('/').pop().replace(/\.[^\.]+$/, '');
return path.split('/').pop().replace(/\.[^.]+$/, '');
}
export default class Algolia {

View File

@ -38,10 +38,10 @@ export default {
*/
export function registerPreviewStyle(style, opts) {
registry.previewStyles.push({ ...opts, value: style });
};
}
export function getPreviewStyles() {
return registry.previewStyles;
};
}
/**
@ -49,10 +49,10 @@ export function getPreviewStyles() {
*/
export function registerPreviewTemplate(name, component) {
registry.templates[name] = component;
};
}
export function getPreviewTemplate(name) {
return registry.templates[name];
};
}
/**
@ -63,13 +63,13 @@ export function registerWidget(name, control, preview) {
// multiple copies with different previews.
const newControl = typeof control === 'string' ? registry.widgets[control].control : control;
registry.widgets[name] = { control: newControl, preview };
};
}
export function getWidget(name) {
return registry.widgets[name];
};
}
export function resolveWidget(name) {
return getWidget(name || 'string') || getWidget('unknown');
};
}
/**
@ -78,10 +78,10 @@ export function resolveWidget(name) {
export function registerEditorComponent(component) {
const plugin = EditorComponent(component);
registry.editorComponents = registry.editorComponents.set(plugin.get('id'), plugin);
};
}
export function getEditorComponents() {
return registry.editorComponents;
};
}
/**
@ -89,10 +89,10 @@ export function getEditorComponents() {
*/
export function registerWidgetValueSerializer(widgetName, serializer) {
registry.widgetValueSerializers[widgetName] = serializer;
};
}
export function getWidgetValueSerializer(widgetName) {
return registry.widgetValueSerializers[widgetName];
};
}
/**
* Backend API

View File

@ -122,7 +122,7 @@ export const selectInferedField = (collection, fieldName) => {
if (inferableField.showError) {
consoleError(
`The Field ${ fieldName } is missing for the collection “${ collection.get('name') }`,
`Netlify CMS tries to infer the entry ${ fieldName } automatically, but one couldn\'t be found for entries of the collection “${ collection.get('name') }”. Please check your site configuration.`
`Netlify CMS tries to infer the entry ${ fieldName } automatically, but one couldn't be found for entries of the collection “${ collection.get('name') }”. Please check your site configuration.`
);
}

View File

@ -18,7 +18,7 @@ const EditorComponent = Record({
});
class Plugin extends Component { // eslint-disable-line
class Plugin extends Component {
static propTypes = {
children: PropTypes.element.isRequired,
};