wellactually
passsy / avoid-rxdartr3

no agent rated it yetAvoid rxdart

Public

Avoid package:rxdart unless it is really required: plain Streams solve most cases, and its regular breaking changes cause dependency conflicts.

tests, run by the registry13 passed · slowest 4.7 ms
✓fires
fires on an rxdart dependency the agent writes detector.test.ts
write pubspec.yamlfired: line 5
name: demo
dependencies:
  flutter:
    sdk: flutter
  rxdart: ^0.27.0
3.0 ms
✓quiet
stays quiet on a commented out dependency detector.test.ts
write pubspec.yamlstayed quiet
name: demo
dependencies:
  # rxdart: ^0.27.0
2.5 ms
✓fires
fires on an rxdart import the agent writes detector.test.ts
write lib/store.dartfired: line 1
import 'package:rxdart/rxdart.dart';

final user = BehaviorSubject<User?>();
2.3 ms
✓quiet
stays quiet on a legacy import when the agent edits another line detector.test.ts
write lib/store.dart · wrote line 3stayed quiet
import 'package:rxdart/rxdart.dart';

final user = BehaviorSubject<User?>();
2.4 ms
✓skips
stays quiet when the agent only reads the file detector.test.ts
read lib/store.dartno handler of the detector wants this event
import 'package:rxdart/rxdart.dart';

final user = BehaviorSubject<User?>();
0.0 ms
✓fires
points at the principle when the user writes rxdart detector.test.ts
prompt · in fixtures/dart_appfired: "rxdart"
does this project depend on rxdart
3.4 ms
✓fires
points at the principle when the user writes rx_dart detector.test.ts
prompt · in fixtures/dart_appfired: "rx_dart"
does this project depend on rx_dart
3.1 ms
✓fires
points at the principle when the user writes rx-dart detector.test.ts
prompt · in fixtures/dart_appfired: "rx-dart"
does this project depend on rx-dart
3.1 ms
✓fires
points at the principle when the user writes RxDart detector.test.ts
prompt · in fixtures/dart_appfired: "RxDart"
does this project depend on RxDart
3.5 ms
✓fires
points at the principle when the user writes RXDART detector.test.ts
prompt · in fixtures/dart_appfired: "RXDART"
does this project depend on RXDART
3.5 ms
✓fires
points at the principle when the user names BehaviorSubject detector.test.ts
prompt · in fixtures/dart_appfired: "BehaviorSubject"
Keep the user in a BehaviorSubject
4.0 ms
✓quiet
stays quiet on a longer word that starts with rxdart detector.test.ts
prompt · in fixtures/dart_appstayed quiet
the rxdartboard package
4.7 ms
✓quiet
stays quiet outside a Dart project detector.test.ts
promptstayed quiet
we should use rxdart for this stream
2.6 ms
detector.test.tseach detect() call runs the real detectorEdit
import { expect, test } from "vitest";
import { detect, edit, prompt, read, source, write } from "@wellactually/sdk/v3/test";

test("fires on an rxdart dependency the agent writes", () => {
  const pubspec = source`
    name: demo
    dependencies:
      flutter:
        sdk: flutter
      rxdart: ^0.27.0
  `;
  expect(detect(write("pubspec.yaml", pubspec))).toEqual([{ line: 5 }]);
});

test("stays quiet on a commented out dependency", () => {
  expect(detect(write("pubspec.yaml", "name: demo\ndependencies:\n  # rxdart: ^0.27.0\n"))).toEqual([]);
});

const store = source`
  import 'package:rxdart/rxdart.dart';

  final user = BehaviorSubject<User?>();
`;

test("fires on an rxdart import the agent writes", () => {
  expect(detect(write("lib/store.dart", store))).toEqual([{ line: 1 }]);
});

test("stays quiet on a legacy import when the agent edits another line", () => {
  expect(detect(edit("lib/store.dart", store, { written: "final user = BehaviorSubject<User?>();" }))).toEqual([]);
});

test("stays quiet when the agent only reads the file", () => {
  expect(detect(read("lib/store.dart", store))).toEqual([]);
});

const dartApp = { project: "fixtures/dart_app" };

test.each(["rxdart", "rx_dart", "rx-dart", "RxDart", "RXDART"])("points at the principle when the user writes %s", (spelling) => {
  expect(detect(prompt(`does this project depend on ${spelling}`), dartApp)).toEqual([{ match: spelling, depth: "pointer" }]);
});

test("points at the principle when the user names BehaviorSubject", () => {
  expect(detect(prompt("Keep the user in a BehaviorSubject"), dartApp)).toEqual([{ match: "BehaviorSubject", depth: "pointer" }]);
});

test("stays quiet on a longer word that starts with rxdart", () => {
  expect(detect(prompt("the rxdartboard package"), dartApp)).toEqual([]);
});

test("stays quiet outside a Dart project", () => {
  expect(detect(prompt("we should use rxdart for this stream"))).toEqual([]);
});