chore: fix lint issues

This commit is contained in:
Roman Hotsiy 2018-03-05 17:58:19 +02:00
parent 67e459f0c7
commit 61bb79e8b0
No known key found for this signature in database
GPG Key ID: 5CB7B3ACABA57CB0
5 changed files with 14 additions and 10 deletions

View File

@ -2,12 +2,12 @@ import { observe } from 'mobx';
import { OpenAPISpec } from '../types'; import { OpenAPISpec } from '../types';
import { loadAndBundleSpec } from '../utils/loadAndBundleSpec'; import { loadAndBundleSpec } from '../utils/loadAndBundleSpec';
import { MarkerService } from './MarkerService';
import { MenuStore } from './MenuStore'; import { MenuStore } from './MenuStore';
import { SpecStore } from './models'; import { SpecStore } from './models';
import { RedocNormalizedOptions, RedocRawOptions } from './RedocNormalizedOptions'; import { RedocNormalizedOptions, RedocRawOptions } from './RedocNormalizedOptions';
import { ScrollService } from './ScrollService'; import { ScrollService } from './ScrollService';
import { SearchStore } from './SearchStore'; import { SearchStore } from './SearchStore';
import { MarkerService } from './MarkerService';
interface StoreData { interface StoreData {
menu: { menu: {
@ -80,11 +80,15 @@ export class AppStore {
const elements: Element[] = []; const elements: Element[] = [];
for (let i = start; i < end; i++) { for (let i = start; i < end; i++) {
let elem = this.menu.getElementAt(i); let elem = this.menu.getElementAt(i);
if (!elem) continue; if (!elem) {
continue;
}
if (this.menu.flatItems[i].type === 'section') { if (this.menu.flatItems[i].type === 'section') {
elem = elem.parentElement!.parentElement; elem = elem.parentElement!.parentElement;
} }
if (elem) elements.push(elem); if (elem) {
elements.push(elem);
}
} }
this.marker.addOnly(elements); this.marker.addOnly(elements);

View File

@ -21,7 +21,7 @@ export class MarkerService {
} }
}); });
for (let el of elements) { for (const el of elements) {
if (!this.map.has(el)) { if (!this.map.has(el)) {
this.map.set(el, new Mark(el as HTMLElement)); this.map.set(el, new Mark(el as HTMLElement));
} }
@ -34,7 +34,9 @@ export class MarkerService {
} }
mark(term?: string) { mark(term?: string) {
if (!term && !this.prevTerm) return; if (!term && !this.prevTerm) {
return;
}
this.map.forEach(val => { this.map.forEach(val => {
val.unmark(); val.unmark();
val.mark(term || this.prevTerm); val.mark(term || this.prevTerm);

View File

@ -1,12 +1,10 @@
import { IMenuItem } from './MenuStore';
import { OperationModel } from './models'; import { OperationModel } from './models';
import worker from './SearchWorker.worker'; import worker from './SearchWorker.worker';
import { IMenuItem } from './MenuStore';
export class SearchStore { export class SearchStore {
searchWorker = new worker(); searchWorker = new worker();
constructor() {}
indexItems(groups: Array<IMenuItem | OperationModel>) { indexItems(groups: Array<IMenuItem | OperationModel>) {
groups.forEach(group => { groups.forEach(group => {
if (group.type !== 'group') { if (group.type !== 'group') {

View File

@ -12,8 +12,8 @@ import {
getOperationSummary, getOperationSummary,
isAbsolutePath, isAbsolutePath,
JsonPointer, JsonPointer,
stripTrailingSlash,
sortByRequired, sortByRequired,
stripTrailingSlash,
} from '../../utils'; } from '../../utils';
import { ContentItemModel, ExtendedOpenAPIOperation } from '../MenuBuilder'; import { ContentItemModel, ExtendedOpenAPIOperation } from '../MenuBuilder';
import { OpenAPIParser } from '../OpenAPIParser'; import { OpenAPIParser } from '../OpenAPIParser';

View File

@ -162,7 +162,7 @@ export function humanizeConstraints(schema: OpenAPISchema): string[] {
} }
export function sortByRequired( export function sortByRequired(
fields: { required: boolean; name: string }[], fields: Array<{ required: boolean; name: string }>,
order: string[] = [], order: string[] = [],
) { ) {
fields.sort((a, b) => { fields.sort((a, b) => {