invertase / dart_custom_lint

💡 Easily write powerful Dart & Flutter lint rules for your projects or for users of your packages.
https://pub.dev/packages/custom_lint
Apache License 2.0
288 stars 65 forks source link

custom_lint throws PathNotFoundException in pnpm workspace #289

Open BuyMyBeard opened 3 weeks ago

BuyMyBeard commented 3 weeks ago

Describe the bug I have a monorepo with a bunch of packages written in TS. At the root is the Flutter front-end project and a node_modules for pnpm dependencies. It is oddly specific, but if I have the npm firebase package installed through pnpm, and I run dart run custom_lint, the following exception is thrown:

Exception ``` W:\DevXpress\custom_lint_issue_repro> dart run custom_lint Building package executable... Built custom_lint:custom_lint. PathNotFoundException: Directory listing failed, path = 'W:\DevXpress\custom_lint_issue_repro\node_modules\.pnpm\@firebase+firestore-compat@0.3.39_@firebase+app-compat@0.2.45_@firebase+app-types@0.9.2_@firebase+app@0.10.15\node_modules\@firebase\firestore\dist\firestore\test\unit\remote\bloom_filter_golden_test_data\*' (OS Error: The system cannot find the path specified. , errno = 3) #0 _Directory._fillWithDirectoryListing (dart:io-patch/directory_patch.dart:42:24) #1 _Directory.listSync (dart:io/directory_impl.dart:228:5) #2 _findRoots (package:custom_lint/src/workspace.dart:411:20) #3 _SyncStarIterator.moveNext (dart:async-patch/async_patch.dart:560:14) #4 ExpandIterator.moveNext (dart:_internal/iterable.dart:487:32) #5 SetBase.addAll (dart:collection/set.dart:58:23) #6 _Set.addAll (dart:collection-patch/compact_hash.dart:986:11) #7 new LinkedHashSet.of (dart:collection/linked_hash_set.dart:192:27) #8 Iterable.toSet (dart:core/iterable.dart:513:21) #9 CustomLintWorkspace.fromPaths (package:custom_lint/src/workspace.dart:440:10) #10 _runServer. (package:custom_lint/custom_lint.dart:90:51) #11 CustomLintServer.runZoned. (package:custom_lint/src/v2/custom_lint_analyzer_plugin.dart:80:17) #12 new Future. (dart:async/future.dart:258:40) #13 _rootRun (dart:async/zone.dart:1391:47) #14 _CustomZone.run (dart:async/zone.dart:1301:19) #15 _CustomZone.runGuarded (dart:async/zone.dart:1209:7) #16 _CustomZone.bindCallbackGuarded. (dart:async/zone.dart:1249:23) #17 _rootRun (dart:async/zone.dart:1399:13) #18 _CustomZone.run (dart:async/zone.dart:1301:19) #19 _CustomZone.bindCallback. (dart:async/zone.dart:1233:23) #20 Timer._createTimer. (dart:async-patch/timer_patch.dart:18:15) #21 _Timer._runTimers (dart:isolate-patch/timer_impl.dart:398:19) #22 _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:429:5) #23 _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12) ```

I find this oddly specific, because I couldn't reproduce the issue by installing the same dependency through npm install instead, or installing a different package through pnpm.

I have tried to exclude node_modules from analysis_options.yaml, but to no avail. It feels nonsensical for custom_lint to try and go lint node_modules.

I am also under the impression this causes some slowdowns to static analysis, but I have not tested it.

To Reproduce

I set up a minimal reproductible example at the following link. Steps for setup are in the readme.

Expected behavior Able to run dart run custom_lint in pnpm workspace