diff --git a/.eslintignore b/.eslintignore index 63520da7..c2b4126b 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,3 +1,9 @@ node_modules dist +examples +scripts +tests/env build + +# temporary fix +playgrounds/vanilla-js diff --git a/.eslintrc.js b/.eslintrc.js index 69de8773..2dbff557 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -10,11 +10,55 @@ module.exports = { context: true, // for jest/puppeteer tests in examples/express jestPuppeteer: true, // for jest/puppeteer tests in examples/express }, - extends: ['standard', 'plugin:prettier/recommended'], - plugins: ['jest'], + extends: [ + 'standard', + 'plugin:@typescript-eslint/recommended', + 'plugin:@typescript-eslint/recommended-requiring-type-checking', + 'plugin:prettier/recommended', + 'prettier/@typescript-eslint', + ], + parser: '@typescript-eslint/parser', parserOptions: { - ecmaVersion: 11, + ecmaVersion: 2020, sourceType: 'module', + project: ['tsconfig.eslint.json'], + projectFolderIgnoreList: ['dist'], + }, + plugins: ['jsdoc', '@typescript-eslint', 'prettier', 'jest'], + rules: { + 'no-dupe-class-members': 'off', // Off due to conflict with typescript overload functions + 'prettier/prettier': ['error', {}, { usePrettierrc: true }], + '@typescript-eslint/array-type': ['warn', { default: 'array-simple' }], + '@typescript-eslint/return-await': 'off', + 'jsdoc/check-alignment': 'error', + 'jsdoc/check-indentation': 'error', + '@typescript-eslint/space-before-function-paren': 0, + '@typescript-eslint/no-explicit-any': 'off', + '@typescript-eslint/explicit-function-return-type': 'off', + '@typescript-eslint/no-throw-literal': 'off', + '@typescript-eslint/no-non-null-assertion': 'off', + '@typescript-eslint/no-unsafe-assignment': 'off', + '@typescript-eslint/no-unsafe-call': 'off', + '@typescript-eslint/no-unsafe-return': 'off', + '@typescript-eslint/no-unsafe-module-boundary-types': 'off', + '@typescript-eslint/prefer-regexp-exec': 'off', + '@typescript-eslint/explicit-module-boundary-types': 'off', + '@typescript-eslint/no-unnecessary-type-assertion': 'off', + '@typescript-eslint/no-unsafe-member-access': 'off', + '@typescript-eslint/ban-types': 'off', + '@typescript-eslint/member-delimiter-style': [ + 'error', + { + multiline: { + delimiter: 'none', // 'none' or 'semi' or 'comma' + requireLast: true, + }, + singleline: { + delimiter: 'semi', // 'semi' or 'comma' + requireLast: false, + }, + }, + ], + 'comma-dangle': 'off', }, - rules: {}, } diff --git a/jest.config.js b/jest.config.js index 845548de..2ba739c7 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,4 +1,6 @@ module.exports = { verbose: true, modulePathIgnorePatterns: ['/examples'], + testMatch: ['/tests/**/*.ts?(x)'], + preset: 'ts-jest', } diff --git a/package.json b/package.json index 52132abe..2742f18b 100644 --- a/package.json +++ b/package.json @@ -4,26 +4,36 @@ "private": false, "description": "The search client to use MeiliSearch with InstantSearch.", "scripts": { + "cleanup": "shx rm -rf dist/", "test": "jest", "test:demo": "yarn build && yarn test:demo:browser && yarn test:demo:nodejs && yarn test:demo:esm", "test:demo:browser": "yarn --cwd examples/express && yarn --cwd examples/express test", "test:demo:nodejs": "node examples/node/index.js", "test:demo:esm": "yarn --cwd examples/esm && yarn --cwd examples/esm start", - "build:playground:vue": "yarn --cwd ./playgrounds/vue && yarn --cwd ./playgrounds/vue build", - "build:playground:react": "yarn --cwd ./playgrounds/react && yarn --cwd ./playgrounds/react build", - "build:playground:vanilla-js": "yarn --cwd ./playgrounds/vanilla-js && yarn --cwd ./playgrounds/vanilla-js build", + "build:playground:vue": "yarn build && yarn --cwd ./playgrounds/vue && yarn --cwd ./playgrounds/vue build", + "build:playground:react": "yarn build && yarn --cwd ./playgrounds/react && yarn --cwd ./playgrounds/react build", + "build:playground:vanilla-js": "yarn build && yarn --cwd ./playgrounds/vanilla-js && yarn --cwd ./playgrounds/vanilla-js build", "test:all": "yarn test && yarn test:demo", "lint": "eslint --ext .js,.ts,.tsx,.vue .", "lint:fix": "eslint --ext .js,.ts,.tsx,.vue --fix .", - "build": "rollup -c rollup.config.js && rollup --environment NODE_ENV:production -c rollup.config.js ", - "playground:vue": "yarn --cwd ./playgrounds/vue && yarn --cwd ./playgrounds/vue serve", - "playground:react": "yarn --cwd ./playgrounds/react && yarn --cwd ./playgrounds/react start", - "playground:vanilla-js": "yarn --cwd ./playgrounds/vanilla-js && yarn --cwd ./playgrounds/vanilla-js start" + "build": "yarn cleanup && rollup -c rollup.config.js && rollup --environment NODE_ENV:production -c rollup.config.js ", + "postbuild": "yarn typingsheader", + "playground:vue": "yarn build && yarn --cwd ./playgrounds/vue && yarn --cwd ./playgrounds/vue serve", + "playground:react": "yarn build && yarn --cwd ./playgrounds/react && yarn --cwd ./playgrounds/react start", + "playground:vanilla-js": "yarn build && yarn --cwd ./playgrounds/vanilla-js && yarn --cwd ./playgrounds/vanilla-js start", + "typingsheader": "node scripts/build.js" }, "main": "./dist/instant-meilisearch.umd.js", "module": "./dist/instant-meilisearch.esm.js", "browser": "./dist/instant-meilisearch.umd.js", "cjs": "./dist/instant-meilisearch.cjs.js", + "source": "src/index.ts", + "typings": "./dist/types/index.d.ts", + "types": "./dist/types/index.d.ts", + "sideEffects": false, + "bugs": { + "url": "https://github.com/meilisearch/instant-meilisearch/issues" + }, "files": [ "dist", "src" @@ -40,7 +50,7 @@ "url": "https://github.com/meilisearch/instant-meilisearch.git" }, "dependencies": { - "meilisearch": "^0.16.0" + "meilisearch": "^0.16.1" }, "devDependencies": { "@babel/cli": "^7.10.5", @@ -59,6 +69,7 @@ "eslint-plugin-flowtype": "^5.2.0", "eslint-plugin-import": "^2.22.0", "eslint-plugin-jest": "^24.0.0", + "eslint-plugin-jsdoc": "^30.7.7", "eslint-plugin-jsx-a11y": "^6.4.1", "eslint-plugin-node": "^11.1.0", "eslint-plugin-prettier": "^3.1.4", @@ -74,6 +85,9 @@ "rollup": "^2.23.0", "rollup-plugin-babel": "^4.4.0", "rollup-plugin-terser": "^7.0.0", + "rollup-plugin-typescript2": "^0.29.0", + "shx": "^0.3.3", + "ts-jest": "^26.4.4", "typescript": "^4.0.0" } } diff --git a/playgrounds/react/src/instant-meilisearch.js b/playgrounds/react/src/instant-meilisearch.js index f9ccdd19..c75a55c0 120000 --- a/playgrounds/react/src/instant-meilisearch.js +++ b/playgrounds/react/src/instant-meilisearch.js @@ -1 +1 @@ -../../../src/index.js \ No newline at end of file +../../../dist/instant-meilisearch.esm.js \ No newline at end of file diff --git a/playgrounds/vue/.eslintignore b/playgrounds/vue/.eslintignore new file mode 100644 index 00000000..e8e65946 --- /dev/null +++ b/playgrounds/vue/.eslintignore @@ -0,0 +1,5 @@ +node_modules +dist +examples +scripts +tests/env diff --git a/playgrounds/vue/src/App.vue b/playgrounds/vue/src/App.vue index 27183b4e..8ff83d07 100644 --- a/playgrounds/vue/src/App.vue +++ b/playgrounds/vue/src/App.vue @@ -5,40 +5,43 @@

Search in Steam video games 🎮

- This is not the official Steam dataset but only for demo purpose. - Enjoy searching with MeiliSearch! + This is not the official Steam dataset but only for demo purpose. Enjoy + searching with MeiliSearch!

- +
Clear all filters

Genres

- +

Players

- +

Platforms

- +

Misc

- +
- + @@ -57,19 +60,19 @@