From 2a0278427e85bca30fe3e3218dbcd55febf0bbb7 Mon Sep 17 00:00:00 2001 From: Rob Dodson Date: Tue, 13 Dec 2016 11:54:03 -0800 Subject: [PATCH] Add ESLint and fixup errors (#951) * Add ESLint and fixup errors * Update config to include recommended. Fixup errors * Add cascading eslintrc * Run npm test --- .eslintrc.json | 16 ++++++++++++++++ .travis.yml | 2 +- index.html | 5 +++-- package.json | 13 +++++++++++++ service-worker.js | 7 ++++++- src/my-app.html | 13 ++++--------- src/my-view1.html | 2 +- src/my-view2.html | 2 +- src/my-view3.html | 2 +- src/my-view404.html | 2 +- src/shared-styles.html | 7 ------- sw-precache-config.js | 7 +++++-- test/.eslintrc.json | 10 ++++++++++ test/index.html | 2 +- test/my-view1.html | 2 +- 15 files changed, 64 insertions(+), 28 deletions(-) create mode 100644 .eslintrc.json create mode 100644 package.json create mode 100644 test/.eslintrc.json diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 00000000..ce13b20e --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,16 @@ +{ + "extends": ["eslint:recommended", "google"], + "env": { + "browser": true + }, + "plugins": [ + "html" + ], + "rules": { + "no-var": "off", + "new-cap": ["error", { "capIsNewExceptions": ["Polymer"] }] + }, + "globals": { + "Polymer": true + } +} diff --git a/.travis.yml b/.travis.yml index 2051ae93..280e8ec2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,4 +16,4 @@ before_script: - npm install -g bower polymer-cli - bower install script: - - xvfb-run polymer test + - xvfb-run npm test diff --git a/index.html b/index.html index ef9fbeb4..1e9fb36f 100644 --- a/index.html +++ b/index.html @@ -50,10 +50,11 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN // Setup Polymer options window.Polymer = { dom: 'shadow', - lazyRegister: true + lazyRegister: true, }; - // Load webcomponentsjs polyfill if browser does not support native Web Components + // Load webcomponentsjs polyfill if browser does not support native + // Web Components (function() { 'use strict'; diff --git a/package.json b/package.json new file mode 100644 index 00000000..f851c4de --- /dev/null +++ b/package.json @@ -0,0 +1,13 @@ +{ + "name": "polymer-starter-kit", + "license": "BSD-3-Clause", + "devDependencies": { + "eslint": "^3.12.0", + "eslint-config-google": "^0.7.1", + "eslint-plugin-html": "^1.7.0" + }, + "scripts": { + "lint": "eslint . --ext js,html; exit 0;", + "test": "npm run lint && polymer test" + } +} diff --git a/service-worker.js b/service-worker.js index 97b9058f..93e9d49d 100644 --- a/service-worker.js +++ b/service-worker.js @@ -7,4 +7,9 @@ * Code distributed by Google as part of the polymer project is also * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ -console.info('Service worker disabled for development, will be generated at build time.'); + +/* eslint no-console: ["error", { allow: ["info"] }] */ + +console.info( + 'Service worker disabled for development, will be generated at build time.' +); diff --git a/src/my-app.html b/src/my-app.html index 00273611..c7b56402 100644 --- a/src/my-app.html +++ b/src/my-app.html @@ -46,19 +46,14 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN .drawer-list a { display: block; - padding: 0 16px; - text-decoration: none; - color: var(--app-secondary-color); - line-height: 40px; } .drawer-list a.iron-selected { color: black; - font-weight: bold; } @@ -113,12 +108,12 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN page: { type: String, reflectToAttribute: true, - observer: '_pageChanged' - } + observer: '_pageChanged', + }, }, observers: [ - '_routePageChanged(routeData.page)' + '_routePageChanged(routeData.page)', ], _routePageChanged: function(page) { @@ -137,7 +132,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN _showPage404: function() { this.page = 'view404'; - } + }, }); diff --git a/src/my-view1.html b/src/my-view1.html index 2171f6f4..b25d0f90 100644 --- a/src/my-view1.html +++ b/src/my-view1.html @@ -31,7 +31,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN diff --git a/src/my-view2.html b/src/my-view2.html index 1590511c..06b082c8 100644 --- a/src/my-view2.html +++ b/src/my-view2.html @@ -31,7 +31,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN diff --git a/src/my-view3.html b/src/my-view3.html index 49c0875d..c69c0723 100644 --- a/src/my-view3.html +++ b/src/my-view3.html @@ -31,7 +31,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN diff --git a/src/my-view404.html b/src/my-view404.html index 73c9352d..3f342a62 100644 --- a/src/my-view404.html +++ b/src/my-view404.html @@ -29,7 +29,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN diff --git a/src/shared-styles.html b/src/shared-styles.html index e6769ea6..5e4f2491 100644 --- a/src/shared-styles.html +++ b/src/shared-styles.html @@ -17,7 +17,6 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN .card { margin: 24px; padding: 16px; - color: #757575; border-radius: 5px; background-color: #fff; @@ -26,25 +25,19 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN .circle { display: inline-block; - width: 64px; height: 64px; - text-align: center; - color: #555; border-radius: 50%; background: #ddd; - font-size: 30px; line-height: 64px; } h1 { margin: 16px 0; - color: #212121; - font-size: 22px; } diff --git a/sw-precache-config.js b/sw-precache-config.js index 6eca8d69..301bb56b 100644 --- a/sw-precache-config.js +++ b/sw-precache-config.js @@ -7,11 +7,14 @@ * Code distributed by Google as part of the polymer project is also * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ + +/* eslint-env node */ + module.exports = { staticFileGlobs: [ '/index.html', '/manifest.json', - '/bower_components/webcomponentsjs/webcomponents-lite.min.js' + '/bower_components/webcomponentsjs/webcomponents-lite.min.js', ], - navigateFallback: 'index.html' + navigateFallback: 'index.html', }; diff --git a/test/.eslintrc.json b/test/.eslintrc.json new file mode 100644 index 00000000..72c94038 --- /dev/null +++ b/test/.eslintrc.json @@ -0,0 +1,10 @@ +{ + "env": { + "mocha": true + }, + "globals": { + "assert": false, + "fixture": false, + "WCT": false + } +} diff --git a/test/index.html b/test/index.html index abbabb50..8678e384 100644 --- a/test/index.html +++ b/test/index.html @@ -22,7 +22,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN diff --git a/test/my-view1.html b/test/my-view1.html index deae2146..bcb79628 100644 --- a/test/my-view1.html +++ b/test/my-view1.html @@ -40,7 +40,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN test('Number in circle should be 1', function() { var circle = Polymer.dom(home.root).querySelector('.circle'); assert.equal(circle.textContent, '1'); - }) + }); });