GeezerVison is showing github.com — Cross-fork lint: Support named export declaration (#20784) · react/react@eee874c
File treeExpand file treeCollapse file tree Open diff view settings packages/react-reconciler/src
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactFiberReconciler.old.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -104,7 +104,7 @@ export { | 104 | 104 | IdleLanePriority as IdleEventPriority, | 105 | 105 | } from './ReactFiberLane.old'; | 106 | 106 |
| 107 | | -export {registerMutableSourceForHydration} from './ReactMutableSource.new'; | | 107 | +export {registerMutableSourceForHydration} from './ReactMutableSource.old'; | 108 | 108 | export {createPortal} from './ReactPortal'; | 109 | 109 | export { | 110 | 110 | createComponentSelector, | |
Collapse file Copy file name to clipboardExpand all lines: scripts/eslint-rules/__tests__/no-cross-fork-imports-test.internal.js +24Lines changed: 24 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -94,5 +94,29 @@ ruleTester.run('eslint-rules/no-cross-fork-imports', rule, { | 94 | 94 | ], | 95 | 95 | output: "import {scheduleUpdateOnFiber} from './ReactFiberWorkLoop.new';", | 96 | 96 | }, | | 97 | + { | | 98 | + code: "export {DiscreteEventPriority} from './ReactFiberLane.old.js';", | | 99 | + filename: 'ReactFiberReconciler.new.js', | | 100 | + errors: [ | | 101 | + { | | 102 | + message: | | 103 | + 'A module that belongs to the new fork cannot import a module ' + | | 104 | + 'from the old fork.', | | 105 | + }, | | 106 | + ], | | 107 | + output: "export {DiscreteEventPriority} from './ReactFiberLane.new';", | | 108 | + }, | | 109 | + { | | 110 | + code: "export {DiscreteEventPriority} from './ReactFiberLane.new.js';", | | 111 | + filename: 'ReactFiberReconciler.old.js', | | 112 | + errors: [ | | 113 | + { | | 114 | + message: | | 115 | + 'A module that belongs to the old fork cannot import a module ' + | | 116 | + 'from the new fork.', | | 117 | + }, | | 118 | + ], | | 119 | + output: "export {DiscreteEventPriority} from './ReactFiberLane.old';", | | 120 | + }, | 97 | 121 | ], | 98 | 122 | }); |
Collapse file Copy file name to clipboardExpand all lines: scripts/eslint-rules/no-cross-fork-imports.js +47-36Lines changed: 47 additions & 36 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -26,48 +26,59 @@ module.exports = { | 26 | 26 | const sourceFilename = context.getFilename(); | 27 | 27 |
| 28 | 28 | if (isOldFork(sourceFilename)) { | | 29 | + const visitor = node => { | | 30 | + const sourceNode = node.source; | | 31 | + if (sourceNode === null) { | | 32 | + return; | | 33 | + } | | 34 | + const filename = sourceNode.value; | | 35 | + if (isNewFork(filename)) { | | 36 | + context.report({ | | 37 | + node: sourceNode, | | 38 | + message: | | 39 | + 'A module that belongs to the old fork cannot import a module ' + | | 40 | + 'from the new fork.', | | 41 | + fix(fixer) { | | 42 | + return fixer.replaceText( | | 43 | + sourceNode, | | 44 | + `'${filename.replace(/\.new(\.js)?$/, '.old')}'` | | 45 | + ); | | 46 | + }, | | 47 | + }); | | 48 | + } | | 49 | + }; | 29 | 50 | return { | 30 | | - ImportDeclaration(node) { | 31 | | - const importSourceNode = node.source; | 32 | | - const filename = importSourceNode.value; | 33 | | - if (isNewFork(filename)) { | 34 | | - context.report({ | 35 | | - node: importSourceNode, | 36 | | - message: | 37 | | - 'A module that belongs to the old fork cannot import a module ' + | 38 | | - 'from the new fork.', | 39 | | - fix(fixer) { | 40 | | - return fixer.replaceText( | 41 | | - importSourceNode, | 42 | | - `'${filename.replace(/\.new(\.js)?$/, '.old')}'` | 43 | | - ); | 44 | | - }, | 45 | | - }); | 46 | | - } | 47 | | - }, | | 51 | + ImportDeclaration: visitor, | | 52 | + ExportNamedDeclaration: visitor, | 48 | 53 | }; | 49 | 54 | } | 50 | 55 |
| 51 | 56 | if (isNewFork(sourceFilename)) { | | 57 | + const visitor = node => { | | 58 | + const sourceNode = node.source; | | 59 | + if (sourceNode === null) { | | 60 | + return; | | 61 | + } | | 62 | + const filename = sourceNode.value; | | 63 | + if (isOldFork(filename)) { | | 64 | + context.report({ | | 65 | + node: sourceNode, | | 66 | + message: | | 67 | + 'A module that belongs to the new fork cannot import a module ' + | | 68 | + 'from the old fork.', | | 69 | + fix(fixer) { | | 70 | + return fixer.replaceText( | | 71 | + sourceNode, | | 72 | + `'${filename.replace(/\.old(\.js)?$/, '.new')}'` | | 73 | + ); | | 74 | + }, | | 75 | + }); | | 76 | + } | | 77 | + }; | | 78 | + | 52 | 79 | return { | 53 | | - ImportDeclaration(node) { | 54 | | - const importSourceNode = node.source; | 55 | | - const filename = importSourceNode.value; | 56 | | - if (isOldFork(filename)) { | 57 | | - context.report({ | 58 | | - node: importSourceNode, | 59 | | - message: | 60 | | - 'A module that belongs to the new fork cannot import a module ' + | 61 | | - 'from the old fork.', | 62 | | - fix(fixer) { | 63 | | - return fixer.replaceText( | 64 | | - importSourceNode, | 65 | | - `'${filename.replace(/\.old(\.js)?$/, '.new')}'` | 66 | | - ); | 67 | | - }, | 68 | | - }); | 69 | | - } | 70 | | - }, | | 80 | + ImportDeclaration: visitor, | | 81 | + ExportNamedDeclaration: visitor, | 71 | 82 | }; | 72 | 83 | } | 73 | 84 |
| |
|