Skip to content

Commit dec371d

Browse files
bors[bot]bbbidoubiwa
authored
Merge #178
178: Convert project to TypeScript r=bidoubiwa a=curquiza The purpose of this PR/branch is to convert this project into a typescript project. Thanks to @bb for his huge participation in this work! Co-authored-by: Benjamin Bock <[email protected]> Co-authored-by: Charlotte Vermandel <[email protected]>
2 parents 80deb03 + 13e8535 commit dec371d

Some content is hidden

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

84 files changed

+18617
-8290
lines changed

.eslintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
node_modules
22
dist
33
build
4+
5+
.cache

.eslintrc.js

Lines changed: 167 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,169 @@
11
module.exports = {
2-
env: {
3-
browser: true,
4-
es2020: true,
5-
'jest/globals': true,
6-
},
7-
globals: {
8-
page: true, // for jest/puppeteer tests in examples/express
9-
browser: true, // for jest/puppeteer tests in examples/express
10-
context: true, // for jest/puppeteer tests in examples/express
11-
jestPuppeteer: true, // for jest/puppeteer tests in examples/express
12-
},
13-
extends: ['standard', 'plugin:prettier/recommended'],
14-
plugins: ['jest'],
15-
parserOptions: {
16-
ecmaVersion: 11,
17-
sourceType: 'module',
18-
},
19-
rules: {},
2+
root: true,
3+
overrides: [
4+
{
5+
/*
6+
* REACT
7+
*/
8+
files: ['playgrounds/react/**/*.js'],
9+
env: {
10+
es2020: true,
11+
commonjs: true, // Needed to avoid import is reserved error
12+
node: true,
13+
browser: true,
14+
jest: true,
15+
},
16+
parser: 'babel-eslint',
17+
extends: ['eslint:recommended', 'plugin:react/recommended'],
18+
plugins: ['react', 'import', 'react-hooks'],
19+
parserOptions: {
20+
ecmaFeatures: {
21+
jsx: true,
22+
},
23+
ecmaVersion: 2020,
24+
sourceType: 'module',
25+
},
26+
rules: {
27+
'react/prop-types': 0,
28+
},
29+
settings: {
30+
react: {
31+
version: 'latest',
32+
},
33+
},
34+
},
35+
{
36+
/*
37+
* JS
38+
*/
39+
files: ['**/*.js'],
40+
env: {
41+
browser: true,
42+
es2020: true,
43+
'jest/globals': true,
44+
node: true,
45+
jasmine: true,
46+
},
47+
globals: {
48+
instantsearch: true,
49+
instantMeiliSearch: true,
50+
page: true, // for jest/puppeteer tests in tests/env/express
51+
browser: true, // for jest/puppeteer tests in tests/env/express
52+
context: true, // for jest/puppeteer tests in tests/env/express
53+
jestPuppeteer: true, // for jest/puppeteer tests in tests/env/express
54+
jasmine: true, // for angular e2e tests in playground/angular
55+
},
56+
extends: [
57+
'standard',
58+
'plugin:prettier/recommended',
59+
'eslint:recommended',
60+
],
61+
plugins: ['jest'],
62+
parserOptions: {
63+
ecmaVersion: 2020,
64+
},
65+
rules: {},
66+
},
67+
{
68+
/*
69+
* VUE FILES
70+
*/
71+
72+
files: ['playgrounds/vue/**/*.vue'],
73+
env: {
74+
browser: true,
75+
commonjs: true,
76+
es6: true,
77+
},
78+
extends: [
79+
'plugin:prettier/recommended',
80+
'prettier/vue',
81+
'plugin:vue/essential',
82+
'plugin:vue/base',
83+
],
84+
parser: 'vue-eslint-parser',
85+
parserOptions: {
86+
parser: 'babel-eslint',
87+
ecmaVersion: 2020,
88+
sourceType: 'module',
89+
ecmaFeatures: {
90+
jsx: true,
91+
},
92+
},
93+
plugins: ['vue', 'prettier', 'jsdoc'],
94+
rules: {},
95+
},
96+
{
97+
/*
98+
* TYPESCRIPT
99+
*/
100+
files: ['*.ts'],
101+
env: {
102+
browser: true,
103+
es2020: true,
104+
'jest/globals': true,
105+
jasmine: true,
106+
},
107+
globals: {
108+
page: true, // for jest/puppeteer tests in tests/env/express
109+
browser: true, // for jest/puppeteer tests in tests/env/express
110+
context: true, // for jest/puppeteer tests in tests/env/express
111+
jestPuppeteer: true, // for jest/puppeteer tests in tests/env/express
112+
jasmine: true, // for angular e2e tests in playground/angular
113+
},
114+
extends: [
115+
'standard',
116+
'plugin:@typescript-eslint/recommended',
117+
'plugin:@typescript-eslint/recommended-requiring-type-checking',
118+
'plugin:prettier/recommended',
119+
'prettier/@typescript-eslint',
120+
],
121+
parser: '@typescript-eslint/parser',
122+
parserOptions: {
123+
ecmaVersion: 2020,
124+
sourceType: 'module',
125+
project: ['tsconfig.eslint.json'],
126+
projectFolderIgnoreList: ['dist'],
127+
},
128+
129+
plugins: ['jsdoc', '@typescript-eslint', 'prettier', 'jest'],
130+
rules: {
131+
'@typescript-eslint/no-empty-interface': 'off', // Due to vue-instantsearch not having typings
132+
'no-dupe-class-members': 'off', // Off due to conflict with typescript overload functions
133+
'prettier/prettier': ['error', {}, { usePrettierrc: true }],
134+
'@typescript-eslint/array-type': ['warn', { default: 'array-simple' }],
135+
'@typescript-eslint/return-await': 'off',
136+
'jsdoc/check-alignment': 'error',
137+
'jsdoc/check-indentation': 'error',
138+
'@typescript-eslint/space-before-function-paren': 0,
139+
'@typescript-eslint/no-explicit-any': 'off',
140+
'@typescript-eslint/explicit-function-return-type': 'off',
141+
'@typescript-eslint/no-throw-literal': 'off',
142+
'@typescript-eslint/no-non-null-assertion': 'off',
143+
'@typescript-eslint/no-unsafe-assignment': 'off',
144+
'@typescript-eslint/no-unsafe-call': 'off',
145+
'@typescript-eslint/no-unsafe-return': 'off',
146+
'@typescript-eslint/no-unsafe-module-boundary-types': 'off',
147+
'@typescript-eslint/prefer-regexp-exec': 'off',
148+
'@typescript-eslint/explicit-module-boundary-types': 'off',
149+
'@typescript-eslint/no-unnecessary-type-assertion': 'off',
150+
'@typescript-eslint/no-unsafe-member-access': 'off',
151+
'@typescript-eslint/ban-types': 'off',
152+
'@typescript-eslint/member-delimiter-style': [
153+
'error',
154+
{
155+
multiline: {
156+
delimiter: 'none', // 'none' or 'semi' or 'comma'
157+
requireLast: true,
158+
},
159+
singleline: {
160+
delimiter: 'semi', // 'semi' or 'comma'
161+
requireLast: false,
162+
},
163+
},
164+
],
165+
'comma-dangle': 'off',
166+
},
167+
},
168+
],
20169
}

.github/workflows/test.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ jobs:
2626
run: yarn build
2727
- name: Run env tests
2828
run: yarn test:env
29+
- name: Run env tests
30+
run: yarn test:env
2931

3032

3133
style:

jest.config.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,25 @@
11
module.exports = {
22
verbose: true,
3-
modulePathIgnorePatterns: ['<rootDir>/tests/env'],
3+
projects: [
4+
{
5+
preset: 'ts-jest',
6+
displayName: 'dom',
7+
// We are using jest-environment-jsdom 25 until we stop supporting node 10
8+
// jest-environment-jsdom 25 uses jsdom 15 which still supports node 10
9+
testEnvironment: 'jest-environment-jsdom',
10+
testPathIgnorePatterns: [
11+
'<rootDir>/tests/env/express',
12+
'<rootDir>/playgrounds/angular',
13+
],
14+
},
15+
{
16+
preset: 'ts-jest',
17+
displayName: 'node',
18+
testEnvironment: 'node',
19+
testPathIgnorePatterns: [
20+
'<rootDir>/tests/env/express',
21+
'<rootDir>/playgrounds/angular',
22+
],
23+
},
24+
],
425
}

package.json

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,45 @@
44
"private": false,
55
"description": "The search client to use MeiliSearch with InstantSearch.",
66
"scripts": {
7-
"test": "jest",
8-
"test:env": "yarn build && yarn test:env:browser && yarn test:env:nodejs && yarn test:env:esm",
7+
"cleanup": "shx rm -rf dist/",
8+
"test": "yarn build && jest",
9+
"test:all": "yarn test && yarn test:env && yarn test:playgrounds && yarn test:e2e",
10+
"test:env": "yarn build && yarn test:env:browser && yarn test:env:nodejs && yarn test:env:esm && yarn test:env:ts",
911
"test:env:browser": "yarn --cwd tests/env/express && yarn --cwd tests/env/express test",
1012
"test:env:nodejs": "node tests/env/node/index.js",
1113
"test:env:esm": "yarn --cwd tests/env/esm && yarn --cwd tests/env/esm start",
12-
"test:playgrounds": "yarn build:playground:vue && yarn build:playground:react && yarn build:playground:javascript && yarn build:playground:html",
14+
"test:env:ts": "yarn --cwd tests/env/typescript-node && yarn --cwd tests/env/typescript-node start",
15+
"test:playgrounds": "yarn build:playground:vue && yarn build:playground:react && yarn build:playground:javascript && yarn build:playground:html && yarn build:playground:angular",
1316
"build:playground:vue": "yarn --cwd ./playgrounds/vue && yarn --cwd ./playgrounds/vue build",
1417
"build:playground:react": "yarn --cwd ./playgrounds/react && yarn --cwd ./playgrounds/react build",
1518
"build:playground:javascript": "yarn --cwd ./playgrounds/javascript && yarn --cwd ./playgrounds/javascript build",
1619
"build:playground:html": "yarn --cwd ./playgrounds/html && yarn --cwd ./playgrounds/html build",
17-
"test:all": "yarn test && yarn test:demo",
18-
"lint": "eslint --ext .js,.ts,.tsx,.vue .",
19-
"lint:fix": "eslint --ext .js,.ts,.tsx,.vue --fix .",
20-
"build": "rollup -c rollup.config.js && rollup --environment NODE_ENV:production -c rollup.config.js ",
20+
"build:playground:angular": "yarn --cwd ./playgrounds/angular && yarn --cwd ./playgrounds/angular build",
2121
"playground:vue": "yarn --cwd ./playgrounds/vue && yarn --cwd ./playgrounds/vue serve",
2222
"playground:react": "yarn --cwd ./playgrounds/react && yarn --cwd ./playgrounds/react start",
2323
"playground:javascript": "yarn --cwd ./playgrounds/javascript && yarn --cwd ./playgrounds/javascript start",
24-
"playground:html": "yarn --cwd ./playgrounds/html && yarn --cwd ./playgrounds/html start"
24+
"playground:html": "yarn --cwd ./playgrounds/html && yarn --cwd ./playgrounds/html start",
25+
"playground:angular": "yarn --cwd ./playgrounds/angular && yarn --cwd ./playgrounds/angular start",
26+
"test:e2e": "yarn e2e:angular",
27+
"e2e:angular": "yarn --cwd ./playgrounds/angular && yarn --cwd ./playgrounds/angular e2e",
28+
"postbuild": "yarn typingsheader",
29+
"typingsheader": "node scripts/build.js",
30+
"build": "yarn cleanup && rollup -c rollup.config.js && rollup --environment NODE_ENV:production -c rollup.config.js ",
31+
"dev": "rollup -c rollup.config.js --watch",
32+
"lint": "eslint --ext .js,.ts,.tsx,.vue .",
33+
"lint:fix": "eslint --ext .js,.ts,.tsx,.vue --fix ."
2534
},
2635
"main": "./dist/instant-meilisearch.umd.js",
2736
"module": "./dist/instant-meilisearch.esm.js",
2837
"browser": "./dist/instant-meilisearch.umd.js",
2938
"cjs": "./dist/instant-meilisearch.cjs.js",
39+
"source": "src/index.ts",
40+
"typings": "./dist/types/index.d.ts",
41+
"types": "./dist/types/index.d.ts",
42+
"sideEffects": false,
43+
"bugs": {
44+
"url": "https://github.com/meilisearch/instant-meilisearch/issues"
45+
},
3046
"files": [
3147
"dist",
3248
"src",
@@ -48,37 +64,44 @@
4864
},
4965
"devDependencies": {
5066
"@babel/cli": "^7.10.5",
51-
"@babel/core": "^7.0.0",
67+
"@babel/core": "^7.0.0-0",
5268
"@babel/preset-env": "^7.10.4",
5369
"@rollup/plugin-commonjs": "^17.1.0",
5470
"@rollup/plugin-node-resolve": "^11.0.0",
5571
"@typescript-eslint/eslint-plugin": "^4.14.0",
5672
"@typescript-eslint/parser": "^4.14.0",
73+
"@vue/eslint-config-typescript": "^7.0.0",
74+
"@vue/eslint-plugin": "^4.2.0",
5775
"babel-eslint": "^10.1.0",
5876
"babel-jest": "^26.1.0",
5977
"cssnano": "^4.1.10",
6078
"eslint": "^7.19.0",
6179
"eslint-config-prettier": "^7.2.0",
62-
"eslint-config-react-app": "^6.0.0",
6380
"eslint-config-standard": "^16.0.0",
6481
"eslint-plugin-flowtype": "^5.2.0",
6582
"eslint-plugin-import": "^2.22.0",
6683
"eslint-plugin-jest": "^24.0.0",
84+
"eslint-plugin-jsdoc": "^30.7.7",
6785
"eslint-plugin-jsx-a11y": "^6.4.1",
6886
"eslint-plugin-node": "^11.1.0",
6987
"eslint-plugin-prettier": "^3.1.4",
7088
"eslint-plugin-promise": "^4.2.1",
71-
"eslint-plugin-react": "^7.21.5",
89+
"eslint-plugin-react": "^7.22.0",
7290
"eslint-plugin-react-hooks": "^4.2.0",
7391
"eslint-plugin-standard": "^5.0.0",
7492
"eslint-plugin-vue": "^7.5.0",
75-
"jest": "^26.1.0",
93+
"instantsearch.js": "^4.14.0",
94+
"jest": "^26.6.3",
95+
"jest-environment-jsdom": "25.5",
7696
"jest-watch-typeahead": "^0.6.0",
7797
"prettier": "^2.0.0",
7898
"regenerator-runtime": "^0.13.7",
7999
"rollup": "^2.38.0",
80100
"rollup-plugin-babel": "^4.4.0",
81101
"rollup-plugin-terser": "^7.0.0",
102+
"rollup-plugin-typescript2": "^0.29.0",
103+
"shx": "^0.3.3",
104+
"ts-jest": "^26.4.4",
82105
"typescript": "^4.0.0"
83106
}
84107
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
2+
# For additional information regarding the format and rule options, please see:
3+
# https://github.com/browserslist/browserslist#queries
4+
5+
# For the full list of supported browsers by the Angular framework, please see:
6+
# https://angular.io/guide/browser-support
7+
8+
# You can see what browsers were selected by your queries by running:
9+
# npx browserslist
10+
11+
last 1 Chrome version
12+
last 1 Firefox version
13+
last 2 Edge major versions
14+
last 2 Safari major versions
15+
last 2 iOS major versions
16+
Firefox ESR
17+
not IE 11 # Angular supports IE 11 only as an opt-in. To opt-in, remove the 'not' prefix on this line.

playgrounds/angular/.gitignore

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# See http://help.github.com/ignore-files/ for more about ignoring files.
2+
3+
# compiled output
4+
/dist
5+
/tmp
6+
/out-tsc
7+
# Only exists if Bazel was run
8+
/bazel-out
9+
10+
# dependencies
11+
/node_modules
12+
13+
# profiling files
14+
chrome-profiler-events*.json
15+
speed-measure-plugin*.json
16+
17+
# IDEs and editors
18+
/.idea
19+
.project
20+
.classpath
21+
.c9/
22+
*.launch
23+
.settings/
24+
*.sublime-workspace
25+
26+
# IDE - VSCode
27+
.vscode/*
28+
!.vscode/settings.json
29+
!.vscode/tasks.json
30+
!.vscode/launch.json
31+
!.vscode/extensions.json
32+
.history/*
33+
34+
# misc
35+
/.sass-cache
36+
/connect.lock
37+
/coverage
38+
/libpeerconnection.log
39+
npm-debug.log
40+
yarn-error.log
41+
testem.log
42+
/typings
43+
44+
# System Files
45+
.DS_Store
46+
Thumbs.db

0 commit comments

Comments
 (0)