diff --git a/.eslintignore b/.eslintignore
new file mode 100644
index 00000000..552fce7f
--- /dev/null
+++ b/.eslintignore
@@ -0,0 +1,5 @@
+node_modules/*
+bower_components/*
+test/*
+src/**/demo/*
+src/**/experimental/*
diff --git a/.eslintrc.json b/.eslintrc.json
new file mode 100644
index 00000000..94a41a64
--- /dev/null
+++ b/.eslintrc.json
@@ -0,0 +1,17 @@
+{
+ "extends": "eslint:recommended",
+ "rules": {
+ "no-console": 0
+ },
+ "env": {
+ "browser": true
+ },
+ "plugins": [
+ "html"
+ ],
+ "globals": {
+ "CustomElements": true,
+ "HTMLImports": true,
+ "Polymer": true
+ }
+}
diff --git a/.travis.yml b/.travis.yml
index 9d3a1a94..0bc7a848 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -15,6 +15,7 @@ before_script:
- npm install -g bower
- bower install
script:
+- gulp lint
- xvfb-run wct
- "if [ \"${TRAVIS_PULL_REQUEST}\" = \"false\" ]; then wct -s 'default'; fi"
env:
diff --git a/gulpfile.js b/gulpfile.js
index c201c2c3..b3e02279 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -20,6 +20,7 @@ var runseq = require('run-sequence');
var lazypipe = require('lazypipe');
var polyclean = require('polyclean');
var del = require('del');
+var eslint = require('gulp-eslint');
var path = require('path');
@@ -124,3 +125,10 @@ gulp.task('audit', function() {
gulp.task('release', function(cb) {
runseq('default', ['copy-bower-json', 'audit'], cb);
});
+
+gulp.task('lint', function() {
+ return gulp.src('src/**/*.html')
+ .pipe(eslint())
+ .pipe(eslint.format())
+ .pipe(eslint.failAfterError());
+});
diff --git a/package.json b/package.json
index a086fad6..58036b0e 100644
--- a/package.json
+++ b/package.json
@@ -9,8 +9,10 @@
},
"devDependencies": {
"del": "^1.1.1",
+ "eslint-plugin-html": "^1.3.0",
"gulp": "^3.8.11",
"gulp-audit": "^1.0.0",
+ "gulp-eslint": "^1.1.1",
"gulp-rename": "^1.2.2",
"gulp-replace": "^0.5.3",
"gulp-vulcanize": "^6.0.1",
@@ -21,7 +23,7 @@
},
"scripts": {
"build": "gulp",
- "test": "wct",
+ "test": "gulp lint && wct",
"test-build": "gulp switch && wct && gulp restore"
},
"repository": {
diff --git a/src/lib/annotations/annotations.html b/src/lib/annotations/annotations.html
index ac19ed98..9cee6b0b 100644
--- a/src/lib/annotations/annotations.html
+++ b/src/lib/annotations/annotations.html
@@ -1,391 +1,391 @@
-
-
-
-
+
+
+
+
diff --git a/src/lib/array-splice.html b/src/lib/array-splice.html
index f51279a7..8c4da154 100644
--- a/src/lib/array-splice.html
+++ b/src/lib/array-splice.html
@@ -10,7 +10,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
\ No newline at end of file
+
diff --git a/src/lib/bind/accessors.html b/src/lib/bind/accessors.html
index 66175dea..99739813 100644
--- a/src/lib/bind/accessors.html
+++ b/src/lib/bind/accessors.html
@@ -23,7 +23,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
_notifyChange: function(source, event, value) {
value = value === undefined ? this[source] : value;
event = event || Polymer.CaseMap.camelToDashCase(source) + '-changed';
- this.fire(event, {value: value},
+ this.fire(event, {value: value},
{bubbles: false, cancelable: false, _useCache: true});
},
@@ -221,8 +221,8 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
} else {
// TODO(sorvell): even though we have a `value` argument, we *must*
// lookup the current value of the property. Multiple listeners and
- // queued events during configuration can theoretically lead to
- // divergence of the passed value from the current value, but we
+ // queued events during configuration can theoretically lead to
+ // divergence of the passed value from the current value, but we
// really need to track down a specific case where this happens.
value = target[property];
if (!isStructured) {
@@ -256,7 +256,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
//if (node._prepParentProperties || !node._propertyInfo || (p && p.notify)) {
this._addNotifyListener(node, inst, info.event, info.changedFn);
//}
- };
+ }
},
// TODO(sorvell): note, adding these synchronously may impact performance,
diff --git a/src/lib/collection.html b/src/lib/collection.html
index 997b3a5f..91d6ca49 100644
--- a/src/lib/collection.html
+++ b/src/lib/collection.html
@@ -50,7 +50,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
},
removeKey: function(key) {
- if (key = this._parseKey(key)) {
+ if ((key = this._parseKey(key))) {
this._removeFromMap(this.store[key]);
delete this.store[key];
}
@@ -95,7 +95,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
},
setItem: function(key, item) {
- if (key = this._parseKey(key)) {
+ if ((key = this._parseKey(key))) {
var old = this.store[key];
if (old) {
this._removeFromMap(old);
@@ -110,7 +110,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
},
getItem: function(key) {
- if (key = this._parseKey(key)) {
+ if ((key = this._parseKey(key))) {
return this.store[key];
}
},
@@ -140,7 +140,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
key = this.getKey(s.removed[j]);
keyMap[key] = keyMap[key] ? null : -1;
}
- for (var j=0; j
(function() {
- var nativeShadow = Polymer.Settings.useNativeShadow;
var propertyUtils = Polymer.StyleProperties;
var styleUtil = Polymer.StyleUtil;
var cssParse = Polymer.CssParse;
diff --git a/src/lib/dom-api-effective-nodes-observer.html b/src/lib/dom-api-effective-nodes-observer.html
index f98de7d4..9eb3fe7e 100644
--- a/src/lib/dom-api-effective-nodes-observer.html
+++ b/src/lib/dom-api-effective-nodes-observer.html
@@ -1,268 +1,264 @@
-
-
-
\ No newline at end of file
+
+
+
diff --git a/src/lib/dom-api-shady.html b/src/lib/dom-api-shady.html
index b15bfac7..7c4da0b2 100644
--- a/src/lib/dom-api-shady.html
+++ b/src/lib/dom-api-shady.html
@@ -93,7 +93,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
if (root) {
// note: we always need to see if an insertion point is added
// since this saves logical tree info; however, invalidation state
- // needs
+ // needs
var ipAdded = this._maybeAddInsertionPoint(node, this.node);
// invalidate insertion points IFF not already invalid!
if (!root._invalidInsertionPoints) {
@@ -107,14 +107,14 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
// if not distributing and not adding to host, do a fast path addition
var handled = this._maybeDistribute(node) ||
this.node.shadyRoot;
- // if shady is handling this node,
+ // if shady is handling this node,
// the actual dom may not be removed if the node or fragment contents
// remain undistributed so we ensure removal here.
// NOTE: we only remove from existing location iff shady dom is involved.
// This is because a node fragment is passed to the native add method
// which expects to see fragment children. Regular elements must also
- // use this check because not doing so causes separation of
- // attached/detached and breaks, for example,
+ // use this check because not doing so causes separation of
+ // attached/detached and breaks, for example,
// dom-if's attached/detached checks.
if (handled) {
if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
@@ -137,7 +137,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
*/
removeChild: function(node) {
if (TreeApi.Logical.getParentNode(node) !== this.node) {
- throw Error('The node to be removed is not a child of this node: ' +
+ throw Error('The node to be removed is not a child of this node: ' +
node);
}
if (!this._removeNode(node)) {
@@ -154,7 +154,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
return node;
},
- // Try to remove node: update logical info and perform distribution iff
+ // Try to remove node: update logical info and perform distribution iff
// needed. Return true if the removal has been handled.
// note that it's possible for both the node's host and its parent
// to require distribution... both cases are handled here.
@@ -214,7 +214,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
}
// memo-ize result for performance but only memo-ize a false-y
// result if node is in the document. This avoids a problem where a root
- // can be cached while an element is inside a fragment.
+ // can be cached while an element is inside a fragment.
// If this happens and we cache the result, the value can become stale
// because for perf we avoid processing the subtree of added fragments.
if (root || document.documentElement.contains(node)) {
@@ -298,7 +298,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
},
_nodeNeedsDistribution: function(node) {
- return node && node.shadyRoot &&
+ return node && node.shadyRoot &&
DomApi.hasInsertionPoint(node.shadyRoot);
},
@@ -587,7 +587,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
return this.node.textContent;
} else {
var tc = [];
- for (var i = 0, cn = this.childNodes, c; c = cn[i]; i++) {
+ for (var i = 0, cn = this.childNodes, c; (c = cn[i]); i++) {
if (c.nodeType !== Node.COMMENT_NODE) {
tc.push(c.textContent);
}
diff --git a/src/lib/dom-innerHTML.html b/src/lib/dom-innerHTML.html
index 755eb4a3..09c8f3b9 100644
--- a/src/lib/dom-innerHTML.html
+++ b/src/lib/dom-innerHTML.html
@@ -1,131 +1,131 @@
-
-
+
+
diff --git a/src/lib/dom-module.html b/src/lib/dom-module.html
index f1f9355a..468e55bf 100644
--- a/src/lib/dom-module.html
+++ b/src/lib/dom-module.html
@@ -45,7 +45,7 @@
* @param {String} id The id at which to register the dom-module.
*/
register: function(id) {
- var id = id || this.id ||
+ id = id || this.id ||
this.getAttribute('name') || this.getAttribute('is');
if (id) {
this.id = id;
@@ -103,7 +103,7 @@
var doc = script && script.ownerDocument || document;
// find all dom-modules
var modules = doc.querySelectorAll('dom-module');
- // minimize work by going backwards and stopping if we find an
+ // minimize work by going backwards and stopping if we find an
// upgraded module.
for (var i= modules.length-1, m; (i >=0) && (m=modules[i]); i--) {
if (m.__upgraded__) {
diff --git a/src/lib/dom-tree-api.html b/src/lib/dom-tree-api.html
index 3fb61da7..ccf0dea0 100644
--- a/src/lib/dom-tree-api.html
+++ b/src/lib/dom-tree-api.html
@@ -11,20 +11,20 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
\ No newline at end of file
+
diff --git a/src/lib/style-defaults.html b/src/lib/style-defaults.html
index 1ffedc18..c015da74 100644
--- a/src/lib/style-defaults.html
+++ b/src/lib/style-defaults.html
@@ -1,91 +1,90 @@
-
-
-
-
+
+
+
+
diff --git a/src/lib/style-extends.html b/src/lib/style-extends.html
index 414f1ba2..3b3896db 100644
--- a/src/lib/style-extends.html
+++ b/src/lib/style-extends.html
@@ -1,101 +1,101 @@
-
-
-
-
+
+
+
+
diff --git a/src/lib/style-properties.html b/src/lib/style-properties.html
index 544a0be9..74436cdc 100644
--- a/src/lib/style-properties.html
+++ b/src/lib/style-properties.html
@@ -71,7 +71,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
var m, rx = this.rx.VAR_ASSIGN;
var cssText = rule.parsedCssText;
var any;
- while (m = rx.exec(cssText)) {
+ while ((m = rx.exec(cssText))) {
// note: group 2 is var, 3 is mixin
properties[m[1]] = (m[2] || m[3]).trim();
any = true;
@@ -103,7 +103,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
collectPropertiesInCssText: function(cssText, props) {
var m;
- while (m = this.rx.VAR_CAPTURE.exec(cssText)) {
+ while ((m = this.rx.VAR_CAPTURE.exec(cssText))) {
props[m[1]] = true;
var def = m[2];
if (def && def.match(this.rx.IS_VAR)) {
@@ -155,7 +155,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
valueForProperties: function(property, props) {
var parts = property.split(';');
for (var i=0, p, m; i=0 ; i--) {
+ for (i=removedIdxs.length-1; i>=0 ; i--) {
var idx = removedIdxs[i];
// Removed idx may be undefined if item was previously filtered out
if (idx !== undefined) {
@@ -583,7 +582,7 @@ Then the `observe` property should be configured as follows:
});
// Insertion-sort new instances into place (from pool or newly created)
var start = 0;
- for (var i=0; i
diff --git a/src/micro/properties.html b/src/micro/properties.html
index 60257e2c..bd3b928d 100644
--- a/src/micro/properties.html
+++ b/src/micro/properties.html
@@ -116,7 +116,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
if (info) {
return info;
}
- };
+ }
}
return info || Polymer.nob;
},
@@ -138,7 +138,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
// union properties, behaviors.properties, and propertyEffects
_prepPropertyInfo: function() {
this._propertyInfo = {};
- for (var i=0, p; i < this.behaviors.length; i++) {
+ for (var i=0; i < this.behaviors.length; i++) {
this._addPropertyInfo(this._propertyInfo, this.behaviors[i].properties);
}
this._addPropertyInfo(this._propertyInfo, this.properties);
@@ -174,7 +174,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
}
}
}
- },
+ }
});
diff --git a/src/mini/shady.html b/src/mini/shady.html
index c06bc2fd..9bc70164 100644
--- a/src/mini/shady.html
+++ b/src/mini/shady.html
@@ -77,12 +77,12 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
this.shadyRoot._isShadyRoot = true;
this.shadyRoot._dirtyRoots = [];
// capture insertion point list
- var i$ = this.shadyRoot._insertionPoints = !this._notes ||
+ var i$ = this.shadyRoot._insertionPoints = !this._notes ||
this._notes._hasContent ?
this.shadyRoot.querySelectorAll('content') : [];
// save logical tree info
- // a. for shadyRoot
- // b. for insertion points (fallback)
+ // a. for shadyRoot
+ // b. for insertion points (fallback)
// c. for parents of insertion points
TreeApi.Logical.saveChildNodes(this.shadyRoot);
for (var i=0, c; i < i$.length; i++) {
@@ -119,7 +119,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
*/
distributeContent: function(updateInsertionPoints) {
if (this.shadyRoot) {
- this.shadyRoot._invalidInsertionPoints =
+ this.shadyRoot._invalidInsertionPoints =
this.shadyRoot._invalidInsertionPoints || updateInsertionPoints;
// Distribute the host that's the top of this element's distribution
// tree. Distributing that host will *always* distibute this element.
@@ -164,7 +164,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
// compose self
if (this._useContent) {
// note: it's important to mark this clean before distribution
- // so that attachment that provokes additional distribution (e.g.
+ // so that attachment that provokes additional distribution (e.g.
// adding something to your parentNode) works
this.shadyRoot._distributionClean = true;
if (DomApi.hasInsertionPoint(this.shadyRoot)) {
@@ -331,7 +331,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
for (var i=0, d=0, s; (i
-
-
+
+
+
diff --git a/src/standard/utils.html b/src/standard/utils.html
index 8f8f5fe9..f223b558 100644
--- a/src/standard/utils.html
+++ b/src/standard/utils.html
@@ -144,7 +144,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
getEffectiveTextContent: function() {
var cn = this.getEffectiveChildNodes();
var tc = [];
- for (var i=0, c; c = cn[i]; i++) {
+ for (var i=0, c; (c = cn[i]); i++) {
if (c.nodeType !== Node.COMMENT_NODE) {
tc.push(Polymer.dom(c).textContent);
}
@@ -215,7 +215,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
fire: function(type, detail, options) {
options = options || Polymer.nob;
var node = options.node || this;
- var detail = (detail === null || detail === undefined) ? {} : detail;
+ detail = (detail === null || detail === undefined) ? {} : detail;
var bubbles = options.bubbles === undefined ? true : options.bubbles;
var cancelable = Boolean(options.cancelable);
var useCache = options._useCache;
diff --git a/src/standard/x-styling.html b/src/standard/x-styling.html
index 8e0ef8ba..e50ff857 100644
--- a/src/standard/x-styling.html
+++ b/src/standard/x-styling.html
@@ -19,7 +19,6 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
var propertyUtils = Polymer.StyleProperties;
var styleTransformer = Polymer.StyleTransformer;
- var styleUtil = Polymer.StyleUtil;
var styleDefaults = Polymer.StyleDefaults;
var nativeShadow = Polymer.Settings.useNativeShadow;
@@ -77,7 +76,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
_findStyleHost: function() {
var e = this, root;
- while (root = Polymer.dom(e).getOwnerRoot()) {
+ while ((root = Polymer.dom(e).getOwnerRoot())) {
if (Polymer.isInstance(root.host)) {
return root.host;
}