Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
arvyy committed Jul 14, 2024
1 parent b361b62 commit 2ff1e9f
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 78 deletions.
52 changes: 52 additions & 0 deletions scheme-index-app/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"root": true,
"ignorePatterns": [
"projects/**/*"
],
"overrides": [
{
"files": [
"*.ts"
],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@angular-eslint/recommended",
"plugin:@angular-eslint/template/process-inline-templates"
],
"rules": {
"@typescript-eslint/no-unused-vars": [
"warn",
{
"argsIgnorePattern": "^_"
}
],
"@angular-eslint/directive-selector": [
"error",
{
"type": "attribute",
"prefix": "app",
"style": "camelCase"
}
],
"@angular-eslint/component-selector": [
"error",
{
"type": "element",
"prefix": "app",
"style": "kebab-case"
}
]
}
},
{
"files": [
"*.html"
],
"extends": [
"plugin:@angular-eslint/template/recommended"
],
"rules": {}
}
]
}
5 changes: 2 additions & 3 deletions scheme-index-app/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import { Component, HostBinding } from '@angular/core';
import { NavigationEnd, Router, RouterModule } from '@angular/router';
import { filter, map, Observable, startWith, combineLatest } from 'rxjs';
import { IndexService } from './index.service';
import { faHome, faSearch, faFile, faTimes } from '@fortawesome/free-solid-svg-icons';
import { IndexErrorHandler } from './index-error-handler';
import { faHome, faSearch, faFile, faTimes, IconDefinition } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
import { FormsModule } from '@angular/forms';
import { CommonModule } from '@angular/common';
Expand Down Expand Up @@ -85,7 +84,7 @@ export class AppComponent {
interface NavbarItem {
label: string;
link?: string;
icon?: any;
icon?: IconDefinition;
externallink?: boolean;
items: NavbarItem[];
isActive: boolean;
Expand Down
49 changes: 0 additions & 49 deletions scheme-index-app/src/app/index-error-handler.ts

This file was deleted.

42 changes: 19 additions & 23 deletions scheme-index-app/src/app/index.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Injectable } from '@angular/core';
import { HttpClient, HttpParams } from '@angular/common/http';
import { HttpClient } from '@angular/common/http';
import { IndexResponse, IndexQuery, Filterset, SearchItem, SearchItemSingle, FuncSignatureReturn, ResponseFacetValue } from './index.types';
import { Observable, shareReplay, map, catchError, of, combineLatest } from 'rxjs';
import { Observable, shareReplay, map, combineLatest } from 'rxjs';
import MiniSearch from 'node_modules/minisearch/dist/es';

@Injectable({
Expand All @@ -19,9 +19,9 @@ export class IndexService {
constructor(private http: HttpClient) {
this.filtersetFilter$ = this.filtersets.pipe(map(filters => {
const result: {[index: string]: Set} = {};
for (let f of filters) {
for (const f of filters) {
const set: Set = {};
for (let lib of f.libs) {
for (const lib of f.libs) {
set[lib] = true;
}
result[f.code] = set;
Expand Down Expand Up @@ -55,7 +55,7 @@ export class IndexService {
public get(filterset: string, lib: string, name: string): Observable<SearchItem> {
return combineLatest([this.searcher$, this.filtersetFilter$])
.pipe(map(([searcher, filters]) => {
for (let e of searcher.all) {
for (const e of searcher.all) {
if (!filters[filterset][e.data.lib])
continue;
if (e.data.lib != lib) {
Expand All @@ -80,13 +80,13 @@ export class IndexService {
facet[value]++;
}
function recordFacetValues(facet: {[index: string]: number }, values: Set) {
for (let v in values) {
for (const v in values) {
recordFacetValue(facet, v);
}
}
function finalizeFacet(facet: {[index: string]: number}) {
const facets: ResponseFacetValue[] = [];
for (let k in facet) {
for (const k in facet) {
facets.push({
value: k,
count: facet[k]
Expand All @@ -112,13 +112,13 @@ export class IndexService {
const returnData = [];
let count = 0;
top:
for (let e of found) {
for (const e of found) {
if (!libs[e.data.lib]) {
continue;
}
if (request.libs && request.libs.length) {
let found = false;
for (let l of request.libs) {
for (const l of request.libs) {
if (e.data.lib == l) {
found = true;
continue;
Expand All @@ -129,21 +129,21 @@ export class IndexService {
}
}
if (request.returns) {
for (let r of request.returns) {
for (const r of request.returns) {
if (!e.returns[r]) {
continue top;
}
}
}
if (request.params) {
for (let p of request.params) {
for (const p of request.params) {
if (!e.params[p]) {
continue top;
}
}
}
if (request.tags) {
for (let t of request.tags) {
for (const t of request.tags) {
if (!e.tags[t]) {
continue top;
}
Expand Down Expand Up @@ -193,7 +193,7 @@ export class IndexService {
if (r.kind == 'return' && r.type != '...' && r.type != '*' && r.type != 'undefined') {
returns[r.type] = true;
} else {
for (let r2 of (r.items || [])) {
for (const r2 of (r.items || [])) {
processReturn(r2);
}
}
Expand All @@ -202,14 +202,14 @@ export class IndexService {
function process(e: SearchItemSingle) {
names[e.name] = true;
name.push(e.name);
for (let tag of e.tags) {
for (const tag of e.tags) {
tags[tag] = true;
}

if (e.signature.type == 'function') {
for (let variant of e.signature.variants) {
for (let param of variant.params) {
for (let type of param.types) {
for (const variant of e.signature.variants) {
for (const param of variant.params) {
for (const type of param.types) {
params[type] = true;
}
}
Expand All @@ -222,7 +222,7 @@ export class IndexService {
}

if (e.signature.type == 'syntax') {
for (let pat of e.signature.patterns) {
for (const pat of e.signature.patterns) {
if (pat.type) {
processReturn(pat.type);
}
Expand All @@ -233,7 +233,7 @@ export class IndexService {
if (e.kind == 'single') {
process(e);
} else if (e.kind == 'group') {
for (let entry of e.entries) {
for (const entry of e.entries) {
process(entry);
}
}
Expand Down Expand Up @@ -264,7 +264,3 @@ interface SearchItemIndexingWrap {
params: Set;
returns: Set;
}

interface Searcher {
data: SearchItem[];
}
4 changes: 2 additions & 2 deletions scheme-index-app/src/app/search-item/search-item.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ export class SearchItemComponent {

constructor() {
this.componentSearchItemGroup = this.searchitem$.pipe(map(s => {
var entries: ComponentSearchItem[];
var groupDesc = '';
let entries: ComponentSearchItem[];
let groupDesc = '';
if (s.kind == 'single') {
entries = [this.searchItemSingleToComponentSearchItem(s)];
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,13 @@ export class SearchPageComponent {

seachItemRouterResolver(item: SearchItem, type: 'param' | 'return' | 'tag' | 'name' | 'lib', value: string): RouterLink | null {
switch (type) {
case 'name':
case 'name': {
const name = item.kind == 'single'? item.name : item.entries[0].name;
return {
routerLink: [`/filterset/${this.filterset}/${encodeURIComponent(item.lib)}/${encodeURIComponent(name)}`],
queryParams: {}
};
}
case 'param':
return {
routerLink: [],
Expand Down

0 comments on commit 2ff1e9f

Please sign in to comment.