broccoli-lint-eslint
Advanced tools
Comparing version 3.3.0 to 3.3.1
'use strict'; | ||
const escape = require('js-string-escape'); | ||
const testGenerators = require('aot-test-generators'); | ||
function render(errors) { | ||
return errors.map(error => `${error.line}:${error.column} - ${error.message} (${error.ruleId})`).join('\n'); | ||
} | ||
let _generators = {}; | ||
function qunit(relativePath, errors, results) { | ||
let passed = hasPassed(results); | ||
let message = createAssertionMessage(relativePath, results); | ||
Object.keys(testGenerators).forEach(name => { | ||
let testGenerator = testGenerators[name]; | ||
return `QUnit.module('ESLint | ${escape(relativePath)}');\n` + | ||
`QUnit.test('should pass ESLint', function(assert) {\n` + | ||
` assert.expect(1);\n` + | ||
` assert.ok(${passed}, '${escape(message)}');\n` + | ||
`});\n`; | ||
} | ||
_generators[name] = function(relativePath, errors, results) { | ||
let passed = hasPassed(results); | ||
let message = createAssertionMessage(relativePath, results); | ||
qunit.testOnly = function(relativePath, errors, results) { | ||
let passed = hasPassed(results); | ||
let message = createAssertionMessage(relativePath, results); | ||
return ( | ||
testGenerator.suiteHeader(`ESLint | ${relativePath}`) + | ||
testGenerator.test('should pass ESLint', passed, message) + | ||
testGenerator.suiteFooter() | ||
); | ||
}; | ||
return `QUnit.test('${escape(relativePath)}', function(assert) {\n` + | ||
` assert.expect(1);\n` + | ||
` assert.ok(${passed}, '${escape(message)}');\n` + | ||
`});\n`; | ||
}; | ||
_generators[name].testOnly = function(relativePath, errors, results) { | ||
let passed = hasPassed(results); | ||
let message = createAssertionMessage(relativePath, results); | ||
qunit.header = function(group) { | ||
return `QUnit.module('ESLint | ${escape(group)}');\n`; | ||
}; | ||
return testGenerator.test(relativePath, passed, message); | ||
}; | ||
qunit.footer = function() { | ||
return ''; | ||
}; | ||
_generators[name].header = function(group) { | ||
return testGenerator.suiteHeader(`ESLint | ${group}`); | ||
}; | ||
function mocha(relativePath, errors, results) { | ||
let passed = hasPassed(results); | ||
let message = createAssertionMessage(relativePath, results); | ||
_generators[name].footer = function() { | ||
return testGenerator.suiteFooter(); | ||
}; | ||
}); | ||
return ( | ||
`describe('ESLint | ${escape(relativePath)}', function() {\n` + | ||
` it('should pass ESLint', function() {\n` + | ||
mochaAssertion(passed, message) + | ||
` });\n` + | ||
`});\n` | ||
); | ||
function render(errors) { | ||
return errors.map(error => `${error.line}:${error.column} - ${error.message} (${error.ruleId})`).join('\n'); | ||
} | ||
mocha.testOnly = function(relativePath, errors, results) { | ||
let passed = hasPassed(results); | ||
let message = createAssertionMessage(relativePath, results); | ||
return ( | ||
` it('${escape(relativePath)}', function() {\n` + | ||
mochaAssertion(passed, message) + | ||
` });\n` | ||
); | ||
}; | ||
mocha.header = function(group) { | ||
return `describe('ESLint | ${escape(group)}', function() {\n`; | ||
}; | ||
mocha.footer = function() { | ||
return '});\n'; | ||
}; | ||
function mochaAssertion(passed, message) { | ||
if (passed) { | ||
return ` // ESLint passed\n`; | ||
} | ||
return ( | ||
` // ESLint failed\n`+ | ||
` var error = new chai.AssertionError('${escape(message)}');\n` + | ||
` error.stack = undefined;\n` + | ||
` throw error;\n` | ||
); | ||
} | ||
function hasPassed(results) { | ||
@@ -97,2 +55,2 @@ return !results.errorCount || results.errorCount.length === 0; | ||
module.exports = { qunit, mocha }; | ||
module.exports = _generators; |
{ | ||
"name": "broccoli-lint-eslint", | ||
"version": "3.3.0", | ||
"version": "3.3.1", | ||
"description": "broccoli filter that runs eslint", | ||
@@ -36,6 +36,6 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"aot-test-generators": "^0.1.0", | ||
"broccoli-concat": "^3.2.2", | ||
"broccoli-persistent-filter": "^1.2.0", | ||
"eslint": "^3.0.0", | ||
"js-string-escape": "^1.0.1", | ||
"json-stable-stringify": "^1.0.1", | ||
@@ -58,3 +58,6 @@ "lodash.defaultsdeep": "^4.6.0", | ||
"sinon-chai": "^2.8.0" | ||
}, | ||
"publishConfig": { | ||
"tag": "latest" | ||
} | ||
} |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
0
31228
244
+ Addedaot-test-generators@^0.1.0
+ Addedaot-test-generators@0.1.0(transitive)
+ Addedjsesc@2.5.2(transitive)
- Removedjs-string-escape@^1.0.1
- Removedjs-string-escape@1.0.1(transitive)