Skip to content

Commit 7f0050e

Browse files
committed
Build: Use JSCS to lint and fix code style
Ref jquery-archivegh-185
1 parent 19122a3 commit 7f0050e

24 files changed

+295
-102
lines changed

.jscsrc

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
{
2+
"disallowKeywords": [ "with" ],
3+
"disallowMixedSpacesAndTabs": "smart",
4+
"disallowMultipleLineBreaks": true,
5+
"disallowMultipleLineStrings": true,
6+
"disallowMultipleSpaces": true,
7+
"disallowOperatorBeforeLineBreak": [ "." ],
8+
"disallowSpaceAfterObjectKeys": true,
9+
"disallowSpaceAfterPrefixUnaryOperators": true,
10+
"disallowSpaceBeforeBinaryOperators": [ ",", ":" ],
11+
"disallowSpaceBeforePostfixUnaryOperators": true,
12+
"disallowSpacesInAnonymousFunctionExpression": {
13+
"beforeOpeningRoundBrace": true
14+
},
15+
"disallowSpacesInCallExpression": true,
16+
"disallowSpacesInFunction": {
17+
"beforeOpeningRoundBrace": true
18+
},
19+
"disallowSpacesInsideParentheses": true,
20+
"disallowTrailingComma": true,
21+
"disallowTrailingWhitespace": true,
22+
"maximumLineLength": {
23+
"value": 100,
24+
"tabSize": 4,
25+
"allowUrlComments": true,
26+
"allowRegex": true
27+
},
28+
"requireCamelCaseOrUpperCaseIdentifiers": true,
29+
"requireCommaBeforeLineBreak": true,
30+
"requireCurlyBraces": [
31+
"if",
32+
"else",
33+
"for",
34+
"while",
35+
"do",
36+
"try",
37+
"catch"
38+
],
39+
"requireDotNotation": true,
40+
"requireLineBreakAfterVariableAssignment": true,
41+
"requireLineFeedAtFileEnd": true,
42+
"requireOperatorBeforeLineBreak": true,
43+
"requirePaddingNewLinesBeforeLineComments": true,
44+
"requireParenthesesAroundIIFE": true,
45+
"requireSemicolons": true,
46+
"requireSpaceAfterBinaryOperators": true,
47+
"requireSpaceAfterKeywords": [
48+
"if",
49+
"else",
50+
"for",
51+
"while",
52+
"do",
53+
"switch",
54+
"return",
55+
"try",
56+
"catch"
57+
],
58+
"requireSpaceAfterLineComment": true,
59+
"requireSpaceBeforeBinaryOperators": true,
60+
"requireSpaceBeforeBlockStatements": true,
61+
"requireSpaceBeforeObjectValues": true,
62+
"requireSpaceBetweenArguments": true,
63+
"requireSpacesInAnonymousFunctionExpression": {
64+
"beforeOpeningCurlyBrace": true
65+
},
66+
"requireSpacesInConditionalExpression": true,
67+
"requireSpacesInForStatement": true,
68+
"requireSpacesInFunction": {
69+
"beforeOpeningCurlyBrace": true
70+
},
71+
"requireSpacesInsideBrackets": true,
72+
"requireSpacesInsideObjectBrackets": "all",
73+
"validateLineBreaks": "LF"
74+
}

CONTRIBUTING.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
Welcome! Thanks for your interest in contributing to PEP. You're **almost** in the right place. More information on how to contribute to this and all other jQuery Foundation projects is over at [contribute.jquery.org](http://contribute.jquery.org). You'll definitely want to take a look at the articles on contributing [code](http://contribute.jquery.org/code).
22

3-
You may also want to take a look at our [commit & pull request guide](http://contribute.jquery.org/commits-and-pull-requests/) and [style guides](http://contribute.jquery.org/style-guide/) for instructions on how to maintain your fork and submit your code. Before we can merge any pull request, we'll also need you to sign our [contributor license agreement](http://contribute.jquery.org/cla/).
3+
You may also want to take a look at our [commit & pull request guide](http://contribute.jquery.org/commits-and-pull-requests/) and [style guides](http://contribute.jquery.org/style-guide/)* for instructions on how to maintain your fork and submit your code. Before we can merge any pull request, we'll also need you to sign our [contributor license agreement](http://contribute.jquery.org/cla/).
44

55
You can find us on [IRC](http://irc.jquery.org), specifically in #pep should you have any questions. If you've never contributed to open source before, we've put together [a short guide with tips, tricks, and ideas on getting started](http://contribute.jquery.org/open-source/).
6+
7+
----
8+
9+
\* PEP follows the [jQuery JavaScript Style Guide](http://contribute.jquery.org/style-guide/js/) with the following exception:
10+
11+
* There are no spaces around anything that appears inside parentheses.

Gruntfile.js

+35-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
11
module.exports = function(grunt) {
22
grunt.loadNpmTasks('grunt-contrib-uglify');
33
grunt.loadNpmTasks('grunt-git-authors');
4+
grunt.loadNpmTasks('grunt-jscs');
45
grunt.loadNpmTasks('intern');
56

67
var version = require('./package').version;
78
var header =
89
'/*!\n' +
910
' * PEP v' + version + ' | https://github.com/jquery/PEP\n' +
10-
' * Copyright jQuery Foundation and other contributors | http://jquery.org/license\n'+
11+
' * Copyright jQuery Foundation and other contributors | http://jquery.org/license\n' +
1112
' */\n';
1213

14+
var srcFiles = [ 'pointerevents.js', 'src/**/*.js' ];
15+
var buildFiles = [ 'Gruntfile.js', 'build/**/*.js' ];
16+
var testFiles = [ 'tests/**/*.js' ];
17+
var allFiles = srcFiles.concat(buildFiles).concat(testFiles);
18+
1319
grunt.initConfig({
1420
uglify: {
1521
pointerevents: {
@@ -35,6 +41,27 @@ module.exports = function(grunt) {
3541
config: 'tests/intern'
3642
}
3743
}
44+
},
45+
jscs: {
46+
lint: {
47+
options: {
48+
config: true,
49+
esnext: true
50+
},
51+
files: {
52+
src: allFiles
53+
}
54+
},
55+
fix: {
56+
options: {
57+
config: true,
58+
esnext: true,
59+
fix: true
60+
},
61+
files: {
62+
src: allFiles
63+
}
64+
}
3865
}
3966
});
4067

@@ -46,13 +73,15 @@ module.exports = function(grunt) {
4673
esperanto.bundle({
4774
base: 'src',
4875
entry: '../pointerevents.js'
49-
}).then(function (bundle) {
76+
}).then(function(bundle) {
5077
var umd = bundle.toUmd({
5178
name: 'PointerEventsPolyfill'
79+
5280
// sourceMap: true,
5381
// sourceMapFile: 'dist/pep.js'
5482
});
5583
grunt.file.write('dist/pep.js', header + umd.code);
84+
5685
// grunt.file.write('dist/pep.js.map', umd.map.toString());
5786
}).then(
5887
function() {
@@ -66,7 +95,8 @@ module.exports = function(grunt) {
6695
);
6796
});
6897

69-
grunt.registerTask('default', ['build', 'uglify']);
70-
grunt.registerTask('test', ['intern:pointerevents']);
71-
grunt.registerTask('ci', ['build', 'intern:ci']);
98+
grunt.registerTask('default', [ 'lint', 'build', 'uglify' ]);
99+
grunt.registerTask('lint', [ 'jscs:lint' ]);
100+
grunt.registerTask('test', [ 'intern:pointerevents' ]);
101+
grunt.registerTask('ci', [ 'lint', 'build', 'intern:ci' ]);
72102
};

build/release.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
module.exports = function( Release ) {
1+
module.exports = function(Release) {
22

3-
Release.define( {
3+
Release.define({
44
issueTracker: "github",
55
cdnPublish: "dist",
66
npmPublish: true,
@@ -9,13 +9,13 @@ Release.define( {
99
return "# " + Release.newVersion + " Changelog\n";
1010
},
1111

12-
generateArtifacts: function( callback ) {
13-
Release.exec( "grunt" );
14-
callback( [
12+
generateArtifacts: function(callback) {
13+
Release.exec("grunt");
14+
callback([
1515
"dist/pep.js",
1616
"dist/pep.min.js"
17-
] );
17+
]);
1818
}
19-
} );
19+
});
2020

2121
};

package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@
2121
"devDependencies": {
2222
"chai-spies": "^0.5.1",
2323
"esperanto": "^0.6.6",
24-
"intern": "2.2.2",
2524
"grunt": "~0.4.1",
2625
"grunt-contrib-uglify": "^0.4.0",
27-
"grunt-git-authors": "^3.0.0"
26+
"grunt-git-authors": "^3.0.0",
27+
"grunt-jscs": "1.8.0",
28+
"intern": "2.2.2"
2829
},
2930
"scripts": {
3031
"test": "grunt test"

src/PointerEvent.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* @constructor
1111
* @param {String} inType The type of the event to create.
1212
* @param {Object} [inDict] An optional dictionary of initial event properties.
13-
* @return {Event} A new PointerEvent of type `inType` and initialized with properties from `inDict`.
13+
* @return {Event} A new PointerEvent of type `inType`, initialized with properties from `inDict`.
1414
*/
1515
var MOUSE_PROPS = [
1616
'bubbles',
@@ -58,9 +58,9 @@ function PointerEvent(inType, inDict) {
5858

5959
// define inherited MouseEvent properties
6060
// skip bubbles and cancelable since they're set above in initEvent()
61-
for(var i = 2, p; i < MOUSE_PROPS.length; i++) {
62-
p = MOUSE_PROPS[i];
63-
e[p] = inDict[p] || MOUSE_DEFAULTS[i];
61+
for (var i = 2, p; i < MOUSE_PROPS.length; i++) {
62+
p = MOUSE_PROPS[ i ];
63+
e[ p ] = inDict[ p ] || MOUSE_DEFAULTS[ i ];
6464
}
6565
e.buttons = inDict.buttons || 0;
6666

0 commit comments

Comments
 (0)