Skip to content

Commit 0abdae5

Browse files
author
John Doherty
committed
added eslint and cleaned up linting issues
1 parent 81408f6 commit 0abdae5

File tree

9 files changed

+179
-113
lines changed

9 files changed

+179
-113
lines changed

.eslintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
test

.eslintrc

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"extends": "airbnb-base",
3+
"env": {
4+
"jasmine": true,
5+
"node": true,
6+
"browser": true
7+
},
8+
"globals": {
9+
"spyOn": true,
10+
"app": true,
11+
"helpers": true
12+
},
13+
"rules": {
14+
"brace-style": ["error", "stroustrup"],
15+
"comma-dangle": ["error", "never"],
16+
"func-names": 0,
17+
"indent": ["error", 4, { "SwitchCase": 1 }],
18+
"max-len": [2, 180, 4, {
19+
"ignoreUrls": true,
20+
"ignoreComments": false
21+
}],
22+
"new-cap": ["error", {"capIsNewExceptions": ["Router", "ObjectId", "DEBUG"], "properties": false}],
23+
"no-underscore-dangle": 0,
24+
"no-unused-vars": ["warn"],
25+
"no-use-before-define": ["error", { "functions": false }],
26+
"no-var": ["off"],
27+
"one-var": ["off"],
28+
"vars-on-top": ["off"],
29+
"no-param-reassign": ["off"],
30+
"padded-blocks": 0,
31+
"prefer-template": ["off"],
32+
"prefer-arrow-callback": ["off"],
33+
"require-jsdoc": ["warn", {
34+
"require": {
35+
"FunctionDeclaration": true,
36+
"MethodDefinition": true,
37+
"ClassDeclaration": true
38+
}
39+
}],
40+
"object-shorthand": ["error", "never"],
41+
"space-before-function-paren": "off",
42+
"strict": "off",
43+
"valid-jsdoc": ["error"]
44+
}
45+
}

README.MD

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,18 @@ $ jsdoc-to-json-schema -i ./example/product.js -o ./example/product.schema.json
3434
### Using this module as an expressjs response
3535

3636
```js
37-
var app = require('express')(),
38-
toJsonSchema = require('../lib/jsdoc-to-json-schema.js');
37+
var express = require('express');
38+
var app = express();
39+
var toJsonSchema = require('../lib/jsdoc-to-json-schema.js');
3940

41+
// create an express route
4042
app.get('/', function(req, res){
4143

4244
// return JSON schema generated from person.js script comments
4345
toJsonSchema('./examples/person.js', res);
4446
});
4547

48+
// start the server listening on port 8080
4649
app.listen(8080, function(){
4750
console.log('Example app listening on port 8080');
4851
});

examples/area.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ var Area = {
4444
* @schema.type string
4545
* @schema.required true
4646
*/
47-
$reql_type$: "GEOMETRY",
47+
$reql_type$: 'GEOMETRY',
4848

4949
/**
5050
* @schema.type array
@@ -56,7 +56,7 @@ var Area = {
5656
* @schema.type string
5757
* @schema.required true
5858
*/
59-
type: "Polygon"
59+
type: 'Polygon'
6060
},
6161

6262
/**
@@ -70,4 +70,4 @@ var Area = {
7070
* @schema.required true
7171
*/
7272
terc: ''
73-
}
73+
};

examples/person.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @schema.description This is an example Person object marked up with JSON schema tags to allow schema generation
44
*/
55
var Person = {
6-
6+
77
/**
88
* @schema.title Name
99
* @schema.description Please enter your full name
@@ -13,21 +13,21 @@ var Person = {
1313
* @schema.required true
1414
*/
1515
name: '',
16-
16+
1717
/**
1818
* @schema.title Job Title
1919
* @schema.type string
2020
*/
2121
jobTitle: '',
22-
22+
2323
/**
2424
* @schema.title Telephone Number
2525
* @schema.description Please enter telephone number including country code
2626
* @schema.type string
2727
* @schema.required true
2828
*/
2929
telephone: '',
30-
30+
3131
/**
3232
* @schema.type string
3333
* @schema.required true
@@ -38,6 +38,6 @@ var Person = {
3838
* @schema.type object
3939
*/
4040
address: {
41-
41+
4242
}
43-
};
43+
};

examples/product.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
* @schema.name Product
33
* @schema.description An example product marked up with json schema comments
44
*/
5-
function Product(){
6-
5+
function Product() {
6+
77
}
88

99
/**
@@ -12,6 +12,6 @@ function Product(){
1212
* @schema.maxItems 6
1313
* @schema.required true
1414
*/
15-
Product.prototype.types = function(){
16-
17-
}
15+
Product.prototype.types = function() {
16+
17+
}

index.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
if (module.parent){
2-
module.exports = require('./lib/jsdoc-to-json-schema.js');
3-
}
4-
else {
1+
if (module.parent) {
2+
module.exports = require('./lib/jsdoc-to-json-schema.js');
3+
}
4+
else {
55

6-
var program = require('commander'),
7-
pjson = require('./package.json');
6+
var program = require('commander');
7+
var pjson = require('./package.json');
88

9-
program.version(pjson.version)
9+
program.version(pjson.version)
1010
.option('-i, --input <string>', 'path to input file or folder')
1111
.option('-o, --output <string>', 'path to output file or folder')
1212
.parse(process.argv);
13-
14-
module.exports = new require('./lib/jsdoc-to-json-schema.js')(program.input, program.output);
15-
}
13+
14+
module.exports = new require('./lib/jsdoc-to-json-schema.js')(program.input, program.output);
15+
}

0 commit comments

Comments
 (0)