Skip to content

Commit

Permalink
Merge pull request GoogleChromeLabs#70 from GoogleChromeLabs/lint-fix
Browse files Browse the repository at this point in the history
Fixing issues raised by the linter. Fixes GoogleChromeLabs#68
  • Loading branch information
surma authored Jun 29, 2018
2 parents 11153b7 + d4cbbc7 commit 5eebf45
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 15 deletions.
8 changes: 3 additions & 5 deletions src/codecs/encoders.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import * as mozJPEG from './mozjpeg/encoder';
import { EncoderState as MozJPEGEncodeData, EncodeOptions as MozJPEGEncodeOptions } from './mozjpeg/encoder';
import * as identity from './identity/encoder';
import { EncoderState as IdentityEncodeData, EncodeOptions as IdentityEncodeOptions } from './identity/encoder';

export type EncoderState = IdentityEncodeData | MozJPEGEncodeData;
export type EncoderOptions = IdentityEncodeOptions | MozJPEGEncodeOptions;
export type EncoderState = identity.EncoderState | mozJPEG.EncoderState;
export type EncoderOptions = identity.EncodeOptions | mozJPEG.EncodeOptions;
export type EncoderType = keyof typeof encoderMap;

export const encoderMap = {
[identity.type]: identity,
[mozJPEG.type]: mozJPEG
[mozJPEG.type]: mozJPEG,
};

export const encoders = Array.from(Object.values(encoderMap));
2 changes: 1 addition & 1 deletion src/codecs/mozjpeg/EncoderWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default class MozJpegEncoder {
encode: m.cwrap('encode', '', ['number', 'number', 'number', 'number']),
free_result: m.cwrap('free_result', '', []),
get_result_pointer: m.cwrap('get_result_pointer', 'number', []),
get_result_size: m.cwrap('get_result_size', 'number', [])
get_result_size: m.cwrap('get_result_size', 'number', []),
};
})();
}
Expand Down
11 changes: 6 additions & 5 deletions src/components/app/custom-els/FileDrop/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { bind } from '../../../../lib/util';
import './styles.css';

// tslint:disable-next-line:max-line-length
function firstMatchingItem(list: DataTransferItemList, acceptVal: string): DataTransferItem | undefined {
// Split accepts values by ',' then by '/'. Trim everything & lowercase.
const accepts = acceptVal.toLowerCase().split(',').map(accept => {
const accepts = acceptVal.toLowerCase().split(',').map((accept) => {
return accept.trim().split('/').map(part => part.trim());
}).filter(acceptParts => acceptParts.length === 2); // Filter invalid values

return Array.from(list).find(item => {
return Array.from(list).find((item) => {
if (item.kind !== 'file') return false;

// 'Parse' the type.
Expand Down Expand Up @@ -56,7 +57,7 @@ export class FileDrop extends HTMLElement {

constructor() {
super();
this.addEventListener('dragover', (event) => event.preventDefault());
this.addEventListener('dragover', event => event.preventDefault());
this.addEventListener('drop', this._onDrop);
this.addEventListener('dragenter', this._onDragEnter);
this.addEventListener('dragend', () => this._reset());
Expand All @@ -73,7 +74,7 @@ export class FileDrop extends HTMLElement {

@bind
private _onDragEnter(event: DragEvent) {
this._dragEnterCount++;
this._dragEnterCount += 1;
if (this._dragEnterCount > 1) return;

// We don't have data, attempt to get it and if it matches, set the correct state.
Expand All @@ -87,7 +88,7 @@ export class FileDrop extends HTMLElement {

@bind
private _onDragLeave() {
this._dragEnterCount--;
this._dragEnterCount -= 1;
if (this._dragEnterCount === 0) {
this._reset();
}
Expand Down
5 changes: 2 additions & 3 deletions src/components/app/custom-els/FileDrop/missing-types.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { FileDropEvent, FileDrop } from ".";

import { FileDropEvent, FileDrop } from '.';

declare global {

Expand All @@ -17,4 +16,4 @@ declare global {
onfiledrop?: ((this: FileDrop, ev: FileDropEvent) => any) | null;
}
}
}
}
2 changes: 1 addition & 1 deletion src/lib/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export async function bitmapToImageData(bitmap: ImageBitmap): Promise<ImageData>
}

/** Replace the contents of a canvas with the given bitmap */
export function drawBitmapToCanvas (canvas: HTMLCanvasElement, img: ImageBitmap) {
export function drawBitmapToCanvas(canvas: HTMLCanvasElement, img: ImageBitmap) {
const ctx = canvas.getContext('2d');
if (!ctx) throw Error('Canvas not initialized');
ctx.clearRect(0, 0, canvas.width, canvas.height);
Expand Down

0 comments on commit 5eebf45

Please sign in to comment.