Unverified Commit fa6b31d0 authored by Tasso Evangelista's avatar Tasso Evangelista Committed by GitHub
Browse files

build(deps)!: Update dependencies (#308)

parent 61cec87d
......@@ -15,7 +15,7 @@ jobs:
key: v1-dependencies-{{ checksum ".circleci/config.yml" }}-{{ checksum "package.json" }}
- run: yarn lerna run lint --stream
- run: yarn lerna run build --stream
- run: yarn lerna run test --stream
- run: yarn lerna run test:ci --stream
- persist_to_workspace:
root: ~/repo
paths:
......
......@@ -21,7 +21,6 @@
"changeProcessCWD": true
}
],
"eslint.enable": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
......
......@@ -8,7 +8,7 @@
"devDependencies": {
"cross-env": "^7.0.2",
"fs-extra": "^9.0.0",
"gh-pages": "^2.2.0",
"gh-pages": "^3.1.0",
"husky": "^4.2.3",
"lerna": "^3.20.2"
},
......@@ -16,7 +16,7 @@
"build": "lerna run build --stream",
"postinstall": "lerna run build --stream",
"build-storybook": "lerna run build-storybook --parallel --stream",
"test": "lerna run test",
"test": "lerna run test:ci --stream",
"lint": "lerna run lint",
"lint-staged": "lerna run lint-staged",
"storybook": "lerna run storybook --parallel",
......
......@@ -14,34 +14,58 @@ module.exports = {
legacyDecorators: true,
},
},
plugins: ['@typescript-eslint', 'react-hooks'],
plugins: ['@typescript-eslint'],
rules: {
'func-call-spacing': 'off',
'indent': 'off',
indent: 'off',
'import/order': ['error', {
'newlines-between': 'always',
groups: ['builtin', 'external', 'internal', ['parent', 'sibling', 'index']],
alphabetize: {
order: 'asc',
},
}],
'no-extra-parens': 'off',
'no-empty-function': 'off',
'no-useless-constructor': 'off',
'no-extra-parens': 'off',
'no-redeclare': 'off',
'no-spaced-func': 'off',
'no-undef': 'off',
'no-unused-vars': 'off',
'no-useless-constructor': 'off',
'no-use-before-define': 'off',
'operator-linebreak': ['error', 'before', {
overrides: {
'=': 'after',
},
}],
'@typescript-eslint/ban-ts-ignore': 'off',
'@typescript-eslint/func-call-spacing': ['error'],
'@typescript-eslint/indent': ['error', 2],
'@typescript-eslint/func-call-spacing': 'error',
'@typescript-eslint/indent': ['error', 2, {
SwitchCase: 1,
}],
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-extra-parens': ['error', 'all', {
conditionalAssign: true,
nestedBinaryExpressions: false,
returnAssign: true,
ignoreJSX: 'all',
enforceForArrowConditionals: false,
}],
'@typescript-eslint/no-redeclare': ['error'],
'@typescript-eslint/no-use-before-define': ['error'],
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/explicit-function-return-type': ['warn', {
allowExpressions: true,
}],
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars-experimental': 'warn',
},
env: {
browser: true,
commonjs: true,
es6: true,
node: true,
jest: true
jest: true,
},
settings: {
'import/resolver': {
......@@ -49,7 +73,7 @@ module.exports = {
extensions: [
'.js',
'.ts',
'.tsx'
'.tsx',
],
},
},
......
......@@ -30,7 +30,8 @@
"scripts": {
"start": "microbundle watch",
"build": "microbundle",
"test": "jest --max-workers=1",
"test": "jest",
"test:ci": "jest --runInBand",
"lint": "eslint --ext js,ts,tsx src",
"lint-staged": "lint-staged",
"docs": "documentation readme 'src/{,**/!(__mocks__)/**/}!(*.spec).ts' --parse-extension=ts --section='API Reference' --readme-file README.md"
......@@ -38,15 +39,16 @@
"devDependencies": {
"@rocket.chat/eslint-config": "^0.4.0",
"@types/jest": "^26.0.0",
"@typescript-eslint/eslint-plugin": "^3.4.0",
"@typescript-eslint/parser": "^3.4.0",
"documentation": "^13.0.1",
"eslint": "^6.5.1",
"@typescript-eslint/eslint-plugin": "^4.5.0",
"@typescript-eslint/parser": "^4.5.0",
"documentation": "^13.0.2",
"eslint": "^7.12.0",
"eslint-plugin-import": "^2.19.1",
"jest": "^26.1.0",
"lint-staged": "^10.0.8",
"microbundle": "^0.12.2",
"ts-jest": "^26.1.1"
"ts-jest": "^26.1.1",
"typescript": "^4.0.3"
},
"publishConfig": {
"access": "public"
......
......@@ -3,8 +3,7 @@ import { memoize } from './memoize';
/**
* Memoized and SSR-compatible facade of CSS.supports API
*/
export const cssSupports: ((value: string) => boolean) = (
(typeof window !== 'undefined' && typeof window.CSS !== 'undefined' && window.CSS.supports)
export const cssSupports: ((value: string) => boolean) =
typeof window !== 'undefined' && typeof window.CSS !== 'undefined' && window.CSS.supports
? memoize((value: string) => window.CSS.supports(value))
: () => false
);
: () => false;
......@@ -21,7 +21,9 @@ export const memoize = <A, R>(fn: (arg: A) => R): typeof fn => {
};
export const clear = <A, R>(fn: (arg: A) => R): void => {
if (store.has(fn)) {
store.get(fn)!.clear();
const x = store.get(fn);
if (x) {
x.clear();
}
};
......@@ -109,12 +109,11 @@ const wrapReferenceCounting = (attacher: RuleAttacher): RuleAttacher => {
*
* @returns a callback to detach the rules
*/
export const attachRules: RuleAttacher = (
export const attachRules: RuleAttacher =
(typeof window === 'undefined' && discardRules)
|| (
process.env.NODE_ENV === 'production'
&& !!CSSStyleSheet.prototype.insertRule
&& wrapReferenceCounting(attachRulesIntoStyleSheet)
)
|| wrapReferenceCounting(attachRulesIntoElement)
);
|| wrapReferenceCounting(attachRulesIntoElement);
import { createAnimationName, escapeName } from './names';
import { memoize } from './memoize';
import { createAnimationName, escapeName } from './names';
/**
* A shared state created by the upmost Evaluable in the call stack
......
......@@ -14,34 +14,58 @@ module.exports = {
legacyDecorators: true,
},
},
plugins: ['@typescript-eslint', 'react-hooks'],
plugins: ['@typescript-eslint'],
rules: {
'func-call-spacing': 'off',
'indent': 'off',
indent: 'off',
'import/order': ['error', {
'newlines-between': 'always',
groups: ['builtin', 'external', 'internal', ['parent', 'sibling', 'index']],
alphabetize: {
order: 'asc',
},
}],
'no-useless-constructor': 'off',
'no-empty-function': 'off',
'no-extra-parens': 'off',
'no-redeclare': 'off',
'no-spaced-func': 'off',
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'warn',
'no-undef': 'off',
'no-unused-vars': 'off',
'no-useless-constructor': 'off',
'no-use-before-define': 'off',
'operator-linebreak': ['error', 'before', {
overrides: {
'=': 'after',
},
}],
'@typescript-eslint/ban-ts-ignore': 'off',
'@typescript-eslint/func-call-spacing': ['error'],
'@typescript-eslint/indent': ['error', 2],
'@typescript-eslint/func-call-spacing': 'error',
'@typescript-eslint/indent': ['error', 2, {
SwitchCase: 1,
}],
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-extra-parens': ['error', 'all', {
conditionalAssign: true,
nestedBinaryExpressions: false,
returnAssign: true,
ignoreJSX: 'all',
enforceForArrowConditionals: false,
}],
'@typescript-eslint/no-redeclare': ['error'],
'@typescript-eslint/no-use-before-define': ['error'],
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/explicit-function-return-type': ['warn', {
allowExpressions: true,
}],
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars-experimental': 'warn',
},
env: {
browser: true,
commonjs: true,
es6: true,
node: true,
jest: true
jest: true,
},
settings: {
'import/resolver': {
......@@ -49,7 +73,7 @@ module.exports = {
extensions: [
'.js',
'.ts',
'.tsx'
'.tsx',
],
},
},
......
......@@ -35,6 +35,9 @@ yarn add @rocket.chat/emitter
#### Table of Contents
- [EventType](#eventtype)
- [Handler](#handler)
- [IEmitter](#iemitter)
- [Emitter](#emitter)
- [has](#has)
- [Parameters](#parameters)
......@@ -46,76 +49,16 @@ yarn add @rocket.chat/emitter
- [Parameters](#parameters-3)
- [emit](#emit)
- [Parameters](#parameters-4)
- [Emitter](#emitter-1)
- [has](#has-1)
- [Parameters](#parameters-5)
- [on](#on-1)
- [Parameters](#parameters-6)
- [once](#once-1)
- [Parameters](#parameters-7)
- [off](#off-1)
- [Parameters](#parameters-8)
- [emit](#emit-1)
- [Parameters](#parameters-9)
- [EventType](#eventtype)
- [Handler](#handler)
### Emitter
#### has
Returns `true` if this emmiter has a listener attached to the `key` event type
##### Parameters
- `key` **[EventType](#eventtype)**
Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**
#### on
Adds the `handler` function to listen events of the `type` type.
##### Parameters
- `type` **[EventType](#eventtype)**
- `handler` **[Handler](#handler)&lt;T>**
Returns **OffCallbackHandler** a function to unsubscribe the handler invoking `this.off(type, handler)`
#### once
Adds a _one-time_ `handler` function for the event of the `type` type.
##### Parameters
- `type` **[EventType](#eventtype)**
- `handler` **[Handler](#handler)&lt;T>**
Returns **OffCallbackHandler** a function to unsubscribe the handler invoking `this.off(type, handler)`
#### off
Removes the specified `handler` from the list of handlers of the event of the `type` type
##### Parameters
- `type` **[EventType](#eventtype)**
- `handler` **[Handler](#handler)&lt;T>**
Returns **void**
#### emit
### EventType
Calls each of the handlers registered for the event of `type` type, in the
order they were registered, passing the supplied argument `e` to each.
Type: ([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) \| [symbol](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol))
##### Parameters
### Handler
- `type` **[EventType](#eventtype)**
- `e` **T**
Type: function (event: T): void
Returns **void**
### IEmitter
### Emitter
......@@ -172,14 +115,6 @@ order they were registered, passing the supplied argument `e` to each.
##### Parameters
- `type` **[EventType](#eventtype)**
- `e` **T**
- `e` **T?**
Returns **void**
### EventType
Type: ([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) \| [symbol](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol))
### Handler
Type: function (event: T): void
......@@ -4,10 +4,12 @@
## Emitter.emit() method
Calls each of the handlers registered for the event of `type` type, in the order they were registered, passing the supplied argument `e` to each.
<b>Signature:</b>
```typescript
emit<T = any>(type: EventType, event?: T): void;
emit<T = any>(type: EventType, e?: T): void;
```
## Parameters
......@@ -15,7 +17,7 @@ emit<T = any>(type: EventType, event?: T): void;
| Parameter | Type | Description |
| --- | --- | --- |
| type | [EventType](./emitter.eventtype.md) | |
| event | T | |
| e | T | |
<b>Returns:</b>
......
......@@ -2,21 +2,24 @@
[Home](./index.md) &gt; [@rocket.chat/emitter](./emitter.md) &gt; [Emitter](./emitter.emitter.md)
## Emitter interface
## Emitter class
The event emitter class.
<b>Signature:</b>
```typescript
export interface Emitter
export declare class Emitter implements IEmitter
```
<b>Implements:</b> [IEmitter](./emitter.iemitter.md)
## Methods
| Method | Description |
| --- | --- |
| [emit(type, event)](./emitter.emitter.emit.md) | |
| [off(type, handler)](./emitter.emitter.off.md) | |
| [on(type, handler)](./emitter.emitter.on.md) | |
| [once(type, handler)](./emitter.emitter.once.md) | |
| Method | Modifiers | Description |
| --- | --- | --- |
| [emit(type, e)](./emitter.emitter.emit.md) | | Calls each of the handlers registered for the event of <code>type</code> type, in the order they were registered, passing the supplied argument <code>e</code> to each. |
| [has(key)](./emitter.emitter.has.md) | | Returns <code>true</code> if this emmiter has a listener attached to the <code>key</code> event type |
| [off(type, handler)](./emitter.emitter.off.md) | | Removes the specified <code>handler</code> from the list of handlers of the event of the <code>type</code> type |
| [on(type, handler)](./emitter.emitter.on.md) | | Adds the <code>handler</code> function to listen events of the <code>type</code> type. |
| [once(type, handler)](./emitter.emitter.once.md) | | Adds a \*one-time\* <code>handler</code> function for the event of the <code>type</code> type. |
......@@ -4,6 +4,8 @@
## Emitter.off() method
Removes the specified `handler` from the list of handlers of the event of the `type` type
<b>Signature:</b>
```typescript
......
......@@ -4,10 +4,12 @@
## Emitter.on() method
Adds the `handler` function to listen events of the `type` type.
<b>Signature:</b>
```typescript
on<T = any>(type: EventType, handler: Handler<T>): void;
on<T = any>(type: EventType, handler: Handler<T>): OffCallbackHandler;
```
## Parameters
......@@ -19,5 +21,7 @@ on<T = any>(type: EventType, handler: Handler<T>): void;
<b>Returns:</b>
void
OffCallbackHandler
a function to unsubscribe the handler invoking `this.off(type, handler)`
......@@ -4,10 +4,12 @@
## Emitter.once() method
Adds a \*one-time\* `handler` function for the event of the `type` type.
<b>Signature:</b>
```typescript
once<T = any>(type: EventType, handler: Handler<T>): void;
once<T = any>(type: EventType, handler: Handler<T>): OffCallbackHandler;
```
## Parameters
......@@ -19,5 +21,7 @@ once<T = any>(type: EventType, handler: Handler<T>): void;
<b>Returns:</b>
void
OffCallbackHandler
a function to unsubscribe the handler invoking `this.off(type, handler)`
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [@rocket.chat/emitter](./emitter.md) &gt; [IEmitter](./emitter.iemitter.md) &gt; [emit](./emitter.iemitter.emit.md)
## IEmitter.emit() method
<b>Signature:</b>
```typescript
emit<T = any>(type: EventType, event?: T): void;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| type | [EventType](./emitter.eventtype.md) | |
| event | T | |
<b>Returns:</b>
void
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [@rocket.chat/emitter](./emitter.md) &gt; [IEmitter](./emitter.iemitter.md)
## IEmitter interface
<b>Signature:</b>
```typescript
export interface IEmitter
```
## Methods
| Method | Description |
| --- | --- |
| [emit(type, event)](./emitter.iemitter.emit.md) | |
| [off(type, handler)](./emitter.iemitter.off.md) | |
| [on(type, handler)](./emitter.iemitter.on.md) | |
| [once(type, handler)](./emitter.iemitter.once.md) | |
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [@rocket.chat/emitter](./emitter.md) &gt; [IEmitter](./emitter.iemitter.md) &gt; [off](./emitter.iemitter.off.md)
## IEmitter.off() method
<b>Signature:</b>
```typescript
off<T = any>(type: EventType, handler: Handler<T>): void;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| type | [EventType](./emitter.eventtype.md) | |
| handler | [Handler](./emitter.handler.md)<!-- -->&lt;T&gt; | |
<b>Returns:</b>
void
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [@rocket.chat/emitter](./emitter.md) &gt; [IEmitter](./emitter.iemitter.md) &gt; [on](./emitter.iemitter.on.md)
## IEmitter.on() method
<b>Signature:</b>
```typescript
on<T = any>(type: EventType, handler: Handler<T>): void;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| type | [EventType](./emitter.eventtype.md) | |
| handler | [Handler](./emitter.handler.md)<!-- -->&lt;T&gt; | |