Skip to content

Commit

Permalink
Minor Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Pinho13 committed Nov 26, 2024
1 parent 7127282 commit 2a315b7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
Empty file.
25 changes: 11 additions & 14 deletions packages/uni_ui/lib/custom_lint.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,32 @@ 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<LintRule> 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',
);

@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);
}
}
Expand All @@ -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;
}
Expand All @@ -58,4 +55,4 @@ class StringLiteralsLint extends DartLintRule {
}
return false;
}
}
}

0 comments on commit 2a315b7

Please sign in to comment.