Skip to content

Commit 2ad0106

Browse files
committed
test case for avoid_using_api
1 parent de6f83a commit 2ad0106

File tree

4 files changed

+43
-0
lines changed

4 files changed

+43
-0
lines changed

lint_test/avoid_using_api/external_source/lib/external_source.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,7 @@ const test2 = 'Hello World';
2222
void test() {}
2323

2424
int banned = 5;
25+
26+
extension BannedExtension on int {
27+
int banned() => this + 10;
28+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
analyzer:
2+
plugins:
3+
- ../../custom_lint
4+
5+
custom_lint:
6+
rules:
7+
- avoid_using_api:
8+
severity: warning
9+
entries:
10+
- class_name: BannedExtension
11+
identifier: banned
12+
source: package:external_source
13+
reason: "Banned identifier from BannedExtension from package:external_source is not allowed"
14+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import 'package:external_source/external_source.dart';
2+
3+
void extensionIdentifierBanTesting(){
4+
const int a = 10;
5+
6+
// expect_lint: avoid_using_api
7+
a.banned();
8+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: identifier_extension_source_ban
2+
description: A sample command-line application.
3+
version: 1.0.0
4+
publish_to: none
5+
6+
environment:
7+
sdk: ^3.7.2
8+
9+
dependencies:
10+
external_source:
11+
path: ../external_source
12+
13+
dev_dependencies:
14+
lints: ^3.0.0
15+
test: ^1.21.0
16+
solid_lints:
17+
path: ../../../

0 commit comments

Comments
 (0)