removed unused imports and variables

This commit is contained in:
Jason Wall 2024-03-09 14:13:56 -05:00
parent eff29f6f92
commit e22668640e
10 changed files with 72 additions and 76 deletions

View File

@ -7,6 +7,8 @@
"sourceType": "module", "sourceType": "module",
"project": "./tsconfig.json" // <-- Point to your project's "tsconfig.json" or create a new one. "project": "./tsconfig.json" // <-- Point to your project's "tsconfig.json" or create a new one.
}, },
"plugins": ["unused-imports"],
"overrides": [ "overrides": [
{ {
"files": ["*.ts"], "files": ["*.ts"],
@ -35,6 +37,17 @@
"prefix": "app", "prefix": "app",
"style": "kebab-case" "style": "kebab-case"
} }
],
"no-unused-vars": "off", // or "@typescript-eslint/no-unused-vars": "off",
"unused-imports/no-unused-imports": "error",
"unused-imports/no-unused-vars": [
"warn",
{
"vars": "all",
"varsIgnorePattern": "^_",
"args": "after-used",
"argsIgnorePattern": "^_"
}
] ]
} }
}, },

31
src/package-lock.json generated
View File

@ -54,6 +54,7 @@
"cypress": "latest", "cypress": "latest",
"eslint": "^8.57.0", "eslint": "^8.57.0",
"eslint-plugin-deprecation": "^2.0.0", "eslint-plugin-deprecation": "^2.0.0",
"eslint-plugin-unused-imports": "^3.1.0",
"firebase-tools": "^13.4.0", "firebase-tools": "^13.4.0",
"fuzzy": "^0.1.3", "fuzzy": "^0.1.3",
"inquirer": "^9.2.15", "inquirer": "^9.2.15",
@ -11979,6 +11980,36 @@
"typescript": "^4.2.4 || ^5.0.0" "typescript": "^4.2.4 || ^5.0.0"
} }
}, },
"node_modules/eslint-plugin-unused-imports": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-unused-imports/-/eslint-plugin-unused-imports-3.1.0.tgz",
"integrity": "sha512-9l1YFCzXKkw1qtAru1RWUtG2EVDZY0a0eChKXcL+EZ5jitG7qxdctu4RnvhOJHv4xfmUf7h+JJPINlVpGhZMrw==",
"dev": true,
"dependencies": {
"eslint-rule-composer": "^0.3.0"
},
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
},
"peerDependencies": {
"@typescript-eslint/eslint-plugin": "6 - 7",
"eslint": "8"
},
"peerDependenciesMeta": {
"@typescript-eslint/eslint-plugin": {
"optional": true
}
}
},
"node_modules/eslint-rule-composer": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/eslint-rule-composer/-/eslint-rule-composer-0.3.0.tgz",
"integrity": "sha512-bt+Sh8CtDmn2OajxvNO+BX7Wn4CIWMpTRm3MaiKPCQcnnlm0CS2mhui6QaoeQugs+3Kj2ESKEEGJUdVafwhiCg==",
"dev": true,
"engines": {
"node": ">=4.0.0"
}
},
"node_modules/eslint-scope": { "node_modules/eslint-scope": {
"version": "8.0.0", "version": "8.0.0",
"resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-8.0.0.tgz", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-8.0.0.tgz",

View File

@ -62,6 +62,7 @@
"cypress": "latest", "cypress": "latest",
"eslint": "^8.57.0", "eslint": "^8.57.0",
"eslint-plugin-deprecation": "^2.0.0", "eslint-plugin-deprecation": "^2.0.0",
"eslint-plugin-unused-imports": "^3.1.0",
"firebase-tools": "^13.4.0", "firebase-tools": "^13.4.0",
"fuzzy": "^0.1.3", "fuzzy": "^0.1.3",
"inquirer": "^9.2.15", "inquirer": "^9.2.15",

View File

@ -924,7 +924,7 @@ export class BibleReference {
if (this.ref.length === 0) { if (this.ref.length === 0) {
return; return;
} }
this.parseBook(false); this.parseBook();
this.parseChapter(false); this.parseChapter(false);
const foundFirstVerse = this.ref.search(/:.*-/) !== -1; const foundFirstVerse = this.ref.search(/:.*-/) !== -1;
@ -932,7 +932,7 @@ export class BibleReference {
this.maybeParseRangeSep(); this.maybeParseRangeSep();
const foundSecondBook = this.ref.search(/\w\s+\d/i) !== -1; const foundSecondBook = this.ref.search(/\w\s+\d/i) !== -1;
this.maybeParseBook(true); this.maybeParseBook();
this.maybeParseChapterOrVerse(foundSecondBook, foundFirstVerse, true); this.maybeParseChapterOrVerse(foundSecondBook, foundFirstVerse, true);
this.maybeParseVerse(true); this.maybeParseVerse(true);
} }
@ -958,7 +958,7 @@ export class BibleReference {
} }
} }
private parseBook(isEnd?: boolean) { private parseBook() {
this.ref = this.ref.toLowerCase().trim(); this.ref = this.ref.toLowerCase().trim();
let fbook = this.ref.substring(0, this.ref.search(/\w\s+\d/i) + 1); let fbook = this.ref.substring(0, this.ref.search(/\w\s+\d/i) + 1);
@ -1039,10 +1039,10 @@ export class BibleReference {
} }
} }
private maybeParseBook(isEnd: boolean) { private maybeParseBook() {
return this.maybeDo(() => { return this.maybeDo(() => {
if (this.ref.search(/\w\s+\d/i) !== -1) { if (this.ref.search(/\w\s+\d/i) !== -1) {
this.parseBook(isEnd); this.parseBook();
} }
}); });
} }

View File

@ -48,16 +48,6 @@ describe('Card Cache', () => {
type: CardType.Passage, type: CardType.Passage,
data: null, data: null,
}; };
const card2: CardItem = {
qry: 'jason',
type: CardType.Passage,
data: {
id: 'adsf',
xref: '',
title: 'adsf',
content: '',
} as NoteItem,
};
const card3: CardItem = { const card3: CardItem = {
qry: 'jason3', qry: 'jason3',
type: CardType.Passage, type: CardType.Passage,

View File

@ -1,4 +1,4 @@
import { Component, Input, OnInit } from '@angular/core'; import { Component, Input } from '@angular/core';
import { CdkDragDrop } from '@angular/cdk/drag-drop'; import { CdkDragDrop } from '@angular/cdk/drag-drop';
import { MatDialog } from '@angular/material/dialog'; import { MatDialog } from '@angular/material/dialog';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';

View File

@ -82,7 +82,7 @@ export class SettingsComponent extends SubscriberBase {
const credential = firebase.auth.GoogleAuthProvider.credential(googleUser.authentication.idToken); const credential = firebase.auth.GoogleAuthProvider.credential(googleUser.authentication.idToken);
(await this.authService.app).auth().signInWithCredential(credential); (await this.authService.app).auth().signInWithCredential(credential);
} else { } else {
this.authService.signInWithPopup(new firebase.auth.GoogleAuthProvider()).then((cred) => { this.authService.signInWithPopup(new firebase.auth.GoogleAuthProvider()).then(() => {
console.log('Authenticated.'); console.log('Authenticated.');
}); });
} }

View File

@ -1,6 +1,5 @@
import { Component, Inject, ChangeDetectionStrategy, Input } from '@angular/core'; import { Component, Inject, ChangeDetectionStrategy } from '@angular/core';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
import { MatTabsModule } from '@angular/material/tabs';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { BibleReference } from 'src/app/common/bible-reference'; import { BibleReference } from 'src/app/common/bible-reference';
import { CardItem } from 'src/app/models/card-state'; import { CardItem } from 'src/app/models/card-state';

View File

@ -8,7 +8,7 @@ import { getCardCacheKey } from '../common/card-cache-operations';
import { MoveDirection } from '../common/move-direction'; import { MoveDirection } from '../common/move-direction';
import { NoteItem } from '../models/note-state'; import { NoteItem } from '../models/note-state';
import { import {
addCardAction, addCardsAction,
addCardToSavedPageAction, addCardToSavedPageAction,
deleteNoteAction, deleteNoteAction,
findNotesAction, findNotesAction,
@ -273,7 +273,7 @@ describe('AppService Reducer', () => {
type: CardType.Strongs, type: CardType.Strongs,
}; };
const testState = addCardAction(card1, null).handle(preState); const testState = addCardsAction([card1], null).handle(preState);
expect(testState.currentCards.value[0]).toBe(card1, 'Failed to add first card to empty list'); expect(testState.currentCards.value[0]).toBe(card1, 'Failed to add first card to empty list');
const testState2 = updateCurrentPageAction().handle(testState); const testState2 = updateCurrentPageAction().handle(testState);
@ -289,7 +289,7 @@ describe('AppService Reducer', () => {
type: CardType.Passage, type: CardType.Passage,
}; };
const preState2 = addCardAction(card1, null).handle(preState); const preState2 = addCardsAction([card1], null).handle(preState);
const testState = savePageAction('my saved page').handle(preState2); const testState = savePageAction('my saved page').handle(preState2);
@ -328,7 +328,7 @@ describe('AppService Reducer', () => {
type: CardType.Strongs, type: CardType.Strongs,
}; };
const testState = addCardAction(card1, null).handle(preState); const testState = addCardsAction([card1], null).handle(preState);
expect(testState.currentCards.value[0]).toBe(card1, 'Failed to add first card to empty list'); expect(testState.currentCards.value[0]).toBe(card1, 'Failed to add first card to empty list');
const card2: CardItem = { const card2: CardItem = {
@ -337,7 +337,7 @@ describe('AppService Reducer', () => {
type: CardType.Strongs, type: CardType.Strongs,
}; };
const testState2 = addCardAction(card2, null).handle(testState); const testState2 = addCardsAction([card2], null).handle(testState);
expect(testState2.currentCards.value.length).toBe(2, 'Failed to add second card to list with 1 item'); expect(testState2.currentCards.value.length).toBe(2, 'Failed to add second card to list with 1 item');
expect(testState2.currentCards.value[1]).toBe(card2); expect(testState2.currentCards.value[1]).toBe(card2);
@ -370,7 +370,7 @@ describe('AppService Reducer', () => {
}, },
}).handle(testState2); }).handle(testState2);
const testState3 = addCardAction(card3, card2).handle(setState); const testState3 = addCardsAction([card3], card2).handle(setState);
expect(testState3.currentCards.value.length).toBe(3, 'Failed to add third card'); expect(testState3.currentCards.value.length).toBe(3, 'Failed to add third card');
expect(testState3.currentCards.value[1]).toBe(card3, 'Failed to insert card above the second card'); expect(testState3.currentCards.value[1]).toBe(card3, 'Failed to insert card above the second card');
@ -397,7 +397,7 @@ describe('AppService Reducer', () => {
}, },
}).handle(testState2); }).handle(testState2);
const testState4 = addCardAction(card3, card1).handle(setState); const testState4 = addCardsAction([card3], card1).handle(setState);
expect(testState4.currentCards.value.length).toBe(3, 'Failed to add third card'); expect(testState4.currentCards.value.length).toBe(3, 'Failed to add third card');
expect(testState4.currentCards.value[1]).toBe(card3, 'Failed to insert card below the first card'); expect(testState4.currentCards.value[1]).toBe(card3, 'Failed to insert card below the first card');
@ -424,7 +424,7 @@ describe('AppService Reducer', () => {
}, },
}).handle(testState2); }).handle(testState2);
const testState5 = addCardAction(card3, card1).handle(setState); const testState5 = addCardsAction([card3], card1).handle(setState);
expect(testState5.currentCards.value.length).toBe(3, 'Failed to add third card'); expect(testState5.currentCards.value.length).toBe(3, 'Failed to add third card');
expect(testState5.currentCards.value[2]).toBe(card3, 'Failed to insert card at end of the list'); expect(testState5.currentCards.value[2]).toBe(card3, 'Failed to insert card at end of the list');
@ -451,7 +451,7 @@ describe('AppService Reducer', () => {
}, },
}).handle(testState2); }).handle(testState2);
const testState6 = addCardAction(card3, card1).handle(setState); const testState6 = addCardsAction([card3], card1).handle(setState);
expect(testState6.currentCards.value.length).toBe(3, 'Failed to add third card'); expect(testState6.currentCards.value.length).toBe(3, 'Failed to add third card');
expect(testState6.currentCards.value[0]).toBe(card3, 'Failed to insert card at start of the list'); expect(testState6.currentCards.value[0]).toBe(card3, 'Failed to insert card at start of the list');
}); });
@ -463,7 +463,7 @@ describe('AppService Reducer', () => {
type: CardType.Strongs, type: CardType.Strongs,
}; };
const preState1 = addCardAction(oldCard, null).handle(preState); const preState1 = addCardsAction([oldCard], null).handle(preState);
const newCard: CardItem = { const newCard: CardItem = {
qry: 'H88', qry: 'H88',
@ -487,7 +487,7 @@ describe('AppService Reducer', () => {
type: CardType.Strongs, type: CardType.Strongs,
}; };
const preState1 = addCardAction(card, null).handle(preState); const preState1 = addCardsAction([card], null).handle(preState);
const testState = removeCardAction(card).handle(preState1); const testState = removeCardAction(card).handle(preState1);
@ -508,7 +508,7 @@ describe('AppService Reducer', () => {
type: CardType.Strongs, type: CardType.Strongs,
}; };
const preState1 = addCardAction(card1, null).handle(preState); const preState1 = addCardsAction([card1], null).handle(preState);
const card2: CardItem = { const card2: CardItem = {
qry: 'H88', qry: 'H88',
@ -516,7 +516,7 @@ describe('AppService Reducer', () => {
type: CardType.Strongs, type: CardType.Strongs,
}; };
const preState2 = addCardAction(card2, null).handle(preState1); const preState2 = addCardsAction([card2], null).handle(preState1);
expect(preState2.currentCards.value.length).toBe(2, 'Should have two cards'); expect(preState2.currentCards.value.length).toBe(2, 'Should have two cards');
expect(preState2.currentCards.value[0].qry).toBe('G123'); expect(preState2.currentCards.value[0].qry).toBe('G123');
expect(preState2.currentCards.value[1].qry).toBe('H88'); expect(preState2.currentCards.value[1].qry).toBe('H88');
@ -605,7 +605,4 @@ describe('AppService Reducer', () => {
//#endregion //#endregion
}); });
function newUserAction(preState: AppState, action1: any) {
throw new Error('Function not implemented.');
}

View File

@ -252,40 +252,6 @@ export const addCardToSavedPageAction = (card: CardItem, pageId: string): AppAct
//#region Cards //#region Cards
export const addCardAction = (card: CardItem, nextToItem: CardItem): AppAction => {
return {
handle(state: AppState) {
let cards = [];
if (nextToItem && state.settings.value.displaySettings.insertCardNextToItem) {
const idx = state.currentCards.value.indexOf(nextToItem);
if (state.settings.value.displaySettings.appendCardToBottom) {
const before = state.currentCards.value.slice(0, idx + 1);
const after = state.currentCards.value.slice(idx + 1);
cards = [...before, card, ...after];
} else {
const before = state.currentCards.value.slice(0, idx);
const after = state.currentCards.value.slice(idx);
cards = [...before, card, ...after];
}
} else {
if (state.settings.value.displaySettings.appendCardToBottom) {
cards = [...state.currentCards.value, card];
} else {
cards = [card, ...state.currentCards.value];
}
}
return {
...state,
currentCards: new Storable(cards),
cardCache: updateInCardCache(card, state.cardCache),
};
},
};
};
export const addCardsAction = (cardsToAdd: CardItem[], nextToItem: CardItem): AppAction => { export const addCardsAction = (cardsToAdd: CardItem[], nextToItem: CardItem): AppAction => {
return { return {
handle(state: AppState) { handle(state: AppState) {
@ -581,7 +547,7 @@ export const getNotesAction = (noteId: string, nextToItem: CardItem): AppAction
data: note, data: note,
}; };
return addCardAction(card, nextToItem).handle(state); return addCardsAction([card], nextToItem).handle(state);
}, },
}; };
}; };
@ -841,7 +807,7 @@ export class AppService extends createReducingService(initialState) {
if (!card) { if (!card) {
return; return;
} }
this.dispatch(addCardAction(card, nextToItem)); this.dispatch(addCardsAction([card], nextToItem));
} }
async updateCards(queries: IStorable<readonly DataReference[]>) { async updateCards(queries: IStorable<readonly DataReference[]>) {
@ -1122,7 +1088,7 @@ export class AppService extends createReducingService(initialState) {
const rmacCrossReferences = await lastValueFrom(this.http.get<RMACCrossReference[]>(url)); const rmacCrossReferences = await lastValueFrom(this.http.get<RMACCrossReference[]>(url));
// deal with RMAC // deal with RMAC
const referencesForThisStrongsNumber = rmacCrossReferences.filter((el, i) => { const referencesForThisStrongsNumber = rmacCrossReferences.filter((el) => {
return el.i === sn.toString(); return el.i === sn.toString();
}); });
@ -1161,7 +1127,7 @@ export class AppService extends createReducingService(initialState) {
return; // nothing was returned. so an error occurred. return; // nothing was returned. so an error occurred.
} }
this.dispatch(addCardAction(card, nextToItem)); this.dispatch(addCardsAction([card], nextToItem));
} }
async updatePassage(oldCard: CardItem, ref: BibleReference) { async updatePassage(oldCard: CardItem, ref: BibleReference) {
@ -1302,7 +1268,6 @@ export class AppService extends createReducingService(initialState) {
// create an initial paragraph to hold verses that might come before a paragraph. // create an initial paragraph to hold verses that might come before a paragraph.
let para = { p: { h: '', p: 0 }, vss: [] }; let para = { p: { h: '', p: 0 }, vss: [] };
const paras = []; const paras = [];
const vss: BibleVerse[] = [];
// for each verse in the chapter, break them into paragraphs. // for each verse in the chapter, break them into paragraphs.
for (const v of ch.vss) { for (const v of ch.vss) {
@ -1350,7 +1315,7 @@ export class AppService extends createReducingService(initialState) {
data: result, data: result,
} as CardItem; } as CardItem;
this.dispatch(addCardAction(card, nextToItem)); this.dispatch(addCardsAction([card], nextToItem));
} }
private async getWordsFromApi(qry: string): Promise<WordLookupResult> { private async getWordsFromApi(qry: string): Promise<WordLookupResult> {
@ -1411,7 +1376,7 @@ export class AppService extends createReducingService(initialState) {
if (excluded.length > 0) { if (excluded.length > 0) {
this.dispatch( this.dispatch(
updateErrorAction({ updateErrorAction({
msg: `The ${excluded.length > 1 ? 'words' : 'word'} "${excluded.reduce((prev, curr, idx, arr) => { msg: `The ${excluded.length > 1 ? 'words' : 'word'} "${excluded.reduce((prev, curr) => {
return `${prev}, ${curr}`; return `${prev}, ${curr}`;
})}" ${excluded.length > 1 ? 'have' : 'has'} been excluded from search because it is too common.`, })}" ${excluded.length > 1 ? 'have' : 'has'} been excluded from search because it is too common.`,
}) })