eslint-plugin-mocha
Advanced tools
Comparing version 4.1.0 to 4.2.0
@@ -0,1 +1,7 @@ | ||
## 4.2.0 (July 26, 2016) | ||
### Features | ||
* Allow custom test functions (#81) | ||
## 4.1.0 (July 22, 2016) | ||
@@ -2,0 +8,0 @@ |
'use strict'; | ||
var getAdditionalTestFunctions = require('../util/settings').getAdditionalTestFunctions; | ||
module.exports = function (context) { | ||
var mochaTestFunctions = [ | ||
'it', | ||
'describe', | ||
'suite', | ||
'test', | ||
'context', | ||
'specify' | ||
]; | ||
'it', | ||
'describe', | ||
'suite', | ||
'test', | ||
'context', | ||
'specify' | ||
], | ||
settings = context.settings, | ||
additionalTestFunctions = getAdditionalTestFunctions(settings); | ||
mochaTestFunctions = mochaTestFunctions.concat(additionalTestFunctions); | ||
function matchesMochaTestFunction(object) { | ||
@@ -23,4 +29,4 @@ return object && mochaTestFunctions.indexOf(object.name) !== -1; | ||
return callee.type === 'MemberExpression' && | ||
matchesMochaTestFunction(callee.object) && | ||
isPropertyNamedOnly(callee.property); | ||
matchesMochaTestFunction(callee.object) && | ||
isPropertyNamedOnly(callee.property); | ||
} | ||
@@ -41,1 +47,17 @@ | ||
}; | ||
module.exports.schema = [ | ||
{ | ||
type: 'object', | ||
properties: { | ||
additionalTestFunctions: { | ||
type: 'array', | ||
items: { | ||
type: 'string' | ||
}, | ||
minItems: 1, | ||
uniqueItems: true | ||
} | ||
} | ||
} | ||
]; |
'use strict'; | ||
module.exports = function (context) { | ||
var mochaTestFunctions = [ | ||
'it', | ||
'describe', | ||
'suite', | ||
'test', | ||
'context', | ||
'specify' | ||
], | ||
mochaXFunctions = [ | ||
'xit', | ||
'xdescribe', | ||
'xcontext', | ||
'xspecify' | ||
]; | ||
var getAdditionalTestFunctions = require('../util/settings').getAdditionalTestFunctions, | ||
getAdditionalXFunctions = require('../util/settings').getAdditionalXFunctions, | ||
mochaTestFunctions, | ||
mochaXFunctions; | ||
function matchesMochaTestFunction(object) { | ||
return object && mochaTestFunctions.indexOf(object.name) !== -1; | ||
} | ||
function matchesMochaTestFunction(object) { | ||
return object && mochaTestFunctions.indexOf(object.name) !== -1; | ||
} | ||
function isPropertyNamedSkip(property) { | ||
return property && (property.name === 'skip' || property.value === 'skip'); | ||
} | ||
function isPropertyNamedSkip(property) { | ||
return property && (property.name === 'skip' || property.value === 'skip'); | ||
} | ||
function isCallToMochasSkipFunction(callee) { | ||
return callee.type === 'MemberExpression' && | ||
matchesMochaTestFunction(callee.object) && | ||
isPropertyNamedSkip(callee.property); | ||
} | ||
function isCallToMochasSkipFunction(callee) { | ||
return callee.type === 'MemberExpression' && | ||
matchesMochaTestFunction(callee.object) && | ||
isPropertyNamedSkip(callee.property); | ||
} | ||
function isMochaXFunction(name) { | ||
return mochaXFunctions.indexOf(name) !== -1; | ||
} | ||
function createSkipAutofixFunction(callee) { | ||
var endRangeOfMemberExpression = callee.range[1], | ||
endRangeOfMemberExpressionObject = callee.object.range[1], | ||
rangeToRemove = [ endRangeOfMemberExpressionObject, endRangeOfMemberExpression ]; | ||
function isCallToMochaXFunction(callee) { | ||
return callee.type === 'Identifier' && isMochaXFunction(callee.name); | ||
} | ||
return function removeSkipProperty(fixer) { | ||
return fixer.removeRange(rangeToRemove); | ||
}; | ||
} | ||
function createSkipAutofixFunction(callee) { | ||
var endRangeOfMemberExpression = callee.range[1], | ||
endRangeOfMemberExpressionObject = callee.object.range[1], | ||
rangeToRemove = [ endRangeOfMemberExpressionObject, endRangeOfMemberExpression ]; | ||
function createXAutofixFunction(callee) { | ||
var rangeToRemove = [ callee.range[0], callee.range[0] + 1 ]; | ||
return function removeSkipProperty(fixer) { | ||
return fixer.removeRange(rangeToRemove); | ||
}; | ||
} | ||
return function removeXPrefix(fixer) { | ||
return fixer.removeRange(rangeToRemove); | ||
}; | ||
} | ||
function createXAutofixFunction(callee) { | ||
var rangeToRemove = [ callee.range[0], callee.range[0] + 1 ]; | ||
function isMochaXFunction(name) { | ||
return mochaXFunctions.indexOf(name) !== -1; | ||
} | ||
return function removeXPrefix(fixer) { | ||
return fixer.removeRange(rangeToRemove); | ||
}; | ||
} | ||
function isCallToMochaXFunction(callee) { | ||
return callee.type === 'Identifier' && isMochaXFunction(callee.name); | ||
} | ||
module.exports = function (context) { | ||
var settings = context.settings, | ||
additionalTestFunctions = getAdditionalTestFunctions(settings), | ||
additionalXFunctions = getAdditionalXFunctions(settings); | ||
mochaTestFunctions = [ | ||
'it', | ||
'describe', | ||
'suite', | ||
'test', | ||
'context', | ||
'specify' | ||
].concat(additionalTestFunctions); | ||
mochaXFunctions = [ | ||
'xit', | ||
'xdescribe', | ||
'xcontext', | ||
'xspecify' | ||
].concat(additionalXFunctions); | ||
return { | ||
@@ -79,1 +88,25 @@ CallExpression: function (node) { | ||
}; | ||
module.exports.schema = [ | ||
{ | ||
type: 'object', | ||
properties: { | ||
additionalTestFunctions: { | ||
type: 'array', | ||
items: { | ||
type: 'string' | ||
}, | ||
minItems: 1, | ||
uniqueItems: true | ||
}, | ||
additionalXFunctions: { | ||
type: 'array', | ||
items: { | ||
type: 'string' | ||
}, | ||
minItems: 1, | ||
uniqueItems: true | ||
} | ||
} | ||
} | ||
]; |
{ | ||
"name": "eslint-plugin-mocha", | ||
"version": "4.1.0", | ||
"version": "4.2.0", | ||
"description": "Eslint rules for mocha.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
27943
19
464