Skip to content

Commit

Permalink
Merge remote-tracking branch 'react-instantsearch/monorepo' into feat…
Browse files Browse the repository at this point in the history
…/introduce-react-to-monorepo
  • Loading branch information
Haroenv committed Dec 15, 2022
2 parents c60dbe0 + 7921352 commit b8e147f
Show file tree
Hide file tree
Showing 859 changed files with 222,853 additions and 3,864 deletions.
10 changes: 7 additions & 3 deletions .codesandbox/ci.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"sandboxes": ["instantsearchjs-es-template-pcw1k"],
"buildCommand": "build --no-private",
"packages": ["packages/instantsearch.js"],
"sandboxes": [
"instantsearchjs-es-template-pcw1k",
"github/algolia/create-instantsearch-app/tree/templates/react-instantsearch",
"/examples/hooks/default-theme"
],
"buildCommand": "build --no-private --ignore *-maps --ignore *-native",
"packages": ["packages/*"],
"node": "14"
}
21 changes: 18 additions & 3 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
# Vendors
node_modules
**/node_modules/**

# Artifacts
dist
build
website
**/cjs
**/es
**/dist
coverage

/website

# Caches
.cache
.parcel-cache
**/node_modules
.expo
.next

# Partially wrong examples:
## React-Native TypeScript wasn't supporting the mix of react 18 and 17
examples/hooks/react-native
## Excluded from global typescript config
examples/hooks/next/next-env.d.ts
204 changes: 182 additions & 22 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,62 @@
module.exports = {
extends: ['algolia', 'algolia/jest', 'algolia/react', 'algolia/typescript'],
/**
* @type {import('eslint').Linter.Config}
*/
const config = {
extends: [
'algolia',
'algolia/jest',
'algolia/react',
'algolia/typescript',
'plugin:react-hooks/recommended',
],
plugins: ['react-hooks', 'deprecation'],
globals: {
__DEV__: false,
},
settings: {
react: {
version: 'detect',
},
'import/resolver': {
node: {
// The migration is an incremental process so we import TypeScript modules
// from JavaScript files.
// By default, `import/resolver` only supports JavaScript modules.
extensions: ['.js', '.ts', '.tsx'],
},
},
},
rules: {
'no-param-reassign': 'off',
'no-use-before-define': 'off',
// @TODO: re-enable once the rule is properly setup for monorepos
// https://github.com/benmosher/eslint-plugin-import/issues/1103
// https://github.com/benmosher/eslint-plugin-import/issues/1174
'import/no-extraneous-dependencies': 'off',
'@typescript-eslint/explicit-member-accessibility': ['off'],
'import/extensions': 'off',
'eslint-comments/disable-enable-pair': 'off',
'react/jsx-no-bind': 'off',
// We can't display an error message with the ESLint version we're using
// See https://github.com/eslint/eslint/pull/14580
'no-restricted-imports': [
'error',
{
// We disallow InstantSearch.js CJS imports to only use ESM and not
// end up having duplicated source code in our bundle.
patterns: ['instantsearch.js/cjs/*'],
// We disallow importing the root ES import because the transformed CJS
// build then includes everything (widgets, components, etc.) and these
// aren't required or useful.
paths: ['instantsearch.js/es'],
},
],
'react-hooks/exhaustive-deps': [
'warn',
{
additionalHooks: '(useIsomorphicLayoutEffect)',
},
],
'new-cap': [
'error',
{
Expand All @@ -16,7 +69,7 @@ module.exports = {
'react/no-deprecated': 'off',
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'warn',
'jest/no-test-callback': 'off',
'jest/no-done-callback': 'warn',
'eslint-comments/disable-enable-pair': ['error', { allowWholeFile: true }],
'@typescript-eslint/no-unused-vars': [
'error',
Expand All @@ -34,7 +87,8 @@ module.exports = {
format: ['camelCase', 'PascalCase', 'UPPER_CASE'],
leadingUnderscore: 'allow',
filter: {
regex: '^EXPERIMENTAL_|__DEV__',
regex:
'^EXPERIMENTAL_|__DEV__|__APP_INITIAL_STATE__|__SERVER_STATE__|free_shipping',
match: false,
},
},
Expand All @@ -56,12 +110,122 @@ module.exports = {
'no-restricted-syntax': [
'error',
{
selector: 'AssignmentExpression [name=defaultProps]',
selector: 'AssignmentExpression MemberExpression Identifier[name=defaultProps]',
message: 'defaultProps are not allowed, use function defaults instead.',
},
],
},
overrides: [
{
files: ['*.ts', '*.tsx'],
rules: {
// This rule has issues with the TypeScript parser, but tsc catches
// these sorts of errors anyway.
// See: https://github.com/typescript-eslint/typescript-eslint/issues/342
'no-undef': 'off',
},
},
{
files: ['stories/**/*'],
rules: {
'react/prop-types': 'off',
'@typescript-eslint/no-use-before-define': ['off'],
},
},
{
files: ['scripts/**/*', '*.config.js', '*.conf.js'],
rules: {
'import/no-commonjs': 'off',
},
},
{
files: [
'packages/react-instantsearch-hooks/**/*',
'packages/react-instantsearch-hooks-*/**/*',
],
rules: {
'@typescript-eslint/consistent-type-assertions': 'off',
// We don't ship PropTypes in the next version of the library.
'react/prop-types': 'off',
'import/order': [
'error',
{
alphabetize: {
order: 'asc',
caseInsensitive: true,
},
'newlines-between': 'always',
groups: [
'builtin',
'external',
'parent',
'sibling',
'index',
'type',
],
pathGroups: [
{
pattern: '@/**/*',
group: 'parent',
position: 'before',
},
],
pathGroupsExcludedImportTypes: ['builtin'],
},
],
'import/extensions': ['error', 'never'],
},
settings: {
'import/parsers': {
'@typescript-eslint/parser': ['.ts', '.tsx'],
},
},
},
{
files: 'packages/**/*',
excludedFiles: ['*.test.*', '**/__tests__/**'],
rules: {
'no-restricted-syntax': [
'error',
{
selector: '[async=true]',
message:
'The polyfill for async/await is very large, which is why we use promise chains',
},
{
selector: 'ForInStatement',
message:
'for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array.',
},
{
selector: 'ForOfStatement',
message:
'iterators/generators require regenerator-runtime, which is too heavyweight for this guide to allow them. Separately, loops should be avoided in favor of array iterations.',
},
{
selector: 'LabeledStatement',
message:
'Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.',
},
{
selector: 'WithStatement',
message:
'`with` is disallowed in strict mode because it makes code impossible to predict and optimize.',
},
],
},
},
// Disable stricter rules introduced for the next versions of the libraries.
{
files: [
'packages/react-instantsearch-core/**/*',
'packages/react-instantsearch-dom/**/*',
],
rules: {
'@typescript-eslint/consistent-type-assertions': 'off',
'@typescript-eslint/ban-types': 'off',
},
},
{
files: ['*.ts', '*.tsx'],
rules: {
Expand All @@ -83,6 +247,12 @@ module.exports = {
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
},
},
{
files: ['examples/hooks/react-native/**/*.ts', 'examples/hooks/react-native/**/*.tsx'],
parserOptions: {
project: 'examples/hooks/react-native/tsconfig.json',
},
},
{
files: [
'packages/instantsearch.js/src/**/*.ts',
Expand All @@ -92,6 +262,11 @@ module.exports = {
rules: {
'import/extensions': ['error', 'never'],
},
settings: {
react: {
pragma: 'h',
},
},
},
{
files: ['*.js'],
Expand Down Expand Up @@ -160,21 +335,6 @@ module.exports = {
},
},
],
settings: {
react: {
version: 'detect',
pragma: 'h',
},
'import/resolver': {
node: {
// The migration is an incremental process so we import TypeScript modules
// from JavaScript files.
// By default, `import/resolver` only supports JavaScript modules.
extensions: ['.js', '.ts', '.tsx'],
},
},
},
globals: {
__DEV__: false,
},
};

module.exports = config;
18 changes: 13 additions & 5 deletions .github/ISSUE_TEMPLATE/Bug_report.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: Bug report
about: Help us improve InstantSearch.js
about: Help us improve InstantSearch
---

## 🐛 Bug description
Expand All @@ -16,11 +16,18 @@ about: Help us improve InstantSearch.js
3. Scroll down to `...`
4. See error

<!-- A live example helps a lot! Fork the sandbox, reproduce the bug and paste the URL here: -->


**Live reproduction:**

https://codesandbox.io/s/github/algolia/create-instantsearch-app/tree/templates/instantsearch.js
<!--
A live example helps a lot! Fork the sandbox, reproduce the bug and paste the URL here:
For a bug in InstantSearch.js: https://codesandbox.io/s/github/algolia/create-instantsearch-app/tree/templates/instantsearch.js
For a bug in React InstantSearch: https://codesandbox.io/s/github/algolia/create-instantsearch-app/tree/templates/react-instantsearch
For a bug in React InstantSearch Hooks: https://codesandbox.io/s/github/algolia/create-instantsearch-app/tree/templates/react-instantsearch-hooks
-->


## 💭 Expected behavior

Expand All @@ -33,8 +40,9 @@ https://codesandbox.io/s/github/algolia/create-instantsearch-app/tree/templates/
## Environment

- OS: [e.g. Windows / Linux / macOS / iOS / Android]
- Browser: [e.g. Chrome, Safari]
- Version: [e.g. 22]
- Browser: [e.g. Chrome 102.0.5005.61, Safari 15.2]
- InstantSearch version: [e.g. 6.24.0]
- React version: [e.g. 18.1.0]

## Additional context

Expand Down
42 changes: 42 additions & 0 deletions .github/ISSUE_TEMPLATE/Bug_report_Hooks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
name: Bug report for Hooks
about: Help us improve React InstantSearch Hooks
---

## 🐛 Bug description

<!-- A clear and concise description of what the bug is. -->

## 🔍 Bug reproduction

**Steps to reproduce the behavior:**

1. Go to `...`
2. Click on `...`
3. Scroll down to `...`
4. See error

<!-- A live example helps a lot! Fork the sandbox, reproduce the bug and paste the URL here: -->

**Live reproduction:**

https://codesandbox.io/s/github/algolia/react-instantsearch/tree/master/examples/hooks

## 💭 Expected behavior

<!-- A clear and concise description of what you expected to happen. -->

## 🖥 Screenshots

<!-- If applicable, add screenshots to help explain your problem. -->

## Environment

- React InstantSearch Hooks version: [e.g. 6.24.0]
- React version: [e.g. 18.1.0]
- Browser: [e.g. Chrome 102.0.5005.61, Safari 15.2]
- OS: [e.g. Windows / Linux / macOS / iOS / Android]

## Additional context

<!-- Add any other context about the problem here. -->
7 changes: 0 additions & 7 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,4 @@
Demonstrate the code is solid.
Example: The exact commands you ran and their output,
screenshots / videos if the pull request changes UI.
You will be able to test out these changes on the deploy
preview (address will be commented by a bot):
1. the documentation site (/)
2. a widget playground (/stories)
-->

Binary file added .github/example-e-commerce.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .github/example-media.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .github/example-tourism.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .github/react-instantsearch-banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit b8e147f

Please sign in to comment.