Skip to content
This repository has been archived by the owner on Feb 6, 2023. It is now read-only.

Commit

Permalink
Upgrade eslint + flow, and fix failed test from nullishCoalescingOper…
Browse files Browse the repository at this point in the history
…ator (#2083)

Summary:
**Summary**

I want to upgrade ESLint and Flow on this project. I ended up with
- Remove unused `eslint-plugin-relay`
- Upgrade all ESLint packages to the latest version and fix all the new lint errors afterward.
  - `eslint-config-fbjs`
  - `eslint-config-prettier`
  - `eslint-plugin-babel`
  - `eslint-plugin-flowtype`
  - `eslint-plugin-jsx-a11y`
  - `eslint-plugin-prettier`
  - `eslint-plugin-react`

- Upgrade Flow (`flow-bin`) to the `0.115.0`.

~Then I found that `yarn test` is failing at~
```
src/component/handlers/composition/__tests__/DraftEditorCompostionHandler-test.js: Support for the experimental syntax 'nullishCoalescingOperator' isn't currently enabled (70:40)
```
~So I added `babel/plugin-proposal-nullish-coalescing-operator` to jest preprocessor as well.~
Move plugins in `.babelrc` to jest preprocessor as #2083 (comment)

**Test Plan**

`yarn lint`, `yarn flow`, and `yarn test` should all pass.
Pull Request resolved: #2083

Reviewed By: claudiopro

Differential Revision: D19398251

Pulled By: mrkev

fbshipit-source-id: 4fc2f6dd6e0cd44266d061455b7b6a433231715a
  • Loading branch information
lukyth authored and facebook-github-bot committed Jan 15, 2020
1 parent bafe30a commit 824fd12
Show file tree
Hide file tree
Showing 8 changed files with 171 additions and 87 deletions.
3 changes: 0 additions & 3 deletions .babelrc

This file was deleted.

2 changes: 1 addition & 1 deletion meta/bundle-size-stats/Draft.js.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion meta/bundle-size-stats/Draft.min.js.json

Large diffs are not rendered by default.

13 changes: 6 additions & 7 deletions package.json
Expand Up @@ -53,17 +53,16 @@
"cross-env": "^6.0.3",
"del": "^5.1.0",
"es6-shim": "^0.35.5",
"eslint": "^6.6.0",
"eslint": "^6.8.0",
"eslint-config-fbjs": "^3.1.1",
"eslint-config-prettier": "^6.5.0",
"eslint-config-prettier": "^6.9.0",
"eslint-plugin-babel": "^5.3.0",
"eslint-plugin-flowtype": "^4.3.0",
"eslint-plugin-flowtype": "^4.6.0",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-prettier": "^3.1.1",
"eslint-plugin-react": "^7.16.0",
"eslint-plugin-relay": "^1.3.12",
"eslint-plugin-prettier": "^3.1.2",
"eslint-plugin-react": "^7.17.0",
"fbjs-scripts": "^1.2.0",
"flow-bin": "^0.110.1",
"flow-bin": "^0.115.0",
"gulp": "^4.0.2",
"gulp-babel": "^8.0.0",
"gulp-clean-css": "^4.2.0",
Expand Down
4 changes: 4 additions & 0 deletions scripts/jest/preprocessor.js
Expand Up @@ -15,6 +15,10 @@ module.exports = {
process(src, filename) {
var options = {
presets: [fbjsConfigurePreset({rewriteModules: {map: moduleMap}})],
plugins: [
require('@babel/plugin-proposal-nullish-coalescing-operator'),
require('@babel/plugin-proposal-optional-chaining')
],
filename: filename,
retainLines: true,
};
Expand Down
2 changes: 1 addition & 1 deletion src/.flowconfig
Expand Up @@ -50,4 +50,4 @@ unsafe-getters-setters
; nonstrict-import

[version]
^0.110.1
^0.115.0
2 changes: 2 additions & 0 deletions src/component/handlers/edit/editOnBlur.js
Expand Up @@ -29,6 +29,8 @@ function editOnBlur(editor: DraftEditor, e: SyntheticEvent<HTMLElement>): void {
// opposed to clicking to another tab or window).
const {ownerDocument} = e.currentTarget;
if (
// This ESLint rule conflicts with `sketchy-null-bool` flow check
// eslint-disable-next-line no-extra-boolean-cast
!Boolean(editor.props.preserveSelectionOnBlur) &&
getActiveElement(ownerDocument) === ownerDocument.body
) {
Expand Down
230 changes: 156 additions & 74 deletions yarn.lock

Large diffs are not rendered by default.

0 comments on commit 824fd12

Please sign in to comment.