Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Build: Use JSCS to lint and fix code style
Browse files Browse the repository at this point in the history
Ref gh-185
  • Loading branch information
scottgonzalez committed May 8, 2015
1 parent 19122a3 commit 7f0050e
Show file tree
Hide file tree
Showing 24 changed files with 295 additions and 102 deletions.
74 changes: 74 additions & 0 deletions .jscsrc
@@ -0,0 +1,74 @@
{
"disallowKeywords": [ "with" ],
"disallowMixedSpacesAndTabs": "smart",
"disallowMultipleLineBreaks": true,
"disallowMultipleLineStrings": true,
"disallowMultipleSpaces": true,
"disallowOperatorBeforeLineBreak": [ "." ],
"disallowSpaceAfterObjectKeys": true,
"disallowSpaceAfterPrefixUnaryOperators": true,
"disallowSpaceBeforeBinaryOperators": [ ",", ":" ],
"disallowSpaceBeforePostfixUnaryOperators": true,
"disallowSpacesInAnonymousFunctionExpression": {
"beforeOpeningRoundBrace": true
},
"disallowSpacesInCallExpression": true,
"disallowSpacesInFunction": {
"beforeOpeningRoundBrace": true
},
"disallowSpacesInsideParentheses": true,
"disallowTrailingComma": true,
"disallowTrailingWhitespace": true,
"maximumLineLength": {
"value": 100,
"tabSize": 4,
"allowUrlComments": true,
"allowRegex": true
},
"requireCamelCaseOrUpperCaseIdentifiers": true,
"requireCommaBeforeLineBreak": true,
"requireCurlyBraces": [
"if",
"else",
"for",
"while",
"do",
"try",
"catch"
],
"requireDotNotation": true,
"requireLineBreakAfterVariableAssignment": true,
"requireLineFeedAtFileEnd": true,
"requireOperatorBeforeLineBreak": true,
"requirePaddingNewLinesBeforeLineComments": true,
"requireParenthesesAroundIIFE": true,
"requireSemicolons": true,
"requireSpaceAfterBinaryOperators": true,
"requireSpaceAfterKeywords": [
"if",
"else",
"for",
"while",
"do",
"switch",
"return",
"try",
"catch"
],
"requireSpaceAfterLineComment": true,
"requireSpaceBeforeBinaryOperators": true,
"requireSpaceBeforeBlockStatements": true,
"requireSpaceBeforeObjectValues": true,
"requireSpaceBetweenArguments": true,
"requireSpacesInAnonymousFunctionExpression": {
"beforeOpeningCurlyBrace": true
},
"requireSpacesInConditionalExpression": true,
"requireSpacesInForStatement": true,
"requireSpacesInFunction": {
"beforeOpeningCurlyBrace": true
},
"requireSpacesInsideBrackets": true,
"requireSpacesInsideObjectBrackets": "all",
"validateLineBreaks": "LF"
}
8 changes: 7 additions & 1 deletion CONTRIBUTING.md
@@ -1,5 +1,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).

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/).
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/).

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/).

----

\* PEP follows the [jQuery JavaScript Style Guide](http://contribute.jquery.org/style-guide/js/) with the following exception:

* There are no spaces around anything that appears inside parentheses.
40 changes: 35 additions & 5 deletions Gruntfile.js
@@ -1,15 +1,21 @@
module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-git-authors');
grunt.loadNpmTasks('grunt-jscs');
grunt.loadNpmTasks('intern');

var version = require('./package').version;
var header =
'/*!\n' +
' * PEP v' + version + ' | https://github.com/jquery/PEP\n' +
' * Copyright jQuery Foundation and other contributors | http://jquery.org/license\n'+
' * Copyright jQuery Foundation and other contributors | http://jquery.org/license\n' +
' */\n';

var srcFiles = [ 'pointerevents.js', 'src/**/*.js' ];
var buildFiles = [ 'Gruntfile.js', 'build/**/*.js' ];
var testFiles = [ 'tests/**/*.js' ];
var allFiles = srcFiles.concat(buildFiles).concat(testFiles);

grunt.initConfig({
uglify: {
pointerevents: {
Expand All @@ -35,6 +41,27 @@ module.exports = function(grunt) {
config: 'tests/intern'
}
}
},
jscs: {
lint: {
options: {
config: true,
esnext: true
},
files: {
src: allFiles
}
},
fix: {
options: {
config: true,
esnext: true,
fix: true
},
files: {
src: allFiles
}
}
}
});

Expand All @@ -46,13 +73,15 @@ module.exports = function(grunt) {
esperanto.bundle({
base: 'src',
entry: '../pointerevents.js'
}).then(function (bundle) {
}).then(function(bundle) {
var umd = bundle.toUmd({
name: 'PointerEventsPolyfill'

// sourceMap: true,
// sourceMapFile: 'dist/pep.js'
});
grunt.file.write('dist/pep.js', header + umd.code);

// grunt.file.write('dist/pep.js.map', umd.map.toString());
}).then(
function() {
Expand All @@ -66,7 +95,8 @@ module.exports = function(grunt) {
);
});

grunt.registerTask('default', ['build', 'uglify']);
grunt.registerTask('test', ['intern:pointerevents']);
grunt.registerTask('ci', ['build', 'intern:ci']);
grunt.registerTask('default', [ 'lint', 'build', 'uglify' ]);
grunt.registerTask('lint', [ 'jscs:lint' ]);
grunt.registerTask('test', [ 'intern:pointerevents' ]);
grunt.registerTask('ci', [ 'lint', 'build', 'intern:ci' ]);
};
14 changes: 7 additions & 7 deletions build/release.js
@@ -1,6 +1,6 @@
module.exports = function( Release ) {
module.exports = function(Release) {

Release.define( {
Release.define({
issueTracker: "github",
cdnPublish: "dist",
npmPublish: true,
Expand All @@ -9,13 +9,13 @@ Release.define( {
return "# " + Release.newVersion + " Changelog\n";
},

generateArtifacts: function( callback ) {
Release.exec( "grunt" );
callback( [
generateArtifacts: function(callback) {
Release.exec("grunt");
callback([
"dist/pep.js",
"dist/pep.min.js"
] );
]);
}
} );
});

};
5 changes: 3 additions & 2 deletions package.json
Expand Up @@ -21,10 +21,11 @@
"devDependencies": {
"chai-spies": "^0.5.1",
"esperanto": "^0.6.6",
"intern": "2.2.2",
"grunt": "~0.4.1",
"grunt-contrib-uglify": "^0.4.0",
"grunt-git-authors": "^3.0.0"
"grunt-git-authors": "^3.0.0",
"grunt-jscs": "1.8.0",
"intern": "2.2.2"
},
"scripts": {
"test": "grunt test"
Expand Down
8 changes: 4 additions & 4 deletions src/PointerEvent.js
Expand Up @@ -10,7 +10,7 @@
* @constructor
* @param {String} inType The type of the event to create.
* @param {Object} [inDict] An optional dictionary of initial event properties.
* @return {Event} A new PointerEvent of type `inType` and initialized with properties from `inDict`.
* @return {Event} A new PointerEvent of type `inType`, initialized with properties from `inDict`.
*/
var MOUSE_PROPS = [
'bubbles',
Expand Down Expand Up @@ -58,9 +58,9 @@ function PointerEvent(inType, inDict) {

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

Expand Down

0 comments on commit 7f0050e

Please sign in to comment.