Skip to content

Commit add5aed

Browse files
committed
style: remove semicolons from codebase
- Change ESLint rule from semi: 'always' to semi: 'never' - Remove all semicolons using ESLint auto-fix - Pure formatting change, no logic modifications
1 parent ceacbc6 commit add5aed

Some content is hidden

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

46 files changed

+1341
-1341
lines changed

eslint.config.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export default [
2626
'@typescript-eslint': tsPlugin
2727
},
2828
rules: {
29-
semi: ['error', 'always'],
29+
semi: ['error', 'never'],
3030
'@typescript-eslint/no-explicit-any': 'error',
3131
'no-unused-vars': 'off',
3232
'@typescript-eslint/no-unused-vars': [
@@ -56,7 +56,7 @@ export default [
5656
}
5757
},
5858
rules: {
59-
semi: ['error', 'always'],
59+
semi: ['error', 'never'],
6060
'no-unused-vars': ['error', { argsIgnorePattern: '^_' }]
6161
}
6262
},

src/adapter-helpers.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { ElasticsearchServiceOptions } from './types';
2-
import { errors } from '@feathersjs/errors';
3-
import { Client } from '@elastic/elasticsearch';
1+
import { ElasticsearchServiceOptions } from './types'
2+
import { errors } from '@feathersjs/errors'
3+
import { Client } from '@elastic/elasticsearch'
44

55
/**
66
* Validates adapter options and throws errors for missing required fields
@@ -9,20 +9,20 @@ import { Client } from '@elastic/elasticsearch';
99
*/
1010
export function validateOptions(options: Partial<ElasticsearchServiceOptions>): void {
1111
if (!options) {
12-
throw new errors.BadRequest('Elasticsearch service requires `options`');
12+
throw new errors.BadRequest('Elasticsearch service requires `options`')
1313
}
1414

1515
if (!options.Model && !options.elasticsearch) {
1616
throw new errors.BadRequest(
1717
'Elasticsearch service requires `options.Model` or `options.elasticsearch` to be provided'
18-
);
18+
)
1919
}
2020

21-
const esConfig = options.elasticsearch as { index?: string } | undefined;
21+
const esConfig = options.elasticsearch as { index?: string } | undefined
2222
if (!options.index && (!options.elasticsearch || !esConfig?.index)) {
2323
throw new errors.BadRequest(
2424
'Elasticsearch service requires `options.index` or `options.elasticsearch.index` to be provided'
25-
);
25+
)
2626
}
2727
}
2828

@@ -38,10 +38,10 @@ export function setupPropertyAliases(
3838
properties.forEach((name) =>
3939
Object.defineProperty(instance, name, {
4040
get() {
41-
return this.options[name];
41+
return this.options[name]
4242
}
4343
})
44-
);
44+
)
4545
}
4646

4747
/**
@@ -53,9 +53,9 @@ export function extractModelAndIndex(options: ElasticsearchServiceOptions): {
5353
Model: Client | Record<string, unknown>
5454
index: string
5555
} {
56-
const Model = options.Model || options.elasticsearch;
57-
const esConfig = options.elasticsearch as { index?: string } | undefined;
58-
const index = options.index || esConfig?.index;
56+
const Model = options.Model || options.elasticsearch
57+
const esConfig = options.elasticsearch as { index?: string } | undefined
58+
const index = options.index || esConfig?.index
5959

60-
return { Model: Model as Client, index: index as string };
60+
return { Model: Model as Client, index: index as string }
6161
}

src/adapter.ts

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
// import { _ } from "@feathersjs/commons";
2-
import { AdapterBase, filterQuery } from '@feathersjs/adapter-commons';
3-
import { Client } from '@elastic/elasticsearch';
2+
import { AdapterBase, filterQuery } from '@feathersjs/adapter-commons'
3+
import { Client } from '@elastic/elasticsearch'
44
import {
55
ElasticsearchServiceOptions,
66
ElasticsearchServiceParams,
77
ElasticAdapterInterface,
88
SecurityConfig
9-
} from './types';
10-
import { errorHandler } from './error-handler';
11-
import { DEFAULT_SECURITY_CONFIG } from './utils/security';
9+
} from './types'
10+
import { errorHandler } from './error-handler'
11+
import { DEFAULT_SECURITY_CONFIG } from './utils/security'
1212
// const errors = require('@feathersjs/errors');
1313
// const debug = makeDebug('feathers-elasticsearch');
1414

15-
import * as methods from './methods/index';
15+
import * as methods from './methods/index'
1616

1717
/**
1818
* Elasticsearch adapter for FeathersJS
@@ -22,16 +22,16 @@ import * as methods from './methods/index';
2222
* @extends {AdapterBase}
2323
*/
2424
export class ElasticAdapter extends AdapterBase implements ElasticAdapterInterface {
25-
Model!: Client;
26-
index!: string;
27-
parent?: string;
28-
routing?: string;
29-
join?: string;
30-
meta!: string;
31-
esVersion?: string;
32-
esParams?: Record<string, unknown>;
33-
security!: Required<SecurityConfig>;
34-
core: Record<string, unknown>;
25+
Model!: Client
26+
index!: string
27+
parent?: string
28+
routing?: string
29+
join?: string
30+
meta!: string
31+
esVersion?: string
32+
esParams?: Record<string, unknown>
33+
security!: Required<SecurityConfig>
34+
core: Record<string, unknown>
3535

3636
/**
3737
* Creates an instance of ElasticAdapter
@@ -40,16 +40,16 @@ export class ElasticAdapter extends AdapterBase implements ElasticAdapterInterfa
4040
*/
4141
constructor(options: ElasticsearchServiceOptions) {
4242
if (typeof options !== 'object') {
43-
throw new Error('Elasticsearch options have to be provided');
43+
throw new Error('Elasticsearch options have to be provided')
4444
}
4545

4646
if (!options || !options.Model) {
47-
throw new Error('Elasticsearch `Model` (client) needs to be provided');
47+
throw new Error('Elasticsearch `Model` (client) needs to be provided')
4848
}
4949

50-
const index = options.index || options.elasticsearch?.index;
50+
const index = options.index || options.elasticsearch?.index
5151
if (!index) {
52-
throw new Error('Elasticsearch `index` needs to be provided');
52+
throw new Error('Elasticsearch `index` needs to be provided')
5353
}
5454

5555
super({
@@ -114,28 +114,28 @@ export class ElasticAdapter extends AdapterBase implements ElasticAdapterInterfa
114114
;['Model', 'index', 'parent', 'meta', 'join', 'esVersion', 'esParams'].forEach((name) =>
115115
Object.defineProperty(this, name, {
116116
get() {
117-
return this.options[name];
117+
return this.options[name]
118118
}
119119
})
120-
);
120+
)
121121

122122
// Initialize security configuration with defaults
123123
this.security = {
124124
...DEFAULT_SECURITY_CONFIG,
125125
...options.security
126-
};
126+
}
127127

128128
// BREAKING CHANGE: Disable $index filter by default for security
129129
// Users must explicitly enable it via security.allowedIndices
130130
if (this.security.allowedIndices.length === 0 && this.options.filters?.$index) {
131-
delete this.options.filters.$index;
131+
delete this.options.filters.$index
132132
}
133133

134134
// Set up core methods reference
135135
this.core = {
136136
find: methods.find,
137137
get: methods.get
138-
};
138+
}
139139
}
140140

141141
/**
@@ -144,20 +144,20 @@ export class ElasticAdapter extends AdapterBase implements ElasticAdapterInterfa
144144
* @returns {Object} Filtered query parameters with pagination settings
145145
*/
146146
filterQuery(params: ElasticsearchServiceParams = {}) {
147-
const options = this.getOptions(params);
148-
const { filters, query } = filterQuery(params?.query || {}, options);
147+
const options = this.getOptions(params)
148+
const { filters, query } = filterQuery(params?.query || {}, options)
149149

150150
if (!filters.$skip || isNaN(filters.$skip as number)) {
151-
filters.$skip = 0;
151+
filters.$skip = 0
152152
}
153153

154154
if (typeof filters.$sort === 'object') {
155155
filters.$sort = Object.entries(filters.$sort).map(([key, val]) => ({
156156
[key]: (val as number) > 0 ? 'asc' : 'desc'
157-
}));
157+
}))
158158
}
159159

160-
return { filters, query, paginate: options.paginate };
160+
return { filters, query, paginate: options.paginate }
161161
}
162162

163163
/**
@@ -173,11 +173,11 @@ export class ElasticAdapter extends AdapterBase implements ElasticAdapterInterfa
173173
| { total: number; skip: number; limit: number; data: Record<string, unknown>[] }
174174
> {
175175
return methods.find(this, params).catch((error: Error) => {
176-
throw errorHandler(error, undefined);
176+
throw errorHandler(error, undefined)
177177
}) as Promise<
178178
| Record<string, unknown>[]
179179
| { total: number; skip: number; limit: number; data: Record<string, unknown>[] }
180-
>;
180+
>
181181
}
182182

183183
/**
@@ -189,8 +189,8 @@ export class ElasticAdapter extends AdapterBase implements ElasticAdapterInterfa
189189
*/
190190
_get(id: string | number, params: ElasticsearchServiceParams = {}): Promise<Record<string, unknown>> {
191191
return (methods.get(this, id, params) as Promise<Record<string, unknown>>).catch((error: Error) => {
192-
throw errorHandler(error, id);
193-
});
192+
throw errorHandler(error, id)
193+
})
194194
}
195195

196196
/**
@@ -208,13 +208,13 @@ export class ElasticAdapter extends AdapterBase implements ElasticAdapterInterfa
208208
// Check if we are creating single item.
209209
if (!Array.isArray(data)) {
210210
return methods.create(this, data, params).catch((error: Error) => {
211-
throw errorHandler(error, (data as Record<string, unknown>)[this.id] as string | number);
212-
}) as Promise<Record<string, unknown>>;
211+
throw errorHandler(error, (data as Record<string, unknown>)[this.id] as string | number)
212+
}) as Promise<Record<string, unknown>>
213213
}
214214

215215
return methods.createBulk(this, data, params).catch((error: Error) => {
216-
throw errorHandler(error);
217-
}) as Promise<Record<string, unknown>[]>;
216+
throw errorHandler(error)
217+
}) as Promise<Record<string, unknown>[]>
218218
}
219219

220220
/**
@@ -227,8 +227,8 @@ export class ElasticAdapter extends AdapterBase implements ElasticAdapterInterfa
227227
*/
228228
_update(id: string | number, data: Record<string, unknown>, params: ElasticsearchServiceParams = {}) {
229229
return methods.update(this, id, data, params).catch((error: Error) => {
230-
throw errorHandler(error, id);
231-
});
230+
throw errorHandler(error, id)
231+
})
232232
}
233233

234234
/**
@@ -247,13 +247,13 @@ export class ElasticAdapter extends AdapterBase implements ElasticAdapterInterfa
247247
// Check if we are patching single item.
248248
if (id !== null) {
249249
return methods.patch(this, id, data, params).catch((error: Error) => {
250-
throw errorHandler(error, id);
251-
}) as Promise<Record<string, unknown>>;
250+
throw errorHandler(error, id)
251+
}) as Promise<Record<string, unknown>>
252252
}
253253

254254
return methods.patchBulk(this, data, params).catch((error: Error) => {
255-
throw errorHandler(error);
256-
}) as Promise<Record<string, unknown>[]>;
255+
throw errorHandler(error)
256+
}) as Promise<Record<string, unknown>[]>
257257
}
258258

259259
/**
@@ -266,13 +266,13 @@ export class ElasticAdapter extends AdapterBase implements ElasticAdapterInterfa
266266
_remove(id: string | number | null, params: ElasticsearchServiceParams = {}) {
267267
if (id !== null) {
268268
return methods.remove(this, id, params).catch((error: Error) => {
269-
throw errorHandler(error, id);
270-
});
269+
throw errorHandler(error, id)
270+
})
271271
}
272272

273273
return methods.removeBulk(this, params).catch((error: Error) => {
274-
throw errorHandler(error);
275-
});
274+
throw errorHandler(error)
275+
})
276276
}
277277

278278
/**
@@ -283,7 +283,7 @@ export class ElasticAdapter extends AdapterBase implements ElasticAdapterInterfa
283283
*/
284284
_raw(method: string, params: ElasticsearchServiceParams = {}) {
285285
return methods.raw(this, method, params).catch((error: Error) => {
286-
throw errorHandler(error);
287-
});
286+
throw errorHandler(error)
287+
})
288288
}
289289
}

src/config/versions.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const ES_TYPE_REQUIREMENTS: VersionMapping<string | null> = {
1919
'7.0': null,
2020
'8.0': null,
2121
'9.0': null
22-
};
22+
}
2323

2424
/**
2525
* Mapping path patterns by ES version
@@ -30,14 +30,14 @@ export const ES_MAPPING_PATHS: VersionMapping<string[]> = {
3030
'7.0': ['test-people.mappings.properties.aka.type', 'join'],
3131
'8.0': ['test-people.mappings.properties.aka.type', 'join'],
3232
'9.0': ['test-people.mappings.properties.aka.type', 'join']
33-
};
33+
}
3434

3535
/**
3636
* Supported ES versions for testing
3737
*/
38-
export const SUPPORTED_ES_VERSIONS = ['5.0', '6.0', '7.0', '8.0', '8.15', '9.0'];
38+
export const SUPPORTED_ES_VERSIONS = ['5.0', '6.0', '7.0', '8.0', '8.15', '9.0']
3939

4040
/**
4141
* Default ES version if none specified
4242
*/
43-
export const DEFAULT_ES_VERSION = '8.0';
43+
export const DEFAULT_ES_VERSION = '8.0'

src/declarations.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { AdapterServiceOptions } from '@feathersjs/adapter-commons';
2-
import { Client } from '@elastic/elasticsearch';
3-
export { estypes } from '@elastic/elasticsearch';
1+
import { AdapterServiceOptions } from '@feathersjs/adapter-commons'
2+
import { Client } from '@elastic/elasticsearch'
3+
export { estypes } from '@elastic/elasticsearch'
44

55
export interface ElasticAdapterServiceOptions extends AdapterServiceOptions {
66
Model: Client

0 commit comments

Comments
 (0)