chore(lint): cleanup unused variables in code (#1563)

This commit is contained in:
Caleb
2018-08-07 09:53:31 -06:00
committed by Shawn Erquhart
parent d0e4435258
commit 88f7dca328
52 changed files with 61 additions and 199 deletions

View File

@ -77,7 +77,7 @@ export default class Shortcode extends React.Component {
}
}
renderControl = (shortcodeData, field, index) => {
renderControl = (shortcodeData, field) => {
if (field.get('widget') === 'hidden') return null;
const value = shortcodeData.get(field.get('name'));
const key = `field-${ field.get('name') }`;
@ -92,7 +92,7 @@ export default class Shortcode extends React.Component {
};
render() {
const { attributes, node, editor } = this.props;
const { attributes, node } = this.props;
const { collapsed } = this.state;
const pluginId = node.data.get('shortcode');
const shortcodeData = Map(this.props.node.data.get('shortcodeData'));

View File

@ -64,13 +64,6 @@ export default class Toolbar extends React.Component {
disabled: PropTypes.bool,
};
constructor(props) {
super(props);
this.state = {
activePlugin: null,
};
}
isHidden = button => {
const { buttons } = this.props;
return List.isList(buttons) ? !buttons.includes(button) : false;
@ -87,14 +80,10 @@ export default class Toolbar extends React.Component {
onToggleMode,
rawMode,
plugins,
onAddAsset,
getAsset,
disabled,
onSubmit,
} = this.props;
const { activePlugin } = this.state;
return (
<ToolbarContainer>
<div>

View File

@ -76,7 +76,7 @@ export default class Editor extends React.Component {
handleBlockClick = (event, type) => {
event.preventDefault();
let { value } = this.state;
const { document: doc, selection } = value;
const { document: doc } = value;
const { unwrapList, wrapInList } = EditListConfigured.changes;
let change = value.change();
@ -178,9 +178,8 @@ export default class Editor extends React.Component {
handleDocumentChange = debounce(change => {
const { onChange, getEditorComponents } = this.props;
const { onChange } = this.props;
const raw = change.value.document.toJSON();
const plugins = getEditorComponents();
const markdown = slateToMarkdown(raw);
onChange(markdown);
}, 150);

View File

@ -1,51 +1,7 @@
import React from 'react';
import { fromJS } from 'immutable';
import { markdownToSlate } from '../../serializers';
const parser = markdownToSlate;
// Temporary plugins test
const testPlugins = fromJS([
{
label: 'Image',
id: 'image',
fromBlock: match => match && {
image: match[2],
alt: match[1],
},
toBlock: data => `![${ data.alt }](${ data.image })`,
toPreview: data => <img src={data.image} alt={data.alt} />, // eslint-disable-line react/display-name
pattern: /^!\[([^\]]+)]\(([^)]+)\)$/,
fields: [{
label: 'Image',
name: 'image',
widget: 'image',
}, {
label: 'Alt Text',
name: 'alt',
}],
},
{
id: "youtube",
label: "Youtube",
fields: [{name: 'id', label: 'Youtube Video ID'}],
pattern: /^{{<\s?youtube (\S+)\s?>}}/,
fromBlock: function(match) {
return {
id: match[1]
};
},
toBlock: function(obj) {
return '{{< youtube ' + obj.id + ' >}}';
},
toPreview: function(obj) {
return (
'<img src="http://img.youtube.com/vi/' + obj.id + '/maxresdefault.jpg" alt="Youtube Video"/>'
);
}
},
]);
describe("Compile markdown to Slate Raw AST", () => {
it("should compile simple markdown", () => {
const value = `

View File

@ -20,7 +20,7 @@ function onKeyDown(event, change) {
* If the selected block is the first block in the document, create the
* new block above it. If not, create the new block below it.
*/
const { document: doc, range, anchorBlock, focusBlock } = change.value;
const { document: doc, anchorBlock, focusBlock } = change.value;
const singleBlockSelected = anchorBlock === focusBlock;
if (!singleBlockSelected || !focusBlock.isVoid) return;
@ -45,7 +45,7 @@ function onKeyDown(event, change) {
[ '`', 'code' ],
];
const [ markKey, markName ] = marks.find(([ key ]) => isHotkey(`mod+${key}`, event)) || [];
const [ , markName ] = marks.find(([ key ]) => isHotkey(`mod+${key}`, event)) || [];
if (markName) {
event.preventDefault();

View File

@ -14,7 +14,7 @@ export function joinPatternSegments(patterns) {
* each in a non-capturing group and interposing alternation characters (|) so
* that each expression is executed separately.
*/
export function combinePatterns(patterns, flags = '') {
export function combinePatterns(patterns) {
return patterns.map(p => `(?:${p.source})`).join('|');
}

View File

@ -16,7 +16,6 @@ export default function remarkAllowHtmlEntities() {
var tokenizer;
var name;
var min;
var now;
/* istanbul ignore if - never used (yet) */
if (silent) {

View File

@ -92,7 +92,7 @@ function transform(node) {
* they were text is a bit of a necessary hack.
*/
function combineTextAndInline(nodes) {
return nodes.reduce((acc, node, idx, nodes) => {
return nodes.reduce((acc, node) => {
const prevNode = last(acc);
const prevNodeLeaves = get(prevNode, 'leaves');
const data = node.data || {};
@ -158,19 +158,6 @@ function processCodeMark(markTypes) {
return { filteredMarkTypes, textNodeType };
}
/**
* Wraps a text node in one or more mark nodes by placing the text node in an
* array and using that as the `children` value of a mark node. The resulting
* mark node is then placed in an array and used as the child of a mark node for
* the next mark type in `markTypes`. This continues for each member of
* `markTypes`. If `markTypes` is empty, the original text node is returned.
*/
function wrapTextWithMarks(textNode, markTypes) {
const wrapTextWithMark = (childNode, markType) => u(markType, [childNode]);
return markTypes.reduce(wrapTextWithMark, textNode);
}
/**
* Converts a Slate Raw text node to an MDAST text node.
*