diff --git a/packages/uni_ui/analysis_options.yaml b/packages/uni_ui/analysis_options.yaml new file mode 100644 index 000000000..e69de29bb diff --git a/packages/uni_ui/lib/custom_lint.dart b/packages/uni_ui/lib/custom_lint.dart index debbc7878..9131a2c85 100644 --- a/packages/uni_ui/lib/custom_lint.dart +++ b/packages/uni_ui/lib/custom_lint.dart @@ -3,22 +3,18 @@ import 'package:custom_lint_builder/custom_lint_builder.dart'; import 'package:analyzer/dart/ast/ast.dart'; import 'package:flutter/cupertino.dart'; -// This is the entrypoint of our custom linter PluginBase createPlugin() => _ExampleLinter(); -/// A plugin class is used to list all the assists/lints defined by a plugin. class _ExampleLinter extends PluginBase { - /// We list all the custom warnings/infos/errors @override List getLintRules(CustomLintConfigs configs) => [ - StringLiteralsLint(), - ]; + StringLiteralsLint(), + ]; } class StringLiteralsLint extends DartLintRule { StringLiteralsLint() : super(code: _code); - static const _code = LintCode( name: 'string_literals_lint', problemMessage: 'There is a string literal inside a widget', @@ -26,13 +22,13 @@ class StringLiteralsLint extends DartLintRule { @override void run( - CustomLintResolver resolver, - ErrorReporter reporter, - CustomLintContext context, - ) { + CustomLintResolver resolver, + ErrorReporter reporter, + CustomLintContext context, + ) { context.registry.addVariableDeclaration((node) { - if(isInsideWidgetClass(node)){ - if(isStringLiteral(node)){ + if (isInsideWidgetClass(node)) { + if (isStringLiteral(node)) { reporter.atNode(node, code); } } @@ -46,7 +42,8 @@ class StringLiteralsLint extends DartLintRule { final extendsClause = parent.extendsClause; if (extendsClause != null) { final superclass = extendsClause.superclass; - return superclass.runtimeType == StatelessWidget || superclass.runtimeType == StatefulWidget; + return superclass.runtimeType == StatelessWidget || + superclass.runtimeType == StatefulWidget; } return false; } @@ -58,4 +55,4 @@ class StringLiteralsLint extends DartLintRule { } return false; } -} \ No newline at end of file +}