dart-lang / linter

Linter for Dart.
https://dart.dev/tools/linter-rules
BSD 3-Clause "New" or "Revised" License
633 stars 170 forks source link

Define a linter API for testing and lint development #2105

Open pq opened 4 years ago

pq commented 4 years ago

Though not designed as a package for extension, the linter is increasingly be used as one. To make this sane, we should define an API and be mindful of breaking changes.

/fyi @davidmorgan @bwilkerson @srawlins

pq commented 4 years ago

On a quick scan, it looks like currently our dependencies converge on 2 libraries:

import 'package:linter/src/analyzer.dart';
import 'package:linter/src/util/dart_type_utilities.dart';

(Together they define a lot of potential surface area so we'll want to audit and narrow as much as possible.)

bwilkerson commented 4 years ago

For the analyzer facade, we might want to re-cast some or all of that as extensions on base analyzer classes. At that point we might even be able to get them added to the analyzer package, which would make it easier for them to be maintained as the analyzer changes.

The test utilities should also be looked at to see whether it makes sense to move them into the analyzer package.

pq commented 4 years ago

Looking specifically at import 'package:linter/src/analyzer.dart', this is largely to get LintRule and NodeLintRule which are required to define lints. NodeLintRule is actually no longer needed so I'll work to remove it. LintRule should become API proper so I'll hoist it up out of src/.

pq commented 4 years ago

Relevant discussion: https://dart-review.googlesource.com/c/sdk/+/149122.