mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2026-07-29 09:12:35 -04:00
Migrated to ESLint
This commit is contained in:
@@ -31,7 +31,7 @@ import { share } from "rxjs/operators"
|
||||
/**
|
||||
* Set up Clipboard.js integration
|
||||
*
|
||||
* @return Clipboard.js event observable
|
||||
* @returns Clipboard.js event observable
|
||||
*/
|
||||
export function setupClipboardJS(): Observable<ClipboardJS.Event> {
|
||||
if (!ClipboardJS.isSupported())
|
||||
|
||||
6
src/assets/javascripts/integrations/search/_/.eslintrc
Normal file
6
src/assets/javascripts/integrations/search/_/.eslintrc
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"rules": {
|
||||
"@typescript-eslint/no-explicit-any": "off",
|
||||
"no-console": "off"
|
||||
}
|
||||
}
|
||||
@@ -113,7 +113,7 @@ export type SearchResult = Array<SearchDocument & SearchMetadata>
|
||||
* @param a - 1st list of strings
|
||||
* @param b - 2nd list of strings
|
||||
*
|
||||
* @return Difference
|
||||
* @returns Difference
|
||||
*/
|
||||
function difference(a: string[], b: string[]): string[] {
|
||||
const [x, y] = [new Set(a), new Set(b)]
|
||||
@@ -168,7 +168,7 @@ export class Search {
|
||||
|
||||
/* If no index was given, create it */
|
||||
if (typeof index === "undefined") {
|
||||
this.index = lunr(function() {
|
||||
this.index = lunr(function () {
|
||||
|
||||
/* Set up multi-language support */
|
||||
if (config.lang.length === 1 && config.lang[0] !== "en") {
|
||||
@@ -222,7 +222,7 @@ export class Search {
|
||||
*
|
||||
* @param query - Query value
|
||||
*
|
||||
* @return Search results
|
||||
* @returns Search results
|
||||
*/
|
||||
public search(query: string): SearchResult[] {
|
||||
if (query) {
|
||||
@@ -283,7 +283,6 @@ export class Search {
|
||||
|
||||
/* Log errors to console (for now) */
|
||||
} catch {
|
||||
// tslint:disable-next-line no-console
|
||||
console.warn(`Invalid query: ${query} – see https://bit.ly/2s3ChXG`)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ export type SearchDocumentMap = Map<string, SearchDocument>
|
||||
*
|
||||
* @param docs - Search index documents
|
||||
*
|
||||
* @return Search document map
|
||||
* @returns Search document map
|
||||
*/
|
||||
export function setupSearchDocumentMap(
|
||||
docs: SearchIndexDocument[]
|
||||
|
||||
@@ -31,7 +31,7 @@ import { SearchIndexConfig } from "../_"
|
||||
*
|
||||
* @param value - Value
|
||||
*
|
||||
* @return Highlighted value
|
||||
* @returns Highlighted value
|
||||
*/
|
||||
export type SearchHighlightFn = (value: string) => string
|
||||
|
||||
@@ -40,7 +40,7 @@ export type SearchHighlightFn = (value: string) => string
|
||||
*
|
||||
* @param query - Query value
|
||||
*
|
||||
* @return Search highlight function
|
||||
* @returns Search highlight function
|
||||
*/
|
||||
export type SearchHighlightFactoryFn = (query: string) => SearchHighlightFn
|
||||
|
||||
@@ -53,7 +53,7 @@ export type SearchHighlightFactoryFn = (query: string) => SearchHighlightFn
|
||||
*
|
||||
* @param config - Search index configuration
|
||||
*
|
||||
* @return Search highlight factory function
|
||||
* @returns Search highlight factory function
|
||||
*/
|
||||
export function setupSearchHighlighter(
|
||||
config: SearchIndexConfig
|
||||
@@ -79,6 +79,6 @@ export function setupSearchHighlighter(
|
||||
/* Highlight string value */
|
||||
return value => value
|
||||
.replace(match, highlight)
|
||||
.replace(/<\/mark>(\s+)<mark[^>]*>/img, "\$1")
|
||||
.replace(/<\/mark>(\s+)<mark[^>]*>/img, "$1")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"rules": {
|
||||
"@typescript-eslint/no-explicit-any": "off"
|
||||
}
|
||||
}
|
||||
@@ -48,7 +48,7 @@ export type SearchQueryTerms = Record<string, boolean>
|
||||
*
|
||||
* @param value - Query value
|
||||
*
|
||||
* @return Search query clauses
|
||||
* @returns Search query clauses
|
||||
*/
|
||||
export function parseSearchQuery(
|
||||
value: string
|
||||
@@ -67,7 +67,7 @@ export function parseSearchQuery(
|
||||
* @param query - Search query clauses
|
||||
* @param terms - Search terms
|
||||
*
|
||||
* @return Search query terms
|
||||
* @returns Search query terms
|
||||
*/
|
||||
export function getSearchQueryTerms(
|
||||
query: SearchQueryClause[], terms: string[]
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"rules": {
|
||||
"no-control-regex": "off"
|
||||
}
|
||||
}
|
||||
@@ -29,7 +29,7 @@
|
||||
*
|
||||
* @param value - Query value
|
||||
*
|
||||
* @return Transformed query value
|
||||
* @returns Transformed query value
|
||||
*/
|
||||
export type SearchTransformFn = (value: string) => string
|
||||
|
||||
@@ -56,7 +56,7 @@ export type SearchTransformFn = (value: string) => string
|
||||
*
|
||||
* @param query - Query value
|
||||
*
|
||||
* @return Transformed query value
|
||||
* @returns Transformed query value
|
||||
*/
|
||||
export function defaultTransform(query: string): string {
|
||||
return query
|
||||
|
||||
@@ -52,7 +52,7 @@ export type SearchWorker = WorkerHandler<SearchMessage>
|
||||
*
|
||||
* @param data - Search index
|
||||
*
|
||||
* @return Search index
|
||||
* @returns Search index
|
||||
*/
|
||||
function setupSearchIndex(
|
||||
{ config, docs, index }: SearchIndex
|
||||
@@ -91,7 +91,7 @@ function setupSearchIndex(
|
||||
* @param url - Worker URL
|
||||
* @param index - Promise resolving with search index
|
||||
*
|
||||
* @return Search worker
|
||||
* @returns Search worker
|
||||
*/
|
||||
export function setupSearchWorker(
|
||||
url: string, index: Promise<SearchIndex>
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"rules": {
|
||||
"@typescript-eslint/no-misused-promises": "off"
|
||||
}
|
||||
}
|
||||
@@ -72,7 +72,7 @@ let index: Search
|
||||
*
|
||||
* @param config - Search index configuration
|
||||
*
|
||||
* @return Promise resolving with no result
|
||||
* @returns Promise resolving with no result
|
||||
*/
|
||||
async function setupSearchLanguages(
|
||||
config: SearchIndexConfig
|
||||
@@ -116,7 +116,7 @@ async function setupSearchLanguages(
|
||||
*
|
||||
* @param message - Source message
|
||||
*
|
||||
* @return Target message
|
||||
* @returns Target message
|
||||
*/
|
||||
export async function handler(
|
||||
message: SearchMessage
|
||||
|
||||
@@ -89,7 +89,7 @@ export type SearchMessage =
|
||||
*
|
||||
* @param message - Search worker message
|
||||
*
|
||||
* @return Test result
|
||||
* @returns Test result
|
||||
*/
|
||||
export function isSearchSetupMessage(
|
||||
message: SearchMessage
|
||||
@@ -102,7 +102,7 @@ export function isSearchSetupMessage(
|
||||
*
|
||||
* @param message - Search worker message
|
||||
*
|
||||
* @return Test result
|
||||
* @returns Test result
|
||||
*/
|
||||
export function isSearchReadyMessage(
|
||||
message: SearchMessage
|
||||
@@ -115,7 +115,7 @@ export function isSearchReadyMessage(
|
||||
*
|
||||
* @param message - Search worker message
|
||||
*
|
||||
* @return Test result
|
||||
* @returns Test result
|
||||
*/
|
||||
export function isSearchQueryMessage(
|
||||
message: SearchMessage
|
||||
@@ -128,7 +128,7 @@ export function isSearchQueryMessage(
|
||||
*
|
||||
* @param message - Search worker message
|
||||
*
|
||||
* @return Test result
|
||||
* @returns Test result
|
||||
*/
|
||||
export function isSearchResultMessage(
|
||||
message: SearchMessage
|
||||
|
||||
Reference in New Issue
Block a user