-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Alexej Yaroshevich <[email protected]>
- Loading branch information
Alexej Yaroshevich
committed
Apr 5, 2014
0 parents
commit 49fc582
Showing
16 changed files
with
1,118 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# This file is for unifying the coding style for different editors and IDEs | ||
# editorconfig.org | ||
|
||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
indent_style = spaces | ||
indent_size = 4 | ||
|
||
[package.json] | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
node_modules | ||
.idea | ||
*.sublime-* | ||
/npm-debug.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"preset": "google" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
jscs-jsdoc-browser.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"node" : true, | ||
"bitwise" : true, | ||
"undef" : true, | ||
"eqeqeq" : true, | ||
"forin" : true, | ||
"immed" : true, | ||
"noarg" : true, | ||
"unused" : true, | ||
"maxlen" : 120, | ||
"predef" : ["describe", "it", "beforeEach", "afterEach"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
language: node_js | ||
|
||
node_js: | ||
- "0.11" | ||
- "0.10" | ||
- "0.8" | ||
|
||
matrix: | ||
allow_failures: | ||
- node_js: "0.11" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
Contribution Guide | ||
================== | ||
|
||
This document describes some points about contribution process for jscs package. | ||
|
||
The maintainers of the project are: | ||
* Alexej Yaroshevich (@zxqfox). | ||
|
||
The project is being developed within community. Maintainer merges pull-requests, fixes critical bugs. | ||
|
||
Pull-requests | ||
------------- | ||
|
||
If you fixed or added something useful to the project, you can send pull-request. | ||
It will be reviewed by maintainer and accepted, or commented for rework, or declined. | ||
|
||
Bugs | ||
---- | ||
|
||
If you found an error, typo or any other flaw in the project, | ||
please report about it using [GitHub Issues](https://github.com/zxqfox/jscs-jsdoc/issues). | ||
The more details you provide, the easier it could be reproduced and the faster it could be fixed. | ||
Unfortunately, sometimes the bug can only be reproduced in your project or in your environment, | ||
so maintainers cannot reproduce it. In this case we believe you can fix the bug and send us the fix. | ||
|
||
Features | ||
-------- | ||
|
||
It you've got an idea about a new feature, it's most likely that you'll have to implement it on your own. | ||
If you cannot implement the feature, but it is very important, you can create an issue at GitHub, | ||
but expect it to be declined by the maintainer. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright 2013 Alexej Yaroshevich and other contributors | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
# jsdoc | ||
[](http://travis-ci.org/zxqfox/jscs-jsdoc) | ||
[](http://badge.fury.io/js/jsdoc) | ||
[](https://david-dm.org/zxqfox/jscs-jsdoc) | ||
|
||
`jscs-jsdoc` plugin for [jscs](https://github.com/mdevils/node-jscs/). | ||
|
||
## Friendly packages | ||
|
||
* JSCS: https://github.com/mdevils/node-jscs/ | ||
|
||
## Plugin installation | ||
|
||
`jscs-jsdoc` can be installed using `npm`. | ||
Install it globally if you are using globally installed `jscs` | ||
|
||
npm -g install jscs-jsdoc | ||
|
||
Or install it into your project | ||
|
||
npm install jscs-jsdoc --save-dev | ||
|
||
## Usage | ||
|
||
To use plugin you should add it to configuration file `.jscsrc`: | ||
|
||
```json | ||
{ | ||
"additionalRules": [ | ||
"node_modules/jscs-jsdoc/lib/rules/*.js" | ||
], | ||
"jsDoc": { | ||
} | ||
} | ||
``` | ||
|
||
## Configuration | ||
|
||
### jsDoc | ||
|
||
Enables JsDoc validation. | ||
|
||
Type: `Object` | ||
|
||
Values: | ||
|
||
- "checkParamNames" ensures param names in jsdoc and in function declaration are equal | ||
- "requireParamTypes" ensures params in jsdoc contains type | ||
- "checkRedundantParams" reports redundant params in jsdoc | ||
- "checkReturnTypes" tries to compare function result type with declared type in jsdoc | ||
- "requireReturnTypes" ensures returns in jsdoc contains type | ||
- "checkRedundantReturns" reports redundant returns in jsdoc | ||
- "checkTypes" reports invalid types in jsdoc | ||
|
||
#### Example | ||
|
||
```js | ||
"jsDoc": { | ||
"checkParamNames": true, | ||
"checkRedundantParams": true, | ||
"requireParamTypes": true, | ||
"checkReturnTypes": true, | ||
"checkRedundantReturns": true, | ||
"requireReturnTypes": true, | ||
"checkTypes": true | ||
} | ||
``` | ||
|
||
##### Valid | ||
|
||
```js | ||
/** | ||
* Adds style error to the list | ||
* | ||
* @param {String} message | ||
* @param {Number|Object} line | ||
* @param {Number} [column] | ||
* @returns {String[]} | ||
*/ | ||
add: function(message, line, column) { | ||
return ['foo', 'bar']; | ||
} | ||
``` | ||
|
||
##### Invalid | ||
|
||
```js | ||
/** | ||
* Adds style error to the list | ||
* | ||
* @param {String} message | ||
* @param {Number,Object} line | ||
* @param {Number} [column] | ||
* @returns {String} | ||
*/ | ||
add: function() { | ||
} | ||
``` | ||
|
||
## Browser Usage | ||
|
||
File [jscs-jsdoc-browser.js](jscs-jsdoc-browser.js) contains browser-compatible version of `jscs-jsdoc`. | ||
|
||
Download and include `jscs-jsdoc-browser.js` into your page just after `jscs-browser.js`. | ||
|
||
```html | ||
<script src="jscs-browser.js"></script> | ||
<script src="jscs-jsdoc-browser.js"></script> | ||
<script> | ||
var checker = new JscsStringChecker(); | ||
checker.registerDefaultRules(); | ||
checker.configure({'jsDoc': {/*...*/}}); | ||
var errors = checker.checkString('var x, y = 1;'); | ||
errors.getErrorList().forEach(function(error) { | ||
console.log(errors.explainError(error)); | ||
}); | ||
</script> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
module.exports = { | ||
closestScopeNode : closestScopeNode, | ||
treeIterator : require('jscs/lib/tree-iterator') | ||
}; | ||
|
||
var scopeNodeTypes = [ | ||
'Program', | ||
'FunctionDeclaration', | ||
'FunctionExpression' | ||
]; | ||
|
||
/** | ||
* Search for the closest scope node tree for Node | ||
* @param {{type: String}} n | ||
*/ | ||
function closestScopeNode (n) { | ||
while (n && scopeNodeTypes.indexOf(n.type) === -1) { | ||
n = n.parentNode; | ||
} | ||
return n; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
|
||
module.exports = { | ||
presets: [ | ||
require('lib/presets/plugin.json') | ||
], | ||
reporters: [ | ||
require('lib/reporters/plugin.js') | ||
], | ||
rules: [ | ||
require('lib/rules/plugin-validation-rules.js') | ||
] | ||
}; |
Oops, something went wrong.