Add jscs style check, fix violations found

This commit is contained in:
Miroslav Bajtoš 2014-11-13 15:54:59 +01:00
parent 83723379a2
commit 5b5071864b
12 changed files with 63 additions and 36 deletions

24
.jscsrc Normal file
View File

@ -0,0 +1,24 @@
{
"preset": "google",
"requireCurlyBraces": [
"do",
"try",
"catch"
],
"disallowSpacesInsideObjectBrackets": null,
"requireSpaceAfterLineComment": true,
"maximumLineLength": {
"value": 80,
"allowRegex": true
},
"validateJSDoc": {
"checkParamNames": false,
"checkRedundantParams": false,
"requireParamTypes": true
},
"excludeFiles": [
"node_modules/**",
"coverage/**",
"test/sandbox/**"
]
}

View File

@ -1,7 +1,6 @@
{
"node": true,
"browser": true,
"camelcase" : true,
"eqnull" : true,
"indent": 2,
"undef": true,

View File

@ -136,7 +136,7 @@ exports.compileToBrowserify = function(options, bundler) {
addInstructionsToBrowserify(compile(options), bundler);
};
//-- undocumented low-level API --//
/*-- undocumented low-level API --*/
exports.ConfigLoader = ConfigLoader;
exports.compile = compile;

View File

@ -309,7 +309,9 @@ function loadModelDefinition(rootDir, jsonFile, allFiles) {
var basename = path.basename(jsonFile, path.extname(jsonFile));
// find a matching file with a supported extension like `.js` or `.coffee`
var base, ext, validFileType;
var base;
var ext;
var validFileType;
var sourceFile = allFiles
.filter(function(f) {
ext = path.extname(f);

View File

@ -189,8 +189,8 @@ function hasCompatibleType(origValue, newValue) {
/**
* Try to read a config file with .json extension
* @param cwd Dirname of the file
* @param fileName Name of the file without extension
* @param {string} cwd Dirname of the file
* @param {string} fileName Name of the file without extension
* @returns {Object|undefined} Content of the file, undefined if not found.
*/
function tryReadJsonConfig(cwd, fileName) {

View File

@ -69,7 +69,7 @@ function assertLoopBackVersion(app) {
}
function setHost(app, instructions) {
//jshint camelcase:false
// jscs:disable requireCamelCaseOrUpperCaseIdentifiers
var host =
process.env.npm_config_host ||
process.env.OPENSHIFT_SLS_IP ||
@ -86,7 +86,7 @@ function setHost(app, instructions) {
}
function setPort(app, instructions) {
//jshint camelcase:false
// jscs:disable requireCamelCaseOrUpperCaseIdentifiers
var port = _.find([
process.env.npm_config_port,
process.env.OPENSHIFT_SLS_PORT,

View File

@ -15,7 +15,7 @@
"main": "index.js",
"browser": "browser.js",
"scripts": {
"pretest": "jshint .",
"pretest": "jscs . && jshint .",
"test": "mocha"
},
"license": {
@ -37,6 +37,7 @@
"coffee-script": "^1.8.0",
"coffeeify": "^0.7.0",
"fs-extra": "^0.12.0",
"jscs": "^1.7.3",
"jshint": "^2.5.6",
"loopback": "^2.5.0",
"mocha": "^1.19.0",

View File

@ -12,7 +12,10 @@ describe('compiler', function() {
beforeEach(appdir.init);
describe('from options', function() {
var options, instructions, appConfig;
var options;
var instructions;
var appConfig;
beforeEach(function() {
options = {
config: {

View File

@ -266,7 +266,7 @@ describe('executor', function() {
});
it('should prioritize sources', function() {
/*jshint camelcase:false */
// jscs:disable requireCamelCaseOrUpperCaseIdentifiers
process.env.npm_config_host = randomHost();
process.env.OPENSHIFT_SLS_IP = randomHost();
process.env.OPENSHIFT_NODEJS_IP = randomHost();
@ -328,7 +328,6 @@ describe('executor', function() {
});
});
function assertValidDataSource(dataSource) {
// has methods
assert.isFunc(dataSource, 'createModel');

View File

@ -2,4 +2,3 @@ process.bootFlags.push('barSyncLoaded');
module.exports = function(app) {
process.bootFlags.push('barSyncExecuted');
};