Merge pull request #69 from roipoussiere/comma_dangle

Set eslint rule comma-dangle to always-multiline and apply it
pull/70/head
Jeroen Akkerman 5 years ago committed by GitHub
commit 07d96c3842
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -9,7 +9,8 @@
"semi": [ "semi": [
"error", "error",
"always" "always"
] ],
"comma-dangle": ["error", "always-multiline"]
}, },
"env": { "env": {
"browser": true, "browser": true,

@ -42,7 +42,7 @@ var bindings = {
'undo': undo, 'undo': undo,
'redo': redo, 'redo': redo,
'toggleSideBySide': toggleSideBySide, 'toggleSideBySide': toggleSideBySide,
'toggleFullScreen': toggleFullScreen 'toggleFullScreen': toggleFullScreen,
}; };
var shortcuts = { var shortcuts = {
@ -59,7 +59,7 @@ var shortcuts = {
'toggleCodeBlock': 'Cmd-Alt-C', 'toggleCodeBlock': 'Cmd-Alt-C',
'togglePreview': 'Cmd-P', 'togglePreview': 'Cmd-P',
'toggleSideBySide': 'F9', 'toggleSideBySide': 'F9',
'toggleFullScreen': 'F11' 'toggleFullScreen': 'F11',
}; };
var getBindingName = function (f) { var getBindingName = function (f) {
@ -321,11 +321,11 @@ function toggleCodeBlock(editor) {
line = line || cm.getLineHandle(line_num); line = line || cm.getLineHandle(line_num);
firstTok = firstTok || cm.getTokenAt({ firstTok = firstTok || cm.getTokenAt({
line: line_num, line: line_num,
ch: 1 ch: 1,
}); });
lastTok = lastTok || (!!line.text && cm.getTokenAt({ lastTok = lastTok || (!!line.text && cm.getTokenAt({
line: line_num, line: line_num,
ch: line.text.length - 1 ch: line.text.length - 1,
})); }));
var types = firstTok.type ? firstTok.type.split(' ') : []; var types = firstTok.type ? firstTok.type.split(' ') : [];
if (lastTok && token_state(lastTok).indentedCode) { if (lastTok && token_state(lastTok).indentedCode) {
@ -358,10 +358,10 @@ function toggleCodeBlock(editor) {
_replaceSelection(cm, false, [repl_start, repl_end]); _replaceSelection(cm, false, [repl_start, repl_end]);
cm.setSelection({ cm.setSelection({
line: start_line_sel, line: start_line_sel,
ch: 0 ch: 0,
}, { }, {
line: end_line_sel, line: end_line_sel,
ch: 0 ch: 0,
}); });
} }
@ -370,7 +370,7 @@ function toggleCodeBlock(editor) {
cur_end = cm.getCursor('end'), cur_end = cm.getCursor('end'),
tok = cm.getTokenAt({ tok = cm.getTokenAt({
line: cur_start.line, line: cur_start.line,
ch: cur_start.ch || 1 ch: cur_start.ch || 1,
}), // avoid ch 0 which is a cursor pos but not token }), // avoid ch 0 which is a cursor pos but not token
line = cm.getLineHandle(cur_start.line), line = cm.getLineHandle(cur_start.line),
is_code = code_type(cm, cur_start.line, line, tok); is_code = code_type(cm, cur_start.line, line, tok);
@ -382,10 +382,10 @@ function toggleCodeBlock(editor) {
end = line.text.slice(cur_start.ch).replace('`', ''); end = line.text.slice(cur_start.ch).replace('`', '');
cm.replaceRange(start + end, { cm.replaceRange(start + end, {
line: cur_start.line, line: cur_start.line,
ch: 0 ch: 0,
}, { }, {
line: cur_start.line, line: cur_start.line,
ch: 99999999999999 ch: 99999999999999,
}); });
cur_start.ch--; cur_start.ch--;
if (cur_start !== cur_end) { if (cur_start !== cur_end) {
@ -406,7 +406,7 @@ function toggleCodeBlock(editor) {
} }
var fencedTok = cm.getTokenAt({ var fencedTok = cm.getTokenAt({
line: block_start, line: block_start,
ch: 1 ch: 1,
}); });
var fence_chars = token_state(fencedTok).fencedChars; var fence_chars = token_state(fencedTok).fencedChars;
var start_text, start_line; var start_text, start_line;
@ -443,25 +443,25 @@ function toggleCodeBlock(editor) {
// end line first, so that line numbers don't change // end line first, so that line numbers don't change
cm.replaceRange(end_text, { cm.replaceRange(end_text, {
line: end_line, line: end_line,
ch: 0 ch: 0,
}, { }, {
line: end_line + (end_text ? 0 : 1), line: end_line + (end_text ? 0 : 1),
ch: 0 ch: 0,
}); });
cm.replaceRange(start_text, { cm.replaceRange(start_text, {
line: start_line, line: start_line,
ch: 0 ch: 0,
}, { }, {
line: start_line + (start_text ? 0 : 1), line: start_line + (start_text ? 0 : 1),
ch: 0 ch: 0,
}); });
}); });
cm.setSelection({ cm.setSelection({
line: start_line + (start_text ? 1 : 0), line: start_line + (start_text ? 1 : 0),
ch: 0 ch: 0,
}, { }, {
line: end_line + (start_text ? 1 : -1), line: end_line + (start_text ? 1 : -1),
ch: 0 ch: 0,
}); });
cm.focus(); cm.focus();
} else { } else {
@ -496,17 +496,17 @@ function toggleCodeBlock(editor) {
cm.operation(function () { cm.operation(function () {
cm.replaceRange('', { cm.replaceRange('', {
line: block_start, line: block_start,
ch: 0 ch: 0,
}, { }, {
line: block_start + 1, line: block_start + 1,
ch: 0 ch: 0,
}); });
cm.replaceRange('', { cm.replaceRange('', {
line: block_end - 1, line: block_end - 1,
ch: 0 ch: 0,
}, { }, {
line: block_end, line: block_end,
ch: 0 ch: 0,
}); });
}); });
cm.focus(); cm.focus();
@ -552,13 +552,13 @@ function toggleCodeBlock(editor) {
var next_line = cm.getLineHandle(block_end + 1), var next_line = cm.getLineHandle(block_end + 1),
next_line_last_tok = next_line && cm.getTokenAt({ next_line_last_tok = next_line && cm.getTokenAt({
line: block_end + 1, line: block_end + 1,
ch: next_line.text.length - 1 ch: next_line.text.length - 1,
}), }),
next_line_indented = next_line_last_tok && token_state(next_line_last_tok).indentedCode; next_line_indented = next_line_last_tok && token_state(next_line_last_tok).indentedCode;
if (next_line_indented) { if (next_line_indented) {
cm.replaceRange('\n', { cm.replaceRange('\n', {
line: block_end + 1, line: block_end + 1,
ch: 0 ch: 0,
}); });
} }
@ -850,7 +850,7 @@ function _replaceSelection(cm, active, startEnd, url) {
end = text.slice(startPoint.ch); end = text.slice(startPoint.ch);
cm.replaceRange(start + end, { cm.replaceRange(start + end, {
line: startPoint.line, line: startPoint.line,
ch: 0 ch: 0,
}); });
} else { } else {
text = cm.getSelection(); text = cm.getSelection();
@ -925,10 +925,10 @@ function _toggleHeading(cm, direction, size) {
cm.replaceRange(text, { cm.replaceRange(text, {
line: i, line: i,
ch: 0 ch: 0,
}, { }, {
line: i, line: i,
ch: 99999999999999 ch: 99999999999999,
}); });
})(i); })(i);
} }
@ -949,14 +949,14 @@ function _toggleLine(cm, name) {
var repl = { var repl = {
'quote': /^(\s*)>\s+/, 'quote': /^(\s*)>\s+/,
'unordered-list': listRegexp, 'unordered-list': listRegexp,
'ordered-list': listRegexp 'ordered-list': listRegexp,
}; };
var _getChar = function (name, i) { var _getChar = function (name, i) {
var map = { var map = {
'quote': '>', 'quote': '>',
'unordered-list': '*', 'unordered-list': '*',
'ordered-list': '%%i.' 'ordered-list': '%%i.',
}; };
return map[name].replace('%%i', i); return map[name].replace('%%i', i);
@ -966,7 +966,7 @@ function _toggleLine(cm, name) {
var map = { var map = {
'quote': '>', 'quote': '>',
'unordered-list': '*', 'unordered-list': '*',
'ordered-list': 'd+.' 'ordered-list': 'd+.',
}; };
var rt = new RegExp(map[name]); var rt = new RegExp(map[name]);
@ -994,10 +994,10 @@ function _toggleLine(cm, name) {
} }
cm.replaceRange(text, { cm.replaceRange(text, {
line: i, line: i,
ch: 0 ch: 0,
}, { }, {
line: i, line: i,
ch: 99999999999999 ch: 99999999999999,
}); });
})(i); })(i);
} }
@ -1035,10 +1035,10 @@ function _toggleBlock(editor, type, start_chars, end_chars) {
} }
cm.replaceRange(start + end, { cm.replaceRange(start + end, {
line: startPoint.line, line: startPoint.line,
ch: 0 ch: 0,
}, { }, {
line: startPoint.line, line: startPoint.line,
ch: 99999999999999 ch: 99999999999999,
}); });
if (type == 'bold' || type == 'strikethrough') { if (type == 'bold' || type == 'strikethrough') {
@ -1087,10 +1087,10 @@ function _cleanBlock(cm) {
cm.replaceRange(text, { cm.replaceRange(text, {
line: line, line: line,
ch: 0 ch: 0,
}, { }, {
line: line, line: line,
ch: 99999999999999 ch: 99999999999999,
}); });
} }
} }
@ -1147,125 +1147,125 @@ var toolbarBuiltInButtons = {
action: toggleBold, action: toggleBold,
className: 'fa fa-bold', className: 'fa fa-bold',
title: 'Bold', title: 'Bold',
default: true default: true,
}, },
'italic': { 'italic': {
name: 'italic', name: 'italic',
action: toggleItalic, action: toggleItalic,
className: 'fa fa-italic', className: 'fa fa-italic',
title: 'Italic', title: 'Italic',
default: true default: true,
}, },
'strikethrough': { 'strikethrough': {
name: 'strikethrough', name: 'strikethrough',
action: toggleStrikethrough, action: toggleStrikethrough,
className: 'fa fa-strikethrough', className: 'fa fa-strikethrough',
title: 'Strikethrough' title: 'Strikethrough',
}, },
'heading': { 'heading': {
name: 'heading', name: 'heading',
action: toggleHeadingSmaller, action: toggleHeadingSmaller,
className: 'fa fa-header fa-heading', className: 'fa fa-header fa-heading',
title: 'Heading', title: 'Heading',
default: true default: true,
}, },
'heading-smaller': { 'heading-smaller': {
name: 'heading-smaller', name: 'heading-smaller',
action: toggleHeadingSmaller, action: toggleHeadingSmaller,
className: 'fa fa-header fa-heading header-smaller', className: 'fa fa-header fa-heading header-smaller',
title: 'Smaller Heading' title: 'Smaller Heading',
}, },
'heading-bigger': { 'heading-bigger': {
name: 'heading-bigger', name: 'heading-bigger',
action: toggleHeadingBigger, action: toggleHeadingBigger,
className: 'fa fa-header fa-heading header-bigger', className: 'fa fa-header fa-heading header-bigger',
title: 'Bigger Heading' title: 'Bigger Heading',
}, },
'heading-1': { 'heading-1': {
name: 'heading-1', name: 'heading-1',
action: toggleHeading1, action: toggleHeading1,
className: 'fa fa-header fa-heading header-1', className: 'fa fa-header fa-heading header-1',
title: 'Big Heading' title: 'Big Heading',
}, },
'heading-2': { 'heading-2': {
name: 'heading-2', name: 'heading-2',
action: toggleHeading2, action: toggleHeading2,
className: 'fa fa-header fa-heading header-2', className: 'fa fa-header fa-heading header-2',
title: 'Medium Heading' title: 'Medium Heading',
}, },
'heading-3': { 'heading-3': {
name: 'heading-3', name: 'heading-3',
action: toggleHeading3, action: toggleHeading3,
className: 'fa fa-header fa-heading header-3', className: 'fa fa-header fa-heading header-3',
title: 'Small Heading' title: 'Small Heading',
}, },
'separator-1': { 'separator-1': {
name: 'separator-1' name: 'separator-1',
}, },
'code': { 'code': {
name: 'code', name: 'code',
action: toggleCodeBlock, action: toggleCodeBlock,
className: 'fa fa-code', className: 'fa fa-code',
title: 'Code' title: 'Code',
}, },
'quote': { 'quote': {
name: 'quote', name: 'quote',
action: toggleBlockquote, action: toggleBlockquote,
className: 'fa fa-quote-left', className: 'fa fa-quote-left',
title: 'Quote', title: 'Quote',
default: true default: true,
}, },
'unordered-list': { 'unordered-list': {
name: 'unordered-list', name: 'unordered-list',
action: toggleUnorderedList, action: toggleUnorderedList,
className: 'fa fa-list-ul', className: 'fa fa-list-ul',
title: 'Generic List', title: 'Generic List',
default: true default: true,
}, },
'ordered-list': { 'ordered-list': {
name: 'ordered-list', name: 'ordered-list',
action: toggleOrderedList, action: toggleOrderedList,
className: 'fa fa-list-ol', className: 'fa fa-list-ol',
title: 'Numbered List', title: 'Numbered List',
default: true default: true,
}, },
'clean-block': { 'clean-block': {
name: 'clean-block', name: 'clean-block',
action: cleanBlock, action: cleanBlock,
className: 'fa fa-eraser', className: 'fa fa-eraser',
title: 'Clean block' title: 'Clean block',
}, },
'separator-2': { 'separator-2': {
name: 'separator-2' name: 'separator-2',
}, },
'link': { 'link': {
name: 'link', name: 'link',
action: drawLink, action: drawLink,
className: 'fa fa-link', className: 'fa fa-link',
title: 'Create Link', title: 'Create Link',
default: true default: true,
}, },
'image': { 'image': {
name: 'image', name: 'image',
action: drawImage, action: drawImage,
className: 'fa fa-image', className: 'fa fa-image',
title: 'Insert Image', title: 'Insert Image',
default: true default: true,
}, },
'table': { 'table': {
name: 'table', name: 'table',
action: drawTable, action: drawTable,
className: 'fa fa-table', className: 'fa fa-table',
title: 'Insert Table' title: 'Insert Table',
}, },
'horizontal-rule': { 'horizontal-rule': {
name: 'horizontal-rule', name: 'horizontal-rule',
action: drawHorizontalRule, action: drawHorizontalRule,
className: 'fa fa-minus', className: 'fa fa-minus',
title: 'Insert Horizontal Line' title: 'Insert Horizontal Line',
}, },
'separator-3': { 'separator-3': {
name: 'separator-3' name: 'separator-3',
}, },
'preview': { 'preview': {
name: 'preview', name: 'preview',
@ -1273,7 +1273,7 @@ var toolbarBuiltInButtons = {
className: 'fa fa-eye', className: 'fa fa-eye',
noDisable: true, noDisable: true,
title: 'Toggle Preview', title: 'Toggle Preview',
default: true default: true,
}, },
'side-by-side': { 'side-by-side': {
name: 'side-by-side', name: 'side-by-side',
@ -1282,7 +1282,7 @@ var toolbarBuiltInButtons = {
noDisable: true, noDisable: true,
noMobile: true, noMobile: true,
title: 'Toggle Side by Side', title: 'Toggle Side by Side',
default: true default: true,
}, },
'fullscreen': { 'fullscreen': {
name: 'fullscreen', name: 'fullscreen',
@ -1291,10 +1291,10 @@ var toolbarBuiltInButtons = {
noDisable: true, noDisable: true,
noMobile: true, noMobile: true,
title: 'Toggle Fullscreen', title: 'Toggle Fullscreen',
default: true default: true,
}, },
'separator-4': { 'separator-4': {
name: 'separator-4' name: 'separator-4',
}, },
'guide': { 'guide': {
name: 'guide', name: 'guide',
@ -1302,43 +1302,43 @@ var toolbarBuiltInButtons = {
className: 'fa fa-question-circle', className: 'fa fa-question-circle',
noDisable: true, noDisable: true,
title: 'Markdown Guide', title: 'Markdown Guide',
default: true default: true,
}, },
'separator-5': { 'separator-5': {
name: 'separator-5' name: 'separator-5',
}, },
'undo': { 'undo': {
name: 'undo', name: 'undo',
action: undo, action: undo,
className: 'fa fa-undo', className: 'fa fa-undo',
noDisable: true, noDisable: true,
title: 'Undo' title: 'Undo',
}, },
'redo': { 'redo': {
name: 'redo', name: 'redo',
action: redo, action: redo,
className: 'fa fa-repeat fa-redo', className: 'fa fa-repeat fa-redo',
noDisable: true, noDisable: true,
title: 'Redo' title: 'Redo',
} },
}; };
var insertTexts = { var insertTexts = {
link: ['[', '](#url#)'], link: ['[', '](#url#)'],
image: ['![](', '#url#)'], image: ['![](', '#url#)'],
table: ['', '\n\n| Column 1 | Column 2 | Column 3 |\n| -------- | -------- | -------- |\n| Text | Text | Text |\n\n'], table: ['', '\n\n| Column 1 | Column 2 | Column 3 |\n| -------- | -------- | -------- |\n| Text | Text | Text |\n\n'],
horizontalRule: ['', '\n\n-----\n\n'] horizontalRule: ['', '\n\n-----\n\n'],
}; };
var promptTexts = { var promptTexts = {
link: 'URL for the link:', link: 'URL for the link:',
image: 'URL of the image:' image: 'URL of the image:',
}; };
var blockStyles = { var blockStyles = {
'bold': '**', 'bold': '**',
'code': '```', 'code': '```',
'italic': '*' 'italic': '*',
}; };
/** /**
@ -1426,7 +1426,7 @@ function EasyMDE(options) {
// Set default options for parsing config // Set default options for parsing config
options.parsingConfig = extend({ options.parsingConfig = extend({
highlightFormatting: true // needed for toggleCodeBlock to detect types of code highlightFormatting: true, // needed for toggleCodeBlock to detect types of code
}, options.parsingConfig || {}); }, options.parsingConfig || {});
@ -1568,7 +1568,7 @@ EasyMDE.prototype.render = function (el) {
backdrop.gitHubSpice = false; backdrop.gitHubSpice = false;
CodeMirrorSpellChecker({ CodeMirrorSpellChecker({
codeMirrorInstance: CodeMirror codeMirrorInstance: CodeMirror,
}); });
} else { } else {
mode = options.parsingConfig; mode = options.parsingConfig;
@ -1579,7 +1579,7 @@ EasyMDE.prototype.render = function (el) {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
function configureMouse(cm, repeat, event) { function configureMouse(cm, repeat, event) {
return { return {
addNew: false addNew: false,
}; };
} }
@ -1597,7 +1597,7 @@ EasyMDE.prototype.render = function (el) {
allowDropFileTypes: ['text/plain'], allowDropFileTypes: ['text/plain'],
placeholder: options.placeholder || el.getAttribute('placeholder') || '', placeholder: options.placeholder || el.getAttribute('placeholder') || '',
styleSelectedText: (options.styleSelectedText != undefined) ? options.styleSelectedText : !isMobile(), styleSelectedText: (options.styleSelectedText != undefined) ? options.styleSelectedText : !isMobile(),
configureMouse: configureMouse configureMouse: configureMouse,
}); });
this.codemirror.getScrollerElement().style.minHeight = options.minHeight; this.codemirror.getScrollerElement().style.minHeight = options.minHeight;
@ -1897,7 +1897,7 @@ EasyMDE.prototype.createStatusbar = function (status) {
items.push({ items.push({
className: status[i].className, className: status[i].className,
defaultValue: status[i].defaultValue, defaultValue: status[i].defaultValue,
onUpdate: status[i].onUpdate onUpdate: status[i].onUpdate,
}); });
} else { } else {
var name = status[i]; var name = status[i];
@ -1935,7 +1935,7 @@ EasyMDE.prototype.createStatusbar = function (status) {
items.push({ items.push({
className: name, className: name,
defaultValue: defaultValue, defaultValue: defaultValue,
onUpdate: onUpdate onUpdate: onUpdate,
}); });
} }
} }

Loading…
Cancel
Save