Skip to content

Commit 564b627

Browse files
authored
chore(javascript-tooling): add eslint (#21)
1 parent 1a23707 commit 564b627

File tree

98 files changed

+3032
-678
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+3032
-678
lines changed

.eslintignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules
2+
dist
3+
playground
4+
build

.eslintrc.js

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
module.exports = {
2+
extends: [
3+
'algolia',
4+
'algolia/typescript',
5+
'plugin:import/errors',
6+
'plugin:import/warnings',
7+
'plugin:import/typescript',
8+
],
9+
10+
env: {
11+
es6: true,
12+
},
13+
14+
parser: '@typescript-eslint/parser',
15+
16+
ignorePatterns: ['.eslintrc.js'],
17+
18+
settings: {
19+
'import/extensions': ['.js', '.ts'],
20+
'import/parsers': {
21+
'@typescript-eslint/parser': ['.ts'],
22+
},
23+
'import/ignore': ['node_modules'],
24+
},
25+
26+
plugins: ['algolia', 'unused-imports'],
27+
28+
rules: {
29+
// disabled
30+
'no-bitwise': 0,
31+
'@typescript-eslint/no-namespace': 0,
32+
'max-classes-per-file': 0,
33+
'no-unused-vars': 0,
34+
'@typescript-eslint/prefer-enum-initializers': 0,
35+
// there's a conflict when declaring `type` and `namespaces`, even with `ignoreDeclarationMerge`
36+
'no-redeclare': 0,
37+
'@typescript-eslint/no-redeclare': 0,
38+
39+
'@typescript-eslint/no-unused-vars': 2,
40+
'unused-imports/no-unused-imports-ts': 2,
41+
'@typescript-eslint/member-ordering': [
42+
'error',
43+
{
44+
default: [
45+
'protected-instance-method',
46+
'private-instance-method',
47+
'public-instance-method',
48+
],
49+
},
50+
],
51+
'@typescript-eslint/ban-types': [
52+
'error',
53+
{
54+
types: {
55+
object: {
56+
message: 'Use Record instead',
57+
fixWith: 'Record<string, any>',
58+
},
59+
},
60+
},
61+
],
62+
},
63+
};

.github/workflows/client_javascript.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
run: yarn client:build-js:recommend
4141

4242
- name: Lint
43-
run: yarn prettier --check clients/algoliasearch-client-javascript
43+
run: yarn lint
4444

4545
build-failure:
4646
if: ${{ github.event.workflow_run.conclusion == 'failure' }}

.prettierrc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
22
"trailingComma": "es5",
3-
"singleQuote": true,
4-
"printWidth": 100
3+
"singleQuote": true
54
}

clients/algoliasearch-client-javascript/client-search/model/baseIndexSettings.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,49 +2,49 @@ export type BaseIndexSettings = {
22
/**
33
* Creates replicas, exact copies of an index.
44
*/
5-
replicas?: Array<string>;
5+
replicas?: string[];
66
/**
77
* Set the maximum number of hits accessible via pagination.
88
*/
99
paginationLimitedTo?: number;
1010
/**
1111
* A list of words for which you want to turn off typo tolerance.
1212
*/
13-
disableTypoToleranceOnWords?: Array<string>;
13+
disableTypoToleranceOnWords?: string[];
1414
/**
1515
* Specify on which attributes to apply transliteration.
1616
*/
17-
attributesToTransliterate?: Array<string>;
17+
attributesToTransliterate?: string[];
1818
/**
1919
* List of attributes on which to do a decomposition of camel case words.
2020
*/
21-
camelCaseAttributes?: Array<string>;
21+
camelCaseAttributes?: string[];
2222
/**
2323
* Specify on which attributes in your index Algolia should apply word segmentation, also known as decompounding.
2424
*/
25-
decompoundedAttributes?: { [key: string]: object };
25+
decompoundedAttributes?: { [key: string]: Record<string, any> };
2626
/**
2727
* Sets the languages at the index level for language-specific processing such as tokenization and normalization.
2828
*/
29-
indexLanguages?: Array<string>;
29+
indexLanguages?: string[];
3030
/**
3131
* Whether promoted results should match the filters of the current search, except for geographic filters.
3232
*/
3333
filterPromotes?: boolean;
3434
/**
3535
* List of attributes on which you want to disable prefix matching.
3636
*/
37-
disablePrefixOnAttributes?: Array<string>;
37+
disablePrefixOnAttributes?: string[];
3838
/**
3939
* Enables compression of large integer arrays.
4040
*/
4141
allowCompressionOfIntegerArray?: boolean;
4242
/**
4343
* List of numeric attributes that can be used as numerical filters.
4444
*/
45-
numericAttributesForFiltering?: Array<string>;
45+
numericAttributesForFiltering?: string[];
4646
/**
4747
* Lets you store custom data in your indices.
4848
*/
49-
userData?: { [key: string]: object };
49+
userData?: { [key: string]: Record<string, any> };
5050
};

clients/algoliasearch-client-javascript/client-search/model/baseSearchParams.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,27 @@ export type BaseSearchParams = {
1414
/**
1515
* Filter hits by facet value.
1616
*/
17-
facetFilters?: Array<string>;
17+
facetFilters?: string[];
1818
/**
1919
* Create filters for ranking purposes, where records that match the filter are ranked higher, or lower in the case of a negative optional filter.
2020
*/
21-
optionalFilters?: Array<string>;
21+
optionalFilters?: string[];
2222
/**
2323
* Filter on numeric attributes.
2424
*/
25-
numericFilters?: Array<string>;
25+
numericFilters?: string[];
2626
/**
2727
* Filter hits by tags.
2828
*/
29-
tagFilters?: Array<string>;
29+
tagFilters?: string[];
3030
/**
3131
* Determines how to calculate the total score for filtering.
3232
*/
3333
sumOrFiltersScores?: boolean;
3434
/**
3535
* Retrieve facets and their facet values.
3636
*/
37-
facets?: Array<string>;
37+
facets?: string[];
3838
/**
3939
* Maximum number of facet values to return for each facet during a regular search.
4040
*/
@@ -82,19 +82,19 @@ export type BaseSearchParams = {
8282
/**
8383
* Search inside a rectangular area (in geo coordinates).
8484
*/
85-
insideBoundingBox?: Array<number>;
85+
insideBoundingBox?: number[];
8686
/**
8787
* Search inside a polygon (in geo coordinates).
8888
*/
89-
insidePolygon?: Array<number>;
89+
insidePolygon?: number[];
9090
/**
9191
* This parameter changes the default values of certain parameters and settings that work best for a natural language query, such as ignorePlurals, removeStopWords, removeWordsIfNoResults, analyticsTags and ruleContexts. These parameters and settings work well together when the query is formatted in natural language instead of keywords, for example when your user performs a voice search.
9292
*/
93-
naturalLanguages?: Array<string>;
93+
naturalLanguages?: string[];
9494
/**
9595
* Enables contextual rules.
9696
*/
97-
ruleContexts?: Array<string>;
97+
ruleContexts?: string[];
9898
/**
9999
* Define the impact of the Personalization feature.
100100
*/
@@ -118,7 +118,7 @@ export type BaseSearchParams = {
118118
/**
119119
* List of tags to apply to the query for analytics purposes.
120120
*/
121-
analyticsTags?: Array<string>;
121+
analyticsTags?: string[];
122122
/**
123123
* Whether to include or exclude a query from the processing-time percentile computation.
124124
*/

clients/algoliasearch-client-javascript/client-search/model/baseSearchResponse.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { BaseSearchResponseFacetsStats } from './baseSearchResponseFacetsStats';
1+
import type { BaseSearchResponseFacetsStats } from './baseSearchResponseFacetsStats';
22

33
export type BaseSearchResponse = {
44
/**
@@ -22,11 +22,11 @@ export type BaseSearchResponse = {
2222
*/
2323
exhaustiveFacetsCount?: boolean;
2424
/**
25-
* Indicate if the nbHits count was exhaustive or approximate
25+
* Indicate if the nbHits count was exhaustive or approximate.
2626
*/
2727
exhaustiveNbHits: boolean;
2828
/**
29-
* Indicate if the typo-tolerence search was exhaustive or approximate (only included when typo-tolerance is enabled)
29+
* Indicate if the typo-tolerence search was exhaustive or approximate (only included when typo-tolerance is enabled).
3030
*/
3131
exhaustiveTypo: boolean;
3232
/**
@@ -54,15 +54,15 @@ export type BaseSearchResponse = {
5454
*/
5555
message?: string;
5656
/**
57-
* Number of hits that the search query matched
57+
* Number of hits that the search query matched.
5858
*/
5959
nbHits: number;
6060
/**
61-
* Number of pages available for the current query
61+
* Number of pages available for the current query.
6262
*/
6363
nbPages: number;
6464
/**
65-
* The number of hits selected and sorted by the relevant sort algorithm
65+
* The number of hits selected and sorted by the relevant sort algorithm.
6666
*/
6767
nbSortedHits?: number;
6868
/**
@@ -96,5 +96,5 @@ export type BaseSearchResponse = {
9696
/**
9797
* Lets you store custom data in your indices.
9898
*/
99-
userData?: { [key: string]: object };
99+
userData?: { [key: string]: Record<string, any> };
100100
};
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
import { Operation } from './operation';
1+
import type { Operation } from './operation';
22

3+
/**
4+
* The `batch` requests.
5+
*/
36
export type BatchObject = {
4-
requests?: Array<Operation>;
7+
requests?: Operation[];
58
};
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
export type BatchResponse = {
22
/**
3-
* taskID of the indexing task to wait for.
3+
* TaskID of the indexing task to wait for.
44
*/
55
taskID?: number;
66
/**
7-
* List of objectID
7+
* List of objectID.
88
*/
9-
objectIDs?: Array<string>;
9+
objectIDs?: string[];
1010
};

clients/algoliasearch-client-javascript/client-search/model/errorBase.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Error
2+
* Error.
33
*/
44
export type ErrorBase = {
55
message?: string;

clients/algoliasearch-client-javascript/client-search/model/highlightResult.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export type HighlightResult = {
1010
/**
1111
* List of words from the query that matched the object.
1212
*/
13-
matchedWords?: Array<string>;
13+
matchedWords?: string[];
1414
/**
1515
* Whether the entire attribute value is highlighted.
1616
*/
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { BaseIndexSettings } from './baseIndexSettings';
2-
import { IndexSettingsAsSearchParams } from './indexSettingsAsSearchParams';
1+
import type { BaseIndexSettings } from './baseIndexSettings';
2+
import type { IndexSettingsAsSearchParams } from './indexSettingsAsSearchParams';
33

44
export type IndexSettings = BaseIndexSettings & IndexSettingsAsSearchParams;

0 commit comments

Comments
 (0)