Skip to content

Commit ed6f4ba

Browse files
authored
chore(javascript): use oxlint (#3895)
1 parent cf65d54 commit ed6f4ba

File tree

90 files changed

+287
-517
lines changed

Some content is hidden

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

90 files changed

+287
-517
lines changed

.eslintrc.cjs

-139
Original file line numberDiff line numberDiff line change
@@ -79,145 +79,6 @@ module.exports = {
7979
'yml/no-empty-mapping-value': 0,
8080
},
8181
},
82-
{
83-
// es linter
84-
files: ['*.ts', '*.js'],
85-
86-
extends: [
87-
'algolia',
88-
'algolia/typescript',
89-
'plugin:import/errors',
90-
'plugin:import/warnings',
91-
'plugin:import/typescript',
92-
],
93-
94-
env: {
95-
es6: true,
96-
},
97-
98-
parser: '@typescript-eslint/parser',
99-
100-
parserOptions: {
101-
tsconfigRootDir: __dirname,
102-
project: './**/tsconfig.json',
103-
},
104-
105-
settings: {
106-
'import/extensions': ['.js', '.ts'],
107-
'import/parsers': {
108-
'@typescript-eslint/parser': ['.ts'],
109-
},
110-
'import/ignore': ['node_modules'],
111-
},
112-
113-
plugins: ['algolia', 'unused-imports'],
114-
115-
rules: {
116-
// disabled
117-
'no-bitwise': 0,
118-
'max-classes-per-file': 0,
119-
'no-continue': 0,
120-
'@typescript-eslint/prefer-enum-initializers': 0,
121-
'@typescript-eslint/no-namespace': 0,
122-
'import/dynamic-import-chunkname': 0,
123-
124-
'unused-imports/no-unused-imports': 2,
125-
'@typescript-eslint/no-unused-vars': 2,
126-
'@typescript-eslint/consistent-indexed-object-style': 2,
127-
'@typescript-eslint/member-ordering': [
128-
'error',
129-
{
130-
default: [
131-
'protected-instance-method',
132-
'private-instance-method',
133-
'public-instance-method',
134-
],
135-
},
136-
],
137-
'@typescript-eslint/no-restricted-types': [
138-
'error',
139-
{
140-
types: {
141-
String: {
142-
message: 'Use `string` instead.',
143-
fixWith: 'string',
144-
},
145-
Number: {
146-
message: 'Use `number` instead.',
147-
fixWith: 'number',
148-
},
149-
Boolean: {
150-
message: 'Use `boolean` instead.',
151-
fixWith: 'boolean',
152-
},
153-
Symbol: {
154-
message: 'Use `symbol` instead.',
155-
fixWith: 'symbol',
156-
},
157-
Object: {
158-
message:
159-
'The `Object` type is mostly the same as `unknown`. You probably want `Record<string, unknown>` instead. See https://github.com/typescript-eslint/typescript-eslint/pull/848',
160-
fixWith: 'Record<string, unknown>',
161-
},
162-
'{}': {
163-
message:
164-
'The `{}` type is mostly the same as `unknown`. You probably want `Record<string, unknown>` instead.',
165-
fixWith: 'Record<string, unknown>',
166-
},
167-
object: {
168-
message:
169-
'The `object` type is hard to use. Use `Record<string, unknown>` instead. See: https://github.com/typescript-eslint/typescript-eslint/pull/848',
170-
fixWith: 'Record<string, unknown>',
171-
},
172-
Function: 'Use a specific function type instead, like `() => void`.',
173-
},
174-
},
175-
],
176-
'jsdoc/match-description': [
177-
'error',
178-
{
179-
matchDescription: '^\n?([A-Z`\[\\d_][\\s\\S]*[.?!`]\\s*)?$'
180-
},
181-
],
182-
},
183-
},
184-
{
185-
files: ['clients/algoliasearch-client-javascript/packages/**/*.ts'],
186-
187-
rules: {
188-
// For a wider browser support (IE>=11), we forbid those two
189-
'no-restricted-syntax': [
190-
'error',
191-
{
192-
selector: "LogicalExpression[operator='??']",
193-
message:
194-
'For wider browser support, nullish coalescing operator is not allowed.',
195-
},
196-
{
197-
selector: 'ChainExpression',
198-
message:
199-
'For wider browser support, optional chaining is not allowed.',
200-
},
201-
],
202-
'@typescript-eslint/prefer-optional-chain': 0,
203-
}
204-
},
205-
{
206-
files: ['clients/algoliasearch-client-javascript/packages/**/__tests__/**/*.ts'],
207-
208-
plugins: ['@vitest/eslint-plugin'],
209-
},
210-
{
211-
files: ['guides/**/*.ts'],
212-
213-
rules: {
214-
'no-console': 0,
215-
216-
// TODO: remove this after https://algolia.atlassian.net/browse/DI-2984
217-
'@typescript-eslint/no-unused-vars': 0,
218-
'@typescript-eslint/explicit-function-return-type': 0,
219-
},
220-
},
22182
{
22283
files: ['*.json'],
22384
parserOptions: {

.github/workflows/check.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ jobs:
146146
run: yarn scripts:test
147147

148148
- name: Lint custom eslint plugin
149-
run: yarn workspace eslint-plugin-automation-custom lint
149+
run: yarn cli format javascript eslint
150150

151151
- name: Test custom eslint plugin
152152
run: yarn workspace eslint-plugin-automation-custom test

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ node_modules
33
.env
44
.pnp.cjs
55
.parcel-cache
6+
**/.parcel-cache
7+
**/.nx
68

79
yarn-error.log
810
debug.log

.lintstagedrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
"generators/**/*.java": "yarn cli format java generators",
33
".github/**/*.yml": "yarn github-actions:lint --fix",
44
"*.json": "yarn fix:json",
5-
"scripts/**/*.(js|ts|mjs|cjs)": "yarn scripts:lint --fix",
5+
"scripts/**/*.(js|ts|mjs|cjs)": "yarn cli format javascript scripts",
66
"specs/**/*.yml": "yarn eslint --ext=yml --fix"
77
}

.prettierignore

+4
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,7 @@ build
55
.gradle
66
target
77
bin
8+
.nx
9+
.parcel-cache
10+
.yarn
11+
builddir

.prettierrc

+13-1
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,26 @@
22
"trailingComma": "all",
33
"singleQuote": true,
44
"plugins": [
5-
"prettier-plugin-java"
5+
"prettier-plugin-java",
6+
"prettier-plugin-organize-imports"
67
],
78
"overrides": [
89
{
910
"files": "*.java",
1011
"options": {
1112
"printWidth": 140
1213
}
14+
},
15+
{
16+
"files": ["*.ts", "*.js", "*.mjs", "*.cjs"],
17+
"options": {
18+
"arrowParens": "always",
19+
"bracketSpacing": true,
20+
"bracketSameLine": false,
21+
"printWidth": 120,
22+
"useTabs": false,
23+
"quoteProps": "as-needed"
24+
}
1325
}
1426
]
1527
}

clients/algoliasearch-client-javascript/CHANGELOG.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353

5454
- [d4df544d6](https://github.com/algolia/api-clients-automation/commit/d4df544d6) fix(specs): remove usage [skip-bc] ([#3691](https://github.com/algolia/api-clients-automation/pull/3691)) by [@kai687](https://github.com/kai687/)
5555
- [d39b87726](https://github.com/algolia/api-clients-automation/commit/d39b87726) chore: assert node helpers ([#3689](https://github.com/algolia/api-clients-automation/pull/3689)) by [@shortcuts](https://github.com/shortcuts/)
56-
- [46d9d8fd0](https://github.com/algolia/api-clients-automation/commit/46d9d8fd0) feat(specs): add (optional) _automaticInsights to search result ([#3688](https://github.com/algolia/api-clients-automation/pull/3688)) by [@raed667](https://github.com/raed667/)
56+
- [46d9d8fd0](https://github.com/algolia/api-clients-automation/commit/46d9d8fd0) feat(specs): add (optional) \_automaticInsights to search result ([#3688](https://github.com/algolia/api-clients-automation/pull/3688)) by [@raed667](https://github.com/raed667/)
5757

5858
## [5.4.0](https://github.com/algolia/algoliasearch-client-javascript/compare/5.3.2...5.4.0)
5959

@@ -765,7 +765,7 @@ New major version released! Browse [our documentation](https://www.algolia.com/d
765765

766766
## [5.0.0-alpha.12](https://github.com/algolia/algoliasearch-client-javascript/compare/5.0.0-alpha.11...5.0.0-alpha.12)
767767

768-
- [ff02ba09](https://github.com/algolia/api-clients-automation/commit/ff02ba09) fix(javascript): revert: do not send user-agent for Predict (#957) ([#919](https://github.com/algolia/api-clients-automation/pull/919)) by [@shortcuts](https://github.com/shortcuts/)
768+
- [ff02ba09](https://github.com/algolia/api-clients-automation/commit/ff02ba09) fix(javascript): revert: do not send user-agent for Predict (#957) ([#919](https://github.com/algolia/api-clients-automation/pull/919)) by [@shortcuts](https://github.com/shortcuts/)
769769

770770
## [5.0.0-alpha.11](https://github.com/algolia/algoliasearch-client-javascript/compare/5.0.0-alpha.10...5.0.0-alpha.11)
771771

clients/algoliasearch-client-javascript/README.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,11 @@
3232

3333
## 💡 Getting Started
3434

35-
3635
To get started, you first need to install algoliasearch (or any other available API client package).
3736
All of our clients comes with type definition, and are available for both browser and node environments.
3837

3938
### With a package manager
4039

41-
4240
```bash
4341
4442
# or
@@ -82,4 +80,4 @@ Encountering an issue? Before reaching out to support, we recommend heading to o
8280

8381
## 📄 License
8482

85-
The Algolia JavaScript API Client is an open-sourced software licensed under the [MIT license](LICENSE).
83+
The Algolia JavaScript API Client is an open-sourced software licensed under the [MIT license](LICENSE).

clients/algoliasearch-client-javascript/base.tsup.config.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import path from 'path';
2-
32
import type { Options } from 'tsup';
43

54
type PKG = {
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
{
2-
"packages": [
3-
"packages/*"
4-
],
2+
"packages": ["packages/*"],
53
"version": "independent",
64
"useNx": true
75
}

clients/algoliasearch-client-javascript/nx.json

+1-5
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,7 @@
33
"default": {
44
"runner": "nx/tasks-runners/default",
55
"options": {
6-
"cacheableOperations": [
7-
"build:many",
8-
"build:all",
9-
"build"
10-
]
6+
"cacheableOperations": ["build:many", "build:all", "build"]
117
}
128
}
139
}

clients/algoliasearch-client-javascript/packages/algoliasearch/__tests__/algoliasearch.browser.test.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/* eslint no-console: 0 */
2-
3-
import { vi, test, expect } from 'vitest';
2+
import { expect, test, vi } from 'vitest';
43

54
import { LogLevelEnum } from '../../client-common/src/types';
65
import { createConsoleLogger } from '../../logger-console/src/logger';

clients/algoliasearch-client-javascript/packages/algoliasearch/__tests__/algoliasearch.common.test.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
import { describe, expect, test } from 'vitest';
2+
13
import {
24
DEFAULT_CONNECT_TIMEOUT_BROWSER,
35
DEFAULT_READ_TIMEOUT_BROWSER,
46
DEFAULT_WRITE_TIMEOUT_BROWSER,
57
} from '@algolia/client-common';
68
import type { EchoResponse } from '@algolia/requester-testing';
7-
import { describe, test, expect } from 'vitest';
89

910
import { browserEchoRequester } from '../../requester-testing/src/browserEchoRequester';
1011
import { algoliasearch, apiClientVersion } from '../builds/browser';

clients/algoliasearch-client-javascript/packages/algoliasearch/__tests__/algoliasearch.fetch.test.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/* eslint no-console: 0 */
2-
3-
import { vi, test, expect } from 'vitest';
2+
import { expect, test, vi } from 'vitest';
43

54
import { LogLevelEnum } from '../../client-common/src/types';
65
import { createConsoleLogger } from '../../logger-console/src/logger';

clients/algoliasearch-client-javascript/packages/algoliasearch/__tests__/algoliasearch.node.test.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/* eslint no-console: 0 */
2-
3-
import { vi, test, expect } from 'vitest';
2+
import { expect, test, vi } from 'vitest';
43

54
import { LogLevelEnum } from '../../client-common/src/types';
65
import { createConsoleLogger } from '../../logger-console/src/logger';

clients/algoliasearch-client-javascript/packages/client-common/src/__tests__/cache/browser-local-storage-cache.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { vi, describe, test, beforeEach, expect } from 'vitest';
1+
import { beforeEach, describe, expect, test, vi } from 'vitest';
22

33
import { createBrowserLocalStorageCache } from '../../cache';
44

clients/algoliasearch-client-javascript/packages/client-common/src/__tests__/cache/fallbackable-cache.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { describe, test, expect } from 'vitest';
1+
import { describe, expect, test } from 'vitest';
22

33
import {
44
createBrowserLocalStorageCache,

clients/algoliasearch-client-javascript/packages/client-common/src/__tests__/cache/memory-cache.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { vi, describe, test, beforeEach, expect } from 'vitest';
1+
import { beforeEach, describe, expect, test, vi } from 'vitest';
22

33
import { createMemoryCache } from '../../cache';
44

clients/algoliasearch-client-javascript/packages/client-common/src/__tests__/cache/null-cache.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { vi, describe, test, beforeEach, expect } from 'vitest';
1+
import { beforeEach, describe, expect, test, vi } from 'vitest';
22

33
import { createNullCache } from '../../cache';
44

clients/algoliasearch-client-javascript/packages/client-common/src/__tests__/create-iterable-promise.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { describe, test, expect } from 'vitest';
1+
import { describe, expect, test } from 'vitest';
22

33
import { createIterablePromise } from '../createIterablePromise';
44

clients/algoliasearch-client-javascript/packages/client-common/src/__tests__/logger/null-logger.test.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/* eslint no-console: 0 */
2-
3-
import { vi, describe, test, expect } from 'vitest';
2+
import { describe, expect, test, vi } from 'vitest';
43

54
import { createNullLogger } from '../../logger';
65

clients/algoliasearch-client-javascript/packages/client-common/src/cache/createFallbackableCache.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import type { FallbackableCacheOptions, Cache, CacheEvents } from '../types';
2-
1+
import type { Cache, CacheEvents, FallbackableCacheOptions } from '../types';
32
import { createNullCache } from './createNullCache';
43

54
export function createFallbackableCache(options: FallbackableCacheOptions): Cache {

clients/algoliasearch-client-javascript/packages/client-common/src/createAlgoliaAgent.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { AlgoliaAgentOptions, AlgoliaAgent } from './types';
1+
import type { AlgoliaAgent, AlgoliaAgentOptions } from './types';
22

33
export function createAlgoliaAgent(version: string): AlgoliaAgent {
44
const algoliaAgent = {

clients/algoliasearch-client-javascript/packages/client-common/src/getAlgoliaAgent.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { createAlgoliaAgent } from './createAlgoliaAgent';
2-
import type { AlgoliaAgentOptions, AlgoliaAgent } from './types';
2+
import type { AlgoliaAgent, AlgoliaAgentOptions } from './types';
33

44
export type GetAlgoliaAgent = {
55
algoliaAgents: AlgoliaAgentOptions[];

clients/algoliasearch-client-javascript/packages/client-common/src/transporter/createTransporter.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
import type {
22
EndRequest,
33
Host,
4+
QueryParameters,
45
Request,
56
RequestOptions,
67
Response,
78
StackFrame,
8-
TransporterOptions,
99
Transporter,
10-
QueryParameters,
10+
TransporterOptions,
1111
} from '../types';
12-
1312
import { createStatefulHost } from './createStatefulHost';
1413
import { RetryError } from './errors';
1514
import { deserializeFailure, deserializeSuccess, serializeData, serializeHeaders, serializeUrl } from './helpers';
1615
import { isRetryable, isSuccess } from './responses';
17-
import { stackTraceWithoutCredentials, stackFrameWithoutCredentials } from './stackTrace';
16+
import { stackFrameWithoutCredentials, stackTraceWithoutCredentials } from './stackTrace';
1817

1918
type RetryableOptions = {
2019
hosts: Host[];

clients/algoliasearch-client-javascript/packages/client-common/src/transporter/helpers.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import type { Headers, Host, QueryParameters, Request, RequestOptions, Response, StackFrame } from '../types';
2-
32
import { ApiError, DeserializationError, DetailedApiError } from './errors';
43

54
export function shuffle<TData>(array: TData[]): TData[] {

0 commit comments

Comments
 (0)