File tree Expand file tree Collapse file tree 13 files changed +284
-4
lines changed
Expand file tree Collapse file tree 13 files changed +284
-4
lines changed Original file line number Diff line number Diff line change 1+ # 20.0.1
2+
3+ - Add the ` example/ ` directory with default and custom configuration examples.
4+
15# 20.0.0
26
37- ** Breaking:** Migrate from custom_lint to the analysis server plugin.
Original file line number Diff line number Diff line change @@ -50,6 +50,10 @@ analyzer:
5050 - ' **/*.g.dart'
5151` ` `
5252
53+ > [!TIP]
54+ > See the [example/](./example) directory for complete, runnable examples
55+ > with both default and custom configuration.
56+
5357## Configuration (custom plugin package)
5458
5559This section is optional. You only need it if you want to customize the
@@ -581,9 +585,9 @@ Assists are IDE refactorings not related to a particular issue. They can be trig
581585
582586See linked source code containing explanation in dart doc.
583587
584- - [Convert positional to named formal](./lib/assists/convert_positional_to_named_formal.dart)
585- - [Convert record into nominal type](./lib/assists/convert_record_into_nominal_type.dart)
586- - [Convert iterable map to collection-for](./lib/assists/convert_iterable_map_to_collection_for.dart)
588+ - [Convert positional to named formal](./lib/src/ assists/convert_positional_to_named_formal.dart)
589+ - [Convert record into nominal type](./lib/src/ assists/convert_record_into_nominal_type.dart)
590+ - [Convert iterable map to collection-for](./lib/src/ assists/convert_iterable_map_to_collection_for.dart)
587591
588592[pub-badge] : https://img.shields.io/pub/v/leancode_lint
589593[pub-badge-link] : https://pub.dev/packages/leancode_lint
Original file line number Diff line number Diff line change 1+ include : package:leancode_lint/analysis_options.yaml
2+
3+ plugins :
4+ my_lints :
5+ path : ../my_lints
Original file line number Diff line number Diff line change 1+ import 'package:flutter/material.dart' ;
2+
3+ /// Design system text widget.
4+ class AppText extends StatelessWidget {
5+ const AppText (this .data, {super .key});
6+
7+ final String data;
8+
9+ @override
10+ Widget build (BuildContext context) {
11+ // When ignoring custom lints, use the prefix with the package name.
12+ // If you provide a custom name to the `LeanCodeLintPlugin`, use it here:
13+ // ignore: my_lints/use_design_system_item_AppText
14+ return Text (data);
15+ }
16+ }
17+
18+ /// Design system scaffold widget.
19+ class AppScaffold extends StatelessWidget {
20+ const AppScaffold ({super .key, this .appBar, required this .body});
21+
22+ final PreferredSizeWidget ? appBar;
23+ final Widget body;
24+
25+ @override
26+ Widget build (BuildContext context) {
27+ // Ignores are case-insensitive:
28+ // ignore: my_lints/use_design_system_item_appscaffold
29+ return Scaffold (appBar: appBar, body: body);
30+ }
31+ }
Original file line number Diff line number Diff line change 1+ import 'package:flutter/material.dart' ;
2+
3+ import 'design_system.dart' ;
4+
5+ void main () {
6+ runApp (const CustomExampleApp ());
7+ }
8+
9+ Future <void > fetchData () async {
10+ try {
11+ await Future <void >.delayed (const Duration (seconds: 1 ));
12+ } catch (error, stackTrace) {
13+ debugPrint ('$error \n $stackTrace ' );
14+ }
15+ }
16+
17+ class CustomExampleApp extends StatelessWidget {
18+ const CustomExampleApp ({super .key});
19+
20+ @override
21+ Widget build (BuildContext context) {
22+ return MaterialApp (
23+ title: 'Custom Config Example' ,
24+ theme: ThemeData (colorScheme: .fromSeed (seedColor: Colors .green)),
25+ home: const CustomExampleHome (),
26+ );
27+ }
28+ }
29+
30+ class CustomExampleHome extends StatelessWidget {
31+ const CustomExampleHome ({super .key});
32+
33+ @override
34+ Widget build (BuildContext context) {
35+ return AppScaffold (
36+ appBar: AppBar (title: const AppText ('leancode_lint custom config' )),
37+ body: const Center (
38+ child: ElevatedButton (
39+ onPressed: fetchData,
40+ child: AppText ('Trigger try-catch' ),
41+ ),
42+ ),
43+ );
44+ }
45+ }
Original file line number Diff line number Diff line change 1+ name : custom_example_app
2+ description : Example app using leancode_lint with custom configuration.
3+ publish_to : none
4+
5+ environment :
6+ sdk : ' >=3.10.0 <4.0.0'
7+
8+ dependency_overrides :
9+ # Flutter pins meta to 1.17.0, but the plugin packages require 1.18.0
10+ meta : ^1.18.0
11+
12+ dependencies :
13+ flutter :
14+ sdk : flutter
15+
16+ dev_dependencies :
17+ flutter_test :
18+ sdk : flutter
19+ my_lints :
20+ path : ../my_lints
Original file line number Diff line number Diff line change 1+ import 'package:leancode_lint/plugin.dart' ;
2+
3+ /// Custom plugin with project-specific configuration.
4+ ///
5+ /// - Uses `error` and `stackTrace` for catch parameters
6+ /// - Configures design system replacements (e.g. use AppText instead of Text)
7+ final plugin = LeanCodeLintPlugin (
8+ name: 'my_lints' ,
9+ config: const LeanCodeLintConfig (
10+ catchParameterNames: CatchParameterNamesConfig (
11+ exception: 'error' ,
12+ stackTrace: 'stackTrace' ,
13+ ),
14+ designSystemItemReplacements: {
15+ 'AppText' : [
16+ DesignSystemForbiddenItem (name: 'Text' , packageName: 'flutter' ),
17+ DesignSystemForbiddenItem (name: 'RichText' , packageName: 'flutter' ),
18+ ],
19+ 'AppScaffold' : [
20+ DesignSystemForbiddenItem (name: 'Scaffold' , packageName: 'flutter' ),
21+ ],
22+ },
23+ ),
24+ );
Original file line number Diff line number Diff line change 1+ name : my_lints
2+ description : Custom analyzer plugin with leancode_lint configuration.
3+ publish_to : none
4+
5+ environment :
6+ sdk : ' >=3.10.0 <4.0.0'
7+
8+ dependencies :
9+ leancode_lint :
10+ path : ../../..
Original file line number Diff line number Diff line change 1+ include : package:leancode_lint/analysis_options.yaml
2+
3+ plugins :
4+ leancode_lint :
5+ path : ../..
Original file line number Diff line number Diff line change 1+ import 'package:flutter/material.dart' ;
2+
3+ void main () {
4+ runApp (const DefaultExampleApp ());
5+ }
6+
7+ Future <void > fetchData () async {
8+ try {
9+ await Future <void >.delayed (const Duration (seconds: 1 ));
10+ } catch (err, st) {
11+ debugPrint ('$err \n $st ' );
12+ }
13+ }
14+
15+ class DefaultExampleApp extends StatelessWidget {
16+ const DefaultExampleApp ({super .key});
17+
18+ @override
19+ Widget build (BuildContext context) {
20+ return MaterialApp (
21+ title: 'Default Config Example' ,
22+ theme: ThemeData (colorScheme: .fromSeed (seedColor: Colors .blue)),
23+ home: const DefaultExampleHome (),
24+ );
25+ }
26+ }
27+
28+ class DefaultExampleHome extends StatelessWidget {
29+ const DefaultExampleHome ({super .key});
30+
31+ @override
32+ Widget build (BuildContext context) {
33+ return Scaffold (
34+ appBar: AppBar (title: const Text ('leancode_lint default config' )),
35+ body: const Center (
36+ child: ElevatedButton (
37+ onPressed: fetchData,
38+ child: Text ('Trigger try-catch' ),
39+ ),
40+ ),
41+ );
42+ }
43+ }
You can’t perform that action at this time.
0 commit comments