eslint-plugin-jasmine
Advanced tools
Comparing version 1.2.0 to 1.3.0
@@ -24,6 +24,6 @@ # Disallow the use of duplicate suite names (no-suite-dupes) | ||
describe("Unique parent", function(){ | ||
// ... | ||
describe("Same suite name", function() {}); | ||
}); | ||
describe("Different parent", function(){ | ||
// ... | ||
describe("Same suite name", function() {}); | ||
}); | ||
@@ -30,0 +30,0 @@ ``` |
@@ -7,3 +7,4 @@ 'use strict'; | ||
'no-disabled-tests': require('./lib/rules/no-disabled-tests'), | ||
'no-suite-dupes': require('./lib/rules/no-suite-dupes') | ||
'no-suite-dupes': require('./lib/rules/no-suite-dupes'), | ||
'no-spec-dupes': require('./lib/rules/no-spec-dupes') | ||
}, | ||
@@ -13,4 +14,5 @@ rulesConfig: { | ||
'no-disabled-tests': 1, | ||
'no-suite-dupes': 1 | ||
'no-suite-dupes': 1, | ||
'no-spec-dupes': 1 | ||
} | ||
}; |
@@ -7,54 +7,11 @@ 'use strict'; | ||
*/ | ||
module.exports = function(context) { | ||
var suites = []; | ||
var branch = []; | ||
var branchMode = context.options[0] === 'branch'; | ||
function notJasmine(node) { | ||
return node.callee.name !== 'describe' || !node.arguments; | ||
} | ||
var branchBlocks = [ | ||
'describe' | ||
]; | ||
return { | ||
'CallExpression': function(node) { | ||
if (notJasmine(node)) { | ||
return; | ||
} | ||
var checkedBlocks = [ | ||
'describe' | ||
]; | ||
var block = node.arguments[0].value; | ||
var suite; | ||
if (branchMode) { | ||
branch.push(block); | ||
suite = branch.join(' '); | ||
} else { | ||
suite = block; | ||
} | ||
if (suites.indexOf(suite) !== -1) { | ||
context.report(node, 'Duplicate suite: "{{suite}}"', { | ||
suite: suite | ||
}); | ||
} | ||
suites.push(suite); | ||
}, | ||
'CallExpression:exit': function(node) { | ||
if (notJasmine(node)) { | ||
return; | ||
} | ||
if (branchMode) { | ||
branch.pop(); | ||
} | ||
} | ||
}; | ||
}; | ||
module.exports.schema = [ | ||
{ | ||
enum: [ | ||
'block', | ||
'branch' | ||
] | ||
} | ||
]; | ||
module.exports = require('../no-dupes')('suite', branchBlocks, checkedBlocks); |
@@ -41,3 +41,3 @@ { | ||
}, | ||
"version": "1.2.0" | ||
"version": "1.3.0" | ||
} |
@@ -33,2 +33,3 @@ # eslint-plugin-jasmine | ||
[no-disabled-tests][] | 1 | | ||
[no-spec-dupes][] | 1, 'block' | ['block', 'branch'] | ||
[no-suite-dupes][] | 1, 'block' | ['block', 'branch'] | ||
@@ -56,2 +57,3 @@ | ||
[no-disabled-tests]: docs/rules/no-disabled-tests.md | ||
[no-spec-dupes]: docs/rules/no-spec-dupes.md | ||
[no-suite-dupes]: docs/rules/no-suite-dupes.md | ||
@@ -58,0 +60,0 @@ [configuring rules]: http://eslint.org/docs/user-guide/configuring#configuring-rules |
@@ -27,2 +27,14 @@ 'use strict'; | ||
]), | ||
toCode([ | ||
'unrelated("The first spec name", function() {}); ', | ||
'unrelated("The second spec name", function() {})' | ||
], 'unrelated'), | ||
toCode([ | ||
// used to cause bug | ||
'justAFunction();' | ||
], 'a regular function'), | ||
toCode([ | ||
'describe("Handling" + " string " + "concatenation", function() {}); ', | ||
'describe("Handling" + " it good", function() {})' | ||
], 'description is concatenated string'), | ||
{ | ||
@@ -120,2 +132,14 @@ code: toCode([ | ||
}, | ||
{ | ||
code: toCode([ | ||
'describe("Handling" + " string " + "concatenation", function() {}); ', | ||
'describe("Handling string concatenation", function() {})' | ||
], 'description is concatenated string'), | ||
errors: [ | ||
{ | ||
message: 'Duplicate suite: "Handling string concatenation"', | ||
type: 'CallExpression' | ||
} | ||
] | ||
}, | ||
@@ -122,0 +146,0 @@ // 'block' |
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
25842
26
705
67