Skip to content

Commit

Permalink
Merge pull request #286 from vaadin/build/linting
Browse files Browse the repository at this point in the history
Add JSHint and JSCS linting to the build process
  • Loading branch information
manolo committed Dec 11, 2015
2 parents 9dcc5bd + caaa76c commit 2691df7
Show file tree
Hide file tree
Showing 39 changed files with 932 additions and 3,492 deletions.
22 changes: 22 additions & 0 deletions .jscsrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"preset": "google",
"maximumLineLength": 180,
"disallowMultipleVarDecl": false,
"validateIndentation": false,
"disallowTrailingWhitespace": false,
"jsDoc": {
"checkAnnotations": {
"extra": {
"polymerBehavior": true,
"param": true,
"return": true,
"private": true,
"default": true,
"event": true,
"property": true,
"type": true,
"method": true
}
}
}
}
3 changes: 2 additions & 1 deletion .jshintrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"browser": true,
"node": true
"node": true,
"expr": true
}
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ language: java
install: travis_retry npm install
jdk: oraclejdk8
script:
- gulp lint:js
- gulp lint:html
- gulp clean
- gulp gwt:validate
- travis_retry gulp test:desktop
Expand Down
4 changes: 2 additions & 2 deletions demo/angular-demo-embed.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@
<script>
var tagName = window.location.hash.substr(1);
document.body.appendChild(document.createElement(tagName));
HTMLImports.whenReady(function(){
HTMLImports.whenReady(function() {

System.config({
transpiler: 'typescript',
typescriptOptions: { emitDecoratorMetadata: true }
typescriptOptions: {emitDecoratorMetadata: true}
});
System.import(tagName + '.ts');

Expand Down
81 changes: 42 additions & 39 deletions demo/columns.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ <h3>Defining Columns</h3>
</table>
</vaadin-grid>
<code demo-var="grid">
var grid = grid || document.querySelector("vaadin-grid");
var grid = grid || document.querySelector('vaadin-grid');

HTMLImports.whenReady(function() {
/*
// code
// Columns can also be configured in JS
grid.columns = [
{ name: "firstColumn" },
{ name: "secondColumn" }
{name: 'firstColumn'},
{name: 'secondColumn'}
];
// end-code
*/
Expand All @@ -76,14 +76,14 @@ <h3>Adding Columns Dynamically</h3>
<vaadin-grid demo hidden></vaadin-grid>

<code demo-var="grid">
var grid = grid || document.querySelector("vaadin-grid");
var grid = grid || document.querySelector('vaadin-grid');

HTMLImports.whenReady(function() {
grid.items = [["One", "Two"]];
grid.items = [['One', 'Two']];
// code
grid.addColumn({ name: "secondColumn" });
grid.addColumn({name: 'secondColumn'});
// Specify the index or name of the column before which to add the new column
grid.addColumn({ name: "firstColumn"}, 0);
grid.addColumn({name: 'firstColumn'}, 0);
// end-code
});
</code>
Expand Down Expand Up @@ -114,21 +114,22 @@ <h3>Column width</h3>
</table>
</vaadin-grid>
<code hidden>
function random(arr) {
return arr[Math.floor(Math.random() * arr.length)];
}

var employees = [];
var names = ["Artur", "Patrik", "Henrik", "Teemu"];
var surnames = ["Signell","Lehtinen","Ahlroos","Paul"];
var activities = ["Design","Implement","Polish","Deliver"];
var targets = ["soup","Vaadin","dog","world peace"];
for (var i = 0; i < 400; i++){
var row = [];
[names, surnames, activities, targets].forEach(function(array){
row.push(array[Math.floor(Math.random()*array.length)]);
});
employees.push(row);
var names = ['Artur', 'Patrik', 'Henrik', 'Teemu'];
var surnames = ['Signell', 'Lehtinen', 'Ahlroos', 'Paul'];
var activities = ['Design', 'Implement', 'Polish', 'Deliver'];
var targets = ['soup', 'Vaadin', 'dog', 'world peace'];
for (var i = 0; i < 400; i++) {
var row = [random(names), random(surnames), random(activities), random(targets)];
employees.push(row);
}
</code>
<code demo-var="grid">
var grid = grid || document.querySelector("vaadin-grid");
var grid = grid || document.querySelector('vaadin-grid');

HTMLImports.whenReady(function() {
grid.items = employees;
Expand Down Expand Up @@ -175,21 +176,22 @@ <h3>Frozen columns</h3>
</table>
</vaadin-grid>
<code hidden>
function random(arr) {
return arr[Math.floor(Math.random() * arr.length)];
}

var employees = [];
var names = ["Artur", "Patrik", "Henrik", "Teemu"];
var surnames = ["Signell","Lehtinen","Ahlroos","Paul"];
var activities = ["Design","Implement","Polish","Deliver"];
var targets = ["soup","Vaadin","dog","world peace"];
for (var i = 0; i < 400; i++){
var row = [];
[names, surnames, activities, targets].forEach(function(array){
row.push(array[Math.floor(Math.random()*array.length)]);
});
employees.push(row);
var names = ['Artur', 'Patrik', 'Henrik', 'Teemu'];
var surnames = ['Signell', 'Lehtinen', 'Ahlroos', 'Paul'];
var activities = ['Design', 'Implement', 'Polish', 'Deliver'];
var targets = ['soup', 'Vaadin', 'dog', 'world peace'];
for (var i = 0; i < 400; i++) {
var row = [random(names), random(surnames), random(activities), random(targets)];
employees.push(row);
}
</code>
<code demo-var="grid">
var grid = grid || document.querySelector("vaadin-grid");
var grid = grid || document.querySelector('vaadin-grid');

HTMLImports.whenReady(function() {
grid.items = employees;
Expand Down Expand Up @@ -232,21 +234,22 @@ <h3>Column hiding</h3>
</table>
</vaadin-grid>
<code hidden>
function random(arr) {
return arr[Math.floor(Math.random() * arr.length)];
}

var employees = [];
var names = ["Artur", "Patrik", "Henrik", "Teemu"];
var surnames = ["Signell","Lehtinen","Ahlroos","Paul"];
var activities = ["Design","Implement","Polish","Deliver"];
var targets = ["soup","Vaadin","dog","world peace"];
for (var i = 0; i < 400; i++){
var row = [];
[names, surnames, activities, targets].forEach(function(array){
row.push(array[Math.floor(Math.random()*array.length)]);
});
var names = ['Artur', 'Patrik', 'Henrik', 'Teemu'];
var surnames = ['Signell', 'Lehtinen', 'Ahlroos', 'Paul'];
var activities = ['Design', 'Implement', 'Polish', 'Deliver'];
var targets = ['soup', 'Vaadin', 'dog', 'world peace'];
for (var i = 0; i < 400; i++) {
var row = [random(names), random(surnames), random(activities), random(targets)];
employees.push(row);
}
</code>
<code demo-var="grid">
var grid = grid || document.querySelector("vaadin-grid");
var grid = grid || document.querySelector('vaadin-grid');

HTMLImports.whenReady(function() {
grid.items = employees;
Expand Down
24 changes: 12 additions & 12 deletions demo/common.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,40 +8,40 @@
var bowerComponents = '../../';

window.xCodeExampleSourceHead =
" <script src='https://cdn.vaadin.com/vaadin-elements/latest/webcomponentsjs/webcomponents-lite.js'><\/script>\n"+
" <link href='https://cdn.vaadin.com/vaadin-elements/latest/vaadin-grid/vaadin-grid.html' rel='import'>\n"+
" <script>var randomUserUrl = '" + randomUserUrl + "';<\/script>\n";
' <script src="https://cdn.vaadin.com/vaadin-elements/latest/webcomponentsjs/webcomponents-lite.js"><\/script>\n' +
' <link href="https://cdn.vaadin.com/vaadin-elements/latest/vaadin-grid/vaadin-grid.html" rel="import">\n' +
' <script>var randomUserUrl = "' + randomUserUrl + '";<\/script>\n';

function createButton(text, fnc) {
var button = document.createElement("button");
var button = document.createElement('button');
button.innerHTML = text;
button.addEventListener("click", fnc);
button.addEventListener('click', fnc);
return button;
}

if (!window.Polymer) {
var link = document.querySelector('link[href$="common.html"]')
var link = document.querySelector('link[href$="common.html"]');
var baseCommon = link.href.replace(/common.html/, '');
var base = baseCommon + bowerComponents;
// Delay all HTMLImports.whenReady calls until polymer and
// grid are ready.
var _whenReady = HTMLImports.whenReady;
HTMLImports.whenReady = function(done) {
var id = setInterval(function() {
if (window.Polymer && window.vaadin && vaadin.elements
&& vaadin.elements.grid && vaadin.elements.grid.GridElement) {
if (window.Polymer && window.vaadin && vaadin.elements &&
vaadin.elements.grid && vaadin.elements.grid.GridElement) {
clearInterval(id);
// Restore whenReady
HTMLImports.whenReady = _whenReady
HTMLImports.whenReady = _whenReady;
// Run original whenReady
_whenReady(done);
_whenReady(function(){
_whenReady(function() {
// For some reason this is not removed in polyfilled browsers
document.body.removeAttribute('unresolved');
})
});
}
}, 3);
}
};

var pol = document.createElement('link');
pol.rel = 'import';
Expand Down
Loading

0 comments on commit 2691df7

Please sign in to comment.