Skip to content

Commit

Permalink
chore: update ESLint packages (#3517)
Browse files Browse the repository at this point in the history
Most of the changes are automatic fixes from `npm run lint:fix`. The only non-trivial change is to `.hasOwnProperty()`, which is now reported by recommended ESLint rules. See [no-prototype-builtins](https://eslint.org/docs/rules/no-prototype-builtins) for more details.
  • Loading branch information
devoto13 authored May 19, 2020
1 parent 1c09f1c commit 5bb19a8
Show file tree
Hide file tree
Showing 22 changed files with 623 additions and 298 deletions.
2 changes: 1 addition & 1 deletion client/karma.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ function Karma (socket, iframe, opener, navigator, location, document) {

// Convert all array-like objects to real arrays.
for (var propertyName in originalResult) {
if (originalResult.hasOwnProperty(propertyName)) {
if (Object.prototype.hasOwnProperty.call(originalResult, propertyName)) {
var propertyValue = originalResult[propertyName]

if (Object.prototype.toString.call(propertyValue) === '[object Array]') {
Expand Down
2 changes: 1 addition & 1 deletion cucumber.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ const options = [
]

module.exports = {
'default': options.join(' ')
default: options.join(' ')
}
2 changes: 1 addition & 1 deletion lib/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class Browser {

reconnect (newSocket) {
if (this.state === EXECUTING_DISCONNECTED) {
this.log.debug(`Lost socket connection, but browser continued to execute. Reconnected ` +
this.log.debug('Lost socket connection, but browser continued to execute. Reconnected ' +
`on socket ${newSocket.id}.`)
this.setState(EXECUTING)
} else if ([CONNECTED, CONFIGURING, EXECUTING].includes(this.state)) {
Expand Down
2 changes: 1 addition & 1 deletion lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ function normalizeConfig (config, configFilePath) {
config.protocol = 'http:'
}

if (config.proxies && config.proxies.hasOwnProperty(config.urlRoot)) {
if (config.proxies && Object.prototype.hasOwnProperty.call(config.proxies, config.urlRoot)) {
log.warn(`"${config.urlRoot}" is proxied, you should probably change urlRoot to avoid conflicts`)
}

Expand Down
7 changes: 3 additions & 4 deletions lib/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,9 @@ exports.mmPatternWeight = (pattern) => {
}

exports.mmComparePatternWeights = (weight1, weight2) => {
let n1, n2, diff
n1 = weight1[0]
n2 = weight2[0]
diff = n1 - n2
const n1 = weight1[0]
const n2 = weight2[0]
const diff = n1 - n2
if (diff !== 0) return diff / Math.abs(diff)
return weight1.length > 1 ? exports.mmComparePatternWeights(weight1.slice(1), weight2.slice(1)) : 0
}
Expand Down
2 changes: 1 addition & 1 deletion lib/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ var questions = [{
condition: (answers) => answers.requirejs
}, {
id: 'includedFiles',
question: `Which files do you want to include with <script> tag ?`,
question: 'Which files do you want to include with <script> tag ?',
hint: 'This should be a script that bootstraps your test by configuring Require.js and ' +
'kicking __karma__.start(), probably your test-main.js file.\n' +
'Enter empty string to move to the next question.',
Expand Down
14 changes: 7 additions & 7 deletions lib/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ function setup (level, colors, appenders) {
const pattern = colors ? constant.COLOR_PATTERN : constant.NO_COLOR_PATTERN
if (appenders) {
// Convert Array to Object for backwards compatibility.
if (appenders['map']) {
if (appenders.map) {
if (appenders.length === 0) {
appenders = [constant.CONSOLE_APPENDER]
}
const v1Appenders = appenders
appenders = {}
v1Appenders.forEach(function (appender, index) {
if (appender.type === 'console') {
appenders['console'] = appender
appenders.console = appender
if (helper.isDefined(appender.layout) && appender.layout.type === 'pattern') {
appender.layout.pattern = pattern
}
Expand All @@ -45,15 +45,15 @@ function setup (level, colors, appenders) {
})
}
} else {
appenders = { 'console': constant.CONSOLE_APPENDER }
appenders = { console: constant.CONSOLE_APPENDER }
}

log4js.configure({
appenders: appenders,
categories: {
'default': {
'appenders': Object.keys(appenders),
'level': level
default: {
appenders: Object.keys(appenders),
level: level
}
}
})
Expand Down Expand Up @@ -93,7 +93,7 @@ const loggerCache = {}
function create (name, level) {
name = name || 'karma'
let logger
if (loggerCache.hasOwnProperty(name)) {
if (Object.prototype.hasOwnProperty.call(loggerCache, name)) {
logger = loggerCache[name]
} else {
logger = log4js.getLogger(name)
Expand Down
12 changes: 6 additions & 6 deletions lib/middleware/karma.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ const common = require('./common')

const VERSION = require('../constants').VERSION
const SCRIPT_TYPE = {
'js': 'text/javascript',
'dart': 'application/dart',
'module': 'module'
js: 'text/javascript',
dart: 'application/dart',
module: 'module'
}
const FILE_TYPES = [
'css',
Expand Down Expand Up @@ -84,7 +84,7 @@ function createKarmaMiddleware (
request.normalizedUrl = normalizedUrl

let requestUrl = normalizedUrl.replace(/\?.*/, '')
const requestedRangeHeader = request.headers['range']
const requestedRangeHeader = request.headers.range

// redirect /__karma__ to /__karma__ (trailing slash)
if (requestUrl === urlRoot.substr(0, urlRoot.length - 1)) {
Expand Down Expand Up @@ -167,9 +167,9 @@ function createKarmaMiddleware (
if (!FILE_TYPES.includes(fileType)) {
if (file.type == null) {
log.warn(
`Unable to determine file type from the file extension, defaulting to js.\n` +
'Unable to determine file type from the file extension, defaulting to js.\n' +
` To silence the warning specify a valid type for ${file.originalPath} in the configuration file.\n` +
` See http://karma-runner.github.io/latest/config/files.html`
' See http://karma-runner.github.io/latest/config/files.html'
)
} else {
log.warn(`Invalid file type (${file.type || 'empty string'}), defaulting to js.`)
Expand Down
2 changes: 1 addition & 1 deletion lib/middleware/source_files.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function createSourceFilesMiddleware (filesPromise, serveFile, basePath, urlRoot
return filesPromise.then(function (files) {
// TODO(vojta): change served to be a map rather then an array
const file = findByPath(files.served, requestedFilePath) || findByPath(files.served, requestedFilePathUnescaped)
const rangeHeader = request.headers['range']
const rangeHeader = request.headers.range

if (file) {
const acceptEncodingHeader = request.headers['accept-encoding']
Expand Down
2 changes: 1 addition & 1 deletion lib/preprocessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function executeProcessor (process, file, content) {

async function runProcessors (preprocessors, file, content) {
try {
for (let process of preprocessors) {
for (const process of preprocessors) {
content = await executeProcessor(process, file, content)
}
} catch (error) {
Expand Down
2 changes: 1 addition & 1 deletion lib/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function run (config, done) {
config = cfg.parseConfig(config.configFile, config)

let exitCode = 1
let emitter = new EventEmitter()
const emitter = new EventEmitter()
const options = {
hostname: config.hostname,
path: config.urlRoot + 'run',
Expand Down
Loading

0 comments on commit 5bb19a8

Please sign in to comment.