Skip to content

Commit 2b94279

Browse files
committed
Updates Patternfly HTML,LESS,JS Linting
* Adds HTMLHint for HTML linting and fixes issues with HTML linter * Adds Stylelint for Less linting and fixes formatting issues in Less * Adds autoprefixer for auto generating CSS prefixes, and removes old prefixes in Less which are now generated * Removes JSHint and adds ESLINT for Javascript linting. Fixes to patternfly.js for ESLINT settings
1 parent 28230d0 commit 2b94279

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+362
-263
lines changed

.htmlhintrc

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"tagname-lowercase": true,
3+
"attr-lowercase": true,
4+
"attr-value-double-quotes": true,
5+
"attr-value-not-empty": false,
6+
"attr-no-duplication": true,
7+
"doctype-first": false,
8+
"tag-pair": true,
9+
"tag-self-close": false,
10+
"spec-char-escape": true,
11+
"id-unique": true,
12+
"src-not-empty": true,
13+
"head-script-disabled": false,
14+
"img-alt-require": true,
15+
"doctype-html5": false,
16+
"id-class-value": false,
17+
"style-disabled": false,
18+
"space-tab-mixed-disabled": true,
19+
"id-class-ad-disabled": true,
20+
"href-abs-or-rel": false,
21+
"attr-unsafe-chars": true
22+
}

.stylelintrc

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"rules": {
3+
"color-hex-case": "lower",
4+
"color-no-invalid-hex": true,
5+
"function-calc-no-unspaced-operator": true,
6+
"function-comma-space-after": "always-single-line",
7+
"function-comma-space-before": "never",
8+
"function-name-case": "lower",
9+
"function-url-quotes": "always",
10+
"function-whitespace-after": "always",
11+
"number-leading-zero": "never",
12+
"number-no-trailing-zeros": true,
13+
"string-no-newline": true,
14+
"string-quotes": "double",
15+
"unit-case": "lower",
16+
"unit-no-unknown": true,
17+
"unit-whitelist": [
18+
"px",
19+
"%",
20+
"deg",
21+
"ms",
22+
"em",
23+
"vh"
24+
],
25+
"value-list-comma-space-after": "always-single-line",
26+
"value-list-comma-space-before": "never",
27+
"value-no-vendor-prefix": true,
28+
"shorthand-property-no-redundant-values": true,
29+
"property-case": "lower",
30+
"declaration-block-no-duplicate-properties": true,
31+
"declaration-block-no-ignored-properties": true,
32+
"declaration-block-trailing-semicolon": "always",
33+
"declaration-block-semicolon-space-before": "never",
34+
"declaration-block-semicolon-space-after": "always-single-line",
35+
"declaration-block-semicolon-newline-before": "never-multi-line",
36+
"declaration-block-semicolon-newline-after": "always-multi-line",
37+
"block-closing-brace-newline-after": "always",
38+
"block-closing-brace-newline-before": "always-multi-line",
39+
"block-no-empty": true,
40+
"block-opening-brace-newline-after": "always-multi-line",
41+
"block-opening-brace-space-before": "always-multi-line",
42+
"selector-attribute-brackets-space-inside": "never",
43+
"selector-attribute-operator-space-after": "never",
44+
"selector-attribute-operator-space-before": "never",
45+
"selector-combinator-space-after": "always",
46+
"selector-combinator-space-before": "always",
47+
"selector-pseudo-class-case": "lower",
48+
"selector-pseudo-class-parentheses-space-inside": "never",
49+
"selector-pseudo-element-case": "lower",
50+
"selector-pseudo-element-colon-notation": "single",
51+
"selector-pseudo-element-no-unknown": true,
52+
"selector-type-case": "lower"
53+
}
54+
}

Gruntfile.js

Lines changed: 61 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
/*global module,require*/
22
module.exports = function (grunt) {
3-
// load all grunt tasks
4-
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
3+
'use strict';
54

65
// configurable paths
76
var projectConfig = {
87
dist: 'dist',
98
src: ''
109
};
1110

11+
// load all grunt tasks
12+
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
13+
1214
try {
13-
projectConfig.src = require('./bower.json').appPath || projectConfig.src;
15+
projectConfig.src = require('./bower.json').appPath || projectConfig.src;
1416
} catch (e) {}
1517

1618
grunt.initConfig({
@@ -77,6 +79,16 @@ module.exports = function (grunt) {
7779
}
7880
}
7981
},
82+
jekyll: {
83+
options: {
84+
src: 'tests/pages'
85+
},
86+
tests: {
87+
options: {
88+
dest: 'dist/tests'
89+
}
90+
}
91+
},
8092
cssmin: {
8193
production: {
8294
files: [{
@@ -91,41 +103,6 @@ module.exports = function (grunt) {
91103
}
92104
}
93105
},
94-
jekyll: {
95-
options: {
96-
src: 'tests/pages'
97-
},
98-
tests: {
99-
options: {
100-
dest: 'dist/tests'
101-
}
102-
}
103-
},
104-
jslint: {
105-
client: {
106-
src: [
107-
'src/js/patternfly.js'
108-
],
109-
directives: {
110-
// node environment
111-
node: false,
112-
// browser environment
113-
browser: true,
114-
// allow dangling underscores
115-
nomen: true,
116-
// allow todo statements
117-
todo: true,
118-
// allow unused parameters
119-
unparam: true,
120-
// add predefined libraries
121-
predef: [
122-
'jQuery',
123-
'Event'
124-
],
125-
indent: 2
126-
}
127-
}
128-
},
129106
less: {
130107
patternfly: {
131108
files: {
@@ -179,11 +156,11 @@ module.exports = function (grunt) {
179156
},
180157
css: {
181158
files: ['dist/css/patternfly*.css', 'dist/css/!*.min.css'],
182-
tasks: ['cssmin', 'csscount']
159+
tasks: ['cssmin','csscount']
183160
},
184161
js: {
185162
files: ['src/js/*.js'],
186-
tasks: ['jslint', 'uglify', 'copy:js']
163+
tasks: ['eslint', 'uglify', 'copy:js']
187164
},
188165
livereload: {
189166
files: ['dist/css/*.css', 'dist/js/*.js', 'dist/tests/*.html', '!tests/pages/*.html']
@@ -196,6 +173,45 @@ module.exports = function (grunt) {
196173
unit: {
197174
configFile: 'karma.conf.js'
198175
}
176+
},
177+
htmlhint: {
178+
html: {
179+
src: ['dist/tests/**/*.html'],
180+
options: {
181+
htmlhintrc: '.htmlhintrc'
182+
}
183+
}
184+
},
185+
eslint: {
186+
options: {
187+
configFile: 'eslint.yaml'
188+
},
189+
target: [
190+
'Gruntfile.js',
191+
'src/js/**/*.js'
192+
]
193+
},
194+
stylelint: {
195+
src: ['less/*.less']
196+
},
197+
postcss: {
198+
options: {
199+
processors: [
200+
require('pixrem')(), // add fallbacks for rem units
201+
require('autoprefixer')({browsers: ['last 3 versions', 'ie 9']}) // add vendor prefixes,
202+
]
203+
},
204+
dist: {
205+
files: [
206+
{
207+
expand: true, // Enable dynamic expansion.
208+
cwd: 'dist/css/', // Src matches are relative to this path.
209+
src: ['*.css'], // Actual pattern(s) to match.
210+
dest: 'dist/css' // Destination path prefix.
211+
}
212+
]
213+
}
214+
199215
}
200216
});
201217

@@ -204,9 +220,12 @@ module.exports = function (grunt) {
204220
'jekyll',
205221
'less',
206222
'cssmin',
223+
'postcss',
207224
'csscount',
208-
'jslint',
209-
'uglify'
225+
'eslint',
226+
'uglify',
227+
'htmlhint',
228+
'stylelint'
210229
]);
211230

212231
grunt.registerTask('server', [

eslint.yaml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
env:
3+
browser: true
4+
node: true
5+
6+
globals:
7+
$: true
8+
9+
rules:
10+
strict: [2, "function"]
11+
quotes: 0
12+
camelcase: 2
13+
indent: [2, 2]
14+
new-cap:
15+
- 2
16+
- {"newIsCap": true, "capIsNew": false}
17+
no-mixed-spaces-and-tabs: 2
18+
no-multiple-empty-lines: 2
19+
no-trailing-spaces: 2
20+
keyword-spacing:
21+
- 2
22+
- {"after": true }
23+
space-before-blocks: 2
24+
space-before-function-paren: 2
25+
space-infix-ops: 2
26+
brace-style: 2
27+
semi: 2
28+
block-scoped-var: 2
29+
consistent-return: 2
30+
curly: 2
31+
eqeqeq: 2
32+
guard-for-in: 2
33+
no-else-return: 2
34+
no-loop-func: 2
35+
vars-on-top: 2
36+
no-debugger: 2
37+
no-cond-assign: 2
38+
no-console: 2
39+
no-extra-semi: 2
40+
no-irregular-whitespace: 2
41+
dot-notation:
42+
- 2
43+
- {"allowPattern": "^[a-z]+(_[a-z]+)+$"}
44+
45+
ecmaFeatures:
46+
blockBindings: true

less/blank-slate.less

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Blank Slate
33
// --------------------------------------------------
44

5-
.blank-slate-pf{
5+
.blank-slate-pf {
66
@media (min-width: @screen-sm-min) {
77
padding: (@jumbotron-padding * 2) (@jumbotron-padding * 2);
88
}
@@ -15,15 +15,15 @@
1515
margin-bottom: 20px;
1616
padding: @jumbotron-padding;
1717
text-align: center;
18-
.blank-slate-pf-icon{
18+
.blank-slate-pf-icon {
1919
color: @gray-light;
2020
font-size: (@font-size-h1 * 2.4);
2121
line-height: (@font-size-h1 * 2.4);
2222
}
23-
.blank-slate-pf-main-action{
23+
.blank-slate-pf-main-action {
2424
margin-top: @line-height-computed;
2525
}
26-
.blank-slate-pf-secondary-action{
26+
.blank-slate-pf-secondary-action {
2727
margin-top: @line-height-computed;
2828
}
2929
}

less/card-view.less

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
font-size: ceil((@font-size-base * 1.5));
4949
margin-right: 2px;
5050
}
51-
.col-lg-2 & { font-size: @font-size-h3 }
51+
.col-lg-2 & { font-size: @font-size-h3; }
5252
}
5353
.card-pf-top-element .card-pf-icon-circle {
5454
border: 2px solid @color-pf-blue-300;

less/cards.less

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,11 @@
141141
font-size: @font-size-h3;
142142
margin-top: @line-height-computed;
143143
margin-bottom: (@line-height-computed / 2);
144-
[class^='col'] & {
144+
[class^="col"] & {
145145
margin-top: 0;
146146
}
147147
@media (max-width: @screen-xs-max) {
148-
.card-pf-body [class^='col'] + [class^='col'] > & {
148+
.card-pf-body [class^="col"] + [class^="col"] > & {
149149
margin-top: (@grid-gutter-width);
150150
}
151151
}
@@ -202,10 +202,8 @@
202202
width: 100%;
203203
.card-pf-utilization-card-details-count,
204204
.card-pf-utilization-card-details-description {
205-
display: table-cell;
206205
float: left;
207206
line-height: 1;
208-
vertical-align: middle;
209207
}
210208
.card-pf-utilization-card-details-count {
211209
font-size: (@font-size-base * 2 + 2); // 26px

less/charts.less

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989

9090
.line-chart-pf {
9191
.c3-zoom-rect {
92-
opacity: 1.0 !important;
92+
opacity: 1 !important;
9393
fill: @color-pf-black-100;
9494
stroke: @table-border-color;
9595
stroke-width: 1px;

less/datatables.less

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
.ColVis_collection {
1919
background-color: @dropdown-bg;
20-
border: 1px solid @dropdown-fallback-border; // IE8 fallback
2120
border: 1px solid @dropdown-border;
2221
border-radius: @border-radius-base;
2322
.box-shadow(0 6px 12px fade(@color-pf-black, 17.5%));
@@ -180,7 +179,6 @@ table.datatable {
180179
.sorting_asc_disabled,
181180
.sorting_desc_disabled {
182181
cursor: pointer;
183-
*cursor: hand;
184182
}
185183
.sorting_asc,
186184
.sorting_desc {
@@ -201,7 +199,7 @@ table.datatable {
201199
}
202200
&:before {
203201
background: @link-color;
204-
content: '';
202+
content: "";
205203
height: 2px;
206204
position: absolute;
207205
left: 0;

0 commit comments

Comments
 (0)