Skip to content

Commit 2696145

Browse files
committed
added eslint to gulp
1 parent a7d2985 commit 2696145

File tree

4 files changed

+86
-56
lines changed

4 files changed

+86
-56
lines changed

.eslintrc.json

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
{
2+
"rules": {
3+
"no-cond-assign": "error",
4+
"no-console": "error",
5+
"no-constant-condition": "error",
6+
"no-control-regex": "error",
7+
"no-dupe-args": "error",
8+
"no-dupe-keys": "error",
9+
"no-duplicate-case": "error",
10+
"no-empty-character-class": "error",
11+
"no-empty": "error",
12+
"no-ex-assign": "error",
13+
"no-extra-boolean-cast": "error",
14+
"no-extra-semi": "error",
15+
"no-func-assign": "error",
16+
"no-inner-declarations": "error",
17+
"no-invalid-regexp": "error",
18+
"no-irregular-whitespace": "error",
19+
"no-obj-calls": "error",
20+
"no-prototype-builtins": "error",
21+
"no-regex-spaces": "error",
22+
"no-sparse-arrays": "error",
23+
"no-template-curly-in-string": "error",
24+
"no-unexpected-multiline": "error",
25+
"no-unreachable": "error",
26+
"no-unsafe-finally": "error",
27+
"no-unsafe-negation": "error",
28+
"use-isnan": "error",
29+
"valid-jsdoc": "error",
30+
"valid-typeof": "error",
31+
"accessor-pairs": "error",
32+
"default-case": "error",
33+
"eqeqeq": [
34+
"error",
35+
"always",
36+
{
37+
"null": "ignore"
38+
}
39+
],
40+
"curly": "error",
41+
"no-alert": "error",
42+
"no-eval": "error",
43+
"no-throw-literal": "error",
44+
"no-unmodified-loop-condition": "error",
45+
"array-bracket-spacing": [
46+
"error",
47+
"never"
48+
],
49+
"block-spacing": "error",
50+
"quotes": [
51+
"error",
52+
"double"
53+
],
54+
"semi": [
55+
"error",
56+
"always"
57+
]
58+
}
59+
}

gulpfile.js

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ var gulp = require("gulp");
33
var merge = require("merge2");
44
var concat = require("gulp-concat");
55
var minify = require("gulp-minify");
6-
var tslint = require("gulp-tslint");
76
var watch = require("gulp-watch");
7+
var tslint = require("gulp-tslint");
8+
var eslint = require("gulp-eslint");
89

910
var jasmine = require("gulp-jasmine");
1011
var jasmineBrowser = require("gulp-jasmine-browser");
@@ -25,14 +26,9 @@ gulp.task("demots", function () {
2526
});
2627

2728
gulp.task("typescript", function () {
29+
gulp.start("tslint");
30+
2831
var tsResult = devTS.src()
29-
.pipe(tslint({
30-
formatter: "prose"
31-
}))
32-
.pipe(tslint.report({
33-
emitError: false,
34-
summarizeFailureOutput: true
35-
}))
3632
.pipe(devTS());
3733

3834
return merge([
@@ -86,7 +82,16 @@ gulp.task("tslint", function(){
8682
}));
8783
});
8884

89-
gulp.task("lint", ["tslint"], function(){
85+
gulp.task("eslint", function(){
86+
return gulp.src(["dist/**/*.js", "!dist/**/*.min.js"])
87+
.pipe(eslint({
88+
configFile: ".eslintrc.json"
89+
}))
90+
.pipe(eslint.format("stylish"))
91+
.pipe(eslint.failAfterError());
92+
});
93+
94+
gulp.task("lint", ["tslint", "eslint"], function(){
9095

9196
});
9297

@@ -122,11 +127,19 @@ gulp.task("server", ["browsersync"], function () {
122127
port: 15666
123128
});
124129

125-
gulp.watch("demo/**/*.ts", ["demots"]);
126130
gulp.watch("test/**/*.ts", ["test"]);
131+
gulp.watch("demo/**/*.ts", ["demots"]);
127132
gulp.watch("dev/**/*.ts", ["typescript"]);
128133

129134
gulp.watch("demo/**/*.html").on("change", browsersync.reload);
130-
gulp.watch("dist/**/*.js").on("change", browsersync.reload);
135+
gulp.watch("dist/**/*.js", ["eslint"]).on("change", browsersync.reload);
131136
gulp.watch("demo/**/*.js").on("change", browsersync.reload);
137+
});
138+
139+
gulp.task("edit", function(){
140+
gulp.watch("test/**/*.ts", ["test"]);
141+
gulp.watch("dev/**/*.ts", ["typescript"]);
142+
gulp.watch("dist/**/*.js", ["eslint"]);
143+
gulp.watch("tslint.json", ["tslint"]);
144+
gulp.watch(".eslintrc.json", ["eslint"]);
132145
});

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"gulp": "^3.9.1",
3232
"gulp-concat": "^2.6.1",
3333
"gulp-connect": "^5.0.0",
34+
"gulp-eslint": "^3.0.1",
3435
"gulp-jasmine": "^2.4.2",
3536
"gulp-jasmine-browser": "^1.7.1",
3637
"gulp-minify": "0.0.14",

tslint.json

Lines changed: 2 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,4 @@
11
{
2-
/*"jsRules": {
3-
"class-name": true,
4-
"comment-format": [
5-
true,
6-
"check-space"
7-
],
8-
"indent": [
9-
true,
10-
"spaces"
11-
],
12-
"no-duplicate-variable": true,
13-
"no-eval": true,
14-
"no-trailing-whitespace": true,
15-
"no-unsafe-finally": true,
16-
"one-line": [
17-
true,
18-
"check-open-brace",
19-
"check-whitespace"
20-
],
21-
"quotemark": [
22-
true,
23-
"double"
24-
],
25-
"semicolon": [
26-
true,
27-
"always"
28-
],
29-
"triple-equals": [
30-
true,
31-
"allow-null-check"
32-
],
33-
"variable-name": [
34-
true,
35-
"ban-keywords"
36-
],
37-
"whitespace": [
38-
true,
39-
"check-branch",
40-
"check-decl",
41-
"check-operator",
42-
"check-separator",
43-
"check-type"
44-
]
45-
},*/
462
"rules": {
473
"class-name": true,
484
"comment-format": [
@@ -144,6 +100,7 @@
144100
"one-variable-per-declaration": [
145101
true
146102
],
147-
"prefer-method-signature": true
103+
"prefer-method-signature": true,
104+
"no-console": [true]
148105
}
149106
}

0 commit comments

Comments
 (0)