Skip to content

Commit

Permalink
Add jshint and jsbeautifier
Browse files Browse the repository at this point in the history
for code linter quality, coding style
  • Loading branch information
hueitan committed Aug 18, 2014
1 parent 5a86859 commit c941b0b
Show file tree
Hide file tree
Showing 10 changed files with 787 additions and 754 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ npm install
**Before coding** <small>Boot the Environment</small>
```
grunt dev
grunt check // check the code quality
```

**Start coding**
Expand Down
30 changes: 18 additions & 12 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = function (grunt) {
module.exports = function(grunt) {

// Variable
var ROOT_PATH = '.';
Expand All @@ -10,14 +10,12 @@ module.exports = function (grunt) {
pkg: grunt.file.readJSON('package.json'),
clean: {
dist: {
files: [
{
dot: true,
src: [
'dist'
]
}
]
files: [{
dot: true,
src: [
'dist'
]
}]
}
},
copy: {
Expand All @@ -44,6 +42,13 @@ module.exports = function (grunt) {
}
}
},
jsbeautifier: {
files: ['*.js', 'src/**/*.js'],
options: {}
},
jshint: {
all: ['*.js', 'src/**/*.js']
},
browserSync: {
dev: {
bsFiles: {
Expand Down Expand Up @@ -80,10 +85,11 @@ module.exports = function (grunt) {
}
});

require( "load-grunt-tasks" )( grunt );
require("load-grunt-tasks")(grunt);

// Register Task
grunt.registerTask('dev', ['browserSync', 'watch']);
grunt.registerTask('build', ['clean', 'concat', 'uglify'])
grunt.registerTask('build', ['clean', 'concat', 'uglify']);
grunt.registerTask('check', ['jshint', 'jsbeautifier']); // use this before commit

};
};
64 changes: 33 additions & 31 deletions dist/angular-validation-rule.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,39 @@
(function () {
(function() {
angular.module('validation.rule', ['validation'])
.config(['$validationProvider', function ($validationProvider) {
.config(['$validationProvider',
function($validationProvider) {

var expression = {
required: function (value) {
return !!value;
},
url: /((([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)/,
email: /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/,
number: /^\d+$/
};
var expression = {
required: function(value) {
return !!value;
},
url: /((([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)/,
email: /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/,
number: /^\d+$/
};

var defaultMsg = {
required: {
error: 'This should be Required!!',
success: 'It\'s Required'
},
url: {
error: 'This should be Url',
success: 'It\'s Url'
},
email: {
error: 'This should be Email',
success: 'It\'s Email'
},
number: {
error: 'This should be Number',
success: 'It\'s Number'
}
};
var defaultMsg = {
required: {
error: 'This should be Required!!',
success: 'It\'s Required'
},
url: {
error: 'This should be Url',
success: 'It\'s Url'
},
email: {
error: 'This should be Email',
success: 'It\'s Email'
},
number: {
error: 'This should be Number',
success: 'It\'s Number'
}
};

$validationProvider.setExpression(expression).setDefaultMsg(defaultMsg);
$validationProvider.setExpression(expression).setDefaultMsg(defaultMsg);

}]);
}
]);

}).call(this);
}).call(this);
Loading

0 comments on commit c941b0b

Please sign in to comment.