diff --git a/src/.eslintrc.json b/src/.eslintrc.json index 24a7b322..e150ef55 100644 --- a/src/.eslintrc.json +++ b/src/.eslintrc.json @@ -8,7 +8,7 @@ "project": "./tsconfig.json" // <-- Point to your project's "tsconfig.json" or create a new one. }, - "plugins": ["unused-imports"], + "plugins": ["unused-imports", "optimize-regex"], "overrides": [ { "files": ["*.ts"], @@ -48,7 +48,8 @@ "args": "after-used", "argsIgnorePattern": "^_" } - ] + ], + "optimize-regex/optimize-regex": "warn" } }, { diff --git a/src/angular.json b/src/angular.json index 02b445b1..4c94f3bb 100644 --- a/src/angular.json +++ b/src/angular.json @@ -177,8 +177,7 @@ "schematicCollections": [ "@cypress/schematic", "@angular-eslint/schematics", - "@angular-eslint/schematics", "@schematics/angular" ] } -} \ No newline at end of file +} diff --git a/src/package-lock.json b/src/package-lock.json index efd22eae..fb386a0e 100644 --- a/src/package-lock.json +++ b/src/package-lock.json @@ -54,6 +54,7 @@ "cypress": "latest", "eslint": "^8.57.0", "eslint-plugin-deprecation": "^2.0.0", + "eslint-plugin-optimize-regex": "^1.2.1", "eslint-plugin-unused-imports": "^3.1.0", "firebase-tools": "^13.4.0", "fuzzy": "^0.1.3", @@ -11980,6 +11981,18 @@ "typescript": "^4.2.4 || ^5.0.0" } }, + "node_modules/eslint-plugin-optimize-regex": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-optimize-regex/-/eslint-plugin-optimize-regex-1.2.1.tgz", + "integrity": "sha512-fUaU7Tj1G/KSTDTABJw4Wp427Rl7RPl9ViYTu1Jrv36fJw4DFhd4elPdXiuYtdPsNsvzn9GcVlKEssGIVjw0UQ==", + "dev": true, + "dependencies": { + "regexp-tree": "^0.1.21" + }, + "engines": { + "node": ">=10" + } + }, "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", @@ -21225,6 +21238,15 @@ "integrity": "sha512-TVILVSz2jY5D47F4mA4MppkBrafEaiUWJO/TcZHEIuI13AqoZMkK1WMA4Om1YkYbTx+9Ki1/tSUXbceyr9saRg==", "dev": true }, + "node_modules/regexp-tree": { + "version": "0.1.27", + "resolved": "https://registry.npmjs.org/regexp-tree/-/regexp-tree-0.1.27.tgz", + "integrity": "sha512-iETxpjK6YoRWJG5o6hXLwvjYAoW+FEZn9os0PD/b6AP6xQwsa/Y7lCVgIixBbUPMfhu+i2LtdeAqVTgGlQarfA==", + "dev": true, + "bin": { + "regexp-tree": "bin/regexp-tree" + } + }, "node_modules/regexpu-core": { "version": "5.3.2", "resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-5.3.2.tgz", diff --git a/src/package.json b/src/package.json index bbc7a4c8..760bdf08 100644 --- a/src/package.json +++ b/src/package.json @@ -62,6 +62,7 @@ "cypress": "latest", "eslint": "^8.57.0", "eslint-plugin-deprecation": "^2.0.0", + "eslint-plugin-optimize-regex": "^1.2.1", "eslint-plugin-unused-imports": "^3.1.0", "firebase-tools": "^13.4.0", "fuzzy": "^0.1.3", diff --git a/src/src/app/services/app.service.ts b/src/src/app/services/app.service.ts index 8f34227d..cd8bd8d3 100644 --- a/src/src/app/services/app.service.ts +++ b/src/src/app/services/app.service.ts @@ -747,7 +747,7 @@ export class AppService extends createReducingService(initialState) { qry = qry.split('"').join(''); // remove any quotes, just in case - if (qry.search(/[0-9]/i) === -1) { + if (qry.search(/\d/i) === -1) { // its a word for (const item of BibleReference.Books) { if ( @@ -772,7 +772,7 @@ export class AppService extends createReducingService(initialState) { } this.dispatch(updateAutoCompleteAction(words)); - } else if (qry.search(/(H|G)[0-9]/i) !== -1) { + } else if (qry.search(/(h|g)\d/i) !== -1) { // its a strongs lookup if (qry.substring(0, 1).toUpperCase() === 'H') { const num = parseInt(qry.substring(1), 10); @@ -852,7 +852,7 @@ export class AppService extends createReducingService(initialState) { type: CardType.Note, data, } as CardItem; - } else if (qry.search(/[0-9]/i) === -1) { + } else if (qry.search(/\d/i) === -1) { // // its a search term. const data = await this.getWordsFromApi(qry); if (!data) { @@ -863,7 +863,7 @@ export class AppService extends createReducingService(initialState) { type: CardType.Word, data, } as CardItem; - } else if (qry.search(/(H|G)[0-9]/i) !== -1) { + } else if (qry.search(/(h|g)\d/i) !== -1) { // its a strongs lookup const dict = qry.substring(0, 1).search(/h/i) !== -1 ? 'heb' : 'grk'; const strongsNumber = qry.substring(1, qry.length);