GeezerVison is showing github.com — Upgrade ESLint so we can use JSX Fragment syntax (#16328) · react/react@0bd0c52
File treeExpand file treeCollapse file tree Open diff view settings fixtures/dom/src/components/fixtures/suspense react-reconciler/src/__tests__ react-refresh/src/__tests__ react-test-renderer/src/__tests__
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: .eslintrc.js +22-17Lines changed: 22 additions & 17 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -12,18 +12,13 @@ module.exports = { | 12 | 12 | extends: 'fbjs', | 13 | 13 |
| 14 | 14 | // Stop ESLint from looking for a configuration file in parent folders | 15 | | - 'root': true, | | 15 | + root: true, | 16 | 16 |
| 17 | | - plugins: [ | 18 | | - 'jest', | 19 | | - 'no-for-of-loops', | 20 | | - 'react', | 21 | | - 'react-internal', | 22 | | - ], | | 17 | + plugins: ['jest', 'no-for-of-loops', 'react', 'react-internal'], | 23 | 18 |
| 24 | | - parser: 'espree', | | 19 | + parser: 'babel-eslint', | 25 | 20 | parserOptions: { | 26 | | - ecmaVersion: 2017, | | 21 | + ecmaVersion: 8, | 27 | 22 | sourceType: 'script', | 28 | 23 | ecmaFeatures: { | 29 | 24 | experimentalObjectRestSpread: true, | @@ -40,8 +35,8 @@ module.exports = { | 40 | 35 | 'dot-location': [ERROR, 'property'], | 41 | 36 | 'dot-notation': ERROR, | 42 | 37 | 'eol-last': ERROR, | 43 | | - 'eqeqeq': [ERROR, 'allow-null'], | 44 | | - 'indent': OFF, | | 38 | + eqeqeq: [ERROR, 'allow-null'], | | 39 | + indent: OFF, | 45 | 40 | 'jsx-quotes': [ERROR, 'prefer-double'], | 46 | 41 | 'keyword-spacing': [ERROR, {after: true, before: true}], | 47 | 42 | 'no-bitwise': OFF, | @@ -51,9 +46,9 @@ module.exports = { | 51 | 46 | 'no-shadow': ERROR, | 52 | 47 | 'no-unused-expressions': ERROR, | 53 | 48 | 'no-unused-vars': [ERROR, {args: 'none'}], | 54 | | - 'no-use-before-define': [ERROR, {functions: false, variables: false}], | | 49 | + 'no-use-before-define': OFF, | 55 | 50 | 'no-useless-concat': OFF, | 56 | | - 'quotes': [ERROR, 'single', {avoidEscape: true, allowTemplateLiterals: true }], | | 51 | + quotes: [ERROR, 'single', {avoidEscape: true, allowTemplateLiterals: true}], | 57 | 52 | 'space-before-blocks': ERROR, | 58 | 53 | 'space-before-function-paren': OFF, | 59 | 54 | 'valid-typeof': [ERROR, {requireStringLiterals: true}], | @@ -65,6 +60,12 @@ module.exports = { | 65 | 60 | 'no-var': ERROR, | 66 | 61 | strict: ERROR, | 67 | 62 |
| | 63 | + // Enforced by Prettier | | 64 | + // TODO: Prettier doesn't handle long strings or long comments. Not a big | | 65 | + // deal. But I turned it off because loading the plugin causes some obscure | | 66 | + // syntax error and it didn't seem worth investigating. | | 67 | + 'max-len': OFF, | | 68 | + | 68 | 69 | // React & JSX | 69 | 70 | // Our transforms set this automatically | 70 | 71 | 'react/jsx-boolean-value': [ERROR, 'always'], | @@ -78,7 +79,10 @@ module.exports = { | 78 | 79 | 'react/react-in-jsx-scope': ERROR, | 79 | 80 | 'react/self-closing-comp': ERROR, | 80 | 81 | // We don't care to do this | 81 | | - 'react/jsx-wrap-multilines': [ERROR, {declaration: false, assignment: false}], | | 82 | + 'react/jsx-wrap-multilines': [ | | 83 | + ERROR, | | 84 | + {declaration: false, assignment: false}, | | 85 | + ], | 82 | 86 |
| 83 | 87 | // Prevent for...of loops because they require a Symbol polyfill. | 84 | 88 | // You can disable this rule for code that isn't shipped (e.g. build scripts and tests). | @@ -112,6 +116,7 @@ module.exports = { | 112 | 116 | files: esNextPaths, | 113 | 117 | parser: 'babel-eslint', | 114 | 118 | parserOptions: { | | 119 | + ecmaVersion: 8, | 115 | 120 | sourceType: 'module', | 116 | 121 | }, | 117 | 122 | rules: { | @@ -124,14 +129,14 @@ module.exports = { | 124 | 129 | rules: { | 125 | 130 | // https://github.com/jest-community/eslint-plugin-jest | 126 | 131 | 'jest/no-focused-tests': ERROR, | 127 | | - } | | 132 | + }, | 128 | 133 | }, | 129 | 134 | { | 130 | 135 | files: ['packages/react-native-renderer/**/*.js'], | 131 | 136 | globals: { | 132 | 137 | nativeFabricUIManager: true, | 133 | | - } | 134 | | - } | | 138 | + }, | | 139 | + }, | 135 | 140 | ], | 136 | 141 |
| 137 | 142 | globals: { | |
Collapse file Copy file name to clipboardExpand all lines: fixtures/dom/src/components/fixtures/suspense/index.js +6-6Lines changed: 6 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -46,15 +46,15 @@ class SuspendyTreeChild extends React.Component { | 46 | 46 |
| 47 | 47 | render() { | 48 | 48 | return ( | 49 | | - <React.Fragment> | | 49 | + <> | 50 | 50 | <Suspense fallback={<div>(display: none)</div>}> | 51 | 51 | <div> | 52 | 52 | <AsyncStep text={`${this.state.step} + ${this.id}`} ms={500} /> | 53 | 53 | {this.props.children} | 54 | 54 | </div> | 55 | 55 | </Suspense> | 56 | 56 | <button onClick={this.increment}>Hide</button> | 57 | | - </React.Fragment> | | 57 | + </> | 58 | 58 | ); | 59 | 59 | } | 60 | 60 | } | @@ -86,22 +86,22 @@ class SuspendyTree extends React.Component { | 86 | 86 | }; | 87 | 87 | render() { | 88 | 88 | return ( | 89 | | - <React.Fragment> | | 89 | + <> | 90 | 90 | <div ref={this.parentContainer}> | 91 | 91 | <div ref={this.container} /> | 92 | 92 | </div> | 93 | 93 | <div> | 94 | 94 | {this.container.current !== null | 95 | 95 | ? ReactDOM.createPortal( | 96 | | - <React.Fragment> | | 96 | + <> | 97 | 97 | <SuspendyTreeChild>{this.props.children}</SuspendyTreeChild> | 98 | 98 | <button onClick={this.removeAndRestore}>Remove</button> | 99 | | - </React.Fragment>, | | 99 | + </>, | 100 | 100 | this.container.current | 101 | 101 | ) | 102 | 102 | : null} | 103 | 103 | </div> | 104 | | - </React.Fragment> | | 104 | + </> | 105 | 105 | ); | 106 | 106 | } | 107 | 107 | } | |
Collapse file Copy file name to clipboardExpand all lines: package.json +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 45 | 45 | "cross-env": "^5.1.1", | 46 | 46 | "danger": "^3.0.4", | 47 | 47 | "error-stack-parser": "^2.0.2", | 48 | | - "eslint": "^4.1.0", | | 48 | + "eslint": "^6.1.0", | 49 | 49 | "eslint-config-fbjs": "^1.1.1", | 50 | | - "eslint-plugin-babel": "^3.3.0", | 51 | 50 | "eslint-plugin-flowtype": "^2.25.0", | 52 | 51 | "eslint-plugin-jest": "^21.6.1", | 53 | 52 | "eslint-plugin-no-for-of-loops": "^1.0.0", | | 53 | + "eslint-plugin-babel": "^5.3.0", | 54 | 54 | "eslint-plugin-react": "^6.7.1", | 55 | 55 | "eslint-plugin-react-internal": "link:./scripts/eslint-rules", | 56 | 56 | "fbjs-scripts": "^0.8.3", | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-dom/src/__tests__/ReactDOMFiber-test.js +5-5Lines changed: 5 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -178,11 +178,11 @@ describe('ReactDOMFiber', () => { | 178 | 178 |
| 179 | 179 | it('renders an empty fragment', () => { | 180 | 180 | const Div = () => <div />; | 181 | | - const EmptyFragment = () => <React.Fragment />; | | 181 | + const EmptyFragment = () => <></>; | 182 | 182 | const NonEmptyFragment = () => ( | 183 | | - <React.Fragment> | | 183 | + <> | 184 | 184 | <Div /> | 185 | | - </React.Fragment> | | 185 | + </> | 186 | 186 | ); | 187 | 187 |
| 188 | 188 | ReactDOM.render(<EmptyFragment />, container); | @@ -475,10 +475,10 @@ describe('ReactDOMFiber', () => { | 475 | 475 | return ( | 476 | 476 | <div> | 477 | 477 | {this.state.show && ( | 478 | | - <React.Fragment> | | 478 | + <> | 479 | 479 | {ReactDOM.createPortal(null, portalContainer)} | 480 | 480 | <div>child</div> | 481 | | - </React.Fragment> | | 481 | + </> | 482 | 482 | )} | 483 | 483 | <div>parent</div> | 484 | 484 | </div> | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-dom/src/__tests__/ReactDOMFiberAsync-test.internal.js +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -581,11 +581,11 @@ describe('ReactDOMFiberAsync', () => { | 581 | 581 | } | 582 | 582 |
| 583 | 583 | root.render( | 584 | | - <React.Fragment> | | 584 | + <> | 585 | 585 | <Text text="A" /> | 586 | 586 | <Text text="B" /> | 587 | 587 | <Text text="C" /> | 588 | | - </React.Fragment>, | | 588 | + </>, | 589 | 589 | ); | 590 | 590 |
| 591 | 591 | // Nothing should have rendered yet | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-dom/src/__tests__/ReactDOMHooks-test.js +4-4Lines changed: 4 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -82,10 +82,10 @@ describe('ReactDOMHooks', () => { | 82 | 82 | }); | 83 | 83 |
| 84 | 84 | return ( | 85 | | - <React.Fragment> | | 85 | + <> | 86 | 86 | <input ref={inputRef} onInput={handleInput} /> | 87 | 87 | <label ref={labelRef}>{text}</label> | 88 | | - </React.Fragment> | | 88 | + </> | 89 | 89 | ); | 90 | 90 | }; | 91 | 91 |
| @@ -115,10 +115,10 @@ describe('ReactDOMHooks', () => { | 115 | 115 | }); | 116 | 116 |
| 117 | 117 | return ( | 118 | | - <React.Fragment> | | 118 | + <> | 119 | 119 | <input ref={inputRef} onInput={handleInput} /> | 120 | 120 | <label ref={labelRef}>{text}</label> | 121 | | - </React.Fragment> | | 121 | + </> | 122 | 122 | ); | 123 | 123 | }; | 124 | 124 |
| |
Collapse file Copy file name to clipboardExpand all lines: packages/react-dom/src/__tests__/ReactDOMServerIntegrationClassContextType-test.js +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -240,12 +240,12 @@ describe('ReactDOMServerIntegration', () => { | 240 | 240 | </Theme.Provider> | 241 | 241 | <LanguageConsumer> | 242 | 242 | {language => ( | 243 | | - <React.Fragment> | | 243 | + <> | 244 | 244 | <ThemeConsumer> | 245 | 245 | {theme => <div id="theme3">{theme}</div>} | 246 | 246 | </ThemeConsumer> | 247 | 247 | <div id="language2">{language}</div> | 248 | | - </React.Fragment> | | 248 | + </> | 249 | 249 | )} | 250 | 250 | </LanguageConsumer> | 251 | 251 | </Theme.Provider> | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-dom/src/__tests__/ReactDOMServerIntegrationFragment-test.js +16-16Lines changed: 16 additions & 16 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -42,9 +42,9 @@ describe('ReactDOMServerIntegration', () => { | 42 | 42 | describe('React.Fragment', () => { | 43 | 43 | itRenders('a fragment with one child', async render => { | 44 | 44 | let e = await render( | 45 | | - <React.Fragment> | | 45 | + <> | 46 | 46 | <div>text1</div> | 47 | | - </React.Fragment>, | | 47 | + </>, | 48 | 48 | ); | 49 | 49 | let parent = e.parentNode; | 50 | 50 | expect(parent.childNodes[0].tagName).toBe('DIV'); | @@ -56,19 +56,19 @@ describe('ReactDOMServerIntegration', () => { | 56 | 56 | }; | 57 | 57 | let Footer = props => { | 58 | 58 | return ( | 59 | | - <React.Fragment> | | 59 | + <> | 60 | 60 | <h2>footer</h2> | 61 | 61 | <h3>about</h3> | 62 | | - </React.Fragment> | | 62 | + </> | 63 | 63 | ); | 64 | 64 | }; | 65 | 65 | let e = await render( | 66 | | - <React.Fragment> | | 66 | + <> | 67 | 67 | <div>text1</div> | 68 | 68 | <span>text2</span> | 69 | 69 | <Header /> | 70 | 70 | <Footer /> | 71 | | - </React.Fragment>, | | 71 | + </>, | 72 | 72 | ); | 73 | 73 | let parent = e.parentNode; | 74 | 74 | expect(parent.childNodes[0].tagName).toBe('DIV'); | @@ -80,21 +80,21 @@ describe('ReactDOMServerIntegration', () => { | 80 | 80 |
| 81 | 81 | itRenders('a nested fragment', async render => { | 82 | 82 | let e = await render( | 83 | | - <React.Fragment> | 84 | | - <React.Fragment> | | 83 | + <> | | 84 | + <> | 85 | 85 | <div>text1</div> | 86 | | - </React.Fragment> | | 86 | + </> | 87 | 87 | <span>text2</span> | 88 | | - <React.Fragment> | 89 | | - <React.Fragment> | 90 | | - <React.Fragment> | | 88 | + <> | | 89 | + <> | | 90 | + <> | 91 | 91 | {null} | 92 | 92 | <p /> | 93 | | - </React.Fragment> | | 93 | + </> | 94 | 94 | {false} | 95 | | - </React.Fragment> | 96 | | - </React.Fragment> | 97 | | - </React.Fragment>, | | 95 | + </> | | 96 | + </> | | 97 | + </>, | 98 | 98 | ); | 99 | 99 | let parent = e.parentNode; | 100 | 100 | expect(parent.childNodes[0].tagName).toBe('DIV'); | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-dom/src/__tests__/ReactDOMServerIntegrationNewContext-test.js +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -270,12 +270,12 @@ describe('ReactDOMServerIntegration', () => { | 270 | 270 | </Theme.Provider> | 271 | 271 | <Language.Consumer> | 272 | 272 | {language => ( | 273 | | - <React.Fragment> | | 273 | + <> | 274 | 274 | <Theme.Consumer> | 275 | 275 | {theme => <div id="theme3">{theme}</div>} | 276 | 276 | </Theme.Consumer> | 277 | 277 | <div id="language2">{language}</div> | 278 | | - </React.Fragment> | | 278 | + </> | 279 | 279 | )} | 280 | 280 | </Language.Consumer> | 281 | 281 | </Theme.Provider> | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-dom/src/__tests__/ReactDOMServerPartialHydration-test.internal.js +4-4Lines changed: 4 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -157,10 +157,10 @@ describe('ReactDOMServerPartialHydration', () => { | 157 | 157 | throw promise; | 158 | 158 | } else { | 159 | 159 | return ( | 160 | | - <React.Fragment> | | 160 | + <> | 161 | 161 | <div>Middle</div> | 162 | 162 | Some text | 163 | | - </React.Fragment> | | 163 | + </> | 164 | 164 | ); | 165 | 165 | } | 166 | 166 | } | @@ -1022,12 +1022,12 @@ describe('ReactDOMServerPartialHydration', () => { | 1022 | 1022 | <div> | 1023 | 1023 | <Suspense | 1024 | 1024 | fallback={ | 1025 | | - <React.Fragment> | | 1025 | + <> | 1026 | 1026 | <Suspense fallback="Loading..."> | 1027 | 1027 | <Child /> | 1028 | 1028 | </Suspense> | 1029 | 1029 | <span>Inner Sibling</span> | 1030 | | - </React.Fragment> | | 1030 | + </> | 1031 | 1031 | }> | 1032 | 1032 | <Child /> | 1033 | 1033 | </Suspense> | |
|