Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

eslint-plugin-mocha

Package Overview
Dependencies
Maintainers
2
Versions
63
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-mocha - npm Package Compare versions

Comparing version 4.1.0 to 4.2.0

lib/util/settings.js

6

CHANGELOG.md

@@ -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 @@

40

lib/rules/no-exclusive-tests.js
'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",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc