Skip to content

Commit

Permalink
style(eslint): Fix ESLint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
hicom150 committed Mar 18, 2019
1 parent d40463d commit eefaaa2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
15 changes: 7 additions & 8 deletions lib/preprocessor.js
Expand Up @@ -13,7 +13,6 @@ var _ = require('lodash')
var SourceMapConsumer = require('source-map').SourceMapConsumer
var SourceMapGenerator = require('source-map').SourceMapGenerator
var globalSourceCache = require('./source-cache')
var extend = require('util')._extend
var coverageMap = require('./coverage-map')

// Regexes
Expand All @@ -29,13 +28,13 @@ function createCoveragePreprocessor (logger, helper, basePath, reporters, covera
// -------

var instrumenterOverrides = {}
var instrumenters = {istanbul: istanbul}
var instrumenters = { istanbul: istanbul }
var includeAllSources = false
var useJSExtensionForCoffeeScript = false

if (coverageReporter) {
instrumenterOverrides = coverageReporter.instrumenter
instrumenters = extend({istanbul: istanbul}, coverageReporter.instrumenters)
instrumenters = Object.assign({}, { istanbul: istanbul }, coverageReporter.instrumenters)
includeAllSources = coverageReporter.includeAllSources === true
useJSExtensionForCoffeeScript = coverageReporter.useJSExtensionForCoffeeScript === true
}
Expand Down Expand Up @@ -84,7 +83,7 @@ function createCoveragePreprocessor (logger, helper, basePath, reporters, covera
var instrumenterLiteral = 'istanbul'

_.forEach(instrumenterOverrides, function (literal, pattern) {
if (minimatch(file.originalPath, pattern, {dot: true})) {
if (minimatch(file.originalPath, pattern, { dot: true })) {
instrumenterLiteral = String(literal)
}
})
Expand All @@ -95,7 +94,7 @@ function createCoveragePreprocessor (logger, helper, basePath, reporters, covera

if (file.sourceMap) {
log.debug('Enabling source map generation for "%s".', file.originalPath)
codeGenerationOptions = extend({
codeGenerationOptions = Object.assign({}, {
format: {
compact: !constructOptions.noCompact
},
Expand All @@ -105,8 +104,8 @@ function createCoveragePreprocessor (logger, helper, basePath, reporters, covera
}, constructOptions.codeGenerationOptions || {})
}

var options = extend({}, constructOptions)
options = extend(options, {codeGenerationOptions: codeGenerationOptions})
var options = Object.assign({}, constructOptions)
options = Object.assign({}, options, { codeGenerationOptions: codeGenerationOptions })

var instrumenter = new InstrumenterConstructor(options)
instrumenter.instrument(content, jsPath, function (err, instrumentedCode) {
Expand All @@ -120,7 +119,7 @@ function createCoveragePreprocessor (logger, helper, basePath, reporters, covera
generator.applySourceMap(new SourceMapConsumer(file.sourceMap))
file.sourceMap = JSON.parse(generator.toString())
instrumentedCode += '\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,'
instrumentedCode += new Buffer(JSON.stringify(file.sourceMap)).toString('base64') + '\n'
instrumentedCode += Buffer.from(JSON.stringify(file.sourceMap)).toString('base64') + '\n'
}

// remember the actual immediate instrumented JS for given original path
Expand Down
10 changes: 5 additions & 5 deletions lib/reporter.js
Expand Up @@ -98,7 +98,7 @@ var CoverageReporter = function (rootConfig, helper, logger, emitter) {
Object.keys(covObj).forEach(function (key) {
// Do any patterns match the resolved key
var found = patterns.some(function (pattern) {
return minimatch(normalize(key), pattern, {dot: true})
return minimatch(normalize(key), pattern, { dot: true })
})

// if no patterns match, keep the key
Expand All @@ -115,7 +115,7 @@ var CoverageReporter = function (rootConfig, helper, logger, emitter) {

// First match wins
Object.keys(overrides).some(function (pattern) {
if (minimatch(normalize(key), pattern, {dot: true})) {
if (minimatch(normalize(key), pattern, { dot: true })) {
thresholds = overrides[pattern]
return true
}
Expand Down Expand Up @@ -283,7 +283,7 @@ var CoverageReporter = function (rootConfig, helper, logger, emitter) {
})
var reporter = istanbul.Report.create(reporterConfig.type || 'html', options)

// If reporting to console or in-memory skip directory creation
// If reporting to console or in-memory skip directory creation
var toDisk = !reporterConfig.type || !reporterConfig.type.match(/^(text|text-summary|in-memory)$/)
var hasNoFile = _.isUndefined(reporterConfig.file)

Expand All @@ -307,8 +307,8 @@ var CoverageReporter = function (rootConfig, helper, logger, emitter) {
if (pendingFileWritings) {
fileWritingFinished = (
typeof config._onExit === 'function'
? (function (done) { return function () { config._onExit(done) } }(done))
: done
? (function (done) { return function () { config._onExit(done) } }(done))
: done
)
} else {
(typeof config._onExit === 'function' ? config._onExit(done) : done())
Expand Down
3 changes: 3 additions & 0 deletions package.json
Expand Up @@ -57,6 +57,9 @@
"sinon": "^1.14.1",
"sinon-chai": "^2.8.0"
},
"engines": {
"node": ">=6.0.0"
},
"contributors": [
"dignifiedquire <dignifiedquire@gmail.com>",
"Friedel Ziegelmayer <dignifiedquire@gmail.com>",
Expand Down

0 comments on commit eefaaa2

Please sign in to comment.