8000 Gulp + JSHint, Embed images · packetloop/angular-webpack@69f0302 · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Jan 21, 2019. It is now read-only.

Commit 69f0302

Browse files
committed
Gulp + JSHint, Embed images
1 parent 359cfc2 commit 69f0302

34 files changed

+542
-26
lines changed

.jshintrc

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
{
2+
3+
// --------------------------------------------------------------------
4+
// JSHint Configuration, Strict Edition
5+
// --------------------------------------------------------------------
6+
//
7+
// This is a options template for [JSHint][1], using [JSHint example][2]
8+
// and [Ory Band's example][3] as basis and setting config values to
9+
// be most strict:
10+
//
11+
// * set all enforcing options to true
12+
// * set all relaxing options to false
13+
// * set all environment options to false, except the browser value
14+
// * set all JSLint legacy options to false
15+
//
16+
// [1]: http://www.jshint.com/
17+
// [2]: https://github.com/jshint/node-jshint/blob/master/example/config.json
18+
// [3]: https://github.com/oryband/dotfiles/blob/master/jshintrc
19+
//
20+
// @author http://michael.haschke.biz/
21+
// @license http://unlicense.org/
22+
23+
// == Enforcing Options ===============================================
24+
//
25+
// These options tell JSHint to be more strict towards your code. Use
26+
// them if you want to allow only a safe subset of JavaScript, very
27+
// useful when your codebase is shared with a big number of developers
28+
// with different skill levels.
29+
30+
"bitwise": true, // Prohibit bitwise operators (&, |, ^, etc.).
31+
"curly": true, // Require {} for every new block or scope.
32+
"eqeqeq": true, // Require triple equals i.e. `===`.
33+
"forin": true, // Tolerate `for in` loops without `hasOwnPrototype`.
34+
"immed": true, // Require immediate invocations to be wrapped in parens e.g. `( function(){}() );`
35+
"latedef": true, // Prohibit variable use before definition.
36+
"newcap": true, // Require capitalization of all constructor functions e.g. `new F()`.
37+
"noarg": true, // Prohibit use of `arguments.caller` and `arguments.callee`.
38+
"noempty": true, // Prohibit use of empty blocks.
39+
"nonew": true, // Prohibit use of constructors for side-effects.
40+
"plusplus": true, // Prohibit use of `++` & `--`.
41+
"regexp": true, // Prohibit `.` and `[^...]` in regular expressions.
42+
"undef": true, // Require all non-global variables be declared before they are used.
43+
"strict": true, // Require `use strict` pragma in every file.
44+
"trailing": true, // Prohibit trailing whitespaces.
45+
"quotmark": "single", // Enforce use of single quotation marks for strings.
46+
"unused": true, // Warn when variables are defined but never used.
47+
"maxlen": 100, // Enforce line length to 100 characters
48+
"camelcase": true, // Force all variable names to use either camelCase style or UPPER_CASE with underscores.
49+
50+
// == Relaxing Options ================================================
51+
//
52+
// These options allow you to suppress certain types of warnings. Use
53+
// them only if you are absolutely positive that you know what you are
54+
// doing.
55+
56+
"asi": false, // Tolerate Automatic Semicolon Insertion (no semicolons).
57+
"boss": false, // Tolerate assignments inside if, for & while. Usually conditions & loops are for comparison, not assignments.
58+
"debug": false, // Allow debugger statements e.g. browser breakpoints.
59+
"eqnull": false, // Tolerate use of `== null`.
60+
"es5": false, // Allow EcmaScript 5 syntax.
61+
"esnext": false, // Allow ES.next specific features such as `const` and `let`.
62+
"evil": false, // Tolerate use of `eval`.
63+
"expr": false, // Tolerate `ExpressionStatement` as Programs.
64+
"funcscope": false, // Tolerate declarations of variables inside of control structures while accessing them later from the outside.
65+
"globalstrict": true, // Allow global "use strict" (also enables 'strict').
66+
"iterator": false, // Allow usage of __iterator__ property.
67+
"lastsemic": false, // Tolerat missing semicolons when the it is omitted for the last statement in a one-line block.
68+
"laxbreak": false, // Tolerate unsafe line breaks e.g. `return [\n] x` without semicolons.
69+
"laxcomma": false, // Suppress warnings about comma-first coding style.
70+
"loopfunc": false, // Allow functions to be defined within loops.
71+
"multistr": false, // Tolerate multi-line strings.
72+
"onecase": false, // Tolerate switches with just one case.
73+
"proto": false, // Tolerate __proto__ property. This property is deprecated.
74+
"regexdash": false, // Tolerate unescaped last dash i.e. `[-...]`.
75+
"scripturl": false, // Tolerate script-targeted URLs.
76+
"smarttabs": false, // Tolerate mixed tabs and spaces when the latter are used for alignmnent only.
77+
"shadow": false, // Allows re-define variables later in code e.g. `var x=1; x=2;`.
78+
"sub": false, // Tolerate all forms of subscript notation besides dot notation e.g. `dict['key']` instead of `dict.key`.
79+
"supernew": false, // Tolerate `new function () { ... };` and `new Object;`.
80+
"validthis": false, // Tolerate strict violations when the code is running in strict mode and you use this in a non-constructor function.
81+
82+
// == Environments ====================================================
83+
//
84+
// These options pre-define global variables that are exposed by
85+
// popular JavaScript libraries and runtime environments—such as
86+
// browser or node.js.
87+
88+
"browser": true, // Standard browser globals e.g. `window`, `document`.
89+
"couch": false, // Enable globals exposed by CouchDB.
90+
"devel": false, // Allow development statements e.g. `console.log();`.
91+
"dojo": false, // Enable globals exposed by Dojo Toolkit.
92+
"jquery": true, // Enable globals exposed by jQuery JavaScript library.
93+
"mootools": false, // Enable globals exposed by MooTools JavaScript framework.
94+
"node": false, // Enable globals available when code is running inside of the NodeJS runtime environment.
95+
"nonstandard": false, // Define non-standard but widely adopted globals such as escape and unescape.
96+
"prototypejs": false, // Enable globals exposed by Prototype JavaScript framework.
97+
"rhino": false, // Enable globals available when your code is running inside of the Rhino runtime environment.
98+
"wsh": false, // Enable globals available when your code is running as a script for the Windows Script Host.
99+
100+
// == JSLint Legacy ===================================================
101+
//
102+
// These options are legacy from JSLint. Aside from bug fixes they will
103+
// not be improved in any way and might be removed at any point.
104+
105+
"nomen": false, // Prohibit use of initial or trailing underbars in names.
106+
"onevar": false, // Allow only one `var` statement per function.
107+
"passfail": false, // Stop on first error.
108+
"white": true, // Check against strict whitespace and indentation rules.
109+
110+
// == Undocumented Options ============================================
111+
//
112+
// While I've found these options in [example1][2] and [example2][3]
113+
// they are not described in the [JSHint Options documentation][4].
114+
//
115+
// [4]: http://www.jshint.com/options/
116+
117+
"maxerr": 100, // Maximum errors before stopping.
118+
"predef": [
119+
120+
// CommonJS
121+
"global",
122+
"module",
123+
"require",
124+
"__dirname",
125+
"__filename",
126+
"exports"
127+
],
128+
"indent": 2 // Specify indentation spacing
129+
}

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ npm test
3131
- [x] `npm test` script with CI-friendly karma + webpack run
3232
- [x] Separate HTML template for `<hello>` + webpack build
3333
- [x] Separate CSS for `<hello>` + webpack build
34-
- [ ] Embed images
34+
- [x] Embed images
3535
- [x] Coverage report
3636
- [x] Multiple pages to load additional components asynchronously
37-
- [ ] Gulp + JSHint + Flow
37+
- [x] Gulp + JSHint

gulp/lint_report.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
'use strict';
2+
var gulp = require('gulp');
3+
var jshint = require('gulp-jshint');
4+
var logCapture = require('gulp-log-capture');
5+
var concat = require('gulp-concat');
6+
var replace = require('gulp-replace');
7+
8+
module.exports = function (stream) {
9+
var regex = new RegExp([
10+
'<\\/checkstyle>',
11+
'<\\?xml version="1\\.0" encoding="utf-8"\\?>',
12+
'<checkstyle version="4\\.3">',
13+
''
14+
].join('\\s'), 'g');
15+
16+
return stream
17+
.pipe(logCapture.start(console, 'log'))
18+
.pipe(jshint.reporter('checkstyle'))
19+
.pipe(logCapture.stop('xml'))
20+
.pipe(concat('jshint.xml'))
21+
.pipe(replace(regex, ''))
22+
.pipe(gulp.dest('reports/'));
23+
};

gulpfile.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
'use strict';
2+
3+
var gulp = require('gulp');
4+
var jshint = require('gulp-jshint');
5+
var stylish = require('jshint-stylish');
6+
var merge = require('merge-stream');
7+
8+
9+
function lint() {
10+
return merge(
11+
gulp.src(['src/**/*_spec.js'])
12+
.pipe(jshint('./spec.jshintrc')),
13+
gulp.src(['src/**/*.js', '!src/**/*_spec.js'])
14+
.pipe(jshint('./.jshintrc')),
15+
gulp.src(['gulpfile.js', 'webpack.config.js', 'karma.conf.js'])
16+
.pipe(jshint('./node.jshintrc'))
17+
);
18+
}
19+
20+
21+
gulp.task('lint', function () {
22+
lint().pipe(jshint.reporter(stylish));
23+
});
24+
25+
26+
gulp.task('lint:report', function () {
27+
require('./gulp/lint_report')(lint());
28+
});
29+
30+
31+
gulp.task('validate', function () {
32+
lint().pipe(jshint.reporter('fail'));
33+
});

karma.conf.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
var webpackConfig = require('./webpack.config');
24
webpackConfig.cache = true;
35
webpackConfig.module.postLoaders = [{

node.jshintrc

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
{
2+
3+
// --------------------------------------------------------------------
4+
// JSHint Configuration, Strict Edition
5+
// --------------------------------------------------------------------
6+
//
7+
// This is a options template for [JSHint][1], using [JSHint example][2]
8+
// and [Ory Band's example][3] as basis and setting config values to
9+
// be most strict:
10+
//
11+
// * set all enforcing options to true
12+
// * set all relaxing options to false
13+
// * set all environment options to false, except the browser value
14+
// * set all JSLint legacy options to false
15+
//
16+
// [1]: http://www.jshint.com/
17+
// [2]: https://github.com/jshint/node-jshint/blob/master/example/config.json
18+
// [3]: https://github.com/oryband/dotfiles/blob/master/jshintrc
19+
//
20+
// @author http://michael.haschke.biz/
21+
// @license http://unlicense.org/
22+
23+
// == Enforcing Options ===============================================
24+
//
25+
// These options tell JSHint to be more strict towards your code. Use
26+
// them if you want to allow only a safe subset of JavaScript, very
27+
// useful when your codebase is shared with a big number of developers
28+
// with different skill levels.
29+
30+
"bitwise": true, // Prohibit bitwise operators (&, |, ^, etc.).
31+
"curly": true, // Require {} for every new block or scope.
32+
"eqeqeq": true, // Require triple equals i.e. `===`.
33+
"forin": true, // Tolerate `for in` loops without `hasOwnPrototype`.
34+
"immed": true, // Require immediate invocations to be wrapped in parens e.g. `( function(){}() );`
35+
"latedef": true, // Prohibit variable use before definition.
36+
"newcap": true, // Require capitalization of all constructor functions e.g. `new F()`.
37+
"noarg": true, // Prohibit use of `arguments.caller` and `arguments.callee`.
38+
"noempty": true, // Prohibit use of empty blocks.
39+
"nonew": true, // Prohibit use of constructors for side-effects.
40+
"plusplus": true, // Prohibit use of `++` & `--`.
41+
"regexp": true, // Prohibit `.` and `[^...]` in regular expressions.
42+
"undef": true, // Require all non-global variables be declared before they are used.
43+
"strict": true, // Require `use strict` pragma in every file.
44+
"trailing": true, // Prohibit trailing whitespaces.
45+
"quotmark": "single", // Enforce use of single quotation marks for strings.
46+
"unused": true, // Warn when variables are defined but never used.
47+
"maxlen": 100, // Enforce line length to 100 characters
48+
"camelcase": true, // Force all variable names to use either camelCase style or UPPER_CASE with underscores.
49+
50+
// == Relaxing Options ================================================
51+
//
52+
// These options allow you to suppress certain types of warnings. Use
53+
// them only if you are absolutely positive that you know what you are
54+
// doing.
55+
56+
"asi": false, // Tolerate Automatic Semicolon Insertion (no semicolons).
57+
"boss": false, // Tolerate assignments inside if, for & while. Usually conditions & loops are for comparison, not assignments.
58+
"debug": false, // Allow debugger statements e.g. browser breakpoints.
59+
"eqnull": false, // Tolerate use of `== null`.
60+
"es5": false, // Allow EcmaScript 5 syntax.
61+
"esnext": false, // Allow ES.next specific features such as `const` and `let`.
62+
"evil": false, // Tolerate use of `eval`.
63+
"expr": false, // Tolerate `ExpressionStatement` as Programs.
64+
"funcscope": false, // Tolerate declarations of variables inside of control structures while accessing them later from the outside.
65+
"globalstrict": true, // Allow global "use strict" (also enables 'strict').
66+
"iterator": false, // Allow usage of __iterator__ property.
67+
"lastsemic": false, // Tolerat missing semicolons when the it is omitted for the last statement in a one-line block.
68+
"laxbreak": false, // Tolerate unsafe line breaks e.g. `return [\n] x` without semicolons.
69+
"laxcomma": false, // Suppress warnings about comma-first coding style.
70+
"loopfunc": false, // Allow functions to be defined within loops.
71+
"multistr": false, // Tolerate multi-line strings.
72+
"onecase": false, // Tolerate switches with just one case.
73+
"proto": false, // Tolerate __proto__ property. This property is deprecated.
74+
"regexdash": false, // Tolerate unescaped last dash i.e. `[-...]`.
75+
"scripturl": false, // Tolerate script-targeted URLs.
76+
"smarttabs": false, // Tolerate mixed tabs and spaces when the latter are used for alignmnent only.
77+
"shadow": false, // Allows re-define variables later in code e.g. `var x=1; x=2;`.
78+
"sub": false, // Tolerate all forms of subscript notation besides dot notation e.g. `dict['key']` instead of `dict.key`.
79+
"supernew": false, // Tolerate `new function () { ... };` and `new Object;`.
80+
"validthis": false, // Tolerate strict violations when the code is running in strict mode and you use this in a non-constructor function.
81+
82+
// == Environments ====================================================
83+
//
84+
// These options pre-define global variables that are exposed by
85+
// popular JavaScript libraries and runtime environments—such as
86+
// browser or node.js.
87+
88+
"browser": false, // Standard browser globals e.g. `window`, `document`.
89+
"couch": false, // Enable globals exposed by CouchDB.
90+
"devel": false, // Allow development statements e.g. `console.log();`.
91+
"dojo": false, // Enable globals exposed by Dojo Toolkit.
92+
"jquery": false, // Enable globals exposed by jQuery JavaScript library.
93+
"mootools": false, // Enable globals exposed by MooTools JavaScript framework.
94+
"node": true, // Enable globals available when code is running inside of the NodeJS runtime environment.
95+
"nonstandard": false, // Define non-standard but widely adopted globals such as escape and unescape.
96+
"prototypejs": false, // Enable globals exposed by Prototype JavaScript framework.
97+
"rhino": false, // Enable globals available when your code is running inside of the Rhino runtime environment.
98+
"wsh": false, // Enable globals available when your code is running as a script for the Windows Script Host.
99+
100+
// == JSLint Legacy ===================================================
101+
//
102+
// These options are legacy from JSLint. Aside from bug fixes they will
103+
// not be improved in any way and might be removed at any point.
104+
105+
"nomen": false, // Prohibit use of initial or trailing underbars in names.
106+
"onevar": false, // Allow only one `var` statement per function.
107+
"passfail": false, // Stop on first error.
108+
"white": true, // Check against strict whitespace and indentation rules.
109+
110+
// == Undocumented Options ============================================
111+
//
112+
// While I've found these options in [example1][2] and [example2][3]
113+
// they are not described in the [JSHint Options documentation][4].
114+
//
115+
// [4]: http://www.jshint.com/options/
116+
117+
"maxerr": 100, // Maximum errors before stopping.
118+
"predef": [],
119+
"indent": 2 // Specify indentation spacing
120+
}

package.json

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
"description": "Angular + Webpack build with Karma tests support",
55
"main": "index.js",
66
"scripts": {
7-
"build": "webpack",
8-
"test": "node ./node_modules/karma/bin/karma start ./karma.conf.js --single-run"
7+
"build": "rm -rf dest && webpack",
8+
"test": "node ./node_modules/karma/bin/karma start ./karma.conf.js --single-run",
9+
"validate": "gulp validate"
910
},
1011
"author": {
1112
"name": "Nik Butenko",
@@ -20,19 +21,28 @@
2021
"angular-mocks": "^1.3.6",
2122
"css-loader": "^0.9.0",
2223
"exports-loader": "^0.6.2",
24+
"file-loader": "^0.8.1",
25+
"gulp": "^3.8.10",
26+
"gulp-concat": "^2.4.2",
27+
"gulp-jshint": "^1.9.0",
28+
"gulp-log-capture": "0.0.6",
29+
"gulp-replace": "^0.5.0",
2330
"imports-loader": "^0.6.3",
2431
"istanbul": "^0.3.5",
2532
"istanbul-instrumenter-loader": "^0.1.2",
2633
"jasmine-core": "^2.1.3",
34+
"jshint-stylish": "^1.0.0",
2735
"karma": "^0.12.28",
2836
"karma-chrome-launcher": "^0.1.7",
2937
"karma-coverage": "^0.2.7",
3038
"karma-jasmine": "^0.3.2",
3139
"karma-sourcemap-loader": "^0.3.0",
3240
"karma-webpack": "^1.3.1",
41+
"merge-stream": "^0.1.6",
3342
"ng-cache-loader": "0.0.7",
3443
"sass-loader": "^0.3.1",
3544
"style-loader": "^0.8.2",
45+
"url-loader": "^0.5.5",
3646
"webpack": "^1.4.13",
3747
"webpack-dev-server": "^1.6.6"
3848
},

0 commit comments

Comments
 (0)
0