Chromium Code Reviews| Index: pkg/polymer/lib/src/build/common.dart |
| diff --git a/pkg/polymer/lib/src/build/common.dart b/pkg/polymer/lib/src/build/common.dart |
| index 4d809f58177fac86205e83f76af5b5e0b4897756..e9239d4eb6eef62032d3984bbab05da808bd24a1 100644 |
| --- a/pkg/polymer/lib/src/build/common.dart |
| +++ b/pkg/polymer/lib/src/build/common.dart |
| @@ -88,10 +88,10 @@ class TransformOptions { |
| /// It will only appear when ![releaseMode] even if this is true. |
| final bool injectBuildLogsInOutput; |
| - /// True to run liner on all html files before starting other phases. |
| + /// Rules to determine whether to run liner on an html file. |
| // TODO(jmesserly): instead of this flag, we should only run linter on |
| // reachable (entry point+imported) html if deploying. See dartbug.com/17199. |
| - final bool lint; |
| + final LintOptions lint; |
| /// This will automatically inject `platform.js` from the `web_components` |
| /// package in all entry points, if it is not already included. |
| @@ -99,7 +99,7 @@ class TransformOptions { |
| TransformOptions({entryPoints, this.inlineStylesheets, |
| this.contentSecurityPolicy: false, this.directlyIncludeJS: true, |
| - this.releaseMode: true, this.lint: true, |
| + this.releaseMode: true, this.lint: const LintOptions(), |
| this.injectBuildLogsInOutput: false, this.injectPlatformJs: true}) |
| : entryPoints = entryPoints == null ? null |
| : entryPoints.map(systemToAssetPath).toList(); |
| @@ -140,6 +140,41 @@ class TransformOptions { |
| } |
| } |
| +class LintOptions { |
| + /// Whether lint is enabled. |
| + final bool enabled; |
| + |
| + /// Patterns explicitly included/excluded from linting (if any). |
| + final List<RegExp> patterns; |
| + |
| + /// When [patterns] is not null, whether they denote inclusion or exclusion. |
| + final bool isInclude; |
| + |
| + const LintOptions() |
| + : enabled = true, patterns = null, isInclude = null; |
| + const LintOptions.disabled() |
| + : enabled = false, patterns = null, isInclude = null; |
| + |
| + LintOptions.include(List<String> patterns) |
| + : enabled = true, |
| + isInclude = true, |
| + patterns = patterns.map((s) => new RegExp(s)).toList(); |
| + |
| + LintOptions.exclude(List<String> patterns) |
| + : enabled = true, |
| + isInclude = false, |
| + patterns = patterns.map((s) => new RegExp(s)).toList(); |
| + |
| + bool shouldLint(String fileName) { |
| + if (!enabled) return false; |
| + if (patterns == null) return true; |
|
jakemac
2014/10/13 14:35:19
this should probably be:
if (patterns == null) re
Siggi Cherem (dart-lang)
2014/10/13 16:09:33
Done.
|
| + for (var pattern in patterns) { |
| + if (pattern.hasMatch(fileName)) return isInclude; |
| + } |
| + return !isInclude; |
| + } |
| +} |
| + |
| /// Mixin for polymer transformers. |
| abstract class PolymerTransformer { |
| TransformOptions get options; |