Skip to content

Instantly share code, notes, and snippets.

@HAKASHUN
Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HAKASHUN/731f9cdca33c240ffeb1 to your computer and use it in GitHub Desktop.
Save HAKASHUN/731f9cdca33c240ffeb1 to your computer and use it in GitHub Desktop.
AngularJSのコードスタイル(jscs設定)見てみる ref: http://qiita.com/HAKASHUN@github/items/8f2431fed3ecb656efc3
{
"disallowKeywords": ["with"],
"disallowMixedSpacesAndTabs": true,
"disallowMultipleLineStrings": true,
"disallowNewlineBeforeBlockStatements": true,
"disallowSpaceAfterObjectKeys": true,
"disallowSpaceAfterPrefixUnaryOperators": ["!"],
"disallowSpaceBeforeBinaryOperators": [","],
"disallowSpacesInAnonymousFunctionExpression": {
"beforeOpeningRoundBrace": true
},
"disallowSpacesInFunctionDeclaration": {
"beforeOpeningRoundBrace": true
},
"disallowSpacesInNamedFunctionExpression": {
"beforeOpeningRoundBrace": true
},
"disallowSpacesInsideParentheses": true,
"disallowTrailingComma": true,
"disallowTrailingWhitespace": true,
"requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return", "try", "catch"],
"requireSpacesInFunction": {
"beforeOpeningCurlyBrace": true
},
"validateParameterSeparator": ", "
}
{
"requireCurlyBraces": ["if", "else", "for", "while", "do", "try", "catch"],
"requireSpaceAfterBinaryOperators": ["?", ":", "+", "-", "/", "*", "%", "==", "===", "!=", "!==", ">", ">=", "<", "<=", "&&", "||"],
"requireSpaceBeforeBinaryOperators": ["?", ":", "+", "-", "/", "*", "%", "==", "===", "!=", "!==", ">", ">=", "<", "<=", "&&", "||"],
"disallowImplicitTypeConversion": ["string"],
"disallowMultipleLineBreaks": true,
"disallowKeywordsOnNewLine": ["else"],
"requireLineFeedAtFileEnd": true,
"validateJSDoc": {
"checkParamNames": true,
"requireParamTypes": true
}
}
// ダメ
function () {}
// オッケー
function() {}
// ダメ
function a () {}
// オッケー
function a() {}
// ダメ
var x = ( 1 + 2 ) * 3;
// オッケー
var x = (1 + 2) * 3;
// ダメ
var foo = [1, 2, 3, ];
var bar = {a: "a", b: "b", }
// オッケー
var foo = [1, 2, 3];
var bar = {a: "a", b: "b"}
// ダメ
var foo = "blah blah"; //<-- whitespace character here
// オッケー
var foo = "blah blah";
// ダメ
if(x) {
x++;
}
//オッケー
if (x) {
x++;
}
// ダメ
return0;
// オッケー
return 0;
// ダメ
function a(){}
//オッケー
function a() {}
// ダメ
function a(b , c) {}
function a(b,c) {}
// オッケー
function a(b, c) {}
// ダメ
if (x) x++;
// オッケー
if (x) {
x++;
}
"?", ":", "+", "-", "/", "*", "%", "==", "===", "!=", "!==", ">", ">=", "<", "<=", "&&", "||"
// ダメ
with (x) {
prop++;
}
// ダメ
x +y;
x+y;
// オッケー
x + y;
// ダメ
x = '' + y;
// オッケー
x = String(y);
var x = 1;
x++;
var x = 1;
x++;
// ダメ
if (x < 0) {
x++;
}
else {
x--;
}
// オッケー
if (x < 0) {
x++;
} else {
x--;
}
// ダメ
var x = "multi \
line";
// オッケー
var x = "multi" +
"line";
var y = "single line";
function bad()
{
var obj =
{
val: true
};
return {
data: obj
};
}
if (cond)
{
foo();
}
for (var e in elements)
{
bar(e);
}
while (cond)
{
foo();
}
function good(){
var obj = {
val: true
};
return {
data: obj
};
}
if (cond){
foo();
}
for (var e in elements){
bar(e);
}
while (cond){
foo();
}
// ダメ
var x = {a : 1};
// オッケー
var x = {a: 1};
// ダメ
x = ! y;
//オッケー
x = !y;
// ダメ
var hoge = [1 , 2 , 3];
// オッケー
var hoge = [1, 2, 3];
// ダメ
function () {}
// オッケー
function() {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment