Skip to content

Commit 07f3fbc

Browse files
committed
Fix lint issues
1 parent 33671cb commit 07f3fbc

File tree

9 files changed

+40
-39
lines changed

9 files changed

+40
-39
lines changed

.eslintrc.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,11 @@ module.exports = {
77
'no-console': 0,
88
'no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
99
'eslint-comments/disable-enable-pair': ['error', { allowWholeFile: true }],
10+
'prettier/prettier': [
11+
'error',
12+
{
13+
trailingComma: 'all',
14+
},
15+
],
1016
},
1117
}

.prettierignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
**/.cache/
2+
.github/
3+
**/dist/

.prettierrc

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,5 @@
22
"trailingComma": "all",
33
"tabWidth": 2,
44
"semi": false,
5-
"singleQuote": true,
6-
"overrides": [
7-
{
8-
"files": "*.scss",
9-
"options": {
10-
"singleQuote": true
11-
}
12-
}
13-
]
5+
"singleQuote": true
146
}

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ If you already have your own scraper but you still want to use MeiliSearch and `
8484
apiKey: 'XXX',
8585
indexUid: 'docs',
8686
inputSelector: '#search-bar-input',
87-
debug: true // Set debug to true if you want to inspect the dropdown
87+
debug: true, // Set debug to true if you want to inspect the dropdown
8888
})
8989
</script>
9090
</body>
@@ -154,7 +154,7 @@ docsSearchBar({
154154
const windowReference = window.open(suggestion.url, '_blank')
155155
windowReference.focus()
156156
}
157-
}
157+
},
158158
})
159159
```
160160

@@ -181,8 +181,8 @@ For example, you might want to increase the number of results displayed in the d
181181
```javascript
182182
docsSearchBar({
183183
meilisearchOptions: {
184-
limit: 10
185-
}
184+
limit: 10,
185+
},
186186
})
187187
```
188188

playgrounds/html/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
console.info(datasetNumber)
4141
console.info(context)
4242
},
43-
debug: true // Set debug to true if you want to inspect the dropdown
43+
debug: true, // Set debug to true if you want to inspect the dropdown
4444
})
4545
</script>
4646
<style>

src/lib/DocsSearchBar.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class DocsSearchBar {
8989
this.autocompleteOptions.cssClasses.root || 'meilisearch-autocomplete'
9090
this.autocompleteOptions.keyboardShortcuts =
9191
this.parseHotkeysAutocompleteOptions(
92-
this.autocompleteOptions.keyboardShortcuts
92+
this.autocompleteOptions.keyboardShortcuts,
9393
) || ['s', 191]
9494

9595
this.isSimpleLayout = layout === 'simple'
@@ -124,18 +124,18 @@ class DocsSearchBar {
124124
`.${this.autocompleteOptions.cssClasses.prefix}-suggestions a`,
125125
(event) => {
126126
event.preventDefault()
127-
}
127+
},
128128
)
129129
}
130130

131131
this.autocomplete.on(
132132
'autocomplete:selected',
133-
this.handleSelected.bind(null, this.autocomplete.autocomplete)
133+
this.handleSelected.bind(null, this.autocomplete.autocomplete),
134134
)
135135

136136
this.autocomplete.on(
137137
'autocomplete:shown',
138-
this.handleShown.bind(null, this.input)
138+
this.handleShown.bind(null, this.input),
139139
)
140140

141141
if (enhancedSearchInput) {
@@ -156,13 +156,13 @@ class DocsSearchBar {
156156

157157
if (typeof args.inputSelector !== 'string') {
158158
throw new Error(
159-
`Error: inputSelector:${args.inputSelector} must be a string. Each selector must match only one element and separated by ','`
159+
`Error: inputSelector:${args.inputSelector} must be a string. Each selector must match only one element and separated by ','`,
160160
)
161161
}
162162

163163
if (!DocsSearchBar.getInputFromSelector(args.inputSelector)) {
164164
throw new Error(
165-
`Error: No input element in the page matches ${args.inputSelector}`
165+
`Error: No input element in the page matches ${args.inputSelector}`,
166166
)
167167
}
168168
}
@@ -248,7 +248,7 @@ class DocsSearchBar {
248248
// eslint-disable-next-line no-param-reassign
249249
hit._formatted = utils.renameKeysWithLevels(
250250
cleanFormatted,
251-
'hierarchy_'
251+
'hierarchy_',
252252
)
253253
}
254254
const cleanHit = utils.replaceNullString(hit)
@@ -261,7 +261,7 @@ class DocsSearchBar {
261261
const groupedHitsByLvl1 = utils.groupBy(collection, 'lvl1')
262262
const flattenedHits = utils.flattenAndFlagFirst(
263263
groupedHitsByLvl1,
264-
'isSubCategoryHeader'
264+
'isSubCategoryHeader',
265265
)
266266
groupedHits[level] = flattenedHits
267267
})
@@ -281,7 +281,7 @@ class DocsSearchBar {
281281
utils.getHighlightedValue(hit, 'lvl6'),
282282
])
283283
.join(
284-
'<span class="aa-suggestion-title-separator" aria-hidden="true"> › </span>'
284+
'<span class="aa-suggestion-title-separator" aria-hidden="true"> › </span>',
285285
)
286286
const text = utils.getSnippetedValue(hit, 'content')
287287
const isTextOrSubcategoryNonEmpty =

src/lib/__tests__/DocsSearchBar-test.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ describe('DocsSearchBar', () => {
183183
MeiliSearch.calledWith({
184184
host: 'https://test.getmeili.com',
185185
apiKey: 'apiKey',
186-
})
186+
}),
187187
).toBe(true)
188188
})
189189
it('should instantiate autocomplete.js', () => {
@@ -212,7 +212,7 @@ describe('DocsSearchBar', () => {
212212
autoselect: true,
213213
ariaLabel: 'search input',
214214
keyboardShortcuts: ['s', 191],
215-
})
215+
}),
216216
).toBe(true)
217217
})
218218
it('should listen to the selected and shown event of autocomplete', () => {
@@ -387,7 +387,7 @@ describe('DocsSearchBar', () => {
387387
}
388388
expect(client.index.calledWith('indexUID')).toBe(true)
389389
expect(
390-
client.index('indexUid').search.calledWith('query', expectedParams)
390+
client.index('indexUid').search.calledWith('query', expectedParams),
391391
).toBe(true)
392392
})
393393
})
@@ -397,7 +397,7 @@ describe('DocsSearchBar', () => {
397397
// Given
398398
const actual = docsSearchBar.getAutocompleteSource(
399399
false,
400-
(query) => `${query} modified`
400+
(query) => `${query} modified`,
401401
)
402402

403403
// When
@@ -415,7 +415,7 @@ describe('DocsSearchBar', () => {
415415
expect(
416416
client
417417
.index('indexUID')
418-
.search.calledWith('query modified', expectedParams)
418+
.search.calledWith('query modified', expectedParams),
419419
).toBe(true)
420420
expect(client.index.calledWith('indexUID')).toBe(true)
421421
})
@@ -440,7 +440,7 @@ describe('DocsSearchBar', () => {
440440

441441
return new Promise((resolve) => {
442442
expect(window.location.assign).toHaveBeenCalledWith(
443-
'https://website.com/doc/page'
443+
'https://website.com/doc/page',
444444
)
445445
resolve()
446446
})
@@ -475,7 +475,7 @@ describe('DocsSearchBar', () => {
475475
expect(customHandleSelected).toHaveBeenCalledWith(
476476
expectedInput,
477477
expectedEvent,
478-
expectedSuggestion
478+
expectedSuggestion,
479479
)
480480
resolve()
481481
})
@@ -527,7 +527,7 @@ describe('DocsSearchBar', () => {
527527
undefined, // Event
528528
mockSuggestion,
529529
undefined, // Dataset
530-
mockContext
530+
mockContext,
531531
)
532532

533533
return new Promise((resolve) => {
@@ -552,7 +552,7 @@ describe('DocsSearchBar', () => {
552552
undefined, // Event
553553
undefined, // Suggestion
554554
undefined, // Dataset
555-
mockContext
555+
mockContext,
556556
)
557557

558558
return new Promise((resolve) => {
@@ -580,7 +580,7 @@ describe('DocsSearchBar', () => {
580580
dsb.autocomplete.trigger('autocomplete:shown')
581581

582582
expect($('.meilisearch-autocomplete').attr('class')).toEqual(
583-
'meilisearch-autocomplete meilisearch-autocomplete-right'
583+
'meilisearch-autocomplete meilisearch-autocomplete-right',
584584
)
585585
})
586586
})
@@ -861,7 +861,7 @@ describe('DocsSearchBar', () => {
861861
'<span class="aa-suggestion-title-separator" aria-hidden="true"> › </span>'
862862
// Then
863863
expect(actual[0].title).toEqual(
864-
`Geo-search${separator}Foo${separator}Bar${separator}Baz`
864+
`Geo-search${separator}Foo${separator}Bar${separator}Baz`,
865865
)
866866
})
867867
it('should concatenate highlighted elements', () => {

src/lib/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ const utils = {
203203
// eslint-disable-next-line no-param-reassign
204204
item[flag] = index === 0
205205
return item
206-
})
206+
}),
207207
)
208208
return this.flatten(values)
209209
},

src/styles/_variables.scss

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ $searchbox-config: (
1616
icon-color: #6d7e96,
1717
icon-background: #458ee1,
1818
icon-background-opacity: 0,
19-
icon-clear-size: 8px
19+
icon-clear-size: 8px,
2020
) !default;
2121

2222
$searchbox-config-dark: (
@@ -27,7 +27,7 @@ $searchbox-config-dark: (
2727
placeholder-color: #bbbbbb,
2828
text-color: #eaeaea,
2929
icon-color: #6d7e96,
30-
icon-background: #458ee1
30+
icon-background: #458ee1,
3131
) !default;
3232

3333
// DROPDOWN
@@ -54,7 +54,7 @@ $dropdown-config: (
5454
highlight-opacity: 0.1,
5555
highlight-type: underline,
5656
suggestion-background-color: #f8f8f8,
57-
hover-color-opacity: 0.05
57+
hover-color-opacity: 0.05,
5858
) !default;
5959

6060
// Dropdown dark mode
@@ -69,7 +69,7 @@ $dropdown-config-dark: (
6969
border-color: #5b6369,
7070
highlight-color: #3881ff,
7171
suggestion-background-color: #6b7278,
72-
hover-color-opacity: 0.5
72+
hover-color-opacity: 0.5,
7373
) !default;
7474

7575
$builder-height: 260px;

0 commit comments

Comments
 (0)