Skip to content

Commit

Permalink
[Refactor] ESLint fixed (codex-team#1100)
Browse files Browse the repository at this point in the history
Co-authored-by: Peter Savchenko <[email protected]>
  • Loading branch information
gohabereg and neSpecc authored Apr 18, 2020
1 parent f5e9a66 commit 4c0d806
Show file tree
Hide file tree
Showing 64 changed files with 938 additions and 754 deletions.
41 changes: 34 additions & 7 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,40 @@
/**
* Temporary suppress some errors. We need to fix them partially in next patches
*/
"@typescript-eslint/explicit-function-return-type": ["warn"],
"@typescript-eslint/explicit-member-accessibility": ["warn"],
"@typescript-eslint/member-ordering": ["warn"],
"@typescript-eslint/no-empty-function": ["warn"],
"no-prototype-builtins": ["warn"],
"no-mixed-operators": ["warn"],
"import/no-duplicates": ["warn"],
"no-case-declarations": ["warn"]
},
"settings": {
"jsdoc": {
"mode": "typescript"
}
},
"globals": {
"Node": true,
"Range": true,
"HTMLElement": true,
"HTMLDivElement": true,
"Element": true,
"Selection": true,
"SVGElement": true,
"Text": true,
"InsertPosition": true,
"PropertyKey": true,
"MouseEvent": true,
"TouchEvent": true,
"KeyboardEvent": true,
"ClipboardEvent": true,
"DragEvent": true,
"Event": true,
"EventTarget": true,
"Document": true,
"NodeList": true,
"File": true,
"FileList": true,
"MutationRecord": true,
"AddEventListenerOptions": true,
"DataTransfer": true,
"DOMRect": true,
"ClientRect": true,
"ArrayLike": true
}
}
2 changes: 1 addition & 1 deletion dist/editor.js

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions dist/editor.js.LICENSE
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*!
* Editor.js
*
* @version 2.17.0
* @version 2.18.0
*
* @licence Apache-2.0
* @author CodeX <https://codex.so>
Expand All @@ -15,8 +15,9 @@
* Or, sanitizing config can be defined globally in editors initialization. That config will be used everywhere
* At least, if there is no config overrides, that API uses Default configuration
*
* @uses https://www.npmjs.com/package/html-janitor
* @license https://github.com/guardian/html-janitor/blob/master/LICENSE
* @see {@link https://www.npmjs.com/package/html-janitor}
* @license Apache-2.0
* @see {@link https://github.com/guardian/html-janitor/blob/master/LICENSE}
*
* @param {SanitizerConfig} config - sanitizer extension
*/
Expand All @@ -26,9 +27,9 @@
*
* Short Description (눈_눈;)
*
* @version 2.0
* @version 2.18.0
*
* @licence Apache-2.0
* @license Apache-2.0
* @author CodeX-Team <https://ifmo.su>
*/

Expand Down
3 changes: 2 additions & 1 deletion docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

### 2.18

- `Improvements` - Deprecated TSLint replaced with ESLint, old config changed to [CodeX ESLint Config](https://github.com/codex-team/eslint-config).
- `Improvements` - TSLint (deprecated) replaced with ESLint, old config changed to [CodeX ESLint Config](https://github.com/codex-team/eslint-config).
- `Improvements` - Fix many code-style issues, add missed annotations.
- `Improvements` - Adjusted GitHub action for ESLint.

### 2.17
Expand Down
5 changes: 4 additions & 1 deletion example/assets/demo.css
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ body {
max-width: 180px;
background: #4A9DF8;
padding: 17px 30px;
box-shadow: 0 6px 4px -4px rgba(137, 207, 255, 0.77);
box-shadow: 0 22px 18px -4px rgba(137, 207, 255, 0.77);
transition: all 150ms ease;
cursor: pointer;
border-radius: 31px;
color: #fff;
Expand All @@ -103,6 +104,8 @@ body {

.ce-example__button:hover {
background: #3D8DE5;
transform: translateY(2px);
box-shadow: 0 20px 15px -4px rgba(137, 207, 255, 0.77);
}

.ce-example__output-footer {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@editorjs/editorjs",
"version": "2.17.0",
"version": "2.18.0",
"description": "Editor.js — Native JS, based on API and Open Source",
"main": "dist/editor.js",
"types": "./types/index.d.ts",
Expand Down
15 changes: 8 additions & 7 deletions src/codex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ declare const VERSION: string;
*
* Short Description (눈_눈;)
*
* @version 2.0
* @version 2.18.0
*
* @licence Apache-2.0
* @license Apache-2.0
* @author CodeX-Team <https://ifmo.su>
*/
export default class EditorJS {
Expand All @@ -35,7 +35,7 @@ export default class EditorJS {
public destroy: () => void;

/** Editor version */
static get version(): string {
public static get version(): string {
return VERSION;
}

Expand All @@ -46,7 +46,8 @@ export default class EditorJS {
/**
* Set default onReady function
*/
let onReady = () => {};
// eslint-disable-next-line @typescript-eslint/no-empty-function
let onReady = (): void => {};

/**
* If `onReady` was passed in `configuration` then redefine onReady function
Expand Down Expand Up @@ -75,18 +76,18 @@ export default class EditorJS {
/**
* Export external API methods
*
* @param editor
* @param {Core} editor — Editor's instance
*/
public exportAPI(editor: Core): void {
const fieldsToExport = [ 'configuration' ];
const destroy = () => {
const destroy = (): void => {
editor.moduleInstances.Listeners.removeAll();
editor.moduleInstances.UI.destroy();
editor.moduleInstances.ModificationsObserver.destroy();
editor = null;

for (const field in this) {
if (this.hasOwnProperty(field)) {
if (Object.prototype.hasOwnProperty.call(this, field)) {
delete this[field];
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/components/__module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default class Module {

/**
* @class
* @param {EditorConfig}
* @param {EditorConfig} config - Editor's config
*/
constructor({ config }: ModuleConfig) {
if (new.target === Module) {
Expand All @@ -41,9 +41,9 @@ export default class Module {
/**
* Editor modules setter
*
* @param {EditorModules} Editor
* @param {EditorModules} Editor - Editor's Modules
*/
set state(Editor: EditorModules) {
public set state(Editor: EditorModules) {
this.Editor = Editor;
}
}
18 changes: 9 additions & 9 deletions src/components/block-tunes/block-tune-delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default class DeleteTune implements BlockTune {
/**
* Property that contains Editor.js API methods
*
* @see {docs/api.md}
* @see {@link docs/api.md}
*/
private readonly api: API;

Expand All @@ -35,7 +35,7 @@ export default class DeleteTune implements BlockTune {
/**
* set false confirmation state
*/
private resetConfirmation: () => void;
private readonly resetConfirmation: () => void;

/**
* Tune nodes
Expand All @@ -47,22 +47,22 @@ export default class DeleteTune implements BlockTune {
/**
* DeleteTune constructor
*
* @param {{api: API}} api
* @param {API} api - Editor's API
*/
constructor({ api }) {
this.api = api;

this.resetConfirmation = () => {
this.resetConfirmation = (): void => {
this.setConfirmation(false);
};
}

/**
* Create "Delete" button and add click event listener
*
* @returns [Element}
* @returns {HTMLElement}
*/
public render() {
public render(): HTMLElement {
this.nodes.button = $.make('div', [this.CSS.button, this.CSS.buttonDelete], {});
this.nodes.button.appendChild($.svg('cross', 12, 12));
this.api.listeners.on(this.nodes.button, 'click', (event: MouseEvent) => this.handleClick(event), false);
Expand All @@ -78,7 +78,7 @@ export default class DeleteTune implements BlockTune {
/**
* Delete block conditions passed
*
* @param {MouseEvent} event
* @param {MouseEvent} event - click event
*/
public handleClick(event: MouseEvent): void {
/**
Expand Down Expand Up @@ -114,9 +114,9 @@ export default class DeleteTune implements BlockTune {
/**
* change tune state
*
* @param state
* @param {boolean} state - delete confirmation state
*/
private setConfirmation(state): void {
private setConfirmation(state: boolean): void {
this.needConfirmation = state;
this.nodes.button.classList.add(this.CSS.buttonConfirm);
}
Expand Down
14 changes: 8 additions & 6 deletions src/components/block-tunes/block-tune-move-down.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default class MoveDownTune implements BlockTune {
/**
* Property that contains Editor.js API methods
*
* @see {api.md}
* @see {@link docs/api.md}
*/
private readonly api: API;

Expand All @@ -33,16 +33,18 @@ export default class MoveDownTune implements BlockTune {
/**
* MoveDownTune constructor
*
* @param {{api: API}} api
* @param {API} api — Editor's API
*/
constructor({ api }) {
this.api = api;
}

/**
* Return 'move down' button
*
* @returns {HTMLElement}
*/
public render() {
public render(): HTMLElement {
const moveDownButton = $.make('div', [this.CSS.button, this.CSS.wrapper], {});

moveDownButton.appendChild($.svg('arrow-down', 14, 14));
Expand All @@ -64,10 +66,10 @@ export default class MoveDownTune implements BlockTune {
/**
* Handle clicks on 'move down' button
*
* @param {MouseEvent} event
* @param {HTMLElement} button
* @param {MouseEvent} event - click event
* @param {HTMLElement} button - clicked button
*/
public handleClick(event: MouseEvent, button: HTMLElement) {
public handleClick(event: MouseEvent, button: HTMLElement): void {
const currentBlockIndex = this.api.blocks.getCurrentBlockIndex();

// If Block is last do nothing
Expand Down
10 changes: 5 additions & 5 deletions src/components/block-tunes/block-tune-move-up.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default class MoveUpTune implements BlockTune {
/**
* Property that contains Editor.js API methods
*
* @see {api.md}
* @see {@link docs/api.md}
*/
private readonly api: API;

Expand All @@ -32,7 +32,7 @@ export default class MoveUpTune implements BlockTune {
/**
* MoveUpTune constructor
*
* @param {{api: API}} api
* @param {API} api - Editor's API
*/
constructor({ api }) {
this.api = api;
Expand All @@ -41,7 +41,7 @@ export default class MoveUpTune implements BlockTune {
/**
* Create "MoveUp" button and add click event listener
*
* @returns [HTMLElement}
* @returns {HTMLElement}
*/
public render(): HTMLElement {
const moveUpButton = $.make('div', [this.CSS.button, this.CSS.wrapper], {});
Expand All @@ -65,8 +65,8 @@ export default class MoveUpTune implements BlockTune {
/**
* Move current block up
*
* @param {MouseEvent} event
* @param {HTMLElement} button
* @param {MouseEvent} event - click event
* @param {HTMLElement} button - clicked button
*/
public handleClick(event: MouseEvent, button: HTMLElement): void {
const currentBlockIndex = this.api.blocks.getCurrentBlockIndex();
Expand Down
Loading

0 comments on commit 4c0d806

Please sign in to comment.