Skip to content

Commit

Permalink
Merge branch 'main' into bump-meilisearch-v1.11.0
Browse files Browse the repository at this point in the history
  • Loading branch information
curquiza authored Oct 3, 2024
2 parents c5be7e2 + 7c6a3e3 commit 2a81772
Show file tree
Hide file tree
Showing 59 changed files with 1,347 additions and 2,404 deletions.
8 changes: 0 additions & 8 deletions .eslintignore

This file was deleted.

82 changes: 0 additions & 82 deletions .eslintrc.js

This file was deleted.

2 changes: 1 addition & 1 deletion .github/scripts/check-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ if [ "$current_tag" != "$package_json_version" ]; then
exit 1
fi

package_version_ts=$(grep "PACKAGE_VERSION =" src/package-version.ts | cut -d "=" -f 2- | tr -d ';' | tr -d " " | tr -d "'")
package_version_ts=$(grep "PACKAGE_VERSION =" src/package-version.ts | cut -d "=" -f 2- | tr -d ';' | tr -d " " | tr -d '"')
if [ "$current_tag" != "$package_version_ts" ]; then
echo "Error: the current tag does not match the version in src/package-version.ts."
echo "$current_tag vs $package_version_ts"
Expand Down
75 changes: 75 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
const eslint = require("@eslint/js");
const tseslint = require("typescript-eslint");
const tsdoc = require("eslint-plugin-tsdoc");
const vitest = require("@vitest/eslint-plugin");
const globals = require("globals");
const prettier = require("eslint-config-prettier");

/** @type {import("eslint").Linter.Config[]} */
module.exports = [
{
ignores: ["dist/", "tests/env/", "coverage/", "playgrounds/", "docs/"],
},
// Standard linting for js files
{
files: ["**/*.js"],
languageOptions: { sourceType: "script", globals: globals.node },
plugins: { eslint },
rules: eslint.configs.recommended.rules,
},
// TypeScript linting for ts files
...tseslint.configs.recommendedTypeChecked.map((config) => ({
...config,
files: ["**/*.ts"],
languageOptions: {
...config.languageOptions,
globals: { ...config.languageOptions?.globals, ...globals.node },
parserOptions: {
...config.languageOptions?.parserOptions,
project: "tsconfig.eslint.json",
},
},
plugins: { ...config.plugins, tsdoc },
rules: {
...config.rules,
"tsdoc/syntax": "error",
// @TODO: Remove the ones between "~~", adapt code
// ~~
"@typescript-eslint/prefer-as-const": "off",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unsafe-return": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-argument": "off",
"@typescript-eslint/no-floating-promises": "off",
// ~~
"@typescript-eslint/array-type": ["warn", { default: "array-simple" }],
// @TODO: Should be careful with this rule, should leave it be and disable
// it within files where necessary with explanations
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-vars": [
"error",
// argsIgnorePattern: https://eslint.org/docs/latest/rules/no-unused-vars#argsignorepattern
// varsIgnorePattern: https://eslint.org/docs/latest/rules/no-unused-vars#varsignorepattern
{ args: "all", argsIgnorePattern: "^_", varsIgnorePattern: "^_" },
],
// @TODO: Not recommended to disable rule, should instead disable locally
// with explanation
"@typescript-eslint/ban-ts-ignore": "off",
},
})),
// Vitest linting for test files
{
files: ["tests/*.ts"],
plugins: { vitest },
rules: {
...vitest.configs.recommended.rules,
// @TODO: Remove all of these rules and adapt code!
"vitest/expect-expect": "off",
"vitest/valid-title": "off",
"vitest/valid-expect": "off",
},
},
prettier,
];
47 changes: 27 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "meilisearch",
"version": "0.42.0",
"version": "0.43.0",
"description": "The Meilisearch JS client for Node.js and the browser.",
"keywords": [
"meilisearch",
Expand All @@ -23,26 +23,34 @@
"types": "./dist/types/index.d.ts",
"jsdelivr": "./dist/bundles/meilisearch.umd.js",
"unpkg": "./dist/bundles/meilisearch.umd.js",
"exports": {
".": {
"types": "./dist/types/index.d.ts",
"browser": "./dist/bundles/meilisearch.umd.js",
"import": "./dist/bundles/meilisearch.esm.js",
"require": "./dist/bundles/meilisearch.cjs.js",
"default": "./dist/bundles/meilisearch.umd.js"
}
},
"sideEffects": false,
"repository": {
"type": "git",
"url": "https://github.com/meilisearch/meilisearch-js"
},
"scripts": {
"playground:javascript": "yarn --cwd ./playgrounds/javascript && yarn --cwd ./playgrounds/javascript start",
"clear_jest": "jest --clearCache",
"cleanup": "shx rm -rf dist/",
"build": "yarn cleanup && rollup -c && rollup -c --environment NODE_ENV:production",
"build:docs": "typedoc",
"watch": "yarn cleanup && rollup -c --watch",
"postbuild": "yarn size && yarn typingsheader",
"test": "yarn clear_jest && jest --runInBand --verbose",
"test": "vitest run --coverage",
"types:watch": "nodemon --config nodemon.json",
"types": "yarn tsc",
"test:env:browser": "yarn build && yarn --cwd tests/env/express && yarn --cwd tests/env/express test",
"test:watch": "yarn clear_jest && yarn test --watch",
"test:coverage": "yarn test --coverage",
"test:ci": "yarn test --ci",
"test:watch": "vitest watch",
"test:coverage": "yarn test",
"test:ci": "yarn test",
"test:env": "yarn build && yarn test:env:nodejs && yarn test:env:esm && yarn test:env:node-ts",
"test:env:node-ts": "yarn --cwd tests/env/typescript-node start",
"test:env:nodejs": "yarn build && node tests/env/node/index.js && node tests/env/node/getting_started.js",
Expand All @@ -53,8 +61,8 @@
"style:fix": "yarn fmt:fix && yarn lint:fix",
"fmt": "prettier -c ./**/*.{js,ts}",
"fmt:fix": "prettier -w ./**/*.{js,ts}",
"lint": "eslint --ext .js,.ts,.tsx .",
"lint:fix": "eslint --ext .js,.ts,.tsx --fix .",
"lint": "eslint .",
"lint:fix": "eslint --fix .",
"typingsheader": "node scripts/build.js"
},
"files": [
Expand All @@ -75,23 +83,21 @@
"devDependencies": {
"@babel/core": "^7.25.2",
"@babel/preset-env": "^7.25.4",
"@eslint/js": "^9.11.1",
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-commonjs": "28.0.0",
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-node-resolve": "15.3.0",
"@types/jest": "^29.5.11",
"@typescript-eslint/eslint-plugin": "^6.19.0",
"@typescript-eslint/parser": "^6.19.0",
"@types/eslint__js": "^8.42.3",
"@vitest/coverage-v8": "2.0.5",
"@vitest/eslint-plugin": "^1.1.4",
"@types/node": "^20.16.10",
"brotli-size": "^4.0.0",
"eslint": "^8.56.0",
"eslint": "^9.11.1",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-jest": "^27.6.3",
"eslint-plugin-tsdoc": "^0.2.17",
"eslint-plugin-tsdoc": "^0.3.0",
"globals": "^15.9.0",
"gzip-size": "^6.0.0",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"jest-fetch-mock": "^3.0.3",
"jest-watch-typeahead": "^2.2.2",
"kleur": "^4.1.5",
"lint-staged": "15.2.10",
"nodemon": "^3.1.7",
Expand All @@ -102,9 +108,10 @@
"rollup-plugin-terser": "^7.0.0",
"rollup-plugin-typescript2": "^0.36.0",
"shx": "^0.3.2",
"ts-jest": "^29.2.5",
"typedoc": "^0.26.7",
"typescript": "^5.4.5"
"typescript": "^5.4.5",
"typescript-eslint": "^8.8.0",
"vitest": "2.0.5"
},
"packageManager": "[email protected]"
}
4 changes: 2 additions & 2 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const nodeResolve = require("@rollup/plugin-node-resolve");
const { resolve } = require("path");
const { resolve } = require("node:path");
const commonjs = require("@rollup/plugin-commonjs");
const json = require("@rollup/plugin-json");
const typescript = require("rollup-plugin-typescript2");
Expand All @@ -18,7 +18,7 @@ const PLUGINS = [
typescript({
useTsconfigDeclarationDir: true,
tsconfigOverride: {
allowJs: false,
compilerOptions: { allowJs: false },
include: ["src"],
exclude: ["tests", "examples", "*.js", "scripts"],
},
Expand Down
5 changes: 3 additions & 2 deletions scripts/build.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/** This file only purpose is to execute any build related tasks */

const { resolve, normalize } = require("path");
const { readFileSync, writeFileSync } = require("fs");
const { resolve, normalize } = require("node:path");
const { readFileSync, writeFileSync } = require("node:fs");

const pkg = require("../package.json");

const ROOT = resolve(__dirname, "..");
Expand Down
6 changes: 3 additions & 3 deletions scripts/file-size.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { basename, normalize } = require("path");
const { readFile: readFileCb } = require("fs");
const { promisify } = require("util");
const { basename, normalize } = require("node:path");
const { readFile: readFileCb } = require("node:fs");
const { promisify } = require("node:util");
const readFile = promisify(readFileCb);

const kolor = require("kleur");
Expand Down
2 changes: 1 addition & 1 deletion src/clients/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ class Client {
const url = `health`;
await this.httpRequest.get(url);
return true;
} catch (e: any) {
} catch {
return false;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/http-requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function constructHostURL(host: string): string {
host = addProtocolIfNotPresent(host);
host = addTrailingSlash(host);
return host;
} catch (e) {
} catch {
throw new MeiliSearchError("The provided host is not valid.");
}
}
Expand Down Expand Up @@ -105,7 +105,7 @@ class HttpRequests {
try {
const host = constructHostURL(config.host);
this.url = new URL(host);
} catch (e) {
} catch {
throw new MeiliSearchError("The provided host is not valid.");
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/package-version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const PACKAGE_VERSION = "0.42.0";
export const PACKAGE_VERSION = "0.43.0";
2 changes: 1 addition & 1 deletion src/token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ async function sign(
encodedHeader: string,
encodedPayload: string,
) {
const { createHmac } = await import("crypto");
const { createHmac } = await import("node:crypto");

return createHmac("sha256", apiKey)
.update(`${encodedHeader}.${encodedPayload}`)
Expand Down
Loading

0 comments on commit 2a81772

Please sign in to comment.