Skip to content

Commit a872d4c

Browse files
committed
Merge pull request #147 from lvarayut/master
Refactoring the project based on airbnb/johnpapa style guides
2 parents 09aed2e + 70f3e02 commit a872d4c

18 files changed

Lines changed: 2115 additions & 2230 deletions

.jshintrc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"quotmark": "single",
3+
"node": true,
4+
"globals": {
5+
"angular": false,
6+
"document": false,
7+
"jasmine": false,
8+
"module": false,
9+
"describe": false,
10+
"beforeEach": false,
11+
"afterEach": false,
12+
"it": false,
13+
"inject": false,
14+
"expect": false,
15+
"spyOn": false
16+
}
17+
}

Gruntfile.js

Lines changed: 92 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -1,100 +1,99 @@
11
module.exports = function(grunt) {
2+
require('time-grunt')(grunt);
23

3-
// Variable
4-
var ROOT_PATH = '.';
5-
6-
require('time-grunt')(grunt);
7-
8-
// Grunt Config
9-
grunt.initConfig({
10-
pkg: grunt.file.readJSON('package.json'),
11-
clean: {
12-
dist: {
13-
files: [{
14-
dot: true,
15-
src: [
16-
'dist'
17-
]
18-
}]
19-
}
20-
},
21-
copy: {
22-
main: {
23-
files: [
24-
// {expand: true, cwd: 'demo', src: ['script.js'], dest: 'dist'} // partials html file
25-
// {expand: true, cwd: 'app', src: ['*.*'], dest: 'dist/'}
26-
]
27-
}
28-
},
29-
concat: {
30-
basic_and_extras: {
31-
files: {
32-
'dist/angular-validation.js': ['src/module.js', 'src/provider.js', 'src/directive.js'],
33-
'dist/angular-validation-rule.js': ['src/rule.js']
34-
}
35-
}
36-
},
37-
uglify: {
38-
my_target: {
39-
files: {
40-
'dist/angular-validation.min.js': ['dist/angular-validation.js'],
41-
'dist/angular-validation-rule.min.js': ['dist/angular-validation-rule.js']
42-
}
43-
}
44-
},
45-
jsbeautifier: {
46-
files: ['*.js', 'src/**/*.js', 'test/unit/*.js'],
47-
options: {}
48-
},
49-
jshint: {
50-
all: ['*.js', 'src/**/*.js'],
51-
options: {
52-
quotmark: 'single'
53-
}
54-
},
55-
browserSync: {
56-
dev: {
57-
bsFiles: {
58-
src: ['index.html', 'demo/**', 'dist/angular-validation.js']
59-
},
60-
options: {
61-
host: 'localhost',
62-
ports: {
63-
min: 8000,
64-
max: 8100
65-
},
66-
server: {
67-
baseDir: '.'
68-
},
69-
watchTask: true
70-
}
71-
}
72-
},
73-
watch: {
74-
files: ['src/*.js'],
75-
tasks: ['build'],
76-
options: {
77-
spawn: false,
78-
interrupt: true
79-
}
4+
// Grunt Config
5+
grunt.initConfig({
6+
pkg: grunt.file.readJSON('package.json'),
7+
clean: {
8+
dist: {
9+
files: [{
10+
dot: true,
11+
src: [
12+
'dist'
13+
]
14+
}]
15+
}
16+
},
17+
copy: {
18+
main: {
19+
files: [
20+
// {expand: true, cwd: 'demo', src: ['script.js'], dest: 'dist'} // partials html file
21+
// {expand: true, cwd: 'app', src: ['*.*'], dest: 'dist/'}
22+
]
23+
}
24+
},
25+
concat: {
26+
basic_and_extras: {
27+
files: {
28+
'dist/angular-validation.js': ['src/module.js', 'src/provider.js', 'src/*.directive.js'],
29+
'dist/angular-validation-rule.js': ['src/rule.js']
30+
}
31+
}
32+
},
33+
uglify: {
34+
my_target: {
35+
files: {
36+
'dist/angular-validation.min.js': ['dist/angular-validation.js'],
37+
'dist/angular-validation-rule.min.js': ['dist/angular-validation-rule.js']
38+
}
39+
}
40+
},
41+
jsbeautifier: {
42+
files: ['*.js', 'src/**/*.js', 'test/unit/*.js', 'demo/*.js'],
43+
options: {
44+
js: {
45+
indent_size: 2
46+
}
47+
}
48+
},
49+
jshint: {
50+
all: ['*.js', 'src/**/*.js', 'test/unit/*.js', 'demo/*.js'],
51+
options: {
52+
jshintrc: true
53+
}
54+
},
55+
browserSync: {
56+
dev: {
57+
bsFiles: {
58+
src: ['index.html', 'demo/**', 'dist/angular-validation.js']
8059
},
81-
karma: {
82-
// angular 1.2.x support to version angular-validation 1.2.x
83-
// angular1_2: {
84-
// configFile: 'config/karma.conf.angular.1.2.js'
85-
// }
86-
angular1_3: {
87-
configFile: 'config/karma.conf.angular.1.3.js'
88-
}
60+
options: {
61+
host: 'localhost',
62+
ports: {
63+
min: 8000,
64+
max: 8100
65+
},
66+
server: {
67+
baseDir: '.'
68+
},
69+
watchTask: true
8970
}
90-
});
91-
92-
require('load-grunt-tasks')(grunt);
71+
}
72+
},
73+
watch: {
74+
files: ['src/*.js'],
75+
tasks: ['build'],
76+
options: {
77+
spawn: false,
78+
interrupt: true
79+
}
80+
},
81+
karma: {
82+
// angular 1.2.x support to version angular-validation 1.2.x
83+
// angular1_2: {
84+
// configFile: 'config/karma.conf.angular.1.2.js'
85+
// }
86+
angular1_3: {
87+
configFile: 'config/karma.conf.angular.1.3.js'
88+
}
89+
}
90+
});
9391

94-
// Register Task
95-
grunt.registerTask('dev', ['browserSync', 'watch']);
96-
grunt.registerTask('build', ['clean', 'concat', 'uglify']);
97-
grunt.registerTask('check', ['jshint', 'jsbeautifier', 'build']); // use this before commit
98-
grunt.registerTask('test', ['karma']);
92+
require('load-grunt-tasks')(grunt);
9993

94+
// Register Task
95+
grunt.registerTask('dev', ['browserSync', 'watch']);
96+
grunt.registerTask('check', ['jshint', 'jsbeautifier']); // use this before commit
97+
grunt.registerTask('build', ['check', 'clean', 'concat', 'uglify']);
98+
grunt.registerTask('test', ['build', 'karma']);
10099
};

config/karma.conf.angular.1.3.js

Lines changed: 60 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,76 @@
11
module.exports = function(config) {
2-
config.set({
3-
// base path, that will be used to resolve files and exclude
4-
basePath: '../',
2+
config.set({
3+
// base path, that will be used to resolve files and exclude
4+
basePath: '../',
55

6-
frameworks: ['jasmine'],
6+
frameworks: ['jasmine'],
77

8-
// list of files / patterns to load in the browser
9-
files: [
10-
'test/lib/angular.1.3.18.js',
11-
'test/lib/angular-mocks.1.3.18.js',
12-
'dist/angular-validation.js',
13-
'dist/angular-validation-rule.js',
14-
'test/unit/*.js'
15-
],
8+
// list of files / patterns to load in the browser
9+
files: [
10+
'test/lib/angular.1.3.18.js',
11+
'test/lib/angular-mocks.1.3.18.js',
12+
'dist/angular-validation.js',
13+
'dist/angular-validation-rule.js',
14+
'test/unit/*.js'
15+
],
1616

17-
// list of files to exclude
18-
exclude: [
17+
// list of files to exclude
18+
exclude: [],
1919

20-
],
20+
preprocessors: {
21+
'test/*.js': []
22+
},
2123

22-
preprocessors: {
23-
'test/*.js': []
24-
},
24+
// use dots reporter, as travis terminal does not support escaping sequences
25+
// possible values: 'dots', 'progress'
26+
// CLI --reporters progress
27+
reporters: ['progress'],
2528

26-
// use dots reporter, as travis terminal does not support escaping sequences
27-
// possible values: 'dots', 'progress'
28-
// CLI --reporters progress
29-
reporters: ['progress'],
29+
// web server port
30+
// CLI --port 9876
31+
port: 9876,
3032

31-
// web server port
32-
// CLI --port 9876
33-
port: 9876,
33+
// enable / disable colors in the output (reporters and logs)
34+
// CLI --colors --no-colors
35+
colors: true,
3436

35-
// enable / disable colors in the output (reporters and logs)
36-
// CLI --colors --no-colors
37-
colors: true,
37+
// level of logging
38+
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
39+
// CLI --log-level debug
40+
logLevel: config.LOG_INFO,
3841

39-
// level of logging
40-
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
41-
// CLI --log-level debug
42-
logLevel: config.LOG_INFO,
42+
// enable / disable watching file and executing tests whenever any file changes
43+
// CLI --auto-watch --no-auto-watch
44+
autoWatch: false,
4345

44-
// enable / disable watching file and executing tests whenever any file changes
45-
// CLI --auto-watch --no-auto-watch
46-
autoWatch: false,
46+
// Start these browsers, currently available:
47+
// - Chrome
48+
// - ChromeCanary
49+
// - Firefox
50+
// - Opera
51+
// - Safari (only Mac)
52+
// - PhantomJS
53+
// - IE (only Windows)
54+
// CLI --browsers Chrome,Firefox,Safari
55+
browsers: ['PhantomJS'],
4756

48-
// Start these browsers, currently available:
49-
// - Chrome
50-
// - ChromeCanary
51-
// - Firefox
52-
// - Opera
53-
// - Safari (only Mac)
54-
// - PhantomJS
55-
// - IE (only Windows)
56-
// CLI --browsers Chrome,Firefox,Safari
57-
browsers: ['PhantomJS'],
57+
// If browser does not capture in given timeout [ms], kill it
58+
// CLI --capture-timeout 5000
59+
captureTimeout: 20000,
5860

59-
// If browser does not capture in given timeout [ms], kill it
60-
// CLI --capture-timeout 5000
61-
captureTimeout: 20000,
61+
// Auto run tests on start (when browsers are captured) and exit
62+
// CLI --single-run --no-single-run
63+
singleRun: true,
6264

63-
// Auto run tests on start (when browsers are captured) and exit
64-
// CLI --single-run --no-single-run
65-
singleRun: true,
65+
// report which specs are slower than 500ms
66+
// CLI --report-slower-than 500
67+
reportSlowerThan: 500,
6668

67-
// report which specs are slower than 500ms
68-
// CLI --report-slower-than 500
69-
reportSlowerThan: 500,
70-
71-
plugins: [
72-
'karma-jasmine',
73-
'karma-chrome-launcher',
74-
'karma-firefox-launcher',
75-
'karma-phantomjs-launcher'
76-
]
77-
});
69+
plugins: [
70+
'karma-jasmine',
71+
'karma-chrome-launcher',
72+
'karma-firefox-launcher',
73+
'karma-phantomjs-launcher'
74+
]
75+
});
7876
};

0 commit comments

Comments
 (0)