Skip to content

Commit

Permalink
Add coffeelint config
Browse files Browse the repository at this point in the history
  • Loading branch information
Omar Khan committed Jun 10, 2012
1 parent 96dae54 commit aceaa5f
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 17 deletions.
53 changes: 53 additions & 0 deletions coffeelint.json
@@ -0,0 +1,53 @@
{
"no_tabs": {
"level": "error"
},

"no_trailing_whitespace": {
"level": "error"
},

"max_line_length": {
"value": 80,
"level": "warn"
},

"camel_case_classes": {
"level": "error"
},

"indentation": {
"value": 4,
"level": "error"
},

"no_implicit_braces": {
"level": "warn"
},

"no_trailing_semicolons": {
"level": "error"
},

"no_plusplus": {
"level": "error"
},

"no_throwing_strings": {
"level": "error"
},

"cyclomatic_complexity": {
"value": 11,
"level": "ignore"
},

"line_endings": {
"value": "unix",
"level": "error"
},

"no_implicit_parens": {
"level": "error"
}
}
9 changes: 6 additions & 3 deletions src/coffeedoc.coffee
Expand Up @@ -29,11 +29,12 @@ documentModule = (script, parser) ->
else
docstring = null

doc =
doc = {
docstring: docstring
deps: parser.getDependencies(nodes)
classes: (documentClass(c) for c in parser.getClasses(nodes))
functions: (documentFunction(f) for f in parser.getFunctions(nodes))
}

return doc

Expand Down Expand Up @@ -86,12 +87,13 @@ documentClass = (cls) ->
else
parent = null

doc =
doc = {
name: getFullName(cls.variable)
docstring: docstring
parent: parent
staticmethods: (documentFunction(m) for m in staticmethods)
instancemethods: (documentFunction(m) for m in instancemethods)
}

for method in doc.staticmethods
method.name = method.name.replace(/^this\./, '')
Expand Down Expand Up @@ -128,10 +130,11 @@ documentFunction = (func) ->
else
params = []

doc =
doc = {
name: getFullName(func.variable)
docstring: docstring
params: params
}


formatDocstring = (str) ->
Expand Down
24 changes: 12 additions & 12 deletions src/parsers.coffee
Expand Up @@ -109,17 +109,17 @@ class RequireJSParser extends BaseParser
result_nodes = []
moduleLdrs = ['define', 'require']
for root_node in nodes
root_node.traverseChildren false, (node) ->
node.type = node.constructor.name
node.level = 1
if node.type is 'Call' and node.variable.base.value in moduleLdrs
for arg in node.args
if arg.constructor.name is 'Code'
arg.body.traverseChildren false, (node) ->
node.type = node.constructor.name
node.level = 2
result_nodes = result_nodes.concat(arg.body.expressions)
# TODO: Support objects passed to require or define
root_node.traverseChildren false, (node) ->
node.type = node.constructor.name
node.level = 1
if node.type is 'Call' and node.variable.base.value in moduleLdrs
for arg in node.args
if arg.constructor.name is 'Code'
arg.body.traverseChildren false, (node) ->
node.type = node.constructor.name
node.level = 2
result_nodes = result_nodes.concat(arg.body.expressions)
# TODO: Support objects passed to require or define
return nodes.concat(result_nodes)

_parseCall: (node, deps) ->
Expand Down Expand Up @@ -175,7 +175,7 @@ class RequireJSParser extends BaseParser
for mod in mods
local_name = if index < args.length then args[index] else mod
deps[local_name] = mod
index++
index += 1

_stripQuotes: (str) ->
return str?.replace(/('|\")/g, '')
Expand Down
4 changes: 2 additions & 2 deletions src/renderers.coffee
Expand Up @@ -144,9 +144,9 @@ class GithubWikiRenderer extends Renderer
a = []
for x in t
if x?
a.push(x)
a.push(x)
else
a.push('{splat}')
a.push('{splat}')
return a.join(', ')

preprocess: (module) =>
Expand Down

0 comments on commit aceaa5f

Please sign in to comment.