From b88ad8b140d1962bf912d68e8ecc0ba45e251be5 Mon Sep 17 00:00:00 2001 From: Maciej Bukowski Date: Sun, 12 May 2019 16:27:46 +0200 Subject: [PATCH 1/6] Changed from tslint configuration to eslint configuration. --- .eslintrc.js | 46 ++++++++++++++++++ angular.json | 21 --------- package.json | 30 ++++++++++-- tslint.json | 131 --------------------------------------------------- 4 files changed, 72 insertions(+), 156 deletions(-) create mode 100644 .eslintrc.js delete mode 100644 tslint.json diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..3558e9b --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,46 @@ +/** + * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved. + * This file is licensed under the terms of the MIT License (see LICENSE.md). + */ + +/* eslint-env node */ +const path = require( 'path' ); + +module.exports = { + extends: [ + 'ckeditor5', + 'plugin:@typescript-eslint/recommended' + ], + env: { + browser: true + }, + parser: '@typescript-eslint/parser', + plugins: [ + '@typescript-eslint/eslint-plugin' + ], + parserOptions: { + tsconfigRootDir: __dirname, + project: './tsconfig.json' + }, + rules: { + '@typescript-eslint/explicit-function-return-type': 'off', + '@typescript-eslint/indent': [ 'error', 'tab' ], + '@typescript-eslint/no-explicit-any': 'off', + '@typescript-eslint/no-namespace': 'off', + '@typescript-eslint/no-non-null-assertion': 'off', + '@typescript-eslint/no-unused-vars': 'error', + '@typescript-eslint/no-use-before-define': [ 'error', 'nofunc' ], + '@typescript-eslint/no-var-requires': 'off', + 'new-cap': 'off', + }, + overrides: [ { + files: [ '**/*.spec.ts' ], + env: { + jasmine: true + }, + parserOptions: { + tsconfigRootDir: path.join( __dirname, 'src' ), + project: 'tsconfig.app.json' + }, + } ] +} diff --git a/angular.json b/angular.json index f89af7a..6ac38b7 100644 --- a/angular.json +++ b/angular.json @@ -81,18 +81,6 @@ "src/assets" ] } - }, - "lint": { - "builder": "@angular-devkit/build-angular:tslint", - "options": { - "tsConfig": [ - "src/tsconfig.app.json", - "src/tsconfig.spec.json" - ], - "exclude": [ - "**/node_modules/**" - ] - } } } }, @@ -106,15 +94,6 @@ "protractorConfig": "e2e/protractor.conf.js", "devServerTarget": "ckeditor5-angular:serve" } - }, - "lint": { - "builder": "@angular-devkit/build-angular:tslint", - "options": { - "tsConfig": "e2e/tsconfig.e2e.json", - "exclude": [ - "**/node_modules/**" - ] - } } } } diff --git a/package.json b/package.json index f04851f..71d5adb 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "build": "ng build --prod", "test": "ng test", "coverage": "ng test --watch=false --code-coverage", - "lint": "ng lint", + "lint": "eslint '*/**/*.+(js|ts)'", "e2e": "ng e2e", "changelog": "node ./scripts/changelog.js", "build-package": "node ./scripts/build-package.js", @@ -39,9 +39,13 @@ "@ckeditor/ckeditor5-dev-utils": "^12.0.1", "@types/jasmine": "^3.3.8", "@types/jasminewd2": "^2.0.3", - "codelyzer": "^4.4.2", + "@typescript-eslint/eslint-plugin": "^1.8.0", + "@typescript-eslint/parser": "^1.8.0", "coveralls": "^3.0.2", + "eslint": "^5.16.0", + "eslint-config-ckeditor5": "^1.0.14", "fs-extra": "^7.0.0", + "husky": "^2.2.0", "jasmine-core": "^3.2.1", "jasmine-spec-reporter": "^4.2.1", "karma": "^4.0.0", @@ -51,11 +55,11 @@ "karma-firefox-launcher": "^1.1.0", "karma-jasmine": "^2.0.1", "karma-jasmine-html-reporter": "^1.3.1", + "lint-staged": "^8.1.6", "ng-packagr": "^4.0.0", "protractor": "^5.4.0", "ts-node": "^8.0.2", "tsickle": "^0.34.3", - "tslint": "^5.11.0", "typescript": "~3.2.4" }, "engines": { @@ -69,5 +73,23 @@ "repository": { "type": "git", "url": "https://github.com/ckeditor/ckeditor5-angular.git" - } + }, + "husky": { + "hooks": { + "pre-commit": "lint-staged" + } + }, + "lint-staged": { + "**/*.js": [ + "eslint --quiet" + ], + "**/*.ts": [ + "eslint --quiet" + ] + }, + "eslintIgnore": [ + "**/node_modules/**", + "**/dist/**", + "src/polyfills.ts" + ] } diff --git a/tslint.json b/tslint.json deleted file mode 100644 index c7fbb29..0000000 --- a/tslint.json +++ /dev/null @@ -1,131 +0,0 @@ -{ - "rulesDirectory": [ - "node_modules/codelyzer" - ], - "rules": { - "arrow-return-shorthand": true, - "callable-types": true, - "class-name": true, - "comment-format": [ - true, - "check-space" - ], - "curly": true, - "deprecation": { - "severity": "warn" - }, - "eofline": true, - "forin": true, - "import-blacklist": [ - true, - "rxjs", - "rxjs/Rx" - ], - "import-spacing": true, - "indent": [ - true, - "tabs" - ], - "interface-over-type-literal": true, - "label-position": true, - "max-line-length": [ - true, - 140 - ], - "member-access": false, - "member-ordering": [ - true, - { - "order": [ - "static-field", - "instance-field", - "static-method", - "instance-method" - ] - } - ], - "no-arg": true, - "no-bitwise": true, - "no-console": [ - true, - "debug", - "info", - "time", - "timeEnd", - "trace" - ], - "no-construct": true, - "no-debugger": true, - "no-duplicate-super": true, - "no-empty": false, - "no-empty-interface": true, - "no-eval": true, - "no-inferrable-types": [ - true, - "ignore-params" - ], - "no-misused-new": true, - "no-non-null-assertion": false, - "no-shadowed-variable": true, - "no-string-literal": false, - "no-string-throw": true, - "no-switch-case-fall-through": true, - "no-trailing-whitespace": true, - "no-unnecessary-initializer": true, - "no-unused-expression": true, - "no-unused-variable": true, - "no-use-before-declare": true, - "no-var-keyword": true, - "object-literal-sort-keys": false, - "one-line": [ - true, - "check-open-brace", - "check-catch", - "check-whitespace" - ], - "prefer-const": true, - "quotemark": [ - true, - "single" - ], - "radix": true, - "semicolon": [ - true, - "always" - ], - "triple-equals": [ - true, - "allow-null-check" - ], - "typedef-whitespace": [ - true, - { - "call-signature": "nospace", - "index-signature": "nospace", - "parameter": "nospace", - "property-declaration": "nospace", - "variable-declaration": "nospace" - } - ], - "unified-signatures": true, - "variable-name": false, - "whitespace": [ - true, - "check-branch", - "check-decl", - "check-operator", - "check-separator", - "check-type" - ], - "no-output-on-prefix": true, - "use-input-property-decorator": true, - "use-output-property-decorator": true, - "use-host-property-decorator": true, - "no-input-rename": true, - "no-output-rename": true, - "use-life-cycle-interface": true, - "use-pipe-transform-interface": true, - "component-class-suffix": true, - "directive-class-suffix": true - } -} From 46048dc3ad54d226842ca3b23c20b924ac8a84d7 Mon Sep 17 00:00:00 2001 From: Maciej Bukowski Date: Sun, 12 May 2019 16:28:09 +0200 Subject: [PATCH 2/6] Aligned code to ESLint rules. --- e2e/protractor.conf.js | 5 ++- e2e/src/app.e2e-spec.ts | 10 +++--- e2e/src/app.po.ts | 20 +++++------ src/app/demo-form/demo-form.component.ts | 21 +++++------ .../simple-usage/simple-usage.component.html | 2 +- .../simple-usage/simple-usage.component.ts | 22 ++++++------ src/ckeditor/ckeditor.component.spec.ts | 14 ++++---- src/ckeditor/ckeditor.component.ts | 35 ++++++++++--------- src/ckeditor/ckeditor.ts | 1 + src/karma.conf.js | 7 ++-- src/typings.d.ts | 16 ++++----- 11 files changed, 80 insertions(+), 73 deletions(-) diff --git a/e2e/protractor.conf.js b/e2e/protractor.conf.js index 6c20f0d..83d713a 100644 --- a/e2e/protractor.conf.js +++ b/e2e/protractor.conf.js @@ -1,6 +1,9 @@ // Protractor configuration file, see link for more information // https://github.com/angular/protractor/blob/master/lib/config.ts +/* eslint-env node */ +/* globals jasmine */ + const { SpecReporter } = require( 'jasmine-spec-reporter' ); exports.config = { @@ -17,7 +20,7 @@ exports.config = { jasmineNodeOpts: { showColors: true, defaultTimeoutInterval: 30000, - print: function() { } + print() {} }, onPrepare() { require( 'ts-node' ).register( { diff --git a/e2e/src/app.e2e-spec.ts b/e2e/src/app.e2e-spec.ts index 89c81ad..571fd27 100644 --- a/e2e/src/app.e2e-spec.ts +++ b/e2e/src/app.e2e-spec.ts @@ -12,13 +12,13 @@ describe( 'app', () => { return page.navigateTo(); } ); - it( 'should display header message', async () => { + it( 'should display header message', async() => { const content = await page.getHeaderContent(); expect( content ).toEqual( 'CKEditor integration with Angular 2+' ); } ); - it( 'should display editor with set content', async () => { + it( 'should display editor with set content', async() => { const content = await page.getEditorContent(); expect( content ).toContain( 'Getting used to an entirely different culture can be challenging.' ); @@ -30,7 +30,7 @@ describe( 'app', () => { return page.navigateTo( 'forms' ); } ); - it( 'should set initial values for name and surname fields', async () => { + it( 'should set initial values for name and surname fields', async() => { const name = await page.getNameInputValue(); const surname = await page.getSurnameInputValue(); @@ -38,13 +38,13 @@ describe( 'app', () => { expect( surname ).toEqual( 'Doe' ); } ); - it( 'should set initial value for the description', async () => { + it( 'should set initial value for the description', async() => { const desc = await page.getDescription(); expect( desc ).toEqual( '

A really nice fellow.

' ); } ); - it( 'should show and update json data preview', async () => { + it( 'should show and update json data preview', async() => { expect( await page.getFormDataPreview() ) .toEqual( '{"name":"John","surname":"Doe","description":"

A really nice fellow.

"}' ); diff --git a/e2e/src/app.po.ts b/e2e/src/app.po.ts index 93275f4..ea15e41 100644 --- a/e2e/src/app.po.ts +++ b/e2e/src/app.po.ts @@ -1,49 +1,49 @@ import { browser, by, element, promise } from 'protractor'; export class AppPage { - navigateTo( url = '' ) { + public navigateTo( url = '' ) { return browser.get( '/' + url ); } - getHeaderContent() { + public getHeaderContent() { return element( by.css( 'app-root h1' ) ).getText(); } - getEditorContent(): promise.Promise { + public getEditorContent(): promise.Promise { return browser.executeScript( 'return arguments[0].innerHTML', element( by.css( 'app-root #classic-editor' ) ) ); } - getNameInputValue() { + public getNameInputValue() { return element( by.css( 'app-root input#name' ) ).getAttribute( 'value' ); } - async setNameInputValue( value: string ) { + public async setNameInputValue( value: string ) { const el = element( by.css( 'app-root input#name' ) ); await el.clear(); await el.sendKeys( value ); } - getSurnameInputValue() { + public getSurnameInputValue() { return element( by.css( 'app-root input#surname' ) ).getAttribute( 'value' ); } - async setSurnameInputValue( value: string ) { + public async setSurnameInputValue( value: string ) { const el = element( by.css( 'app-root input#surname' ) ); await el.clear(); await el.sendKeys( value ); } - getDescription() { + public getDescription() { return browser.executeScript( 'return arguments[0].innerHTML', element( by.css( 'app-root #description .ck-editor__editable' ) ) ); } - getFormDataPreview() { + public getFormDataPreview() { return element( by.css( 'app-root pre' ) ).getText(); } - async setDescription( value: string ) { + public async setDescription( value: string ) { const descEl = element( by.css( 'app-root #description .ck-editor__editable' ) ); // Select the whole content. diff --git a/src/app/demo-form/demo-form.component.ts b/src/app/demo-form/demo-form.component.ts index 222def8..b345d44 100644 --- a/src/app/demo-form/demo-form.component.ts +++ b/src/app/demo-form/demo-form.component.ts @@ -13,7 +13,7 @@ import { NgForm } from '@angular/forms'; styleUrls: [ './demo-form.component.css' ] } ) export class DemoFormComponent implements AfterViewInit { - @ViewChild( 'demoForm' ) demoForm?: NgForm; + @ViewChild( 'demoForm' ) public demoForm?: NgForm; public Editor = ClassicEditorBuild; public model = { @@ -24,20 +24,21 @@ export class DemoFormComponent implements AfterViewInit { public formDataPreview?: string; - ngAfterViewInit() { - this.demoForm!.control.valueChanges - .subscribe( values => this.formDataPreview = JSON.stringify( values ) ); + public get description() { + return this.demoForm!.controls.description; } - onSubmit() { - console.log( 'Form submit, model', this.model ); + public ngAfterViewInit() { + this.demoForm!.control.valueChanges.subscribe( values => { + this.formDataPreview = JSON.stringify( values ); + } ); } - reset() { - this.demoForm!.reset(); + public onSubmit() { + console.log( 'Form submit, model', this.model ); } - get description() { - return this.demoForm!.controls.description; + public reset() { + this.demoForm!.reset(); } } diff --git a/src/app/simple-usage/simple-usage.component.html b/src/app/simple-usage/simple-usage.component.html index 7857a44..df01c6d 100644 --- a/src/app/simple-usage/simple-usage.component.html +++ b/src/app/simple-usage/simple-usage.component.html @@ -23,6 +23,6 @@

Classic build

Component events:

  • - {{ eventInfo }} + {{ eventInfo[ 0 ] }}
diff --git a/src/app/simple-usage/simple-usage.component.ts b/src/app/simple-usage/simple-usage.component.ts index 8b82ca2..e4a2eea 100644 --- a/src/app/simple-usage/simple-usage.component.ts +++ b/src/app/simple-usage/simple-usage.component.ts @@ -14,29 +14,29 @@ export class SimpleUsageComponent { public isDisabled = false; public editorData = - `

Getting used to an entirely different culture can be challenging. + `

Getting used to an entirely different culture can be challenging. While it’s also nice to learn about cultures online or from books, nothing comes close to experiencing cultural diversity in person. You learn to appreciate each and every single one of the differences while you become more culturally fluid.

`; - public componentEvents: string[] = []; + public componentEvents: [string, object][] = []; - toggleDisableEditors() { + public toggleDisableEditors() { this.isDisabled = !this.isDisabled; } - onReady( editor: CKEditor5.Editor ): void { - this.componentEvents.push( 'The editor is ready.' ); + public onReady( editor: CKEditor5.Editor ): void { + this.componentEvents.push( [ 'The editor is ready.', editor ] ); } - onChange( event: ChangeEvent ): void { - this.componentEvents.push( 'Editor model changed.' ); + public onChange( event: ChangeEvent ): void { + this.componentEvents.push( [ 'Editor model changed.', event ] ); } - onFocus( event: FocusEvent ): void { - this.componentEvents.push( 'Focused the editing view.' ); + public onFocus( event: FocusEvent ): void { + this.componentEvents.push( [ 'Focused the editing view.', event ] ); } - onBlur( event: BlurEvent ): void { - this.componentEvents.push( 'Blurred the editing view.' ); + public onBlur( event: BlurEvent ): void { + this.componentEvents.push( [ 'Blurred the editing view.', event ] ); } } diff --git a/src/ckeditor/ckeditor.component.spec.ts b/src/ckeditor/ckeditor.component.spec.ts index 7703cdd..77fc424 100644 --- a/src/ckeditor/ckeditor.component.spec.ts +++ b/src/ckeditor/ckeditor.component.spec.ts @@ -128,27 +128,27 @@ describe( 'CKEditorComponent', () => { it( 'should not be set using `editor.setData()` during the initialization step', () => { class EventEmitter { - on() {} + public on() {} } class EditorMock { - model = { + public model = { document: new EventEmitter() }; - editing = { + public editing = { view: { document: new EventEmitter() } }; - setData = createSpy(); + public setData = createSpy(); - static create() { + public static create() { return Promise.resolve( new this() ); } - destroy() {} + public destroy() {} } function createSpy() { @@ -294,7 +294,7 @@ describe( 'CKEditorComponent', () => { let component: CKEditorComponent; class EditorThatThrowsErrorDuringInitialization { - static create() { + public static create() { return Promise.resolve().then( () => { return Promise.reject( new Error() ); } ); diff --git a/src/ckeditor/ckeditor.component.ts b/src/ckeditor/ckeditor.component.ts index d19656a..4e3ca3c 100644 --- a/src/ckeditor/ckeditor.component.ts +++ b/src/ckeditor/ckeditor.component.ts @@ -29,6 +29,7 @@ import { CKEditor5 } from './ckeditor'; providers: [ { provide: NG_VALUE_ACCESSOR, + // eslint-disable-next-line @typescript-eslint/no-use-before-define useExisting: forwardRef( () => CKEditorComponent ), multi: true, } @@ -44,38 +45,38 @@ export class CKEditorComponent implements AfterViewInit, OnDestroy, ControlValue * The constructor of the editor to be used for the instance of the component. * It can be e.g. the `ClassicEditorBuild`, `InlineEditorBuild` or some custom editor. */ - @Input() editor?: CKEditor5.EditorConstructor; + @Input() public editor?: CKEditor5.EditorConstructor; /** * The configuration of the editor. * See https://ckeditor.com/docs/ckeditor5/latest/api/module_core_editor_editorconfig-EditorConfig.html * to learn more. */ - @Input() config: CKEditor5.Config = {}; + @Input() public config: CKEditor5.Config = {}; /** * The initial data of the editor. Useful when not using the ngModel. * See https://angular.io/api/forms/NgModel to learn more. */ - @Input() data = ''; + @Input() public data = ''; /** * Tag name of the editor component. * * The default tag is 'div'. */ - @Input() tagName = 'div'; + @Input() public tagName = 'div'; /** * When set `true`, the editor becomes read-only. * See https://ckeditor.com/docs/ckeditor5/latest/api/module_core_editor_editor-Editor.html#member-isReadOnly * to learn more. */ - @Input() set disabled( isDisabled: boolean ) { + @Input() public set disabled( isDisabled: boolean ) { this.setDisabledState( isDisabled ); } - get disabled() { + public get disabled() { if ( this.editorInstance ) { return this.editorInstance.isReadOnly; } @@ -88,28 +89,28 @@ export class CKEditorComponent implements AfterViewInit, OnDestroy, ControlValue * https://ckeditor.com/docs/ckeditor5/latest/api/module_core_editor_editor-Editor.html#event-ready * event. */ - @Output() ready = new EventEmitter(); + @Output() public ready = new EventEmitter(); /** * Fires when the content of the editor has changed. It corresponds with the `editor.model.document#change` * https://ckeditor.com/docs/ckeditor5/latest/api/module_engine_model_document-Document.html#event-change * event. */ - @Output() change: EventEmitter = new EventEmitter(); + @Output() public change: EventEmitter = new EventEmitter(); /** * Fires when the editing view of the editor is blurred. It corresponds with the `editor.editing.view.document#blur` * https://ckeditor.com/docs/ckeditor5/latest/api/module_engine_view_document-Document.html#event-event:blur * event. */ - @Output() blur: EventEmitter = new EventEmitter(); + @Output() public blur: EventEmitter = new EventEmitter(); /** * Fires when the editing view of the editor is focused. It corresponds with the `editor.editing.view.document#focus` * https://ckeditor.com/docs/ckeditor5/latest/api/module_engine_view_document-Document.html#event-event:focus * event. */ - @Output() focus: EventEmitter = new EventEmitter(); + @Output() public focus: EventEmitter = new EventEmitter(); /** * The instance of the editor created by this component. @@ -149,20 +150,20 @@ export class CKEditorComponent implements AfterViewInit, OnDestroy, ControlValue */ private editorElement?: HTMLElement; - constructor( elementRef: ElementRef, ngZone: NgZone ) { + public constructor( elementRef: ElementRef, ngZone: NgZone ) { this.ngZone = ngZone; this.elementRef = elementRef; } // Implementing the AfterViewInit interface. - ngAfterViewInit() { + public ngAfterViewInit() { this.ngZone.runOutsideAngular( () => { this.createEditor(); } ); } // Implementing the OnDestroy interface. - ngOnDestroy() { + public ngOnDestroy() { if ( this.editorInstance ) { this.editorInstance.destroy(); this.editorInstance = null; @@ -170,7 +171,7 @@ export class CKEditorComponent implements AfterViewInit, OnDestroy, ControlValue } // Implementing the ControlValueAccessor interface (only when binding to ngModel). - writeValue( value: string | null ): void { + public writeValue( value: string | null ): void { // This method is called with the `null` value when the form resets. // A component's responsibility is to restore to the initial state. if ( value === null ) { @@ -194,17 +195,17 @@ export class CKEditorComponent implements AfterViewInit, OnDestroy, ControlValue } // Implementing the ControlValueAccessor interface (only when binding to ngModel). - registerOnChange( callback: ( data: string ) => void ): void { + public registerOnChange( callback: ( data: string ) => void ): void { this.cvaOnChange = callback; } // Implementing the ControlValueAccessor interface (only when binding to ngModel). - registerOnTouched( callback: () => void ): void { + public registerOnTouched( callback: () => void ): void { this.cvaOnTouched = callback; } // Implementing the ControlValueAccessor interface (only when binding to ngModel). - setDisabledState( isDisabled: boolean ): void { + public setDisabledState( isDisabled: boolean ): void { // If already initialized if ( this.editorInstance ) { this.editorInstance.isReadOnly = isDisabled; diff --git a/src/ckeditor/ckeditor.ts b/src/ckeditor/ckeditor.ts index 09d6eb2..5960354 100644 --- a/src/ckeditor/ckeditor.ts +++ b/src/ckeditor/ckeditor.ts @@ -7,6 +7,7 @@ * Basic typings for the CKEditor5 elements. */ export namespace CKEditor5 { + /** * The CKEditor5 editor constructor. */ diff --git a/src/karma.conf.js b/src/karma.conf.js index fb3ba3a..72bd295 100644 --- a/src/karma.conf.js +++ b/src/karma.conf.js @@ -2,6 +2,7 @@ // https://karma-runner.github.io/1.0/config/configuration-file.html /* eslint-env node */ +/* eslint-disable @typescript-eslint/camelcase */ module.exports = function( config ) { const karmaConfig = { @@ -74,14 +75,14 @@ module.exports = function( config ) { function getBuildName() { const repoSlug = process.env.TRAVIS_REPO_SLUG; - if ( !repoSlug ) { + if ( !repoSlug ) { return; } - const repositoryName = repoSlug.split( '/' )[ 1 ].replace( /-/g, '_' ); + const repositoryName = repoSlug.split( '/' )[ 1 ].replace( /-/g, '_' ); const date = new Date().getTime(); - return `${ repositoryName } ${ date }`; + return `${ repositoryName } ${ date }`; } function getPlugins() { diff --git a/src/typings.d.ts b/src/typings.d.ts index 8237c99..12f8f91 100644 --- a/src/typings.d.ts +++ b/src/typings.d.ts @@ -1,25 +1,25 @@ // Simple typings for editors used in the sample app. -declare module "@ckeditor/ckeditor5-build-classic" { - var ClassicEditorBuild: any; +declare module '@ckeditor/ckeditor5-build-classic' { + let ClassicEditorBuild: any; export = ClassicEditorBuild; } -declare module "@ckeditor/ckeditor5-build-inline" { - var InlineEditorBuild: any; +declare module '@ckeditor/ckeditor5-build-inline' { + let InlineEditorBuild: any; export = InlineEditorBuild; } -declare module "@ckeditor/ckeditor5-build-balloon" { - var BalloonEditorBuild: any; +declare module '@ckeditor/ckeditor5-build-balloon' { + let BalloonEditorBuild: any; export = BalloonEditorBuild; } -declare module "@ckeditor/ckeditor5-build-decoupled-document" { - var DecoupledDocumentEditorBuild: any; +declare module '@ckeditor/ckeditor5-build-decoupled-document' { + let DecoupledDocumentEditorBuild: any; export = DecoupledDocumentEditorBuild; } From 832735f9be5ff5d0c74b1362ac3434793ba5f7d0 Mon Sep 17 00:00:00 2001 From: Maciej Bukowski Date: Sun, 12 May 2019 16:29:11 +0200 Subject: [PATCH 3/6] Improved lint-staged glob. --- package.json | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/package.json b/package.json index 71d5adb..8587804 100644 --- a/package.json +++ b/package.json @@ -80,10 +80,7 @@ } }, "lint-staged": { - "**/*.js": [ - "eslint --quiet" - ], - "**/*.ts": [ + "**/*.+(js|ts)": [ "eslint --quiet" ] }, From b280db0601872915eabb2f3ac8fc8b16822e0344 Mon Sep 17 00:00:00 2001 From: Maciej Bukowski Date: Sun, 12 May 2019 16:55:24 +0200 Subject: [PATCH 4/6] Fixed .travis.yml file. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 64aa096..c394166 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,7 @@ before_install: install: - npm install script: -- ng lint && npm run coverage && ng e2e && cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js +- npm run lint && npm run coverage && ng e2e && cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js env: global: - secure: U+n/+bjnWUdkmcRtPzYGciEaHpzwuyKf2g4JA78QmRHGdmaPLmfrX65bjYFZcfnO4YboCr6nlnziDCQwdbXb1hbGnBTgyzLkk5xxAY4GVzZKoyyGIZ+jYQ6fMsC8d6ZG1LOwDAZAmIN/mpNXg/63mTuJmsOUBEnt9GkcVGz0PD4FsFrVQ48Gk2EAc9vYYZs9JcXc0thh7QUS107Mz9m/szbaNUvX4V2iC0AoQBiNfShxEDOKdhXjuFH0vZ3Faex39r6hfuGk9SWEfCqR+ebOdgZA/Vgcb54k/BNifFiI7SuMjeoeEYpVHxsEXrUsLgzKOmZpah0JOjXixcGwpvyZXr7JvJ2IMCIGzpO5VpzunXfu5ahViLn2c759vEbZEddJBBHVEzxbY0IMCxlS0iP2ALfmIPzSU1mMdLFRohcRGYUinVvzi/7oRmDcQ/sj0ar1yuKCB0Be53XGwWdd1Nz++nMZihNW1UqsQX9MyZuGrDChM2pf2AIEUPUdSq2Bps92SVz31eYJ1BSjkXbgqUhd1dCl+jUC5YHwryQoxDfY+9gxZMkak0cohoB7flnZG4wfj5IfqygGmk8kk8HHXefAEFJhosLx+FyZKAaaBmp98t/UbCRqV16XG2wNENklcTnNQdP8QIWSxhx7BnLV5HbKwXgTv2C6ILRkRf2YFuZRZYg= From 48ebc76b3c50a55b11a2ef1853578e31d12ccc18 Mon Sep 17 00:00:00 2001 From: Maciej Bukowski Date: Sun, 12 May 2019 17:24:01 +0200 Subject: [PATCH 5/6] Removed unused events params. --- .../simple-usage/simple-usage.component.html | 8 ++++---- .../simple-usage/simple-usage.component.ts | 20 +++++++++---------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/app/simple-usage/simple-usage.component.html b/src/app/simple-usage/simple-usage.component.html index df01c6d..d9c8dab 100644 --- a/src/app/simple-usage/simple-usage.component.html +++ b/src/app/simple-usage/simple-usage.component.html @@ -14,10 +14,10 @@

Classic build

id="classic-editor" name="classic-editor" - (ready)="onReady($event)" - (change)="onChange($event)" - (focus)="onFocus($event)" - (blur)="onBlur($event)"> + (ready)="onReady()" + (change)="onChange()" + (focus)="onFocus()" + (blur)="onBlur()">

Component events:

diff --git a/src/app/simple-usage/simple-usage.component.ts b/src/app/simple-usage/simple-usage.component.ts index e4a2eea..1410de7 100644 --- a/src/app/simple-usage/simple-usage.component.ts +++ b/src/app/simple-usage/simple-usage.component.ts @@ -1,8 +1,6 @@ import { Component } from '@angular/core'; import * as ClassicEditorBuild from '@ckeditor/ckeditor5-build-classic'; -import { CKEditor5 } from '../../ckeditor/ckeditor'; -import { ChangeEvent, FocusEvent, BlurEvent } from '../../ckeditor/ckeditor.component'; @Component( { selector: 'app-simple-usage', @@ -18,25 +16,25 @@ export class SimpleUsageComponent { While it’s also nice to learn about cultures online or from books, nothing comes close to experiencing cultural diversity in person. You learn to appreciate each and every single one of the differences while you become more culturally fluid.

`; - public componentEvents: [string, object][] = []; + public componentEvents: string[] = []; public toggleDisableEditors() { this.isDisabled = !this.isDisabled; } - public onReady( editor: CKEditor5.Editor ): void { - this.componentEvents.push( [ 'The editor is ready.', editor ] ); + public onReady() { + this.componentEvents.push( 'The editor is ready.' ); } - public onChange( event: ChangeEvent ): void { - this.componentEvents.push( [ 'Editor model changed.', event ] ); + public onChange() { + this.componentEvents.push( 'Editor model changed.' ); } - public onFocus( event: FocusEvent ): void { - this.componentEvents.push( [ 'Focused the editing view.', event ] ); + public onFocus() { + this.componentEvents.push( 'Focused the editing view.' ); } - public onBlur( event: BlurEvent ): void { - this.componentEvents.push( [ 'Blurred the editing view.', event ] ); + public onBlur() { + this.componentEvents.push( 'Blurred the editing view.' ); } } From 21e9929046639f6f8a3665f5fb1b364503acddcd Mon Sep 17 00:00:00 2001 From: Maciej Bukowski Date: Mon, 13 May 2019 14:47:49 +0200 Subject: [PATCH 6/6] Fixed editor typings. --- src/typings.d.ts | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/src/typings.d.ts b/src/typings.d.ts index 12f8f91..f297c29 100644 --- a/src/typings.d.ts +++ b/src/typings.d.ts @@ -1,25 +1,7 @@ -// Simple typings for editors used in the sample app. +// Typings for the editor used in the sample app to satisfy the TS compiler. declare module '@ckeditor/ckeditor5-build-classic' { - let ClassicEditorBuild: any; + const ClassicEditorBuild: any; export = ClassicEditorBuild; } - -declare module '@ckeditor/ckeditor5-build-inline' { - let InlineEditorBuild: any; - - export = InlineEditorBuild; -} - -declare module '@ckeditor/ckeditor5-build-balloon' { - let BalloonEditorBuild: any; - - export = BalloonEditorBuild; -} - -declare module '@ckeditor/ckeditor5-build-decoupled-document' { - let DecoupledDocumentEditorBuild: any; - - export = DecoupledDocumentEditorBuild; -}