diff --git a/.travis.yml b/.travis.yml index cf6ec2d9..cbd8f5ee 100644 --- a/.travis.yml +++ b/.travis.yml @@ -35,8 +35,6 @@ jobs: script: - if [[ "$POLYMER" = "2" ]]; then npm -q i && npm i -q --no-save bower polymer-cli && bower -q i && - gulp lint version:check && - polymer lint --rules polymer-2 --input ./src/*.html ./theme/**/*.html && if [[ "$TRAVIS_EVENT_TYPE" != "pull_request" && "$TRAVIS_BRANCH" != quick/* ]]; then if [[ "$TEST_SUITE" = "visual_tests" ]]; then npm i -q --no-save gemini@^4.0.0 gemini-sauce gemini-polyserve && @@ -45,6 +43,8 @@ script: wct --env saucelabs; fi; else + npm run check && + npm run lint && xvfb-run -s '-screen 0 1024x768x24' wct; fi && if [[ "$TRAVIS_EVENT_TYPE" = "cron" && "$TEST_SUITE" = "unit_tests" ]]; then @@ -52,7 +52,7 @@ script: fi; fi - if [[ "$POLYMER" = "3" ]]; then - npm --no-save -q install -g yarn bower magi-cli web-component-tester polymer-modulizer@0.4.1 && + npm --no-save -q install -g yarn bower magi-cli web-component-tester polymer-modulizer && rm -rf node_modules && magi p3-convert --out . --import-style=name && yarn install --flat && diff --git a/README.md b/README.md index f13b6d77..3cf9d8c1 100644 --- a/README.md +++ b/README.md @@ -137,7 +137,7 @@ To use the Material theme, import the correspondent file from the `theme/materia ## Following the coding style -We are using [ESLint](http://eslint.org/) for linting JavaScript code. You can check if your code is following our standards by running `gulp lint`, which will automatically lint all `.js` files as well as JavaScript snippets inside `.html` files. +We are using [ESLint](http://eslint.org/) for linting JavaScript code. You can check if your code is following our standards by running `npm run lint`, which will automatically lint all `.js` files as well as JavaScript snippets inside `.html` files. ## Big Thanks diff --git a/bower.json b/bower.json index a4ba0459..d0e3911c 100644 --- a/bower.json +++ b/bower.json @@ -20,7 +20,6 @@ "**/.*", "node_modules", "bower_components", - "gulpfile.js", "package-lock.json", "wct.conf.js" ], diff --git a/gulpfile.js b/gulpfile.js deleted file mode 100644 index 61fa1d20..00000000 --- a/gulpfile.js +++ /dev/null @@ -1,88 +0,0 @@ -'use strict'; - -const gulp = require('gulp'); -const eslint = require('gulp-eslint'); -const htmlExtract = require('gulp-html-extract'); -const lec = require('gulp-line-ending-corrector'); -const stylelint = require('gulp-stylelint'); -const find = require('gulp-find'); -const replace = require('gulp-replace'); -const expect = require('gulp-expect-file'); -const grepContents = require('gulp-grep-contents'); -const clip = require('gulp-clip-empty-files'); -const git = require('gulp-git'); - -gulp.task('lint', ['lint:js', 'lint:html', 'lint:css']); - -gulp.task('lint:js', () => { - return gulp.src([ - '*.js', - 'test/**/*.js' - ]) - .pipe(eslint()) - .pipe(eslint.format()) - .pipe(eslint.failAfterError()); -}); - -gulp.task('lint:html', () => { - return gulp.src([ - '*.html', - 'src/**/*.html', - 'demo/**/*.html', - 'test/**/*.html' - ]) - .pipe(htmlExtract({ - sel: 'script, code-example code', - strip: true - })) - .pipe(lec()) - .pipe(eslint()) - .pipe(eslint.format()) - .pipe(eslint.failAfterError()); -}); - -gulp.task('lint:css', () => { - return gulp.src([ - '*.html', - 'src/**/*.html', - 'demo/**/*.html', - 'theme/**/*.html', - 'test/**/*.html' - ]) - .pipe(htmlExtract({ - sel: 'style' - })) - .pipe(stylelint({ - reporters: [ - {formatter: 'string', console: true} - ] - })); -}); - -gulp.task('version:check', function() { - const expectedVersion = new RegExp('^' + require('./package.json').version + '$'); - return gulp.src(['src/*.html']) - .pipe(htmlExtract({sel: 'script'})) - .pipe(find(/static get version.*\n.*/)) - .pipe(clip()) // Remove non-matching files - .pipe(replace(/.*\n.*return '(.*)'.*/, '$1')) - .pipe(grepContents(expectedVersion, {invert: true})) - .pipe(expect({reportUnexpected: true}, [])); -}); - -gulp.task('version:update', ['version:check'], function() { - // Should be run from 'preversion' - // Assumes that the old version is in package.json and the new version in the `npm_package_version` environment variable - const oldversion = require('./package.json').version; - const newversion = process.env.npm_package_version; - if (!oldversion) { - throw new 'No old version found in package.json'; - } - if (!newversion) { - throw new 'New version must be given as a npm_package_version environment variable.'; - } - return gulp.src(['src/*.html']) - .pipe(replace(oldversion, newversion)) - .pipe(gulp.dest('src/.')) - .pipe(git.add()); -}); diff --git a/package.json b/package.json index 4870b093..33e04aba 100644 --- a/package.json +++ b/package.json @@ -22,13 +22,26 @@ "src", "theme" ], - "devDependencies": { - "@vaadin/vaadin-component-dev-dependencies": "^1.0.0" + "husky": { + "hooks": { + "pre-commit": "npm run lint" + } }, "scripts": { "test": "wct", + "check": "npm-run-all --parallel check:*", + "check:bower": "magi check-bower", + "check:version": "magi check-version", + "lint": "npm-run-all --parallel lint:*", + "lint:css": "stylelint *.html src/*.html demo/*.html theme/**/*.html test/*html", + "lint:html": "eslint *.html src demo test --ext .html", + "lint:js": "eslint *.js test", + "lint:polymer": "polymer lint --rules polymer-2 --input ./src/*.html ./theme/**/*.html", "prestart": "polymer analyze vaadin-* > analysis.json", "start": "polymer serve --port 3000 --open", - "preversion": "gulp version:update" + "preversion": "magi update-version" + }, + "devDependencies": { + "@vaadin/vaadin-component-dev-dependencies": "^3.0.0" } }