diff --git a/pubspec.yaml b/pubspec.yaml index b2c86733e..2c4d9a4d0 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -42,6 +42,20 @@ dev_dependencies: yaml: ^3.1.0 mocktail: ^1.0.3 +dependency_overrides: + react: + git: + url: https://github.com/workiva/react-dart.git + ref: react-18-2-0 + react_testing_library: + git: + url: https://github.com/workiva/react_testing_library.git + ref: r18 + over_react_test: + git: + url: https://github.com/workiva/over_react_test.git + ref: react-18-test + workiva: core_checks: version: 1 diff --git a/test/over_react/component/context_test.dart b/test/over_react/component/context_test.dart index 59653e828..4605e0a3b 100644 --- a/test/over_react/component/context_test.dart +++ b/test/over_react/component/context_test.dart @@ -206,7 +206,7 @@ void main() { }); }); - group('experimental calculateChangeBits argument functions correctly', () { + group('experimental calculateChangeBits argument does not throw when used (has no effect in React 18)', () { late Ref providerRef; int? consumerEvenValue; int? consumerOddValue; @@ -243,15 +243,14 @@ void main() { }); test('on value updates', () { + // Test common behavior between React 17 (calculateChangedBits working) + // and React 18 (it having no effect). providerRef.current!.increment(); expect(consumerEvenValue, 2); - expect(consumerOddValue, 1); providerRef.current!.increment(); - expect(consumerEvenValue, 2); expect(consumerOddValue, 3); providerRef.current!.increment(); expect(consumerEvenValue, 4); - expect(consumerOddValue, 3); }); }); }); diff --git a/test/over_react/component/error_boundary/shared_stack_tests.dart b/test/over_react/component/error_boundary/shared_stack_tests.dart index 176005485..f65ddc05f 100644 --- a/test/over_react/component/error_boundary/shared_stack_tests.dart +++ b/test/over_react/component/error_boundary/shared_stack_tests.dart @@ -12,9 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. +import 'dart:html'; + import 'package:meta/meta.dart'; import 'package:over_react/over_react.dart' hide ErrorBoundary; -import 'package:react_testing_library/react_testing_library.dart' as rtl; +import 'package:over_react/react_dom.dart' as react_dom; import 'package:over_react/components.dart'; import 'package:test/test.dart'; @@ -27,17 +29,15 @@ void sharedErrorBoundaryStackTests() { void expectRenderErrorWithComponentName(ReactElement element, {required String expectedComponentName}) { final capturedInfos = []; - expect(() { - rtl.render((ErrorBoundary() - ..shouldLogErrors = false - ..onComponentDidCatch = (error, info) { - capturedInfos.add(info); - })(element)); - // Use prints as an easy way to swallow `print` calls and - // prevent RTL from forwarding console errors to the test output, - // since React error boundary logging is pretty noisy. - // TODO instead, disable logging in this rtl.render call once that option is available: FED-1641 - }, prints(anything)); + final mountNode = DivElement(); + // Use react_dom.render instead of RTL to avoid errors on React 18 about + // `act` being used in prod builds. + react_dom.render((ErrorBoundary() + ..shouldLogErrors = false + ..onComponentDidCatch = (error, info) { + capturedInfos.add(info); + })(element), mountNode); + addTearDown(() => react_dom.unmountComponentAtNode(mountNode)); expect(capturedInfos, hasLength(1), reason: 'test setup check; should have captured a single component error'); diff --git a/tools/analyzer_plugin/lib/src/diagnostic/exhaustive_deps.dart b/tools/analyzer_plugin/lib/src/diagnostic/exhaustive_deps.dart index 7bc5983d6..81c75407a 100644 --- a/tools/analyzer_plugin/lib/src/diagnostic/exhaustive_deps.dart +++ b/tools/analyzer_plugin/lib/src/diagnostic/exhaustive_deps.dart @@ -1605,12 +1605,6 @@ Iterable> resolvedReferencesWithin(AstNode node) sy } } -extension on NamedType { - // NamedType.element is added in analyzer 5.11.0; we can't resolve to that version in Dart 2.18, - // so we'll add it here so we don't have to go back through and change it later. - Element? get element => name.staticElement; -} - enum HookTypeWithStableMethods { stateHook, reducerHook, transitionHook } abstract class HookConstants { diff --git a/tools/analyzer_plugin/lib/src/diagnostic/missing_required_prop.dart b/tools/analyzer_plugin/lib/src/diagnostic/missing_required_prop.dart index 1be8b7c55..969f13042 100644 --- a/tools/analyzer_plugin/lib/src/diagnostic/missing_required_prop.dart +++ b/tools/analyzer_plugin/lib/src/diagnostic/missing_required_prop.dart @@ -1,5 +1,4 @@ import 'package:analyzer/dart/analysis/results.dart'; -import 'package:analyzer/dart/ast/ast.dart'; import 'package:analyzer/dart/element/element.dart'; import 'package:over_react_analyzer_plugin/src/diagnostic/analyzer_debug_helper.dart'; import 'package:over_react_analyzer_plugin/src/diagnostic_contributor.dart'; @@ -7,7 +6,6 @@ import 'package:over_react_analyzer_plugin/src/util/ast_util.dart'; import 'package:over_react_analyzer_plugin/src/util/pretty_print.dart'; import 'package:over_react_analyzer_plugin/src/util/prop_declarations/props_set_by_factory.dart'; import 'package:over_react_analyzer_plugin/src/util/prop_forwarding/forwarded_props.dart'; -import 'package:over_react_analyzer_plugin/src/util/util.dart'; import 'package:over_react_analyzer_plugin/src/util/weak_map.dart'; import '../fluent_interface_util.dart'; diff --git a/tools/analyzer_plugin/tool/doc_generation_utils/visitor.dart b/tools/analyzer_plugin/tool/doc_generation_utils/visitor.dart index 25c672dae..2bc35a818 100644 --- a/tools/analyzer_plugin/tool/doc_generation_utils/visitor.dart +++ b/tools/analyzer_plugin/tool/doc_generation_utils/visitor.dart @@ -32,7 +32,9 @@ class ContributorVisitor extends RecursiveElementVisitor { void visitClassElement(ClassElement element) { for (final config in _configs) { if (!element.isOrIsSubtypeOfElementFromPackage( - config.typeNameOfContributorClass, config.packageNameContainingContributorClass)) continue; + config.typeNameOfContributorClass, config.packageNameContainingContributorClass)) { + continue; + } final annotatedFields = element.fields .where((f) => f.metadata.any((a) => a.element!.thisOrAncestorOfType()?.name == 'DocsMeta'));