Skip to content

Commit abc0568

Browse files
committed
Update build scripts (package.json, Grunt, Travis)
build: * Use UglifyJS2 instead of jsmin.py. * Set up package.json and Gruntfile to make it easy to install necessary packages and run linters, minification and qunit tests from the command line. * Update JSHint to latest version. * The coding style options we were using from JSHint were deprecated. Using node-jscs instead which is much better at this (find inconsistencies and fix them). test: * Disable test that has always been broken in PhantomJS so that the build passes and we can enable Travis CI. libs: * Update jQuery to v1.8.3 * Update QUnit to v1.14.0 Travis CI: * Add .travis.yml to enable automatic running of tests after each commit on submission of pull request on GitHub. readme: * Add Travis CI badge. * Update build instructions. * Backtick "<major>". It was interpreted as HTML tag instead of code (became invisible, rendered as "..") Also: * Add LICENSE.txt.
1 parent 915d1c8 commit abc0568

19 files changed

+1531
-1187
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

.jscsrc

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
{
2+
"requireCurlyBraces": [
3+
"if",
4+
"else",
5+
"for",
6+
"while",
7+
"do",
8+
"try",
9+
"catch"
10+
],
11+
"requireSpaceAfterKeywords": [
12+
"if",
13+
"else",
14+
"for",
15+
"while",
16+
"do",
17+
"switch",
18+
"return",
19+
"try",
20+
"catch",
21+
"function"
22+
],
23+
"requireSpaceBeforeBlockStatements": true,
24+
"requireParenthesesAroundIIFE": true,
25+
"requireSpacesInConditionalExpression": true,
26+
"disallowSpacesInNamedFunctionExpression": {
27+
"beforeOpeningRoundBrace": true
28+
},
29+
"disallowSpacesInFunctionDeclaration": {
30+
"beforeOpeningRoundBrace": true
31+
},
32+
"requireMultipleVarDecl": true,
33+
"requireBlocksOnNewline": 1,
34+
"disallowEmptyBlocks": true,
35+
"disallowSpacesInsideParentheses": true,
36+
"requireSpacesInsideObjectBrackets": "all",
37+
"disallowSpacesInsideArrayBrackets": true,
38+
"disallowQuotedKeysInObjects": true,
39+
"disallowDanglingUnderscores": true,
40+
"disallowSpaceAfterObjectKeys": true,
41+
"requireCommaBeforeLineBreak": true,
42+
"disallowSpaceAfterPrefixUnaryOperators": [
43+
"++",
44+
"--",
45+
"+",
46+
"-",
47+
"~",
48+
"!"
49+
],
50+
"disallowSpaceBeforePostfixUnaryOperators": [
51+
"++",
52+
"--"
53+
],
54+
"disallowSpaceBeforeBinaryOperators": [
55+
","
56+
],
57+
"requireSpaceBeforeBinaryOperators": [
58+
"=",
59+
"+",
60+
"-",
61+
"/",
62+
"*",
63+
"==",
64+
"===",
65+
"!=",
66+
"!==",
67+
">",
68+
">=",
69+
"<",
70+
"<="
71+
],
72+
"requireSpaceAfterBinaryOperators": [
73+
"=",
74+
"+",
75+
"-",
76+
"/",
77+
"*",
78+
"==",
79+
"===",
80+
"!=",
81+
"!==",
82+
">",
83+
">=",
84+
"<",
85+
"<="
86+
],
87+
"requireCamelCaseOrUpperCaseIdentifiers": true,
88+
"disallowKeywords": [ "with" ],
89+
"disallowMultipleLineBreaks": true,
90+
"validateLineBreaks": "LF",
91+
"validateQuoteMarks": "'",
92+
"validateIndentation": "\t",
93+
"disallowMixedSpacesAndTabs": true,
94+
"disallowTrailingWhitespace": true,
95+
"disallowTrailingComma": true,
96+
"disallowKeywordsOnNewLine": ["else"],
97+
"requireLineFeedAtFileEnd": true,
98+
"requireCapitalizedConstructors": true,
99+
"requireDotNotation": true,
100+
"disallowYodaConditions": true
101+
}

.jshintignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
build/
2-
libs/
1+
dist
2+
libs
3+
node_modules

.jshintrc

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,18 @@
11
{
2-
"predef": [
3-
"jQuery"
4-
],
5-
6-
"bitwise": true,
7-
"camelcase": true,
8-
"curly": true,
2+
// Enforcing
3+
"bitwise": false,
94
"eqeqeq": true,
10-
"forin": true,
11-
"immed": true,
12-
"indent": true,
5+
"freeze": true,
136
"latedef": true,
14-
"newcap": true,
157
"noarg": true,
16-
"noempty": true,
178
"nonew": true,
18-
"quotmark": "single",
19-
"regexp": true,
209
"undef": true,
2110
"unused": true,
22-
"strict": true,
23-
"trailing": true,
2411

12+
// Environment
2513
"browser": true,
2614

27-
"nomen": true,
28-
"onevar": false,
29-
"white": false
30-
}
15+
"globals": {
16+
"jQuery": false
17+
}
18+
}

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
language: node_js
2+
node_js:
3+
- "0.10"

Gruntfile.js

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*jshint node:true */
2+
module.exports = function (grunt) {
3+
grunt.loadNpmTasks('grunt-contrib-connect');
4+
grunt.loadNpmTasks('grunt-contrib-jshint');
5+
grunt.loadNpmTasks('grunt-contrib-qunit');
6+
grunt.loadNpmTasks('grunt-contrib-uglify');
7+
grunt.loadNpmTasks('grunt-contrib-watch');
8+
grunt.loadNpmTasks('grunt-jscs-checker');
9+
10+
grunt.initConfig({
11+
pkg: grunt.file.readJSON('package.json'),
12+
jshint: {
13+
options: {
14+
jshintrc: true
15+
},
16+
all: ['*.js', '{src,test}/**/*.js']
17+
},
18+
jscs: {
19+
all: '<%= jshint.all %>'
20+
},
21+
connect: {
22+
qunit: {
23+
options: {
24+
hostname: 'localhost',
25+
port: 9002
26+
}
27+
}
28+
},
29+
qunit: {
30+
all: {
31+
options: {
32+
urls: [
33+
'http://localhost:9002/test/index.html?disableNative=true',
34+
'http://localhost:9002/test/index.html?disableNative=true&distmin=true'
35+
]
36+
}
37+
}
38+
},
39+
uglify: {
40+
all: {
41+
files: {
42+
'dist/jquery.json.min.js': ['src/jquery.json.js']
43+
},
44+
options: {
45+
banner: '/*! jQuery JSON plugin v<%= pkg.version %> | github.com/Krinkle/jquery-json */\n'
46+
}
47+
}
48+
},
49+
watch: {
50+
files: [
51+
'.{jscsrc,jshintignore,jshintrc}',
52+
'<%= jshint.all %>'
53+
],
54+
tasks: 'test'
55+
}
56+
});
57+
58+
grunt.registerTask('lint', ['jshint', 'jscs']);
59+
grunt.registerTask('build', ['lint', 'uglify']);
60+
grunt.registerTask('test', ['build', 'connect', 'qunit']);
61+
grunt.registerTask('default', 'test');
62+
};

LICENSE.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Copyright 2009-2011 Brantley Harris
2+
Copyright 2010–2014 Timo Tijhof
3+
4+
Permission is hereby granted, free of charge, to any person obtaining
5+
a copy of this software and associated documentation files (the
6+
"Software"), to deal in the Software without restriction, including
7+
without limitation the rights to use, copy, modify, merge, publish,
8+
distribute, sublicense, and/or sell copies of the Software, and to
9+
permit persons to whom the Software is furnished to do so, subject to
10+
the following conditions:
11+
12+
The above copyright notice and this permission notice shall be
13+
included in all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,40 @@
1-
## Build
1+
[![Build Status](https://travis-ci.org/Krinkle/jquery-json.svg?branch=master)](https://travis-ci.org/Krinkle/jquery-json)
22

3-
To run the minifier, run this command from the root directory of the repository:
3+
# jQuery JSON
44

5-
$ ./build.sh
5+
JSON plugin for jQuery, provides simple ways to convert to JSON and back again.
6+
7+
## Development
8+
9+
To create the minified build, run this command from the root directory of the repository:
10+
11+
```bash
12+
$ npm run build
13+
```
614

715
## Test
816

9-
Open up ./test/index.html in your browsers and run the test.
17+
Open up `./test/index.html` in your browser to run the test suite, or run it from
18+
the command line with Grunt:
19+
20+
```
21+
$ npm install
22+
$ npm test
23+
```
24+
1025
For it to pass in modern browsers, you have to enable the `disable_native`
1126
option from the QUnit toolbar.
1227

13-
Also, before releasing. Make sure to test the build version as well, you can
14-
do so by enabling the `build-min` option in the QUnit toolbar. This will load
15-
the code from the `./build/` directory instead of `./src/`.
28+
Also, before releasing. Make sure to test the minifed version as well, you can
29+
do so by enabling the `distmin` option in the QUnit toolbar. This will load
30+
the minified build from the `./dist/` directory instead of `./src/`.
1631

17-
## Version
32+
## Versioning
1833

1934
We use the Semantic Versioning guidelines as much as possible.
2035

2136
Releases will be numbered in the following format:
2237

23-
<major>.<minor>.<patch>
24-
25-
The -alpha suffix is used to indicate unreleased versions in development.
38+
`<major>.<minor>.<patch>`
2639

2740
For more information on SemVer, please visit http://semver.org/.

build.sh

Lines changed: 0 additions & 3 deletions
This file was deleted.

build/jquery.json.min.js

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)