eslint-plugin-ftgp
Advanced tools
Comparing version 1.3.1 to 1.3.2
@@ -162,3 +162,4 @@ /** | ||
unwrap: true, | ||
sloppy: true | ||
sloppy: true, | ||
lineNumbers: true | ||
}); | ||
@@ -189,4 +190,7 @@ } catch (ex) { | ||
var lines; | ||
var line; | ||
var col; | ||
jsdoc.tags.forEach(function(tag) { | ||
switch (tag.title.toLowerCase()) { | ||
@@ -198,6 +202,13 @@ | ||
if (!tag.type) { | ||
lines = jsdocNode.value.split('\n'); | ||
line = lines[tag.lineNumber]; | ||
col = line.indexOf(tag.name); | ||
context.report({ | ||
node: jsdocNode, | ||
message: 'Missing JSDoc parameter type for \'{{name}}\'.', | ||
data: {name: tag.name} | ||
data: {name: tag.name}, | ||
loc: { | ||
line: jsdocNode.loc.start.line + tag.lineNumber, | ||
col: col | ||
} | ||
}); | ||
@@ -207,15 +218,47 @@ } | ||
if (tag.name !== 'spec' && tag.name !== 'that' && tag.name !== 'my' && !tag.description && requireParamDescription) { | ||
lines = jsdocNode.value.split('\n'); | ||
line = lines[tag.lineNumber]; | ||
col = line.indexOf(tag.name) + tag.name.length; | ||
context.report({ | ||
node: jsdocNode, | ||
message: 'Missing JSDoc parameter description for \'{{name}}\'.', | ||
data: {name: tag.name} | ||
data: {name: tag.name}, | ||
loc: { | ||
line: jsdocNode.loc.start.line + tag.lineNumber, | ||
col: col | ||
} | ||
}); | ||
} | ||
var regexp = new RegExp('\[?' + tag.name + '\]?'+ "\ -\ "); | ||
var match = jsdocNode.value.match(regexp); | ||
if (tag.description && !match) { | ||
lines = jsdocNode.value.split('\n'); | ||
line = lines[tag.lineNumber]; | ||
col = line.indexOf(tag.name) + tag.name.length; | ||
context.report({ | ||
node: jsdocNode, | ||
message: 'JSDoc parameter description for \'{{name}}\' should start with \'-\'.', | ||
data: {name: tag.name}, | ||
loc: { | ||
line: jsdocNode.loc.start.line + tag.lineNumber, | ||
column: col | ||
} | ||
}); | ||
} | ||
if (params[tag.name] || specParams[tag.name]) { | ||
lines = jsdocNode.value.split('\n'); | ||
line = lines[tag.lineNumber]; | ||
col = line.indexOf('*'); | ||
context.report({ | ||
node: jsdocNode, | ||
message: 'Duplicate JSDoc parameter \'{{name}}\'.', | ||
data: {name: tag.name} | ||
}); | ||
data: {name: tag.name}, | ||
loc: { | ||
line: jsdocNode.loc.start.line + tag.lineNumber, | ||
col: col | ||
} | ||
}) | ||
} else if (tag.name.indexOf('.') === -1) { | ||
@@ -222,0 +265,0 @@ params[tag.name] = 1; |
{ | ||
"name": "eslint-plugin-ftgp", | ||
"version": "1.3.1", | ||
"version": "1.3.2", | ||
"description": "Custom rules for FTGP", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -5,4 +5,4 @@ module.exports = { | ||
' * Foo\n' + | ||
' * @param {string} spec.bar identifier\n' + | ||
' * @param {number} spec.baz number\n' + | ||
' * @param {string} spec.bar - identifier\n with long description\n' + | ||
' * @param {number} spec.baz - number\n' + | ||
' */\n' + | ||
@@ -22,9 +22,31 @@ 'model.subclass(function(that, my){\n' + | ||
' */\n' + | ||
'var bar = object.subclass(function(){});' | ||
'var bar = object.subclass(function(){});', | ||
optionalParams: '/**\n' + | ||
' * Foo\n' + | ||
' * @param {number} [spec.baz] - number\n' + | ||
' */\n' + | ||
'model.subclass(function(that, my){\n' + | ||
' my.initialize = function(spec) {\n' + | ||
' my.baz = spec.baz\n' + | ||
' };\n' + | ||
'})' | ||
}, | ||
invalid: { | ||
missingDash: { | ||
code: '/**\n' + | ||
' * Awesome description\n' + | ||
' * @param {boolean} foo Foo\n' + | ||
' */\n' + | ||
'model.subclass(function(){});', | ||
errors: [ | ||
{ | ||
message: 'JSDoc parameter description for \'foo\' should start with \'-\'.', | ||
type: 'Block' | ||
} | ||
] | ||
}, | ||
missingParams: { | ||
code: '/**\n' + | ||
' * Foo\n' + | ||
' * @param {string} spec.bar identifier\n' + | ||
' * @param {string} spec.bar - identifier\n' + | ||
' */\n' + | ||
@@ -47,4 +69,4 @@ 'model.subclass(function(that, my){\n' + | ||
' * Foo\n' + | ||
' * @param {string} spec.bar identifier\n' + | ||
' * @param {string} spec.baz identifier\n' + | ||
' * @param {string} spec.bar - identifier\n' + | ||
' * @param {string} spec.baz - identifier\n' + | ||
' */\n' + | ||
@@ -66,4 +88,4 @@ 'model.subclass(function(that, my){\n' + | ||
' * Foo\n' + | ||
' * @param {string} spec.bar identifier\n' + | ||
' * @param {string} spec.bar identifier\n' + | ||
' * @param {string} spec.bar - identifier\n' + | ||
' * @param {string} spec.bar - identifier\n' + | ||
' */\n' + | ||
@@ -97,2 +119,2 @@ 'model.subclass(function(that, my){\n' + | ||
} | ||
}; | ||
}; |
@@ -42,3 +42,4 @@ /** | ||
fixtures.valid.twoClasses, | ||
fixtures.valid.params | ||
fixtures.valid.params, | ||
fixtures.valid.optionalParams | ||
], | ||
@@ -77,3 +78,3 @@ | ||
" * Test\n" + | ||
" * @param foo {boolean}\n" + | ||
" * @param foo - another description\n" + | ||
" */\n" + | ||
@@ -117,4 +118,5 @@ "model.subclass(function(){})", | ||
fixtures.invalid.duplicateParams, | ||
fixtures.invalid.extraParams | ||
fixtures.invalid.extraParams, | ||
fixtures.invalid.missingDash | ||
] | ||
}); |
Sorry, the diff of this file is not supported yet
214847
5312