diff --git a/analysis_options.yaml b/analysis_options.yaml index 9d14291..a20ed49 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -4,6 +4,7 @@ linter: rules: - prefer_equal_for_default_values - prefer_generic_function_type_aliases + - prefer_typing_uninitialized_variables - slash_for_doc_comments - unnecessary_const - unnecessary_new diff --git a/lib/parser.dart b/lib/parser.dart index 1f3d185..ca1f465 100644 --- a/lib/parser.dart +++ b/lib/parser.dart @@ -549,7 +549,7 @@ class _Parser { _next(); // Page name - var name; + Identifier name; if (_peekIdentifier()) { name = identifier(); } @@ -666,7 +666,7 @@ class _Parser { // '}' _next(); - var name; + dynamic name; if (_peekIdentifier()) { name = identifier(); } @@ -897,7 +897,7 @@ class _Parser { } } else if (mixinParameter && _peekToken.kind == TokenKind.VAR_DEFINITION) { _next(); - var definedName; + Identifier definedName; if (_peekIdentifier()) definedName = identifier(); Expressions exprs; @@ -917,7 +917,7 @@ class _Parser { // @include IDENT [(args,...)]; _next(); - var name; + Identifier name; if (_peekIdentifier()) { name = identifier(); } @@ -931,7 +931,7 @@ class _Parser { // the first has 3 terms and the second has 1 term. if (_maybeEat(TokenKind.LPAREN)) { var terms = []; - var expr; + dynamic expr; var keepGoing = true; while (keepGoing && (expr = processTerm()) != null) { // VarUsage is returns as a list @@ -960,7 +960,7 @@ class _Parser { _next(); // '@-moz-document' var functions = []; do { - var function; + LiteralTerm function; // Consume function token: IDENT '(' var ident = identifier(); @@ -1431,7 +1431,7 @@ class _Parser { // than the error message for element. Should consolidate the // code. // TODO(terry): Need to handle attribute namespace too. - var first; + dynamic first; var start = _peekToken.span; switch (_peek()) { case TokenKind.ASTERISK: @@ -1632,7 +1632,7 @@ class _Parser { var expressions = []; Token termToken; - var value; + dynamic value; var keepParsing = true; while (keepParsing) { @@ -1719,7 +1719,7 @@ class _Parser { op = TokenKind.NO_MATCH; } - var value; + dynamic value; if (op != TokenKind.NO_MATCH) { // Operator hit so we require a value too. if (_peekIdentifier()) { @@ -2158,7 +2158,7 @@ class _Parser { var expressions = Expressions(_makeSpan(start)); var keepGoing = true; - var expr; + dynamic expr; while (keepGoing && (expr = processTerm(ieFilter)) != null) { Expression op; @@ -2242,7 +2242,7 @@ class _Parser { [bool ieFilter = false]) { var start = _peekToken.span; Token t; // token for term's value - var value; // value of term (numeric values) + dynamic value; // value of term (numeric values) var unary = ''; switch (_peek()) { diff --git a/lib/src/analyzer.dart b/lib/src/analyzer.dart index e9fd7c9..2f6d449 100644 --- a/lib/src/analyzer.dart +++ b/lib/src/analyzer.dart @@ -547,7 +547,7 @@ class _TopLevelIncludeReplacer extends Visitor { /// Utility function to match an include to a list of either Declarations or /// RuleSets, depending on type of mixin (ruleset or declaration). The include /// can be an include in a declaration or an include directive (top-level). -int _findInclude(List list, var node) { +int _findInclude(List list, TreeNode node) { IncludeDirective matchNode = (node is IncludeMixinAtDeclaration) ? node.include : node; @@ -844,13 +844,13 @@ class DeclarationIncludes extends Visitor { /// @include as a top-level with ruleset(s). class _IncludeReplacer extends Visitor { - final _include; + final TreeNode _include; final List _newDeclarations; /// Look for the [ruleSet] inside of a @media directive; if found then replace /// with the [newRules]. static void replace( - StyleSheet ss, var include, List newDeclarations) { + StyleSheet ss, TreeNode include, List newDeclarations) { var visitor = _IncludeReplacer(include, newDeclarations); visitor.visitStyleSheet(ss); } diff --git a/lib/src/polyfill.dart b/lib/src/polyfill.dart index 2582bae..0c2ef04 100644 --- a/lib/src/polyfill.dart +++ b/lib/src/polyfill.dart @@ -174,7 +174,7 @@ class _VarDefAndUsage extends Visitor { var result = []; var varDef = _knownVarDefs[usage.name]; - var expressions; + List expressions; if (varDef == null) { // VarDefinition not found try the defaultValues. expressions = usage.defaultValues; diff --git a/lib/src/token.dart b/lib/src/token.dart index 7c5ef65..444b8ee 100644 --- a/lib/src/token.dart +++ b/lib/src/token.dart @@ -41,7 +41,7 @@ class Token { /// A token containing a parsed literal value. class LiteralToken extends Token { - var value; + dynamic value; LiteralToken(int kind, FileSpan span, this.value) : super(kind, span); } diff --git a/lib/src/tokenizer_base.dart b/lib/src/tokenizer_base.dart index a648e62..5f22112 100644 --- a/lib/src/tokenizer_base.dart +++ b/lib/src/tokenizer_base.dart @@ -261,7 +261,7 @@ abstract class TokenizerBase { } Token _makeRawStringToken(bool isMultiline) { - var s; + String s; if (isMultiline) { // Skip initial newline in multiline strings var start = _startIndex + 4; diff --git a/lib/src/tree.dart b/lib/src/tree.dart index b050442..8a17b53 100644 --- a/lib/src/tree.dart +++ b/lib/src/tree.dart @@ -171,7 +171,7 @@ class SimpleSelectorSequence extends TreeNode { // All other selectors (element, #id, .class, attribute, pseudo, negation, // namespace, *) are derived from this selector. abstract class SimpleSelector extends TreeNode { - final _name; // Wildcard, ThisOperator, Identifier, Negation, others? + final dynamic _name; // Wildcard, ThisOperator, Identifier, Negation, others? SimpleSelector(this._name, SourceSpan span) : super(span); @@ -200,7 +200,7 @@ class ElementSelector extends SimpleSelector { // namespace|element class NamespaceSelector extends SimpleSelector { - final _namespace; // null, Wildcard or Identifier + final dynamic _namespace; // null, Wildcard or Identifier NamespaceSelector(this._namespace, var name, SourceSpan span) : super(name, span); @@ -1689,7 +1689,7 @@ class BorderExpression extends BoxExpression { } class HeightExpression extends DartStyleExpression { - final height; + final dynamic height; HeightExpression(SourceSpan span, this.height) : super(DartStyleExpression.heightStyle, span); @@ -1712,7 +1712,7 @@ class HeightExpression extends DartStyleExpression { } class WidthExpression extends DartStyleExpression { - final width; + final dynamic width; WidthExpression(SourceSpan span, this.width) : super(DartStyleExpression.widthStyle, span);