From bfb0f6446eba3c7f3e277e1138b3151da6e0aa2c Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Sat, 3 Oct 2015 15:11:57 +0300 Subject: [PATCH] Added linting --- .eslintrc | 15 +++++ .jshintrc | 117 ------------------------------------ build/tasks/lint.js | 10 +++ lib/RedocTest/redoc-test.js | 4 +- lib/index.js | 2 + package.json | 9 ++- 6 files changed, 36 insertions(+), 121 deletions(-) create mode 100644 .eslintrc delete mode 100644 .jshintrc create mode 100644 build/tasks/lint.js diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 00000000..a4e474cb --- /dev/null +++ b/.eslintrc @@ -0,0 +1,15 @@ +{ + "parser": "babel-eslint", + "extends": "eslint:recommended", + "env": { + "browser": true, + }, + "rules": { + "quotes": [2, "single"], + "no-console": 0, + "comma-spacing": 2, + "comma-style": [2, "last"], + "consistent-return": 2, + "strict": [2, "global"] + } +} diff --git a/.jshintrc b/.jshintrc deleted file mode 100644 index 60df8a47..00000000 --- a/.jshintrc +++ /dev/null @@ -1,117 +0,0 @@ -{ - "bitwise" : false, - "curly" : false, - "eqeqeq" : true, - "forin" : true, - "immed" : true, - "latedef" : true, - "newcap" : true, - "noarg" : true, - "noempty" : true, - "nonew" : true, - "plusplus" : false, - "quotmark" : "single", - "regexp" : false, - "undef" : true, - "unused" : true, - "strict" : false, - "camelcase" : false, - "trailing" : true, - "indent" : 2, - "maxlen" : 120, - "maxdepth" : 4, - "maxstatements" : 30, - "maxcomplexity" : 5, - - "asi" : false, - "boss" : true, - "debug" : true, - "eqnull" : true, - "esnext" : true, - "evil" : true, - "expr" : true, - "funcscope" : false, - "globalstrict" : false, - "iterator" : false, - "lastsemic" : true, - "laxbreak" : false, - "laxcomma" : false, - "loopfunc" : false, - "multistr" : false, - "onecase" : false, - "proto" : false, - "regexdash" : false, - "scripturl" : false, - "smarttabs" : false, - "shadow" : false, - "sub" : false, - "supernew" : false, - "validthis" : false, - - "browser" : true, - "couch" : false, - "devel" : true, - "dojo" : false, - "jquery" : true, - "mootools" : false, - "node" : true, - "nonstandard" : false, - "prototypejs" : false, - "rhino" : false, - "wsh" : false, - - "nomen" : false, - "onevar" : false, - "passfail" : false, - "white" : false, - - "maxerr" : 100, - "globals": { - "_": true, - "queryCss": true, - "SVGInjector": true - }, - "predef" : [ - "__dirname", - "System", - "element", - "browser", - "require", - "jasmine", - "protractor", - "ptor", - "describe", - "ddescribe", - "xdescribe", - "it", - "iit", - "angular", - "inject", - "xit", - "beforeEach", - "afterEach", - "expect", - "input", - "pause", - "spyOn", - "runs", - "waits", - "waitsFor", - "Benchmark", - "Raphael", - "Backbone", - "Modernizr", - "Handlebars", - "Ext", - "_gaq", - "module", - "exports", - "define", - "$", - "jQuery", - "grunt", - "phantom", - "WebPage", - "by" - ] -} diff --git a/build/tasks/lint.js b/build/tasks/lint.js new file mode 100644 index 00000000..e073f8fa --- /dev/null +++ b/build/tasks/lint.js @@ -0,0 +1,10 @@ +var gulp = require('gulp'); +var eslint = require('gulp-eslint'); +var paths = require('../paths'); + +gulp.task('lint', function () { + return gulp.src(paths.source) + .pipe(eslint()) + .pipe(eslint.format()) + .pipe(eslint.failAfterError()); +}); diff --git a/lib/RedocTest/redoc-test.js b/lib/RedocTest/redoc-test.js index dc75a85a..9b150ca9 100644 --- a/lib/RedocTest/redoc-test.js +++ b/lib/RedocTest/redoc-test.js @@ -1,9 +1,11 @@ +'use strict'; + import {Component, View} from 'angular2/angular2'; @Component({selector: 'redoc-test'}) @View({ templateUrl: './lib/RedocTest/redoc-test.html', - styleUrls: ['./lib/RedocTest/redoc-test.css'], + styleUrls: ['./lib/RedocTest/redoc-test.css'] }) // Component controller export class RedocTest { diff --git a/lib/index.js b/lib/index.js index 5de85392..78c2dc2f 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,3 +1,5 @@ +'use strict'; + import 'zone.js'; import 'reflect-metadata'; import { bootstrap } from 'angular2/angular2'; diff --git a/package.json b/package.json index dd98e2e4..08304ef4 100644 --- a/package.json +++ b/package.json @@ -5,9 +5,8 @@ "private": true, "repository": "RomanGotsiy/redoc-prototype", "scripts": { - "server": "webpack-dev-server --hot --inline --colors --display-error-details --display-cached", - "start": "npm run server", - "test": "echo \"Error: no test specified\" && exit 1" + "test": "gulp lint", + "postinstall": "jspm install" }, "keywords": [ "Swagger", @@ -33,10 +32,14 @@ } }, "devDependencies": { + "babel-eslint": "^4.1.3", "browser-sync": "^2.9.8", "del": "^2.0.2", "gulp": "^3.9.0", + "gulp-eslint": "^1.0.0", "gulp-inline-ng2-template": "0.0.7", + "gulp-jshint": "^1.11.2", + "jshint-stylish": "^2.0.1", "jspm": "^0.16.11", "require-dir": "^0.3.0", "run-sequence": "^1.1.4",