Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Unified Diff: pkg/polymer/lib/src/build/common.dart

Issue 648883002: Add more options to configure the linter. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/polymer/lib/deploy.dart ('k') | pkg/polymer/lib/src/build/linter.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..99098f89e6f2d87b4a18ce79c919111f32af26c1 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 = true;
+ const LintOptions.disabled()
+ : enabled = false, patterns = null, isInclude = true;
+
+ 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 isInclude;
+ for (var pattern in patterns) {
+ if (pattern.hasMatch(fileName)) return isInclude;
+ }
+ return !isInclude;
+ }
+}
+
/// Mixin for polymer transformers.
abstract class PolymerTransformer {
TransformOptions get options;
« no previous file with comments | « pkg/polymer/lib/deploy.dart ('k') | pkg/polymer/lib/src/build/linter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698