Permalink
Browse files

eslint fixes

  • Loading branch information...
1 parent 7cf31c5 commit 189563a27fe18ef97688d948d458eabe316db1d3 @jhchen jhchen committed Oct 16, 2016
View
@@ -2,7 +2,7 @@ import Embed from './embed';
class Break extends Embed {
- static value(domNode) {
+ static value() {
return undefined;
}
View
@@ -5,7 +5,7 @@ import Emitter from '../core/emitter';
class Cursor extends Embed {
- static value(domNode) {
+ static value() {
return undefined;
}
@@ -48,7 +48,7 @@ class Cursor extends Embed {
return this._length;
}
- position(index) {
+ position() {
return [this.textNode, this.textNode.data.length];
}
View
@@ -1,4 +1,3 @@
-import extend from 'extend';
import Embed from './embed';
import Text from './text';
import Parchment from 'parchment';
@@ -32,8 +31,8 @@ class Inline extends Parchment.Inline {
optimize() {
super.optimize();
- let ref = this.parent.parent;
- if (this.parent instanceof Inline && Inline.compare(this.statics.blotName, this.parent.statics.blotName) > 0) {
+ if (this.parent instanceof Inline &&
+ Inline.compare(this.statics.blotName, this.parent.statics.blotName) > 0) {
let parent = this.parent.isolate(this.offset(), this.length());
this.moveChildren(parent);
parent.wrap(this);
View
@@ -84,7 +84,7 @@ class Editor {
Object.keys(formats).forEach((format) => {
let lines = this.scroll.lines(index, Math.max(length, 1));
let lengthRemaining = length;
- lines.forEach((line, i) => {
+ lines.forEach((line) => {
let lineLength = line.length();
if (!(line instanceof CodeBlock)) {
line.format(format, formats[format]);
View
@@ -3,7 +3,7 @@ let level = 'warn';
function debug(method, ...args) {
if (levels.indexOf(method) <= levels.indexOf(level)) {
- console[method].apply(console, args);
+ console[method].apply(console, args); // eslint-disable-line no-console
}
}
View
@@ -309,6 +309,7 @@ Quill.DEFAULTS = {
};
Quill.events = Emitter.events;
Quill.sources = Emitter.sources;
+// eslint-disable-next-line no-undef
Quill.version = typeof(QUILL_VERSION) === 'undefined' ? 'dev' : QUILL_VERSION;
Quill.imports = {
View
@@ -1,7 +1,6 @@
import Parchment from 'parchment';
import clone from 'clone';
import equal from 'deep-equal';
-import BreakBlot from '../blots/break';
import Emitter from './emitter';
import logger from './logger';
@@ -104,6 +103,7 @@ class Selection {
bounds = range.getBoundingClientRect();
} else {
let side = 'left';
+ let rect;
if (node instanceof Text) {
if (offset < node.data.length) {
range.setStart(node, offset);
@@ -113,9 +113,9 @@ class Selection {
range.setEnd(node, offset);
side = 'right';
}
- var rect = range.getBoundingClientRect();
+ rect = range.getBoundingClientRect();
} else {
- var rect = leaf.domNode.getBoundingClientRect();
+ rect = leaf.domNode.getBoundingClientRect();
if (offset > 0) side = 'right';
}
bounds = {
View
@@ -1,7 +1,3 @@
-import extend from 'extend';
-import Emitter from './emitter';
-
-
class Theme {
constructor(quill, options) {
this.quill = quill;
View
@@ -1,11 +1,11 @@
import Inline from '../blots/inline';
class Bold extends Inline {
- static create(value) {
+ static create() {
return super.create();
}
- static formats(domNode) {
+ static formats() {
return true;
}
View
@@ -17,7 +17,7 @@ class CodeBlock extends Block {
return domNode;
}
- static formats(domNode) {
+ static formats() {
return true;
}
View
@@ -1,5 +1,5 @@
import Embed from '../blots/embed';
-import Link, { sanitize } from '../formats/link';
+import { sanitize } from '../formats/link';
const ATTRIBUTES = [
'alt',
View
@@ -1,5 +1,3 @@
-import extend from 'extend';
-import Delta from 'quill-delta';
import Parchment from 'parchment';
import Block from '../blots/block';
import Container from '../blots/container';
@@ -227,7 +227,7 @@ function matchBreak(node, delta) {
return delta;
}
-function matchIgnore(node, delta) {
+function matchIgnore() {
return new Delta();
}
@@ -270,10 +270,11 @@ function matchText(node, delta) {
return delta.insert(text.trim());
}
if (!computeStyle(node.parentNode).whiteSpace.startsWith('pre')) {
- function replacer(collapse, match) {
+ // eslint-disable-next-line func-style
+ let replacer = function(collapse, match) {
match = match.replace(/[^\u00a0]/g, ''); // \u00a0 is nbsp;
return match.length < 1 && collapse ? ' ' : match;
- }
+ };
text = text.replace(/\r\n/g, ' ').replace(/\n/g, ' ');
text = text.replace(/\s\s+/g, replacer.bind(replacer, true)); // collapse whitespace
if ((node.previousSibling == null && isLine(node.parentNode)) ||
View
@@ -6,7 +6,7 @@ class FormulaBlot extends Embed {
static create(value) {
let node = super.create(value);
if (typeof value === 'string') {
- katex.render(value, node);
+ window.katex.render(value, node);
node.setAttribute('data-value', value);
}
node.setAttribute('contenteditable', false);
@@ -17,7 +17,7 @@ class FormulaBlot extends Embed {
return domNode.getAttribute('data-value');
}
- index(node, offset) {
+ index() {
return 1;
}
}
View
@@ -1,13 +1,11 @@
import clone from 'clone';
import equal from 'deep-equal';
import extend from 'extend';
-import Delta from 'quill-delta';
import DeltaOp from 'quill-delta/lib/op';
import Parchment from 'parchment';
import Quill from '../core/quill';
import logger from '../core/logger';
import Module from '../core/module';
-import Block from '../blots/block';
let debug = logger('quill:keyboard');
@@ -189,7 +187,7 @@ Keyboard.DEFAULTS = {
shiftKey: true,
collapsed: true,
prefix: /\t$/,
- handler: function(range, context) {
+ handler: function(range) {
this.quill.deleteText(range.index - 1, 1, Quill.sources.USER);
}
},
View
@@ -1,4 +1,3 @@
-import extend from 'extend';
import Delta from 'quill-delta';
import Parchment from 'parchment';
import Quill from '../core/quill';
@@ -202,7 +201,7 @@ function addSelect(container, format, values) {
Toolbar.DEFAULTS = {
container: null,
handlers: {
- clean: function(value) {
+ clean: function() {
let range = this.quill.getSelection();
if (range == null) return;
if (range.length == 0) {
View
@@ -1,6 +1,6 @@
import Quill from './core';
-import { AlignAttribute, AlignClass, AlignStyle } from './formats/align';
+import { AlignClass, AlignStyle } from './formats/align';
import { DirectionAttribute, DirectionClass, DirectionStyle } from './formats/direction';
import { IndentClass as Indent } from './formats/indent';
@@ -1,4 +1,3 @@
-import Delta from 'quill-delta';
import Editor from '../../core/editor';
import Emitter from '../../core/emitter';
import Selection from '../../core/selection';
@@ -56,16 +55,15 @@ function compareHTML(actual, expected, ignoreClassId) {
}
let message = compareNodes(div1, div2, ignoredAttributes)
if (message != null) {
- console.error(div1.innerHTML);
- console.error(div2.innerHTML);
+ console.error(div1.innerHTML); // eslint-disable-line no-console
+ console.error(div2.innerHTML); // eslint-disable-line no-console
return { pass: false, message: message };
} else {
return { pass: true, message: 'HTMLs equal' };
}
}
function compareNodes(node1, node2, ignoredAttributes = []) {
- let attr1, attr2, message, ref;
if (node1.nodeType !== node2.nodeType) {
return `Expected nodeType '${node1.nodeType}' to equal '${node2.nodeType}'`;
}
@@ -1,4 +1,3 @@
-import Parchment from 'parchment';
import Scroll from '../../../blots/scroll';
@@ -410,7 +410,7 @@ describe('Quill', function() {
});
it('toolbar custom handler, default container', function() {
- let handler = function(value) {};
+ let handler = function() {}; // eslint-disable-line func-style
let config = expandConfig('#test-container', {
modules: {
toolbar: {
@@ -1,7 +1,5 @@
-import Delta from 'quill-delta';
import Selection, { Range } from '../../../core/selection';
import Cursor from '../../../blots/cursor';
-import Scroll from '../../../blots/scroll';
describe('Selection', function() {
@@ -17,7 +17,7 @@ describe('Link', function() {
it('add invalid', function() {
let editor = this.initialize(Editor, '<p>0123</p>');
- editor.formatText(1, 2, { link: 'javascript:alert(0);' });
+ editor.formatText(1, 2, { link: 'javascript:alert(0);' }); // eslint-disable-line no-script-url
expect(editor.getDelta()).toEqual(new Delta()
.insert('0')
.insert('12', { link: Link.SANITIZED_URL })
@@ -1,4 +1,3 @@
-import Delta from 'quill-delta';
import Editor from '../../../core/editor';
@@ -70,11 +70,12 @@ describe('History', function() {
it('limits undo stack size', function () {
let quill = new Quill(this.container.firstChild, {
modules: {
- history: {delay: 0, maxStack: 2}
+ history: { delay: 0, maxStack: 2 }
}
});
-
- ['A', 'B', 'C'].forEach(text => quill.insertText(0, text));
+ ['A', 'B', 'C'].forEach(function(text) {
+ quill.insertText(0, text)
+ });
expect(quill.history.stack.undo.length).toEqual(2);
});
@@ -1,5 +1,5 @@
import Quill from '../../../core/quill';
-import Toolbar, { addControls } from '../../../modules/toolbar';
+import { addControls } from '../../../modules/toolbar';
describe('Toolbar', function() {
@@ -3,7 +3,7 @@ import Picker from '../../../ui/picker';
describe('Picker', function() {
it('initialization', function() {
this.container.innerHTML = '<select><option selected>0</option><option value="1">1</option></select>';
- let picker = new Picker(this.container.firstChild);
+ let picker = new Picker(this.container.firstChild); // eslint-disable-line no-unused-vars
expect(this.container.querySelector('.ql-picker')).toBeTruthy();
expect(this.container.querySelector('.ql-active')).toBeFalsy();
expect(this.container.querySelector('.ql-picker-item.ql-selected').outerHTML).toEqualHTML('<span class="ql-picker-item ql-selected" data-label="0"></span>');
View
@@ -117,10 +117,10 @@ BaseTheme.DEFAULTS = extend(true, {}, Theme.DEFAULTS, {
modules: {
toolbar: {
handlers: {
- formula: function(value) {
+ formula: function() {
this.quill.theme.tooltip.edit('formula');
},
- image: function(value) {
+ image: function() {
let fileInput = this.container.querySelector('input.ql-image[type=file]');
if (fileInput == null) {
fileInput = document.createElement('input');
@@ -146,7 +146,7 @@ BaseTheme.DEFAULTS = extend(true, {}, Theme.DEFAULTS, {
}
fileInput.click();
},
- video: function(value) {
+ video: function() {
this.quill.theme.tooltip.edit('video');
}
}
@@ -201,7 +201,7 @@ class BaseTooltip extends Tooltip {
save() {
let value = this.textbox.value;
switch(this.root.getAttribute('data-mode')) {
- case 'link':
+ case 'link': {
let scrollTop = this.quill.root.scrollTop;
if (this.linkRange) {
this.quill.formatText(this.linkRange, 'link', value, Emitter.sources.USER);
@@ -212,16 +212,17 @@ class BaseTooltip extends Tooltip {
}
this.quill.root.scrollTop = scrollTop;
break;
- case 'video':
+ }
+ case 'video': {
let match = value.match(/^(https?):\/\/(www\.)?youtube\.com\/watch.*v=([a-zA-Z0-9_-]+)/) ||
value.match(/^(https?):\/\/(www\.)?youtu\.be\/([a-zA-Z0-9_-]+)/);
if (match) {
value = match[1] + '://www.youtube.com/embed/' + match[3] + '?showinfo=0';
- } else if (match = value.match(/^(https?):\/\/(www\.)?vimeo\.com\/(\d+)/)) {
+ } else if (match = value.match(/^(https?):\/\/(www\.)?vimeo\.com\/(\d+)/)) { // eslint-disable-line no-cond-assign
value = match[1] + '://player.vimeo.com/video/' + match[3] + '/';
}
- // fallthrough
- case 'formula':
+ } // eslint-disable-next-line no-fallthrough
+ case 'formula': {
let range = this.quill.getSelection(true);
let index = range.index + range.length;
if (range != null) {
@@ -232,6 +233,7 @@ class BaseTooltip extends Tooltip {
this.quill.setSelection(index + 2, Emitter.sources.USER);
}
break;
+ }
default:
}
this.textbox.value = '';
View
@@ -1,8 +1,6 @@
import extend from 'extend';
import Emitter from '../core/emitter';
-import Keyboard from '../modules/keyboard';
import BaseTheme, { BaseTooltip } from './base';
-import icons from '../ui/icons';
import { Range } from '../core/selection';
@@ -73,7 +71,7 @@ class BubbleTooltip extends BaseTooltip {
listen() {
super.listen();
- this.root.querySelector('.ql-close').addEventListener('click', (event) => {
+ this.root.querySelector('.ql-close').addEventListener('click', () => {
this.root.classList.remove('ql-editing');
});
this.quill.on(Emitter.events.SCROLL_OPTIMIZE, () => {
Oops, something went wrong.

0 comments on commit 189563a

Please sign in to comment.