Skip to content
This repository has been archived by the owner on May 26, 2023. It is now read-only.

Commit

Permalink
Merge pull request #36 from willowtreeapps/rule/camel-case-func
Browse files Browse the repository at this point in the history
Add rule 'camel-case-func'
  • Loading branch information
vannuysm authored Oct 16, 2017
2 parents 0e83794 + 943f460 commit 5c2f327
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
35 changes: 35 additions & 0 deletions lib/rules/camel-case-func.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
'use strict';

const Parser = require('../../parser');

module.exports = {
create(context) {
const report = (node) => {
const funcName = node.children[1].getText();
if (funcName == null) {
return;
}

const first = funcName.charAt(0);

if (first !== first.toLowerCase()) {
context.report({
message: `Function '${funcName}' is not camel case`,
loc: {
start: node.start,
end: node.stop
}
});
}
};

return {
'functionDeclaration:exit': function(node) {
report(node);
},
'subDeclaration:exit': function(node) {
report(node);
}
};
}
};
3 changes: 2 additions & 1 deletion sample-project/.bslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"no-void-func": "warn",
"no-shorthand-if": "warn",
"no-private-func": "warn",
"function-return-statement": "error"
"function-return-statement": "error",
"camel-case-func": "warn"
}
}

0 comments on commit 5c2f327

Please sign in to comment.