1
0
Fork 0
mirror of https://github.com/openstf/stf synced 2025-10-04 02:09:32 +02:00

Added JSCS style checking.

However, there are thousands of errors: it may need some rule relaxing.
Still needs to check for JSHint overlap.

Heated rules left out:
"disallowAnonymousFunctions": true,
"disallowCommaBeforeLineBreak": true
"requireCommaBeforeLineBreak": true,
"disallowKeywordsOnNewLine": true,
"requireKeywordsOnNewLine": true
This commit is contained in:
Gunther Brunner 2014-09-09 16:28:00 +09:00
parent 883fce71ea
commit 2445b179ee
3 changed files with 115 additions and 12 deletions

93
.jscsrc Normal file
View file

@ -0,0 +1,93 @@
{
"requireCurlyBraces": [
"if",
"else",
"for",
"while",
"do",
"try",
"catch",
"case",
"default"
],
"requireSpaceAfterKeywords": [
"do",
"for",
"if",
"else",
"switch",
"case",
"try",
"catch",
"void",
"while",
"with",
"return",
"typeof",
"function"
],
"requireSpaceBeforeBlockStatements": true,
"requireParenthesesAroundIIFE": true,
"requireSpacesInConditionalExpression": true,
"requireSpacesInFunctionExpression": {
"beforeOpeningRoundBrace": true,
"beforeOpeningCurlyBrace": true
},
"requireSpacesInNamedFunctionExpression": {
"beforeOpeningRoundBrace": true,
"beforeOpeningCurlyBrace": true
},
"requireSpacesInFunctionDeclaration": {
"beforeOpeningRoundBrace": true,
"beforeOpeningCurlyBrace": true
},
"requireSpacesInFunction": {
"beforeOpeningRoundBrace": true,
"beforeOpeningCurlyBrace": true
},
"disallowMultipleVarDecl": true,
"requireBlocksOnNewline": true,
"disallowPaddingNewlinesInBlocks": true,
"disallowEmptyBlocks": true,
"disallowSpacesInsideArrayBrackets": "nested",
"disallowQuotedKeysInObjects": "allButReserved",
"disallowSpaceAfterObjectKeys": true,
"requireOperatorBeforeLineBreak": true,
"disallowSpaceAfterPrefixUnaryOperators": true,
"disallowSpaceBeforePostfixUnaryOperators": true,
"requireSpaceBeforeBinaryOperators": true,
"requireSpaceAfterBinaryOperators": true,
"disallowImplicitTypeConversion": [
"numeric",
"boolean",
"binary",
"string"
],
"requireCamelCaseOrUpperCaseIdentifiers": true,
"disallowKeywords": ["with"],
"disallowMultipleLineStrings": true,
"disallowMultipleLineBreaks": true,
"validateLineBreaks": "LF",
"validateQuoteMarks": {
"mark": "'",
"escape": true
},
"validateIndentation": 2,
"disallowMixedSpacesAndTabs": true,
"disallowTrailingWhitespace": true,
"disallowTrailingComma": true,
"requireLineFeedAtFileEnd": true,
"maximumLineLength": 90,
"requireCapitalizedConstructors": true,
"safeContextKeyword": ["that"],
"requireDotNotation": true,
"disallowYodaConditions": true,
"validateJSDoc": {
"checkParamNames": true,
"checkRedundantParams": true,
"requireParamTypes": true
},
"requireSpaceAfterLineComment": true,
"disallowNewlineBeforeBlockStatements": true
}

View file

@ -15,6 +15,7 @@ var protractorConfig = './res/test/protractor.conf'
var karma = require('karma').server var karma = require('karma').server
var karmaConfig = '/res/test/karma.conf.js' var karmaConfig = '/res/test/karma.conf.js'
var stream = require('stream') var stream = require('stream')
var jscs = require('gulp-jscs')
gulp.task('jshint', function () { gulp.task('jshint', function () {
return gulp.src([ return gulp.src([
@ -34,6 +35,15 @@ gulp.task('jsonlint', function () {
.pipe(jsonlint.reporter()) .pipe(jsonlint.reporter())
}) })
gulp.task('jscs', function () {
return gulp.src([
'lib/**/*.js', 'res/app/**/*.js', 'res/auth-ldap/**/*.js',
'res/auth-mock/**/*.js', 'res/common/**/*.js', 'res/test/**/*.js',
'*.js'
])
.pipe(jscs())
});
gulp.task('lint', ['jshint', 'jsonlint']) gulp.task('lint', ['jshint', 'jsonlint'])
gulp.task('test', ['lint', 'protractor']) gulp.task('test', ['lint', 'protractor'])
gulp.task('build', ['translate', 'webpack:build']) gulp.task('build', ['translate', 'webpack:build'])
@ -65,7 +75,7 @@ gulp.task('protractor-explorer', function (callback) {
}, callback) }, callback)
}) })
gulp.task('protractor', ['webdriver-update'],function (callback) { gulp.task('protractor', ['webdriver-update'], function (callback) {
gulp.src(["./res/test/e2e/**/*.js"]) gulp.src(["./res/test/e2e/**/*.js"])
.pipe(protractor.protractor({ .pipe(protractor.protractor({
configFile: protractorConfig, configFile: protractorConfig,
@ -162,7 +172,7 @@ gulp.task('jade', function (cb) {
locals: { locals: {
// So res/views/docs.jade doesn't complain // So res/views/docs.jade doesn't complain
markdownFile: { markdownFile: {
parseContent: function() { parseContent: function () {
} }
} }
} }

View file

@ -1,6 +1,6 @@
var pathutil = require('./lib/util/pathutil') var pathutil = require('./lib/util/pathutil')
var webpack = require('webpack') var webpack = require('webpack')
var CommonsChunkPlugin = require("webpack/lib/optimize/CommonsChunkPlugin") var CommonsChunkPlugin = require('webpack/lib/optimize/CommonsChunkPlugin')
module.exports = { module.exports = {
webpack: { webpack: {
@ -38,14 +38,14 @@ module.exports = {
{ test: /\.css$/, loader: 'style!css' }, { test: /\.css$/, loader: 'style!css' },
{ test: /\.less$/, loader: 'style-loader!css-loader!less-loader'}, { test: /\.less$/, loader: 'style-loader!css-loader!less-loader'},
{ test: /\.json$/, loader: 'json' }, { test: /\.json$/, loader: 'json' },
{ test: /\.jpg$/, loader: "url-loader?limit=1000&mimetype=image/jpeg" }, { test: /\.jpg$/, loader: 'url-loader?limit=1000&mimetype=image/jpeg' },
{ test: /\.png$/, loader: "url-loader?limit=1000&mimetype=image/png" }, { test: /\.png$/, loader: 'url-loader?limit=1000&mimetype=image/png' },
{ test: /\.gif$/, loader: "url-loader?limit=1000&mimetype=image/gif" }, { test: /\.gif$/, loader: 'url-loader?limit=1000&mimetype=image/gif' },
{ test: /\.svg/, loader: "url-loader?limit=1&mimetype=image/svg+xml" }, { test: /\.svg/, loader: 'url-loader?limit=1&mimetype=image/svg+xml' },
{ test: /\.woff/, loader: "url-loader?limit=1&mimetype=application/font-woff" }, { test: /\.woff/, loader: 'url-loader?limit=1&mimetype=application/font-woff' },
{ test: /\.otf/, loader: "url-loader?limit=1&mimetype=application/font-woff" }, { test: /\.otf/, loader: 'url-loader?limit=1&mimetype=application/font-woff' },
{ test: /\.ttf/, loader: "url-loader?limit=1&mimetype=application/font-woff" }, { test: /\.ttf/, loader: 'url-loader?limit=1&mimetype=application/font-woff' },
{ test: /\.eot/, loader: "url-loader?limit=1&mimetype=vnd.ms-fontobject" }, { test: /\.eot/, loader: 'url-loader?limit=1&mimetype=vnd.ms-fontobject' },
{ test: /\.jade$/, loader: 'template-html-loader' }, { test: /\.jade$/, loader: 'template-html-loader' },
{ test: /\.html$/, loader: 'html-loader' }, { test: /\.html$/, loader: 'html-loader' },
{ test: /angular\.js$/, loader: 'exports?angular'}, { test: /angular\.js$/, loader: 'exports?angular'},
@ -82,7 +82,7 @@ module.exports = {
, ['main'] , ['main']
) )
) )
, new CommonsChunkPlugin("entry/commons.entry.js") , new CommonsChunkPlugin('entry/commons.entry.js')
] ]
}, },
webpackServer: { webpackServer: {