Skip to content

Commit 565bb40

Browse files
committed
Update ESLint and related pacakges, adapt config
1 parent 3b7e7e4 commit 565bb40

File tree

7 files changed

+391
-341
lines changed

7 files changed

+391
-341
lines changed

.eslintignore

Lines changed: 0 additions & 8 deletions
This file was deleted.

eslint.config.js

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
const eslint = require('@eslint/js');
2+
const tseslint = require('typescript-eslint');
3+
const tsdoc = require('eslint-plugin-tsdoc');
4+
const jest = require('eslint-plugin-jest');
5+
const globals = require('globals');
6+
const prettier = require('eslint-config-prettier');
7+
8+
/** @type {import('eslint').Linter.Config[]} */
9+
module.exports = [
10+
{
11+
ignores: ['dist/', 'tests/env/', 'coverage/', 'playgrounds/', 'docs/'],
12+
},
13+
// Standard linting for js files
14+
{
15+
files: ['**/*.js'],
16+
languageOptions: { sourceType: 'script', globals: globals.node },
17+
plugins: { eslint },
18+
rules: eslint.configs.recommended.rules,
19+
},
20+
// TypeScript linting for ts files
21+
...tseslint.configs.recommendedTypeChecked.map((config) => ({
22+
...config,
23+
files: ['**/*.ts'],
24+
languageOptions: {
25+
globals: globals.node,
26+
parser: tseslint.parser,
27+
parserOptions: { project: 'tsconfig.eslint.json' },
28+
},
29+
plugins: { ...config.plugins, tsdoc },
30+
rules: {
31+
...config.rules,
32+
'tsdoc/syntax': 'error',
33+
// @TODO: Remove the ones between "~~", adapt code
34+
// ~~
35+
'@typescript-eslint/prefer-as-const': 'off',
36+
'@typescript-eslint/ban-ts-comment': 'off',
37+
'@typescript-eslint/no-unsafe-call': 'off',
38+
'@typescript-eslint/no-unsafe-member-access': 'off',
39+
'@typescript-eslint/no-unsafe-return': 'off',
40+
'@typescript-eslint/no-unsafe-assignment': 'off',
41+
'@typescript-eslint/no-unsafe-argument': 'off',
42+
'@typescript-eslint/no-floating-promises': 'off',
43+
// ~~
44+
'@typescript-eslint/array-type': ['warn', { default: 'array-simple' }],
45+
// @TODO: Should be careful with this rule, should leave it be and disable
46+
// it within files where necessary with explanations
47+
'@typescript-eslint/no-explicit-any': 'off',
48+
'@typescript-eslint/no-unused-vars': [
49+
'error',
50+
// argsIgnorePattern: https://eslint.org/docs/latest/rules/no-unused-vars#argsignorepattern
51+
// varsIgnorePattern: https://eslint.org/docs/latest/rules/no-unused-vars#varsignorepattern
52+
{ args: 'all', argsIgnorePattern: '^_', varsIgnorePattern: '^_' },
53+
],
54+
// @TODO: Not recommended to disable rule, should instead disable locally
55+
// with explanation
56+
'@typescript-eslint/ban-ts-ignore': 'off',
57+
'@typescript-eslint/no-require-imports': 'off',
58+
},
59+
})),
60+
// Jest linting for test files
61+
{
62+
files: ['tests/*.ts'],
63+
...jest.configs['flat/recommended'],
64+
// languageOptions: {
65+
// ...jest.configs['flat/recommended'].languageOptions,
66+
// globals: globals.jest,
67+
// },
68+
rules: {
69+
...jest.configs['flat/recommended'].rules,
70+
// @TODO: Remove all of these rules and adapt code!
71+
'jest/no-disabled-tests': 'off',
72+
'jest/expect-expect': 'off',
73+
'jest/no-conditional-expect': 'off',
74+
'jest/valid-title': 'off',
75+
'jest/no-jasmine-globals': 'off',
76+
'jest/valid-expect-in-promise': 'off',
77+
'jest/valid-expect': 'off',
78+
'jest/no-alias-methods': 'off',
79+
},
80+
},
81+
prettier,
82+
];

package.json

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@
5353
"style:fix": "yarn fmt:fix && yarn lint:fix",
5454
"fmt": "prettier -c ./**/*.{js,ts}",
5555
"fmt:fix": "prettier -w ./**/*.{js,ts}",
56-
"lint": "eslint --ext .js,.ts,.tsx .",
57-
"lint:fix": "eslint --ext .js,.ts,.tsx --fix .",
56+
"lint": "eslint .",
57+
"lint:fix": "eslint --fix .",
5858
"typingsheader": "node scripts/build.js"
5959
},
6060
"files": [
@@ -75,18 +75,19 @@
7575
"devDependencies": {
7676
"@babel/core": "^7.25.2",
7777
"@babel/preset-env": "^7.25.4",
78+
"@eslint/js": "^9.9.0",
7879
"@rollup/plugin-babel": "^6.0.4",
7980
"@rollup/plugin-commonjs": "28.0.0",
8081
"@rollup/plugin-json": "^6.1.0",
8182
"@rollup/plugin-node-resolve": "15.3.0",
83+
"@types/eslint__js": "^8.42.3",
8284
"@types/jest": "^29.5.11",
83-
"@typescript-eslint/eslint-plugin": "^6.19.0",
84-
"@typescript-eslint/parser": "^6.19.0",
8585
"brotli-size": "^4.0.0",
86-
"eslint": "^8.56.0",
86+
"eslint": "^9.9.0",
8787
"eslint-config-prettier": "^9.1.0",
88-
"eslint-plugin-jest": "^27.6.3",
89-
"eslint-plugin-tsdoc": "^0.2.17",
88+
"eslint-plugin-jest": "^28.8.0",
89+
"eslint-plugin-tsdoc": "^0.3.0",
90+
"globals": "^15.9.0",
9091
"gzip-size": "^6.0.0",
9192
"jest": "^29.7.0",
9293
"jest-environment-jsdom": "^29.7.0",
@@ -104,7 +105,8 @@
104105
"shx": "^0.3.2",
105106
"ts-jest": "^29.2.5",
106107
"typedoc": "^0.26.7",
107-
"typescript": "^5.4.5"
108+
"typescript": "^5.4.5",
109+
"typescript-eslint": "^8.2.0"
108110
},
109111
"packageManager": "[email protected]"
110112
}

src/clients/client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ class Client {
403403
const url = `health`;
404404
await this.httpRequest.get(url);
405405
return true;
406-
} catch (e: any) {
406+
} catch {
407407
return false;
408408
}
409409
}

src/http-requests.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ function constructHostURL(host: string): string {
3333
host = addProtocolIfNotPresent(host);
3434
host = addTrailingSlash(host);
3535
return host;
36-
} catch (e) {
37-
throw new MeiliSearchError("The provided host is not valid.");
36+
} catch {
37+
throw new MeiliSearchError('The provided host is not valid.');
3838
}
3939
}
4040

@@ -105,8 +105,8 @@ class HttpRequests {
105105
try {
106106
const host = constructHostURL(config.host);
107107
this.url = new URL(host);
108-
} catch (e) {
109-
throw new MeiliSearchError("The provided host is not valid.");
108+
} catch {
109+
throw new MeiliSearchError('The provided host is not valid.');
110110
}
111111
}
112112

src/types/types.ts

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ export type Pagination = {
2424
limit?: number;
2525
};
2626

27-
// TODO fix
28-
// eslint-disable-next-line @typescript-eslint/ban-types
2927
export type ResourceQuery = Pagination & {};
3028

3129
export type ResourceResults<T> = Pagination & {
@@ -48,12 +46,8 @@ export type IndexObject = {
4846
updatedAt: Date;
4947
};
5048

51-
// TODO fix
52-
// eslint-disable-next-line @typescript-eslint/ban-types
5349
export type IndexesQuery = ResourceQuery & {};
5450

55-
// TODO fix
56-
// eslint-disable-next-line @typescript-eslint/ban-types
5751
export type IndexesResults<T> = ResourceResults<T> & {};
5852

5953
/*
@@ -529,12 +523,10 @@ export type TasksQuery = {
529523
limit?: number;
530524
from?: number;
531525
};
532-
// TODO fix
533-
// eslint-disable-next-line @typescript-eslint/ban-types
534-
export type CancelTasksQuery = Omit<TasksQuery, "limit" | "from"> & {};
535-
// TODO fix
536-
// eslint-disable-next-line @typescript-eslint/ban-types
537-
export type DeleteTasksQuery = Omit<TasksQuery, "limit" | "from"> & {};
526+
527+
export type CancelTasksQuery = Omit<TasksQuery, 'limit' | 'from'> & {};
528+
529+
export type DeleteTasksQuery = Omit<TasksQuery, 'limit' | 'from'> & {};
538530

539531
export type EnqueuedTaskObject = {
540532
taskUid: number;
@@ -684,12 +676,8 @@ export type KeyUpdate = {
684676
description?: string;
685677
};
686678

687-
// TODO fix
688-
// eslint-disable-next-line @typescript-eslint/ban-types
689679
export type KeysQuery = ResourceQuery & {};
690680

691-
// TODO fix
692-
// eslint-disable-next-line @typescript-eslint/ban-types
693681
export type KeysResults = ResourceResults<Key[]> & {};
694682

695683
/*

0 commit comments

Comments
 (0)