Skip to content

Commit c080e4b

Browse files
committed
Added beautifiers, improved linters, improved source code to fit coding standards
1 parent 946f2c2 commit c080e4b

File tree

8 files changed

+290
-26
lines changed

8 files changed

+290
-26
lines changed

.jscsrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"preset": "jquery"
3+
}

.jshintrc

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"boss": true,
3+
"curly": true,
4+
"eqeqeq": true,
5+
"eqnull": true,
6+
"expr": true,
7+
"immed": true,
8+
"latedef": true,
9+
"newcap": true,
10+
"noarg": true,
11+
"quotmark": "double",
12+
"sub": true,
13+
"undef": false,
14+
"unused": true,
15+
"browser": true,
16+
"jquery": true
17+
}

gulpfile.js

+32-17
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,11 @@ var gulp = require('gulp'),
2222
autoprefixer = require('gulp-autoprefixer'),
2323
scsslint = require('gulp-scss-lint'),
2424
jshint = require('gulp-jshint'),
25+
jscs = require('gulp-jscs'),
2526
stylish = require('jshint-stylish'),
26-
html5Lint = require('gulp-html5-lint');
27+
html5Lint = require('gulp-html5-lint'),
28+
sassBeautify = require('gulp-sassbeautify'),
29+
jsBeautify = require('gulp-js-prettify');
2730

2831
gulp.task('clean', function(callback) {
2932
del('../dist');
@@ -40,8 +43,12 @@ gulp.task('html', function() {
4043
});
4144

4245
gulp.task('compile-sass', function() {
43-
return gulp.src('source/scss/**/*.scss')
46+
return gulp.src(['source/scss/*.scss', '!source/scss/_sprites.scss'])
4447
.pipe(plumber())
48+
.pipe(scsslint({
49+
bundleExec: false,
50+
config: 'scss-lint.yml'
51+
}))
4552
.pipe(sourcemaps.init())
4653
.pipe(sass())
4754
.pipe(autoprefixer('last 2 version', 'safari 5', 'ie 9', 'opera 12.1', 'ios 6', 'android 4'))
@@ -54,15 +61,27 @@ gulp.task('compile-sass', function() {
5461
.pipe(gulp.dest('../dist/css'))
5562
});
5663

64+
gulp.task('beautify-sass', function () {
65+
return gulp.src('source/scss/*.scss')
66+
.pipe(sassBeautify())
67+
.pipe(gulp.dest('source/scss/'));
68+
});
69+
5770
gulp.task('compile-jquery', function() {
5871
return jquery.src({
59-
release: 2,
60-
flags: ['-deprecated']
72+
release: 2,
73+
flags: ['-deprecated']
6174
})
6275
.pipe(gulp.dest('source/js/vendor'));
6376
});
6477

6578
gulp.task('compile-js', function(){
79+
gulp.src('source/js/*.js')
80+
.pipe(jshint('.jshintrc'))
81+
.pipe(jshint.reporter(stylish))
82+
.pipe(jscs())
83+
.pipe(jscs.reporter());
84+
6685
return gulp.src([
6786
'source/js/vendor/jquery.custom.js',
6887
'bower_components/bootstrap-sass/assets/javascripts/bootstrap.min.js',
@@ -80,6 +99,13 @@ gulp.task('compile-js', function(){
8099
.pipe(gulp.dest('../dist/js'))
81100
});
82101

102+
gulp.task('beautify-js', function() {
103+
gulp.src('source/js/*.js')
104+
.pipe(jscs({fix:true}))
105+
.pipe(jsBeautify({collapseWhitespace: true}))
106+
.pipe(gulp.dest('source/js'));
107+
});
108+
83109
gulp.task('select-icons', function() {
84110
return gulp.src('bower_components/Font-Awesome-SVG-PNG/white/svg/*.svg')
85111
.pipe(gulp.dest('source/iconfont/icons'));
@@ -126,10 +152,6 @@ gulp.task('optimize-images', function(){
126152
.pipe(gulp.dest('../dist/images'))
127153
});
128154

129-
gulp.task('default', function(callback){
130-
runSequence('clean', 'select-icons', 'compile-iconfont', 'compile-sprites', 'optimize-images', 'compile-sass', 'compile-jquery', 'compile-js', 'html', 'screens', callback)
131-
});
132-
133155
gulp.task('screens', function () {
134156
return gulp.src('../dist/*.html')
135157
.pipe(localScreenshots({
@@ -139,15 +161,8 @@ gulp.task('screens', function () {
139161
}));
140162
});
141163

142-
gulp.task('lint', function() {
143-
gulp.src('source/scss/**/*.scss')
144-
.pipe(scsslint({
145-
bundleExec: false
146-
}));
147-
148-
gulp.src('source/js/*.js')
149-
.pipe(jshint())
150-
.pipe(jshint.reporter(stylish));
164+
gulp.task('default', function(callback){
165+
runSequence('clean', 'select-icons', 'compile-iconfont', 'compile-sprites', 'optimize-images', 'compile-sass', 'compile-jquery', 'compile-js', 'html', 'screens', callback)
151166
});
152167

153168
gulp.task('watch', function(){

package.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@
3737
"gulp-jshint": "~1.11.2",
3838
"gulp-autoprefixer": "~3.0.2",
3939
"gulp-html5-lint": "~1.0.1",
40-
"gulp-csso": "~1.0.0",
41-
"es6-promise": "~3.0.2"
40+
"gulp-csso": "~1.0.0",
41+
"es6-promise": "~3.0.2",
42+
"gulp-sassbeautify": "~0.1.0",
43+
"gulp-js-prettify": "~0.1.0",
44+
"gulp-jscs": "~3.0.1"
4245
}
4346
}

scss-lint.yml

+225
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,225 @@
1+
linters:
2+
BangFormat:
3+
enabled: true
4+
space_before_bang: true
5+
space_after_bang: false
6+
7+
BemDepth:
8+
enabled: false
9+
max_elements: 1
10+
11+
BorderZero:
12+
enabled: true
13+
convention: zero # or `none`
14+
15+
ColorKeyword:
16+
enabled: true
17+
18+
ColorVariable:
19+
enabled: true
20+
21+
Comment:
22+
enabled: true
23+
24+
DebugStatement:
25+
enabled: true
26+
27+
DeclarationOrder:
28+
enabled: true
29+
30+
DisableLinterReason:
31+
enabled: false
32+
33+
DuplicateProperty:
34+
enabled: true
35+
36+
ElsePlacement:
37+
enabled: true
38+
style: same_line # or 'new_line'
39+
40+
EmptyLineBetweenBlocks:
41+
enabled: true
42+
ignore_single_line_blocks: true
43+
44+
EmptyRule:
45+
enabled: true
46+
47+
ExtendDirective:
48+
enabled: false
49+
50+
FinalNewline:
51+
enabled: true
52+
present: true
53+
54+
HexLength:
55+
enabled: true
56+
style: short # or 'long'
57+
58+
HexNotation:
59+
enabled: true
60+
style: lowercase # or 'uppercase'
61+
62+
HexValidation:
63+
enabled: true
64+
65+
IdSelector:
66+
enabled: true
67+
68+
ImportantRule:
69+
enabled: true
70+
71+
ImportPath:
72+
enabled: true
73+
leading_underscore: false
74+
filename_extension: false
75+
76+
Indentation:
77+
enabled: true
78+
allow_non_nested_indentation: false
79+
character: space # or 'tab'
80+
width: 2
81+
82+
LeadingZero:
83+
enabled: true
84+
style: exclude_zero # or 'include_zero'
85+
86+
MergeableSelector:
87+
enabled: true
88+
force_nesting: true
89+
90+
NameFormat:
91+
enabled: true
92+
allow_leading_underscore: true
93+
convention: hyphenated_lowercase # or 'camel_case', or 'snake_case', or a regex pattern
94+
95+
NestingDepth:
96+
enabled: true
97+
max_depth: 3
98+
ignore_parent_selectors: false
99+
100+
PlaceholderInExtend:
101+
enabled: false # true
102+
103+
PropertyCount:
104+
enabled: false
105+
include_nested: false
106+
max_properties: 10
107+
108+
PropertySortOrder:
109+
enabled: true
110+
ignore_unspecified: false
111+
min_properties: 2
112+
separate_groups: false
113+
114+
PropertySpelling:
115+
enabled: true
116+
extra_properties: []
117+
118+
PropertyUnits:
119+
enabled: true
120+
global: [
121+
'ch', 'em', 'ex', 'rem', # Font-relative lengths
122+
'cm', 'in', 'mm', 'pc', 'pt', 'px', 'q', # Absolute lengths
123+
'vh', 'vw', 'vmin', 'vmax', # Viewport-percentage lengths
124+
'deg', 'grad', 'rad', 'turn', # Angle
125+
'ms', 's', # Duration
126+
'Hz', 'kHz', # Frequency
127+
'dpi', 'dpcm', 'dppx', # Resolution
128+
'%'] # Other
129+
properties: {}
130+
131+
QualifyingElement:
132+
enabled: true
133+
allow_element_with_attribute: false
134+
allow_element_with_class: false
135+
allow_element_with_id: false
136+
137+
SelectorDepth:
138+
enabled: true
139+
max_depth: 3
140+
141+
SelectorFormat:
142+
enabled: true
143+
convention: hyphenated_lowercase # or 'strict_BEM', or 'hyphenated_BEM', or 'snake_case', or 'camel_case', or a regex pattern
144+
145+
Shorthand:
146+
enabled: true
147+
allowed_shorthands: [1, 2, 3]
148+
149+
SingleLinePerProperty:
150+
enabled: true
151+
allow_single_line_rule_sets: true
152+
153+
SingleLinePerSelector:
154+
enabled: true
155+
156+
SpaceAfterComma:
157+
enabled: true
158+
style: one_space # or 'no_space', or 'at_least_one_space'
159+
160+
SpaceAfterPropertyColon:
161+
enabled: true
162+
style: one_space # or 'no_space', or 'at_least_one_space', or 'aligned'
163+
164+
SpaceAfterPropertyName:
165+
enabled: true
166+
167+
SpaceAfterVariableName:
168+
enabled: true
169+
170+
SpaceAroundOperator:
171+
enabled: true
172+
style: one_space # or 'no_space'
173+
174+
SpaceBeforeBrace:
175+
enabled: true
176+
style: space # or 'new_line'
177+
allow_single_line_padding: false
178+
179+
SpaceBetweenParens:
180+
enabled: true
181+
spaces: 0
182+
183+
StringQuotes:
184+
enabled: true
185+
style: double_quotes # or single_quotes
186+
187+
TrailingSemicolon:
188+
enabled: true
189+
190+
TrailingWhitespace:
191+
enabled: true
192+
193+
TrailingZero:
194+
enabled: false
195+
196+
TransitionAll:
197+
enabled: false
198+
199+
UnnecessaryMantissa:
200+
enabled: true
201+
202+
UnnecessaryParentReference:
203+
enabled: true
204+
205+
UrlFormat:
206+
enabled: true
207+
208+
UrlQuotes:
209+
enabled: true
210+
211+
VariableForProperty:
212+
enabled: false
213+
properties: []
214+
215+
VendorPrefix:
216+
enabled: true
217+
identifier_list: base
218+
additional_identifiers: []
219+
excluded_identifiers: []
220+
221+
ZeroUnit:
222+
enabled: true
223+
224+
Compass::*:
225+
enabled: false

source/js/app.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
$(document).ready(function() {
2-
$('.image-popup').magnificPopup({
3-
type: 'image',
1+
$( document ).ready( function() {
2+
$( ".image-popup" ).magnificPopup( {
3+
type: "image",
44
closeOnContentClick: true,
55
image: {
66
verticalFit: true
77
}
8-
});
9-
});
8+
} );
9+
} );

source/templates/partials/layout.twig

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html class="no-js" lang="">
33
<head>
44
<meta charset="utf-8">
5-
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
66
<title>{% block title %}{% endblock %}</title>
77
<meta name="description" content="">
88
<meta name="viewport" content="width=device-width, initial-scale=1">
@@ -25,6 +25,7 @@
2525
<ul class="nav navbar-nav">
2626
<li><a href="index.html">Homepage</a></li>
2727
<li><a href="second-page.html">Second page</a></li>
28+
</ul>
2829
</div>
2930
</div>
3031
</nav>

0 commit comments

Comments
 (0)