Przeglądaj źródła

Code style: Switched to ESLint.

Kamil Piechaczek 8 lat temu
rodzic
commit
bef2554bce

+ 1 - 0
packages/ckeditor5-clipboard/package.json

@@ -18,6 +18,7 @@
     "@ckeditor/ckeditor5-list": "^0.6.1",
     "@ckeditor/ckeditor5-typing": "^0.9.1",
     "@ckeditor/ckeditor5-undo": "^0.8.1",
+    "eslint-config-ckeditor5": "^1.0.0",
     "gulp": "^3.9.1",
     "guppy-pre-commit": "^0.4.0"
   },

+ 6 - 6
packages/ckeditor5-clipboard/src/utils/viewtoplaintext.js

@@ -7,6 +7,11 @@
  * @module clipboard/utils/viewtoplaintext
  */
 
+// Elements which should not have empty-line padding.
+// Most `view.ContainerElement` want to be separate by new-line, but some are creating one structure
+// together (like `<li>`) so it is better to separate them by only one "\n".
+const smallPaddingElements = [ 'figcaption', 'li' ];
+
 /**
  * Deeply converts {@link module:engine/model/view/item view item} to plain text.
  *
@@ -27,7 +32,7 @@ export default function viewToPlainText( viewItem ) {
 		// They don't have their own text value, so convert their children.
 		let prev = null;
 
-		for ( let child of viewItem.getChildren() ) {
+		for ( const child of viewItem.getChildren() ) {
 			const childText = viewToPlainText( child );
 
 			// Separate container element children with one or more new-line characters.
@@ -46,8 +51,3 @@ export default function viewToPlainText( viewItem ) {
 
 	return text;
 }
-
-// Elements which should not have empty-line padding.
-// Most `view.ContainerElement` want to be separate by new-line, but some are creating one structure
-// together (like `<li>`) so it is better to separate them by only one "\n".
-const smallPaddingElements = [ 'figcaption', 'li' ];

+ 18 - 18
packages/ckeditor5-clipboard/tests/clipboard.js

@@ -27,13 +27,13 @@ describe( 'Clipboard feature', () => {
 
 	beforeEach( () => {
 		return VirtualTestEditor.create( {
-				plugins: [ Clipboard, Paragraph ]
-			} )
-			.then( ( newEditor ) => {
-				editor = newEditor;
-				editingView = editor.editing.view;
-				clipboardPlugin = editor.plugins.get( 'clipboard/clipboard' );
-			} );
+			plugins: [ Clipboard, Paragraph ]
+		} )
+		.then( newEditor => {
+			editor = newEditor;
+			editingView = editor.editing.view;
+			clipboardPlugin = editor.plugins.get( 'clipboard/clipboard' );
+		} );
 	} );
 
 	describe( 'constructor()', () => {
@@ -44,7 +44,7 @@ describe( 'Clipboard feature', () => {
 
 	describe( 'clipboard paste pipeline', () => {
 		describe( 'takes HTML data from the dataTransfer', () => {
-			it( 'and fires the clipboardInput event on the editingView', ( done ) => {
+			it( 'and fires the clipboardInput event on the editingView', done => {
 				const dataTransferMock = createDataTransfer( { 'text/html': '<p>x</p>', 'text/plain': 'y' } );
 				const preventDefaultSpy = sinon.spy();
 
@@ -61,7 +61,7 @@ describe( 'Clipboard feature', () => {
 				} );
 			} );
 
-			it( 'and fires the inputTransformation event on the clipboardPlugin', ( done ) => {
+			it( 'and fires the inputTransformation event on the clipboardPlugin', done => {
 				const dataTransferMock = createDataTransfer( { 'text/html': '<p>x</p>', 'text/plain': 'y' } );
 				const preventDefaultSpy = sinon.spy();
 
@@ -80,7 +80,7 @@ describe( 'Clipboard feature', () => {
 		} );
 
 		describe( 'takes plain text data from the dataTransfer if there is no HTML', () => {
-			it( 'and fires the clipboardInput event on the editingView', ( done ) => {
+			it( 'and fires the clipboardInput event on the editingView', done => {
 				const dataTransferMock = createDataTransfer( { 'text/plain': 'x\n\ny  z' } );
 				const preventDefaultSpy = sinon.spy();
 
@@ -97,7 +97,7 @@ describe( 'Clipboard feature', () => {
 				} );
 			} );
 
-			it( 'and fires the inputTransformation event on the clipboardPlugin', ( done ) => {
+			it( 'and fires the inputTransformation event on the clipboardPlugin', done => {
 				const dataTransferMock = createDataTransfer( { 'text/plain': 'x\n\ny  z' } );
 				const preventDefaultSpy = sinon.spy();
 
@@ -115,7 +115,7 @@ describe( 'Clipboard feature', () => {
 			} );
 		} );
 
-		it( 'fires events with empty data if there is no HTML nor plain text', ( done ) => {
+		it( 'fires events with empty data if there is no HTML nor plain text', done => {
 			const dataTransferMock = createDataTransfer( {} );
 			const preventDefaultSpy = sinon.spy();
 			const editorViewCalled = sinon.spy();
@@ -147,7 +147,7 @@ describe( 'Clipboard feature', () => {
 			const dataTransferMock = createDataTransfer( { 'text/html': 'x' } );
 			const spy = sinon.spy();
 
-			editingView.on( 'paste', ( evt ) => {
+			editingView.on( 'paste', evt => {
 				evt.stop();
 			} );
 
@@ -205,7 +205,7 @@ describe( 'Clipboard feature', () => {
 			const dataTransferMock = createDataTransfer( { 'text/html': 'x' } );
 			const spy = sinon.stub( editor.data, 'insertContent' );
 
-			editingView.on( 'clipboardInput', ( evt ) => {
+			editingView.on( 'clipboardInput', evt => {
 				evt.stop();
 			} );
 
@@ -227,7 +227,7 @@ describe( 'Clipboard feature', () => {
 	} );
 
 	describe( 'clipboard copy/cut pipeline', () => {
-		it( 'fires clipboardOutput for copy with the selected content and correct method', ( done ) => {
+		it( 'fires clipboardOutput for copy with the selected content and correct method', done => {
 			const dataTransferMock = createDataTransfer();
 			const preventDefaultSpy = sinon.spy();
 
@@ -251,7 +251,7 @@ describe( 'Clipboard feature', () => {
 			} );
 		} );
 
-		it( 'fires clipboardOutput for cut with the selected content and correct method', ( done ) => {
+		it( 'fires clipboardOutput for cut with the selected content and correct method', done => {
 			const dataTransferMock = createDataTransfer();
 			const preventDefaultSpy = sinon.spy();
 
@@ -273,7 +273,7 @@ describe( 'Clipboard feature', () => {
 			const dataTransferMock = createDataTransfer();
 			const spy = sinon.spy();
 
-			editingView.on( 'copy', ( evt ) => {
+			editingView.on( 'copy', evt => {
 				evt.stop();
 			} );
 
@@ -413,7 +413,7 @@ describe( 'Clipboard feature', () => {
 		it( 'uses low priority observer for the clipboardOutput event', () => {
 			const dataTransferMock = createDataTransfer();
 
-			editingView.on( 'clipboardOutput', ( evt ) => {
+			editingView.on( 'clipboardOutput', evt => {
 				evt.stop();
 			} );
 

+ 3 - 3
packages/ckeditor5-clipboard/tests/utils/normalizeclipboarddata.js

@@ -7,9 +7,9 @@ import normalizeClipboardData from '../../src/utils/normalizeclipboarddata';
 
 describe( 'normalizeClipboardData', () => {
 	it( 'should strip all span.Apple-converted-space', () => {
-		expect(
-			normalizeClipboardData( '<span class="Apple-converted-space"> \t\n</span>x<span class="Apple-converted-space">\u00a0\u00a0</span>' )
-		).to.equal( ' \t\nx\u00a0\u00a0' );
+		expect( normalizeClipboardData(
+			'<span class="Apple-converted-space"> \t\n</span>x<span class="Apple-converted-space">\u00a0\u00a0</span>'
+		) ).to.equal( ' \t\nx\u00a0\u00a0' );
 	} );
 
 	it( 'should replace span.Apple-converted-space of length one with a normal space', () => {