Skip to content

Commit 61cf346

Browse files
renovate[bot]renovate-botbodinsamuel
authored
chore(deps): update dependency eslint-config-algolia to v18 (#239)
* chore(deps): update dependency eslint-config-algolia to v18 * fix * fix Co-authored-by: Renovate Bot <[email protected]> Co-authored-by: Samuel Bodin <[email protected]>
1 parent 93048f2 commit 61cf346

File tree

10 files changed

+105
-58
lines changed

10 files changed

+105
-58
lines changed

frontend/src/AlgoliasearchNetlify.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const mandatory: Array<keyof Options> = [
2323

2424
const instances: AutocompleteWrapper[] = [];
2525

26-
function algoliasearchNetlify(_options: Options) {
26+
function algoliasearchNetlify(_options: Options): void {
2727
const options = {
2828
...defaultOptions,
2929
..._options,
@@ -38,7 +38,7 @@ function algoliasearchNetlify(_options: Options) {
3838
instances.push(autocomplete);
3939

4040
// Wait for DOM initialization, then render
41-
const render = () => {
41+
const render = (): void => {
4242
autocomplete.render();
4343
};
4444
if (['complete', 'interactive'].includes(document.readyState)) {

frontend/src/AutocompleteWrapper.ts

Lines changed: 38 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
1-
import type { SearchClient } from 'algoliasearch/lite';
2-
import type { HighlightedHit } from '@algolia/autocomplete-preset-algolia';
3-
4-
import algoliasearch from 'algoliasearch/lite';
5-
import type { Hit } from '@algolia/client-search';
61
import {
72
autocomplete,
8-
AutocompleteApi,
93
highlightHit,
104
snippetHit,
5+
} from '@algolia/autocomplete-js';
6+
import type {
7+
VNode,
8+
AutocompleteApi,
119
AutocompleteSource,
10+
SourceTemplates,
1211
} from '@algolia/autocomplete-js';
13-
import type { VNode } from '@algolia/autocomplete-js';
12+
import type { HighlightedHit } from '@algolia/autocomplete-preset-algolia';
1413
import { getAlgoliaHits } from '@algolia/autocomplete-preset-algolia';
14+
import type { Hit } from '@algolia/client-search';
15+
import algoliasearch from 'algoliasearch/lite';
16+
import type { SearchClient } from 'algoliasearch/lite';
1517

16-
import type { Options, AlgoliaRecord, HighlightedHierarchy } from './types';
18+
// @ts-expect-error
19+
import { version } from '../package.json';
1720

1821
import { templates } from './templates';
19-
20-
// @ts-ignore
21-
import { version } from '../package.json';
22+
import type { Options, AlgoliaRecord, HighlightedHierarchy } from './types';
2223

2324
class AutocompleteWrapper {
2425
private options;
@@ -33,7 +34,7 @@ class AutocompleteWrapper {
3334
this.indexName = this.computeIndexName();
3435
}
3536

36-
render() {
37+
render(): void {
3738
const $input = document.querySelector(this.options.selector) as HTMLElement;
3839
if (!$input) {
3940
console.error(
@@ -89,7 +90,28 @@ class AutocompleteWrapper {
8990

9091
private getSources(): AutocompleteSource<HighlightedHit<AlgoliaRecord>> {
9192
const poweredBy = this.options.poweredBy;
92-
return {
93+
const tpls: SourceTemplates<HighlightedHit<AlgoliaRecord>> = {
94+
header() {
95+
return '';
96+
},
97+
item({ item }) {
98+
return templates.item(
99+
item,
100+
highlightHit({ hit: item, attribute: 'title' }),
101+
getSuggestionSnippet(item),
102+
getHighlightedHierarchy(item)
103+
);
104+
},
105+
footer() {
106+
if (poweredBy) {
107+
return templates.poweredBy({
108+
hostname: window.location.host,
109+
});
110+
}
111+
return '';
112+
},
113+
};
114+
const res: AutocompleteSource<HighlightedHit<AlgoliaRecord>> = {
93115
sourceId: 'algoliaHits',
94116
getItems: ({ query }) => {
95117
return getAlgoliaHits({
@@ -109,31 +131,12 @@ class AutocompleteWrapper {
109131
getItemUrl({ item }) {
110132
return item.url;
111133
},
112-
templates: {
113-
header() {
114-
return '';
115-
},
116-
item({ item }) {
117-
return templates.item(
118-
item,
119-
highlightHit({ hit: item, attribute: 'title' }),
120-
getSuggestionSnippet(item),
121-
getHighlightedHierarchy(item)
122-
);
123-
},
124-
footer() {
125-
if (poweredBy) {
126-
return templates.poweredBy({
127-
hostname: window.location.host,
128-
});
129-
}
130-
return '';
131-
},
132-
},
134+
templates: tpls,
133135
};
136+
return res;
134137
}
135138

136-
private applyTheme(el: HTMLElement | null) {
139+
private applyTheme(el: HTMLElement | null): void {
137140
if (!el || !this.options.theme) {
138141
return;
139142
}

frontend/src/templates.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { VNode } from '@algolia/autocomplete-js';
2-
import { AlgoliaRecord, HighlightedHierarchy } from './types';
2+
3+
import type { AlgoliaRecord, HighlightedHierarchy } from './types';
34

45
export const templates = {
56
poweredBy: ({ hostname }: { hostname: string }): VNode => {
@@ -58,8 +59,8 @@ export const templates = {
5859
* Transform a highlighted hierarchy object into an array of VNode[].
5960
* 3 levels max are returned.
6061
*
61-
* @param {Hierarchy} hierarchy An highlighted hierarchy, i.e. { lvl0: (string | VNode)[], lvl1: (string | VNode)[], lvl2: (string | VNode)[], ... }
62-
* @returns {Array<string | Array<string | VNode>>} An array of VNode[], representing of the highlighted hierarchy starting from lvl1.
62+
* @param hierarchy - An highlighted hierarchy, i.e. { lvl0: (string | VNode)[], lvl1: (string | VNode)[], lvl2: (string | VNode)[], ... }.
63+
* @returns An array of VNode[], representing of the highlighted hierarchy starting from lvl1.
6364
* Between each VNode[] we insert a ' > ' character to render them as breadcrumbs eventually.
6465
*/
6566
function hierarchyToBreadcrumbVNodes(

frontend/webpack.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
/* eslint-disable @typescript-eslint/no-var-requires */
12
/* eslint import/no-commonjs: 'off' */
23
const path = require('path');
34

45
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
56
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
6-
const TerserPlugin = require('terser-webpack-plugin');
77
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
8-
8+
const TerserPlugin = require('terser-webpack-plugin');
99
const { HotModuleReplacementPlugin } = require('webpack');
1010

1111
function plugins({ production }) {

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,14 @@
3333
"conventional-changelog": "3.1.24",
3434
"conventional-changelog-cli": "2.1.1",
3535
"eslint": "7.22.0",
36-
"eslint-config-algolia": "17.0.1",
36+
"eslint-config-algolia": "18.0.0",
3737
"eslint-config-prettier": "8.1.0",
3838
"eslint-config-standard": "16.0.2",
3939
"eslint-plugin-algolia": "2.0.0",
4040
"eslint-plugin-eslint-comments": "3.2.0",
4141
"eslint-plugin-import": "2.22.1",
4242
"eslint-plugin-jest": "24.1.5",
43+
"eslint-plugin-jsdoc": "32.3.0",
4344
"eslint-plugin-node": "11.1.0",
4445
"eslint-plugin-prettier": "3.3.1",
4546
"eslint-plugin-promise": "4.3.1",

plugin/src/dev.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import path from 'path';
22

3-
function forceEnvVar(env: Record<string, string>, key: string) {
3+
function forceEnvVar(env: Record<string, string>, key: string): void {
44
if (env[key] === undefined) {
55
throw new Error(`Missing ${key} in .env`);
66
}
@@ -9,7 +9,8 @@ function forceEnvVar(env: Record<string, string>, key: string) {
99

1010
// In dev env, yarn netlify build inherits of the env vars set in Netlify's UI.
1111
// We need to manually override them.
12-
export function loadDevEnvVariables() {
12+
export function loadDevEnvVariables(): void {
13+
// eslint-disable-next-line @typescript-eslint/no-var-requires
1314
const dotenv = require('dotenv');
1415

1516
const filePath = path.join(__dirname, '..', '..', '.env');

plugin/src/index.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
import fetch, { Response } from 'node-fetch';
1+
import type { Response } from 'node-fetch';
2+
import fetch from 'node-fetch';
23

3-
// @ts-ignore
4+
// @ts-expect-error
45
import { version } from '../package.json';
6+
57
import { loadDevEnvVariables } from './dev';
68
import { starMatch } from './starMatch';
7-
import { BuildParams } from './types';
9+
import type { BuildParams } from './types';
810

911
function createSummaryLogger(
1012
show: BuildParams['utils']['status']['show']
1113
): (message: string) => void {
12-
return (message) => {
14+
return (message): void => {
1315
show({ title: 'Algolia Crawler', summary: message });
1416
console.log(message);
1517
};
@@ -79,7 +81,7 @@ export async function onSuccess(params: BuildParams): Promise<void> {
7981
}
8082

8183
// Check required env vars
82-
const missingEnvMessage = (key: string) =>
84+
const missingEnvMessage = (key: string): string =>
8385
`Missing ${key}, please go to ${algoliaBaseUrl}/admin/netlify to complete your installation.`;
8486
if (!algoliaBaseUrl) {
8587
return utils.build.failPlugin(missingEnvMessage('ALGOLIA_BASE_URL'));

plugin/src/starMatch.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { escapeRegExp } from './escapeRegExp';
22

3-
export function starMatch(pattern: string, value: string) {
3+
export function starMatch(pattern: string, value: string): boolean {
44
const regexp = pattern.split('*').map(escapeRegExp).join('.*');
55
return new RegExp(`^${regexp}$`).test(value);
66
}

plugin/src/types.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,15 @@ export interface BuildParams {
1414
};
1515
utils: {
1616
status: {
17-
show(params: { title?: string; summary: string; text?: string }): void;
17+
show: (params: {
18+
title?: string;
19+
summary: string;
20+
text?: string;
21+
}) => void;
1822
};
1923
build: {
2024
// failBuild(str: string): void; // Do not use https://github.com/algolia/algoliasearch-netlify/issues/69
21-
failPlugin(str: string): void;
25+
failPlugin: (str: string) => void;
2226
};
2327
};
2428
}

yarn.lock

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5268,6 +5268,11 @@ commander@~2.8.1:
52685268
dependencies:
52695269
graceful-readlink ">= 1.0.0"
52705270

5271+
5272+
version "1.1.2"
5273+
resolved "https://registry.yarnpkg.com/comment-parser/-/comment-parser-1.1.2.tgz#e5317d7a2ec22b470dcb54a29b25426c30bf39d8"
5274+
integrity sha512-AOdq0i8ghZudnYv8RUnHrhTgafUGs61Rdz9jemU5x2lnZwAWyOq7vySo626K59e1fVKH1xSRorJwPVRLSWOoAQ==
5275+
52715276
common-path-prefix@^2.0.0:
52725277
version "2.0.0"
52735278
resolved "https://registry.yarnpkg.com/common-path-prefix/-/common-path-prefix-2.0.0.tgz#25b0265f318bf093a6ec630813aac97b29dea230"
@@ -5991,6 +5996,13 @@ debug@^4.0.0, debug@^4.0.1, debug@^4.1.0, debug@^4.1.1:
59915996
dependencies:
59925997
ms "^2.1.1"
59935998

5999+
debug@^4.3.1:
6000+
version "4.3.1"
6001+
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.1.tgz#f0d229c505e0c6d8c49ac553d1b13dc183f6b2ee"
6002+
integrity sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==
6003+
dependencies:
6004+
ms "2.1.2"
6005+
59946006
decamelize-keys@^1.0.0, decamelize-keys@^1.1.0:
59956007
version "1.1.0"
59966008
resolved "https://registry.yarnpkg.com/decamelize-keys/-/decamelize-keys-1.1.0.tgz#d171a87933252807eb3cb61dc1c1445d078df2d9"
@@ -6685,10 +6697,10 @@ escodegen@^1.14.1, escodegen@^1.8.0:
66856697
optionalDependencies:
66866698
source-map "~0.6.1"
66876699

6688-
eslint-config-algolia@17.0.1:
6689-
version "17.0.1"
6690-
resolved "https://registry.yarnpkg.com/eslint-config-algolia/-/eslint-config-algolia-17.0.1.tgz#a1ad0222686dc6796234020edc7a7068e6226a5d"
6691-
integrity sha512-/5kWZYj3WNDG7/AtAX1ncnLUEijOWUey7sEaix0v1bedA2v5OvZkJ3j+SYKgPJMN9Al5qnG2hdOuUwSHCmU9Dw==
6700+
eslint-config-algolia@18.0.0:
6701+
version "18.0.0"
6702+
resolved "https://registry.yarnpkg.com/eslint-config-algolia/-/eslint-config-algolia-18.0.0.tgz#4317d58c06692d88877d6182b9a6f50cc26af9d2"
6703+
integrity sha512-ZjFDOSsGaDc04cgB/2/yKWrOGq3w4UXk/z7yqjY/MEj7HAKCgWoA6jDW3NPsSDL1ZC36901SLFDY5kgXoPn18w==
66926704

66936705
66946706
version "8.1.0"
@@ -6763,6 +6775,19 @@ [email protected]:
67636775
dependencies:
67646776
"@typescript-eslint/experimental-utils" "^4.0.1"
67656777

6778+
6779+
version "32.3.0"
6780+
resolved "https://registry.yarnpkg.com/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-32.3.0.tgz#7c9fa5da8c72bd6ad7d97bbf8dee8bc29bec3f9e"
6781+
integrity sha512-zyx7kajDK+tqS1bHuY5sapkad8P8KT0vdd/lE55j47VPG2MeenSYuIY/M/Pvmzq5g0+3JB+P3BJGUXmHxtuKPQ==
6782+
dependencies:
6783+
comment-parser "1.1.2"
6784+
debug "^4.3.1"
6785+
jsdoctypeparser "^9.0.0"
6786+
lodash "^4.17.20"
6787+
regextras "^0.7.1"
6788+
semver "^7.3.4"
6789+
spdx-expression-parse "^3.0.1"
6790+
67666791
67676792
version "11.1.0"
67686793
resolved "https://registry.yarnpkg.com/eslint-plugin-node/-/eslint-plugin-node-11.1.0.tgz#c95544416ee4ada26740a30474eefc5402dc671d"
@@ -9622,6 +9647,11 @@ jsbn@~0.1.0:
96229647
resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513"
96239648
integrity sha1-peZUwuWi3rXyAdls77yoDA7y9RM=
96249649

9650+
jsdoctypeparser@^9.0.0:
9651+
version "9.0.0"
9652+
resolved "https://registry.yarnpkg.com/jsdoctypeparser/-/jsdoctypeparser-9.0.0.tgz#8c97e2fb69315eb274b0f01377eaa5c940bd7b26"
9653+
integrity sha512-jrTA2jJIL6/DAEILBEh2/w9QxCuwmvNXIry39Ay/HVfhE3o2yVV0U44blYkqdHA/OKloJEqvJy0xU+GSdE2SIw==
9654+
96259655
jsdom@^16.4.0:
96269656
version "16.4.0"
96279657
resolved "https://registry.yarnpkg.com/jsdom/-/jsdom-16.4.0.tgz#36005bde2d136f73eee1a830c6d45e55408edddb"
@@ -13040,6 +13070,11 @@ regexpu-core@^4.7.0, regexpu-core@^4.7.1:
1304013070
unicode-match-property-ecmascript "^1.0.4"
1304113071
unicode-match-property-value-ecmascript "^1.2.0"
1304213072

13073+
regextras@^0.7.1:
13074+
version "0.7.1"
13075+
resolved "https://registry.yarnpkg.com/regextras/-/regextras-0.7.1.tgz#be95719d5f43f9ef0b9fa07ad89b7c606995a3b2"
13076+
integrity sha512-9YXf6xtW+qzQ+hcMQXx95MOvfqXFgsKDZodX3qZB0x2n5Z94ioetIITsBtvJbiOyxa/6s9AtyweBLCdPmPko/w==
13077+
1304313078
registry-auth-token@^4.0.0:
1304413079
version "4.1.1"
1304513080
resolved "https://registry.yarnpkg.com/registry-auth-token/-/registry-auth-token-4.1.1.tgz#40a33be1e82539460f94328b0f7f0f84c16d9479"
@@ -13865,7 +13900,7 @@ spdx-exceptions@^2.1.0:
1386513900
resolved "https://registry.yarnpkg.com/spdx-exceptions/-/spdx-exceptions-2.3.0.tgz#3f28ce1a77a00372683eade4a433183527a2163d"
1386613901
integrity sha512-/tTrYOC7PPI1nUAgx34hUpqXuyJG+DTHJTnIULG4rDygi4xu/tfgmq1e1cIRwRzwZgo4NLySi+ricLkZkw4i5A==
1386713902

13868-
spdx-expression-parse@^3.0.0:
13903+
spdx-expression-parse@^3.0.0, spdx-expression-parse@^3.0.1:
1386913904
version "3.0.1"
1387013905
resolved "https://registry.yarnpkg.com/spdx-expression-parse/-/spdx-expression-parse-3.0.1.tgz#cf70f50482eefdc98e3ce0a6833e4a53ceeba679"
1387113906
integrity sha512-cbqHunsQWnJNE6KhVSMsMeH5H/L9EpymbzqTQ3uLwNCLZ1Q481oWaofqH7nO6V07xlXwY6PhQdQ2IedWx/ZK4Q==

0 commit comments

Comments
 (0)