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

@ -29,7 +29,7 @@ export default class Bitbucket {
}
if (!this.options.proxied && !config.getIn(["backend", "repo"], false)) {
throw new Error("The BitBucket backend needs a \"repo\ in the backend configuration.");
throw new Error("The BitBucket backend needs a \"repo\" in the backend configuration.");
}
this.api = this.options.API || null;

View File

@ -143,14 +143,14 @@ export default class API {
const cache = localForage.getItem(`gh.meta.${ key }`);
return cache.then((cached) => {
if (cached && cached.expires > Date.now()) { return cached.data; }
console.log("%c Checking for MetaData files", "line-height: 30px;text-align: center;font-weight: bold"); // eslint-disable-line
console.log("%c Checking for MetaData files", "line-height: 30px;text-align: center;font-weight: bold");
return this.request(`${ this.repoURL }/contents/${ key }.json`, {
params: { ref: "refs/meta/_netlify_cms" },
headers: { Accept: "application/vnd.github.VERSION.raw" },
cache: "no-store",
})
.then(response => JSON.parse(response))
.catch(error => console.log("%c %s does not have metadata", "line-height: 30px;text-align: center;font-weight: bold", key)); // eslint-disable-line
.catch(error => console.log("%c %s does not have metadata", "line-height: 30px;text-align: center;font-weight: bold", key));
});
}
@ -227,7 +227,7 @@ export default class API {
}
listUnpublishedBranches() {
console.log("%c Checking for Unpublished entries", "line-height: 30px;text-align: center;font-weight: bold"); // eslint-disable-line
console.log("%c Checking for Unpublished entries", "line-height: 30px;text-align: center;font-weight: bold");
return this.request(`${ this.repoURL }/git/refs/heads/cms`)
.then(branches => filterPromises(branches, (branch) => {
const branchName = branch.ref.substring("/refs/heads/".length - 1);
@ -245,7 +245,7 @@ export default class API {
.then(prs => prs.some(pr => pr.head.ref === branchName));
}))
.catch((error) => {
console.log("%c No Unpublished entries", "line-height: 30px;text-align: center;font-weight: bold"); // eslint-disable-line
console.log("%c No Unpublished entries", "line-height: 30px;text-align: center;font-weight: bold");
throw error;
});
}
@ -262,7 +262,7 @@ export default class API {
parts = file.path.split("/").filter(part => part);
filename = parts.pop();
subtree = fileTree;
while (part = parts.shift()) {
while (part = parts.shift()) { // eslint-disable-line no-cond-assign
subtree[part] = subtree[part] || {};
subtree = subtree[part];
}
@ -636,7 +636,7 @@ export default class API {
closePR(pullrequest, objects) {
const headSha = pullrequest.head;
const prNumber = pullrequest.number;
console.log("%c Deleting PR", "line-height: 30px;text-align: center;font-weight: bold"); // eslint-disable-line
console.log("%c Deleting PR", "line-height: 30px;text-align: center;font-weight: bold");
return this.request(`${ this.repoURL }/pulls/${ prNumber }`, {
method: "PATCH",
body: JSON.stringify({
@ -648,7 +648,7 @@ export default class API {
mergePR(pullrequest, objects) {
const headSha = pullrequest.head;
const prNumber = pullrequest.number;
console.log("%c Merging PR", "line-height: 30px;text-align: center;font-weight: bold"); // eslint-disable-line
console.log("%c Merging PR", "line-height: 30px;text-align: center;font-weight: bold");
return this.request(`${ this.repoURL }/pulls/${ prNumber }/merge`, {
method: "PUT",
body: JSON.stringify({
@ -673,7 +673,7 @@ export default class API {
files.forEach((file) => {
commitMessage += `\n* "${ file.path }"`;
});
console.log("%c Automatic merge not possible - Forcing merge.", "line-height: 30px;text-align: center;font-weight: bold"); // eslint-disable-line
console.log("%c Automatic merge not possible - Forcing merge.", "line-height: 30px;text-align: center;font-weight: bold");
return this.getBranch()
.then(branchData => this.updateTree(branchData.commit.sha, "/", fileTree))
.then(changeTree => this.commit(commitMessage, changeTree))
@ -738,7 +738,7 @@ export default class API {
for (let i = 0, len = tree.tree.length; i < len; i++) {
obj = tree.tree[i];
if (fileOrDir = fileTree[obj.path]) {
if (fileOrDir = fileTree[obj.path]) { // eslint-disable-line no-cond-assign
added[obj.path] = true;
if (fileOrDir.file) {
updates.push({ path: obj.path, mode: obj.mode, type: obj.type, sha: fileOrDir.sha });

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,
};

View File

@ -8,7 +8,7 @@ const image = {
alt: match[1],
},
toBlock: data => `![${ data.alt || '' }](${ data.image || '' })`,
toPreview: (data, getAsset) => <img src={getAsset(data.image) || ''} alt={data.alt || ''} />,
toPreview: (data, getAsset) => <img src={getAsset(data.image) || ''} alt={data.alt || ''} />, // eslint-disable-line react/display-name
pattern: /^!\[(.*)\]\((.*)\)$/,
fields: [{
label: 'Image',

View File

@ -1,7 +1,7 @@
const absolutePath = new RegExp('^(?:[a-z]+:)?//', 'i');
const normalizePath = path => path.replace(/[\\\/]+/g, '/');
const normalizePath = path => path.replace(/[\\/]+/g, '/');
export function resolvePath(path, basePath) { // eslint-disable-line
export function resolvePath(path, basePath) {
// No path provided, skip
if (!path) return null;

View File

@ -49,7 +49,7 @@ const FileWidgetButtonRemove = styled.button`
`
export default function withFileControl({ forImage } = {}) {
return class extends React.Component {
return class FileControl extends React.Component {
static propTypes = {
field: PropTypes.object.isRequired,
getAsset: PropTypes.func.isRequired,
@ -164,4 +164,4 @@ export default function withFileControl({ forImage } = {}) {
);
}
}
};
}

View File

@ -307,4 +307,4 @@ export default class ListControl extends React.Component {
className={classNameWrapper}
/>);
}
};
}

View File

@ -112,4 +112,4 @@ export default class Shortcode extends React.Component {
</ShortcodeContainer>
);
}
};
}

View File

@ -14,7 +14,7 @@ const testPlugins = fromJS([
alt: match[1],
},
toBlock: data => `![${ data.alt }](${ data.image })`,
toPreview: data => <img src={data.image} alt={data.alt} />,
toPreview: data => <img src={data.image} alt={data.alt} />, // eslint-disable-line react/display-name
pattern: /^!\[([^\]]+)]\(([^)]+)\)$/,
fields: [{
label: 'Image',

View File

@ -51,4 +51,4 @@ function onKeyDown(event, change) {
event.preventDefault();
return change.toggleMark(markName);
}
};
}

View File

@ -86,4 +86,4 @@ export function validateNode(node) {
);
}
}
};
}

View File

@ -70,6 +70,13 @@ export default css`
white-space: pre-wrap;
}
code {
background-color: ${colors.background};
border-radius: ${lengths.borderRadius};
padding: 0 2px;
font-size: 85%;
}
pre > code {
display: block;
width: 100%;
@ -80,13 +87,6 @@ export default css`
padding: 10px;
}
code {
background-color: ${colors.background};
border-radius: ${lengths.borderRadius};
padding: 0 2px;
font-size: 85%;
}
blockquote {
padding-left: 16px;
border-left: 3px solid ${colors.background};

View File

@ -1,5 +1,3 @@
/* eslint max-len:0 */
import React from 'react';
import renderer from 'react-test-renderer';
import { padStart } from 'lodash';

View File

@ -106,7 +106,7 @@ export const remarkToMarkdown = obj => {
const Compiler = this.Compiler;
const visitors = Compiler.prototype.visitors;
visitors.text = node => node.value;
};
}
/**
* Provide an empty MDAST if no value is provided.

View File

@ -56,4 +56,4 @@ export default function remarkAllowHtmlEntities() {
value: subvalue,
});
}
};
}

View File

@ -93,7 +93,7 @@ const escapePatterns = [
*
* Match strings surrounded by one or more asterisks on both sides.
*/
/(\*+)[^\*]*(\1)/g,
/(\*+)[^*]*(\1)/g,
/**
* Emphasis - Underscore

View File

@ -48,7 +48,7 @@ export default function remarkPaddedLinks() {
const children = processedChildren.map(transform);
return { ...node, children };
};
}
function transformChildren(node) {
if (node.type !== 'link') return node;
@ -102,7 +102,7 @@ export default function remarkPaddedLinks() {
*/
let findFn;
if (end) { findFn = findLast }
else { findFn = find };
else { findFn = find }
let edgeChildWithValue;
setEdgeChildWithValue(node);

View File

@ -53,4 +53,4 @@ export default function remarkStripTrailingBreaks() {
return node;
};
return transform;
};
}

View File

@ -176,4 +176,4 @@ export default class RelationControl extends React.Component {
</div>
);
}
};
}

View File

@ -52,9 +52,6 @@ h3 {
margin: 0;
}
h3 > p {
}
p, ul {
font-size: 18px;
line-height: 26px;

View File

@ -1,15 +1,3 @@
.docs-content,
.blog-content {
pre {
margin: 30px -16px !important;
}
@media (min-width: $xlarge) {
pre {
margin-right: -120px !important;
}
}
}
.docs.page,
.blog.page {
padding: 69px $tiny $xl;
@ -225,6 +213,13 @@
border-radius: $borderRadius;
}
pre {
margin: 30px -16px !important;
@media (min-width: $xlarge) {
margin-right: -120px !important;
}
}
:not(pre) > code {
color: inherit;
background: $lightestGrey;

View File

@ -11,7 +11,6 @@
font-size: inherit;
line-height: inherit;
background: transparent;
border: 0;
color: $darkGrey;
border: 2px solid $darkGreen;
border-radius: $borderRadius;