Skip to content

Commit 2a81772

Browse files
authored
Merge branch 'main' into bump-meilisearch-v1.11.0
2 parents c5be7e2 + 7c6a3e3 commit 2a81772

Some content is hidden

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

59 files changed

+1347
-2404
lines changed

.eslintignore

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

.eslintrc.js

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

.github/scripts/check-release.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ if [ "$current_tag" != "$package_json_version" ]; then
1010
exit 1
1111
fi
1212

13-
package_version_ts=$(grep "PACKAGE_VERSION =" src/package-version.ts | cut -d "=" -f 2- | tr -d ';' | tr -d " " | tr -d "'")
13+
package_version_ts=$(grep "PACKAGE_VERSION =" src/package-version.ts | cut -d "=" -f 2- | tr -d ';' | tr -d " " | tr -d '"')
1414
if [ "$current_tag" != "$package_version_ts" ]; then
1515
echo "Error: the current tag does not match the version in src/package-version.ts."
1616
echo "$current_tag vs $package_version_ts"

eslint.config.js

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
const eslint = require("@eslint/js");
2+
const tseslint = require("typescript-eslint");
3+
const tsdoc = require("eslint-plugin-tsdoc");
4+
const vitest = require("@vitest/eslint-plugin");
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+
...config.languageOptions,
26+
globals: { ...config.languageOptions?.globals, ...globals.node },
27+
parserOptions: {
28+
...config.languageOptions?.parserOptions,
29+
project: "tsconfig.eslint.json",
30+
},
31+
},
32+
plugins: { ...config.plugins, tsdoc },
33+
rules: {
34+
...config.rules,
35+
"tsdoc/syntax": "error",
36+
// @TODO: Remove the ones between "~~", adapt code
37+
// ~~
38+
"@typescript-eslint/prefer-as-const": "off",
39+
"@typescript-eslint/ban-ts-comment": "off",
40+
"@typescript-eslint/no-unsafe-call": "off",
41+
"@typescript-eslint/no-unsafe-member-access": "off",
42+
"@typescript-eslint/no-unsafe-return": "off",
43+
"@typescript-eslint/no-unsafe-assignment": "off",
44+
"@typescript-eslint/no-unsafe-argument": "off",
45+
"@typescript-eslint/no-floating-promises": "off",
46+
// ~~
47+
"@typescript-eslint/array-type": ["warn", { default: "array-simple" }],
48+
// @TODO: Should be careful with this rule, should leave it be and disable
49+
// it within files where necessary with explanations
50+
"@typescript-eslint/no-explicit-any": "off",
51+
"@typescript-eslint/no-unused-vars": [
52+
"error",
53+
// argsIgnorePattern: https://eslint.org/docs/latest/rules/no-unused-vars#argsignorepattern
54+
// varsIgnorePattern: https://eslint.org/docs/latest/rules/no-unused-vars#varsignorepattern
55+
{ args: "all", argsIgnorePattern: "^_", varsIgnorePattern: "^_" },
56+
],
57+
// @TODO: Not recommended to disable rule, should instead disable locally
58+
// with explanation
59+
"@typescript-eslint/ban-ts-ignore": "off",
60+
},
61+
})),
62+
// Vitest linting for test files
63+
{
64+
files: ["tests/*.ts"],
65+
plugins: { vitest },
66+
rules: {
67+
...vitest.configs.recommended.rules,
68+
// @TODO: Remove all of these rules and adapt code!
69+
"vitest/expect-expect": "off",
70+
"vitest/valid-title": "off",
71+
"vitest/valid-expect": "off",
72+
},
73+
},
74+
prettier,
75+
];

package.json

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "meilisearch",
3-
"version": "0.42.0",
3+
"version": "0.43.0",
44
"description": "The Meilisearch JS client for Node.js and the browser.",
55
"keywords": [
66
"meilisearch",
@@ -23,26 +23,34 @@
2323
"types": "./dist/types/index.d.ts",
2424
"jsdelivr": "./dist/bundles/meilisearch.umd.js",
2525
"unpkg": "./dist/bundles/meilisearch.umd.js",
26+
"exports": {
27+
".": {
28+
"types": "./dist/types/index.d.ts",
29+
"browser": "./dist/bundles/meilisearch.umd.js",
30+
"import": "./dist/bundles/meilisearch.esm.js",
31+
"require": "./dist/bundles/meilisearch.cjs.js",
32+
"default": "./dist/bundles/meilisearch.umd.js"
33+
}
34+
},
2635
"sideEffects": false,
2736
"repository": {
2837
"type": "git",
2938
"url": "https://github.com/meilisearch/meilisearch-js"
3039
},
3140
"scripts": {
3241
"playground:javascript": "yarn --cwd ./playgrounds/javascript && yarn --cwd ./playgrounds/javascript start",
33-
"clear_jest": "jest --clearCache",
3442
"cleanup": "shx rm -rf dist/",
3543
"build": "yarn cleanup && rollup -c && rollup -c --environment NODE_ENV:production",
3644
"build:docs": "typedoc",
3745
"watch": "yarn cleanup && rollup -c --watch",
3846
"postbuild": "yarn size && yarn typingsheader",
39-
"test": "yarn clear_jest && jest --runInBand --verbose",
47+
"test": "vitest run --coverage",
4048
"types:watch": "nodemon --config nodemon.json",
4149
"types": "yarn tsc",
4250
"test:env:browser": "yarn build && yarn --cwd tests/env/express && yarn --cwd tests/env/express test",
43-
"test:watch": "yarn clear_jest && yarn test --watch",
44-
"test:coverage": "yarn test --coverage",
45-
"test:ci": "yarn test --ci",
51+
"test:watch": "vitest watch",
52+
"test:coverage": "yarn test",
53+
"test:ci": "yarn test",
4654
"test:env": "yarn build && yarn test:env:nodejs && yarn test:env:esm && yarn test:env:node-ts",
4755
"test:env:node-ts": "yarn --cwd tests/env/typescript-node start",
4856
"test:env:nodejs": "yarn build && node tests/env/node/index.js && node tests/env/node/getting_started.js",
@@ -53,8 +61,8 @@
5361
"style:fix": "yarn fmt:fix && yarn lint:fix",
5462
"fmt": "prettier -c ./**/*.{js,ts}",
5563
"fmt:fix": "prettier -w ./**/*.{js,ts}",
56-
"lint": "eslint --ext .js,.ts,.tsx .",
57-
"lint:fix": "eslint --ext .js,.ts,.tsx --fix .",
64+
"lint": "eslint .",
65+
"lint:fix": "eslint --fix .",
5866
"typingsheader": "node scripts/build.js"
5967
},
6068
"files": [
@@ -75,23 +83,21 @@
7583
"devDependencies": {
7684
"@babel/core": "^7.25.2",
7785
"@babel/preset-env": "^7.25.4",
86+
"@eslint/js": "^9.11.1",
7887
"@rollup/plugin-babel": "^6.0.4",
7988
"@rollup/plugin-commonjs": "28.0.0",
8089
"@rollup/plugin-json": "^6.1.0",
8190
"@rollup/plugin-node-resolve": "15.3.0",
82-
"@types/jest": "^29.5.11",
83-
"@typescript-eslint/eslint-plugin": "^6.19.0",
84-
"@typescript-eslint/parser": "^6.19.0",
91+
"@types/eslint__js": "^8.42.3",
92+
"@vitest/coverage-v8": "2.0.5",
93+
"@vitest/eslint-plugin": "^1.1.4",
94+
"@types/node": "^20.16.10",
8595
"brotli-size": "^4.0.0",
86-
"eslint": "^8.56.0",
96+
"eslint": "^9.11.1",
8797
"eslint-config-prettier": "^9.1.0",
88-
"eslint-plugin-jest": "^27.6.3",
89-
"eslint-plugin-tsdoc": "^0.2.17",
98+
"eslint-plugin-tsdoc": "^0.3.0",
99+
"globals": "^15.9.0",
90100
"gzip-size": "^6.0.0",
91-
"jest": "^29.7.0",
92-
"jest-environment-jsdom": "^29.7.0",
93-
"jest-fetch-mock": "^3.0.3",
94-
"jest-watch-typeahead": "^2.2.2",
95101
"kleur": "^4.1.5",
96102
"lint-staged": "15.2.10",
97103
"nodemon": "^3.1.7",
@@ -102,9 +108,10 @@
102108
"rollup-plugin-terser": "^7.0.0",
103109
"rollup-plugin-typescript2": "^0.36.0",
104110
"shx": "^0.3.2",
105-
"ts-jest": "^29.2.5",
106111
"typedoc": "^0.26.7",
107-
"typescript": "^5.4.5"
112+
"typescript": "^5.4.5",
113+
"typescript-eslint": "^8.8.0",
114+
"vitest": "2.0.5"
108115
},
109116
"packageManager": "[email protected]"
110117
}

rollup.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const nodeResolve = require("@rollup/plugin-node-resolve");
2-
const { resolve } = require("path");
2+
const { resolve } = require("node:path");
33
const commonjs = require("@rollup/plugin-commonjs");
44
const json = require("@rollup/plugin-json");
55
const typescript = require("rollup-plugin-typescript2");
@@ -18,7 +18,7 @@ const PLUGINS = [
1818
typescript({
1919
useTsconfigDeclarationDir: true,
2020
tsconfigOverride: {
21-
allowJs: false,
21+
compilerOptions: { allowJs: false },
2222
include: ["src"],
2323
exclude: ["tests", "examples", "*.js", "scripts"],
2424
},

scripts/build.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
/** This file only purpose is to execute any build related tasks */
22

3-
const { resolve, normalize } = require("path");
4-
const { readFileSync, writeFileSync } = require("fs");
3+
const { resolve, normalize } = require("node:path");
4+
const { readFileSync, writeFileSync } = require("node:fs");
5+
56
const pkg = require("../package.json");
67

78
const ROOT = resolve(__dirname, "..");

scripts/file-size.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
const { basename, normalize } = require("path");
2-
const { readFile: readFileCb } = require("fs");
3-
const { promisify } = require("util");
1+
const { basename, normalize } = require("node:path");
2+
const { readFile: readFileCb } = require("node:fs");
3+
const { promisify } = require("node:util");
44
const readFile = promisify(readFileCb);
55

66
const kolor = require("kleur");

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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function constructHostURL(host: string): string {
3333
host = addProtocolIfNotPresent(host);
3434
host = addTrailingSlash(host);
3535
return host;
36-
} catch (e) {
36+
} catch {
3737
throw new MeiliSearchError("The provided host is not valid.");
3838
}
3939
}
@@ -105,7 +105,7 @@ class HttpRequests {
105105
try {
106106
const host = constructHostURL(config.host);
107107
this.url = new URL(host);
108-
} catch (e) {
108+
} catch {
109109
throw new MeiliSearchError("The provided host is not valid.");
110110
}
111111
}

0 commit comments

Comments
 (0)