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

eslint-plugin-jasmine

Package Overview
Dependencies
Maintainers
1
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-jasmine - npm Package Compare versions

Comparing version 2.8.2 to 2.8.3

3

docs/rules/no-global-setup.md

@@ -5,2 +5,5 @@ # Disallow using setup and teardown methods outside a suite

The only appropriate use of these methods in a global context is within jasmine helpers where the intent of the global definition is explicit (e.g. setting up globally applied matchers).
See example: [/jasmine/jasmine/lib/jasmine-core/example/node_example/spec/helpers/jasmine_examples/SpecHelper.js](https://github.com/jasmine/jasmine/blob/8624a52ee0b6f13b3b608ea6417ccc02257c5412/lib/jasmine-core/example/node_example/spec/helpers/jasmine_examples/SpecHelper.js)
## Rule details

@@ -7,0 +10,0 @@

@@ -13,13 +13,18 @@ 'use strict'

var suiteDepth = 0
var hasGlobalSetup = false
var hasRootSuite = false
var globalSetupNodes = []
return {
CallExpression: function (node) {
if (suiteRegexp.test(node.callee.name)) {
hasRootSuite = true
suiteDepth++
} else if (setupRegexp.test(node.callee.name) && suiteDepth === 0) {
context.report({
data: {
name: node.callee.name
},
message: 'Do not use `{{name}}` outside a `describe`.',
node
hasGlobalSetup = true
globalSetupNodes.push({
name: node.callee.name,
loc: {
line: node.loc.line,
column: node.loc.column
}
})

@@ -32,4 +37,18 @@ }

}
},
'Program:exit': function () {
if (hasGlobalSetup && hasRootSuite) {
for (var i = 0, nodeDetail, len = globalSetupNodes.length; i < len; i++) {
nodeDetail = globalSetupNodes[i]
context.report({
data: {
name: nodeDetail.name
},
message: 'Do not use `{{name}}` outside a `describe` except for in global helpers.',
loc: nodeDetail.loc
})
}
}
}
}
}

2

package.json

@@ -54,3 +54,3 @@ {

},
"version": "2.8.2"
"version": "2.8.3"
}

@@ -9,15 +9,26 @@ 'use strict'

eslintTester.run('no-global-setup', rule, {
valid: [
'describe("", function() { beforeEach(function() {}) })'
],
invalid: [
{
code: 'beforeEach(function() {})',
errors: [{message: 'Do not use `beforeEach` outside a `describe`.'}]
},
{
code: 'afterEach(function() {})',
errors: [{message: 'Do not use `afterEach` outside a `describe`.'}]
}
]
valid: [{
code: 'describe("", function() { beforeEach(function() {}) })'
}, {
code: 'beforeEach(function() {})'
}, {
code: 'beforeEach(function() {}); afterEach(function() {})'
}],
invalid: [{
code: 'beforeEach(function() {}); describe(function() {})',
errors: [{
message: 'Do not use `beforeEach` outside a `describe` except for in global helpers.'
}]
}, {
code: 'beforeEach(function() {}); afterEach(function() {}); beforeAll(function() {}); afterAll(function() {}); describe(function() {})',
errors: [{
message: 'Do not use `beforeEach` outside a `describe` except for in global helpers.'
}, {
message: 'Do not use `afterEach` outside a `describe` except for in global helpers.'
}, {
message: 'Do not use `beforeAll` outside a `describe` except for in global helpers.'
}, {
message: 'Do not use `afterAll` outside a `describe` except for in global helpers.'
}]
}]
})
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