Skip to content

chore(javascript-tooling): add eslint #21

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Dec 1, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
dist
playground
build
63 changes: 63 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
module.exports = {
extends: [
'algolia',
'algolia/typescript',
'plugin:import/errors',
'plugin:import/warnings',
'plugin:import/typescript',
],

env: {
es6: true,
},

parser: '@typescript-eslint/parser',

ignorePatterns: ['.eslintrc.js'],

settings: {
'import/extensions': ['.js', '.ts'],
'import/parsers': {
'@typescript-eslint/parser': ['.ts'],
},
'import/ignore': ['node_modules'],
},

plugins: ['algolia', 'unused-imports'],

rules: {
// disabled
'no-bitwise': 0,
'@typescript-eslint/no-namespace': 0,
'max-classes-per-file': 0,
'no-unused-vars': 0,
'@typescript-eslint/prefer-enum-initializers': 0,
// there's a conflict when declaring `type` and `namespaces`, even with `ignoreDeclarationMerge`
'no-redeclare': 0,
'@typescript-eslint/no-redeclare': 0,

'@typescript-eslint/no-unused-vars': 2,
'unused-imports/no-unused-imports-ts': 2,
'@typescript-eslint/member-ordering': [
'error',
{
default: [
'protected-instance-method',
'private-instance-method',
'public-instance-method',
],
},
],
'@typescript-eslint/ban-types': [
'error',
{
types: {
object: {
message: 'Use Record instead',
fixWith: 'Record<string, any>',
},
},
},
],
},
};
2 changes: 1 addition & 1 deletion .github/workflows/client_javascript.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
run: yarn client:build-js:recommend

- name: Lint
run: yarn prettier --check clients/algoliasearch-client-javascript
run: yarn lint

build-failure:
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
Expand Down
3 changes: 1 addition & 2 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"trailingComma": "es5",
"singleQuote": true,
"printWidth": 100
"singleQuote": true
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,49 +2,49 @@ export type BaseIndexSettings = {
/**
* Creates replicas, exact copies of an index.
*/
replicas?: Array<string>;
replicas?: string[];
/**
* Set the maximum number of hits accessible via pagination.
*/
paginationLimitedTo?: number;
/**
* A list of words for which you want to turn off typo tolerance.
*/
disableTypoToleranceOnWords?: Array<string>;
disableTypoToleranceOnWords?: string[];
/**
* Specify on which attributes to apply transliteration.
*/
attributesToTransliterate?: Array<string>;
attributesToTransliterate?: string[];
/**
* List of attributes on which to do a decomposition of camel case words.
*/
camelCaseAttributes?: Array<string>;
camelCaseAttributes?: string[];
/**
* Specify on which attributes in your index Algolia should apply word segmentation, also known as decompounding.
*/
decompoundedAttributes?: { [key: string]: object };
decompoundedAttributes?: { [key: string]: Record<string, any> };
/**
* Sets the languages at the index level for language-specific processing such as tokenization and normalization.
*/
indexLanguages?: Array<string>;
indexLanguages?: string[];
/**
* Whether promoted results should match the filters of the current search, except for geographic filters.
*/
filterPromotes?: boolean;
/**
* List of attributes on which you want to disable prefix matching.
*/
disablePrefixOnAttributes?: Array<string>;
disablePrefixOnAttributes?: string[];
/**
* Enables compression of large integer arrays.
*/
allowCompressionOfIntegerArray?: boolean;
/**
* List of numeric attributes that can be used as numerical filters.
*/
numericAttributesForFiltering?: Array<string>;
numericAttributesForFiltering?: string[];
/**
* Lets you store custom data in your indices.
*/
userData?: { [key: string]: object };
userData?: { [key: string]: Record<string, any> };
};
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,27 @@ export type BaseSearchParams = {
/**
* Filter hits by facet value.
*/
facetFilters?: Array<string>;
facetFilters?: string[];
/**
* Create filters for ranking purposes, where records that match the filter are ranked higher, or lower in the case of a negative optional filter.
*/
optionalFilters?: Array<string>;
optionalFilters?: string[];
/**
* Filter on numeric attributes.
*/
numericFilters?: Array<string>;
numericFilters?: string[];
/**
* Filter hits by tags.
*/
tagFilters?: Array<string>;
tagFilters?: string[];
/**
* Determines how to calculate the total score for filtering.
*/
sumOrFiltersScores?: boolean;
/**
* Retrieve facets and their facet values.
*/
facets?: Array<string>;
facets?: string[];
/**
* Maximum number of facet values to return for each facet during a regular search.
*/
Expand Down Expand Up @@ -82,19 +82,19 @@ export type BaseSearchParams = {
/**
* Search inside a rectangular area (in geo coordinates).
*/
insideBoundingBox?: Array<number>;
insideBoundingBox?: number[];
/**
* Search inside a polygon (in geo coordinates).
*/
insidePolygon?: Array<number>;
insidePolygon?: number[];
/**
* 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.
*/
naturalLanguages?: Array<string>;
naturalLanguages?: string[];
/**
* Enables contextual rules.
*/
ruleContexts?: Array<string>;
ruleContexts?: string[];
/**
* Define the impact of the Personalization feature.
*/
Expand All @@ -118,7 +118,7 @@ export type BaseSearchParams = {
/**
* List of tags to apply to the query for analytics purposes.
*/
analyticsTags?: Array<string>;
analyticsTags?: string[];
/**
* Whether to include or exclude a query from the processing-time percentile computation.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BaseSearchResponseFacetsStats } from './baseSearchResponseFacetsStats';
import type { BaseSearchResponseFacetsStats } from './baseSearchResponseFacetsStats';

export type BaseSearchResponse = {
/**
Expand All @@ -22,11 +22,11 @@ export type BaseSearchResponse = {
*/
exhaustiveFacetsCount?: boolean;
/**
* Indicate if the nbHits count was exhaustive or approximate
* Indicate if the nbHits count was exhaustive or approximate.
*/
exhaustiveNbHits: boolean;
/**
* Indicate if the typo-tolerence search was exhaustive or approximate (only included when typo-tolerance is enabled)
* Indicate if the typo-tolerence search was exhaustive or approximate (only included when typo-tolerance is enabled).
*/
exhaustiveTypo: boolean;
/**
Expand Down Expand Up @@ -54,15 +54,15 @@ export type BaseSearchResponse = {
*/
message?: string;
/**
* Number of hits that the search query matched
* Number of hits that the search query matched.
*/
nbHits: number;
/**
* Number of pages available for the current query
* Number of pages available for the current query.
*/
nbPages: number;
/**
* The number of hits selected and sorted by the relevant sort algorithm
* The number of hits selected and sorted by the relevant sort algorithm.
*/
nbSortedHits?: number;
/**
Expand Down Expand Up @@ -96,5 +96,5 @@ export type BaseSearchResponse = {
/**
* Lets you store custom data in your indices.
*/
userData?: { [key: string]: object };
userData?: { [key: string]: Record<string, any> };
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { Operation } from './operation';
import type { Operation } from './operation';

/**
* The `batch` requests.
*/
export type BatchObject = {
requests?: Array<Operation>;
requests?: Operation[];
};
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
export type BatchResponse = {
/**
* taskID of the indexing task to wait for.
* TaskID of the indexing task to wait for.
*/
taskID?: number;
/**
* List of objectID
* List of objectID.
*/
objectIDs?: Array<string>;
objectIDs?: string[];
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Error
* Error.
*/
export type ErrorBase = {
message?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export type HighlightResult = {
/**
* List of words from the query that matched the object.
*/
matchedWords?: Array<string>;
matchedWords?: string[];
/**
* Whether the entire attribute value is highlighted.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BaseIndexSettings } from './baseIndexSettings';
import { IndexSettingsAsSearchParams } from './indexSettingsAsSearchParams';
import type { BaseIndexSettings } from './baseIndexSettings';
import type { IndexSettingsAsSearchParams } from './indexSettingsAsSearchParams';

export type IndexSettings = BaseIndexSettings & IndexSettingsAsSearchParams;
Loading