8
0
Pārlūkot izejas kodu

Code style: Switched to ESLint.

Kamil Piechaczek 8 gadi atpakaļ
vecāks
revīzija
0153ae3649

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

@@ -21,6 +21,7 @@
     "@ckeditor/ckeditor5-paragraph": "^0.8.0",
     "@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"
   },

+ 2 - 2
packages/ckeditor5-upload/src/imageuploadbutton.js

@@ -34,7 +34,7 @@ export default class ImageUploadButton extends Plugin {
 		const t = editor.t;
 
 		// Setup `insertImage` button.
-		editor.ui.componentFactory.add( 'insertImage', ( locale ) => {
+		editor.ui.componentFactory.add( 'insertImage', locale => {
 			const view = new FileDialogButtonView( locale );
 
 			view.set( {
@@ -47,7 +47,7 @@ export default class ImageUploadButton extends Plugin {
 
 			view.on( 'done', ( evt, files ) => {
 				for ( const file of files ) {
-					editor.execute( 'imageUpload', { file: file } );
+					editor.execute( 'imageUpload', { file } );
 				}
 			} );
 

+ 3 - 3
packages/ckeditor5-upload/tests/filereader.js

@@ -57,7 +57,7 @@ describe( 'FileReader', () => {
 			const promise = reader.read( fileMock )
 				.then( () => {
 					throw new Error( 'Reader should not resolve.' );
-				}, ( status ) => {
+				}, status => {
 					expect( status ).to.equal( 'error' );
 					expect( reader.error ).to.equal( 'Error during file reading.' );
 				} );
@@ -71,7 +71,7 @@ describe( 'FileReader', () => {
 			const promise = reader.read( fileMock )
 				.then( () => {
 					throw new Error( 'Reader should not resolve.' );
-				}, ( status ) => {
+				}, status => {
 					expect( status ).to.equal( 'aborted' );
 				} );
 
@@ -86,7 +86,7 @@ describe( 'FileReader', () => {
 			const promise = reader.read( fileMock )
 				.then( () => {
 					throw new Error( 'Reader should not resolve.' );
-				}, ( status ) => {
+				}, status => {
 					expect( status ).to.equal( 'aborted' );
 				} );
 

+ 14 - 10
packages/ckeditor5-upload/tests/filerepository.js

@@ -41,7 +41,7 @@ describe( 'FileRepository', () => {
 			expect( fileRepository.loaders ).to.be.instanceOf( Collection );
 		} );
 
-		it( 'should initialize uploaded observable', ( done ) => {
+		it( 'should initialize uploaded observable', done => {
 			expect( fileRepository.uploaded ).to.equal( 0 );
 
 			fileRepository.on( 'change:uploaded', ( evt, name, value ) => {
@@ -52,7 +52,7 @@ describe( 'FileRepository', () => {
 			fileRepository.uploaded = 10;
 		} );
 
-		it( 'should initialize uploadTotal', ( done ) => {
+		it( 'should initialize uploadTotal', done => {
 			expect( fileRepository.uploadTotal ).to.be.null;
 
 			fileRepository.on( 'change:uploadTotal', ( evt, name, value ) => {
@@ -63,7 +63,7 @@ describe( 'FileRepository', () => {
 			fileRepository.uploadTotal = 10;
 		} );
 
-		it( 'should initialize uploadedPercent', ( done ) => {
+		it( 'should initialize uploadedPercent', done => {
 			expect( fileRepository.uploadedPercent ).to.equal( 0 );
 
 			fileRepository.on( 'change:uploadedPercent', ( evt, name, value ) => {
@@ -83,7 +83,10 @@ describe( 'FileRepository', () => {
 			fileRepository.createLoader( createNativeFileMock() );
 
 			sinon.assert.calledOnce( stub );
-			sinon.assert.calledWithExactly( stub, 'FileRepository: no createAdapter method found. Please define it before creating a loader.' );
+			sinon.assert.calledWithExactly(
+				stub,
+				'FileRepository: no createAdapter method found. Please define it before creating a loader.'
+			);
 		} );
 
 		it( 'should setup listeners to update progress observables', () => {
@@ -176,7 +179,7 @@ describe( 'FileRepository', () => {
 				expect( loader._reader ).to.be.instanceOf( FileReader );
 			} );
 
-			it( 'should initialize status observable', ( done ) => {
+			it( 'should initialize status observable', done => {
 				expect( loader.status ).to.equal( 'idle' );
 
 				loader.on( 'change:status', ( evt, name, value ) => {
@@ -187,7 +190,7 @@ describe( 'FileRepository', () => {
 				loader.status = 'uploading';
 			} );
 
-			it( 'should initialize uploaded observable', ( done ) => {
+			it( 'should initialize uploaded observable', done => {
 				expect( loader.uploaded ).to.equal( 0 );
 
 				loader.on( 'change:uploaded', ( evt, name, value ) => {
@@ -198,7 +201,7 @@ describe( 'FileRepository', () => {
 				loader.uploaded = 100;
 			} );
 
-			it( 'should initialize uploadTotal observable', ( done ) => {
+			it( 'should initialize uploadTotal observable', done => {
 				expect( loader.uploadTotal ).to.equal( null );
 
 				loader.on( 'change:uploadTotal', ( evt, name, value ) => {
@@ -209,7 +212,7 @@ describe( 'FileRepository', () => {
 				loader.uploadTotal = 100;
 			} );
 
-			it( 'should initialize uploadedPercent observable', ( done ) => {
+			it( 'should initialize uploadedPercent observable', done => {
 				expect( loader.uploadedPercent ).to.equal( 0 );
 
 				loader.on( 'change:uploadedPercent', ( evt, name, value ) => {
@@ -221,7 +224,9 @@ describe( 'FileRepository', () => {
 				loader.uploadTotal = 100;
 			} );
 
-			it( 'should initialize uploadResponse observable', ( done ) => {
+			it( 'should initialize uploadResponse observable', done => {
+				const response = {};
+
 				expect( loader.uploadResponse ).to.equal( null );
 
 				loader.on( 'change:uploadResponse', ( evt, name, value ) => {
@@ -229,7 +234,6 @@ describe( 'FileRepository', () => {
 					done();
 				} );
 
-				const response = {};
 				loader.uploadResponse = response;
 			} );
 		} );

+ 6 - 5
packages/ckeditor5-upload/tests/imageuploadengine.js

@@ -20,6 +20,7 @@ import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
 import Notification from '@ckeditor/ckeditor5-ui/src/notification/notification';
 
 describe( 'ImageUploadEngine', () => {
+	// eslint-disable-next-line max-len
 	const base64Sample = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII=';
 	let editor, document, fileRepository, viewDocument, nativeReaderMock, loader, adapterMock;
 	testUtils.createSinonSandbox();
@@ -102,7 +103,7 @@ describe( 'ImageUploadEngine', () => {
 			'</figure>' );
 	} );
 
-	it( 'should use read data once it is present', ( done ) => {
+	it( 'should use read data once it is present', done => {
 		const file = createNativeFileMock();
 		setModelData( document, '<paragraph>{}foo bar</paragraph>' );
 		editor.execute( 'imageUpload', { file } );
@@ -122,7 +123,7 @@ describe( 'ImageUploadEngine', () => {
 		nativeReaderMock.mockSuccess( base64Sample );
 	} );
 
-	it( 'should replace read data with server response once it is present', ( done ) => {
+	it( 'should replace read data with server response once it is present', done => {
 		const file = createNativeFileMock();
 		setModelData( document, '<paragraph>{}foo bar</paragraph>' );
 		editor.execute( 'imageUpload', { file } );
@@ -143,7 +144,7 @@ describe( 'ImageUploadEngine', () => {
 		nativeReaderMock.mockSuccess( base64Sample );
 	} );
 
-	it( 'should fire notification event in case of error', ( done ) => {
+	it( 'should fire notification event in case of error', done => {
 		const notification = editor.plugins.get( Notification );
 		const file = createNativeFileMock();
 
@@ -160,7 +161,7 @@ describe( 'ImageUploadEngine', () => {
 		nativeReaderMock.mockError( 'Reading error.' );
 	} );
 
-	it( 'should not fire notification on abort', ( done ) => {
+	it( 'should not fire notification on abort', done => {
 		const notification = editor.plugins.get( Notification );
 		const file = createNativeFileMock();
 		const spy = testUtils.sinon.spy();
@@ -188,7 +189,7 @@ describe( 'ImageUploadEngine', () => {
 		);
 	} );
 
-	it( 'should remove image in case of upload error', ( done ) => {
+	it( 'should remove image in case of upload error', done => {
 		const file = createNativeFileMock();
 		const spy = testUtils.sinon.spy();
 		const notification = editor.plugins.get( Notification );

+ 4 - 3
packages/ckeditor5-upload/tests/imageuploadprogress.js

@@ -19,6 +19,7 @@ import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
 import imagePlaceholder from '../theme/icons/image_placeholder.svg';
 
 describe( 'ImageUploadProgress', () => {
+	// eslint-disable-next-line max-len
 	const base64Sample = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII=';
 	let editor, document, fileRepository, viewDocument, nativeReaderMock, loader, adapterMock;
 	testUtils.createSinonSandbox();
@@ -63,7 +64,7 @@ describe( 'ImageUploadProgress', () => {
 		);
 	} );
 
-	it( 'should convert image\'s "uploading" uploadStatus attribute', ( done ) => {
+	it( 'should convert image\'s "uploading" uploadStatus attribute', done => {
 		setModelData( document, '<paragraph>[]foo</paragraph>' );
 		editor.execute( 'imageUpload', { file: createNativeFileMock() } );
 
@@ -81,7 +82,7 @@ describe( 'ImageUploadProgress', () => {
 		nativeReaderMock.mockSuccess( base64Sample );
 	} );
 
-	it( 'should update progressbar width on progress', ( done ) => {
+	it( 'should update progressbar width on progress', done => {
 		setModelData( document, '<paragraph>[]foo</paragraph>' );
 		editor.execute( 'imageUpload', { file: createNativeFileMock() } );
 
@@ -101,7 +102,7 @@ describe( 'ImageUploadProgress', () => {
 		nativeReaderMock.mockSuccess( base64Sample );
 	} );
 
-	it( 'should convert image\'s "complete" uploadStatus attribute', ( done ) => {
+	it( 'should convert image\'s "complete" uploadStatus attribute', done => {
 		setModelData( document, '<paragraph>[]foo</paragraph>' );
 		editor.execute( 'imageUpload', { file: createNativeFileMock() } );
 

+ 1 - 1
packages/ckeditor5-upload/tests/manual/imageupload.js

@@ -31,7 +31,7 @@ ClassicEditor.create( document.querySelector( '#editor' ), {
 	],
 	toolbar: [ 'headings', 'undo', 'redo', 'bold', 'italic', 'bulletedList', 'numberedList', 'insertImage' ],
 	image: {
-		toolbar: [ 'imageStyleFull', 'imageStyleSide', '|' , 'imageTextAlternative' ]
+		toolbar: [ 'imageStyleFull', 'imageStyleSide', '|', 'imageTextAlternative' ]
 	}
 } )
 .then( editor => {

+ 1 - 1
packages/ckeditor5-upload/tests/ui/filedialogbuttonview.js

@@ -52,7 +52,7 @@ describe( 'FileDialogButtonView', () => {
 		expect( view.fileInputView.allowMultipleFiles ).to.be.true;
 	} );
 
-	it( 'should delegate input view done event', ( done ) => {
+	it( 'should delegate input view done event', done => {
 		const files = [];
 
 		view.on( 'done', ( evt, data ) => {

+ 1 - 1
packages/ckeditor5-upload/tests/utils.js

@@ -27,5 +27,5 @@ describe( 'utils', () => {
 			expect( isImageType( { type: 'audio/mp3' } ) ).to.be.false;
 			expect( isImageType( { type: 'video/mpeg' } ) ).to.be.false;
 		} );
-	}  );
+	} );
 } );