Skip to content

Commit

Permalink
chore(eslint): enable no-var rule
Browse files Browse the repository at this point in the history
  • Loading branch information
Guillaume Chau committed Oct 30, 2019
1 parent 15bb71b commit edd42a9
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 47 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ module.exports = {
'vue/html-closing-bracket-newline': ['error', {
'singleline': 'never',
'multiline': 'always'
}]
}],
'no-var': ['error']
}
}
32 changes: 16 additions & 16 deletions packages/app-backend/src/clone.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ export default function clone (parent, {
} = {}) {
// maintain two arrays for circular references, where corresponding parents
// and children have the same index
var allParents = []
var allChildren = []
let allParents = []
let allChildren = []

var useBuffer = typeof Buffer !== 'undefined' && typeof Buffer.isBuffer === 'function'
let useBuffer = typeof Buffer !== 'undefined' && typeof Buffer.isBuffer === 'function'

const isBuffer = typeof window !== 'undefined' ? browserIsBuffer : Buffer.isBuffer

Expand All @@ -46,8 +46,8 @@ export default function clone (parent, {

if (depth === 0) { return parent }

var child
var proto
let child
let proto
if (typeof parent !== 'object') {
return parent
}
Expand Down Expand Up @@ -95,7 +95,7 @@ export default function clone (parent, {
}

if (circular) {
var index = allParents.indexOf(parent)
let index = allParents.indexOf(parent)

if (index !== -1) {
return allChildren[index]
Expand All @@ -106,20 +106,20 @@ export default function clone (parent, {

if (_instanceof(parent, NativeMap)) {
parent.forEach(function (value, key) {
var keyChild = _clone(key, depth - 1)
var valueChild = _clone(value, depth - 1)
let keyChild = _clone(key, depth - 1)
let valueChild = _clone(value, depth - 1)
child.set(keyChild, valueChild)
})
}
if (_instanceof(parent, NativeSet)) {
parent.forEach(function (value) {
var entryChild = _clone(value, depth - 1)
let entryChild = _clone(value, depth - 1)
child.add(entryChild)
})
}

for (var i in parent) {
var attrs = Object.getOwnPropertyDescriptor(parent, i)
for (let i in parent) {
let attrs = Object.getOwnPropertyDescriptor(parent, i)
if (attrs) {
if (attrs.hasOwnProperty('get') && attrs.get.name === 'computedGetter') {
Object.defineProperty(child, i, attrs)
Expand All @@ -131,12 +131,12 @@ export default function clone (parent, {
}

if (Object.getOwnPropertySymbols) {
var symbols = Object.getOwnPropertySymbols(parent)
let symbols = Object.getOwnPropertySymbols(parent)
for (let i = 0; i < symbols.length; i++) {
// Don't need to worry about cloning a symbol because it is a primitive,
// like a number or string.
var symbol = symbols[i]
var descriptor = Object.getOwnPropertyDescriptor(parent, symbol)
let symbol = symbols[i]
let descriptor = Object.getOwnPropertyDescriptor(parent, symbol)
if (descriptor && !descriptor.enumerable && !includeNonEnumerable) {
continue
}
Expand All @@ -146,7 +146,7 @@ export default function clone (parent, {
}

if (includeNonEnumerable) {
var allPropertyNames = Object.getOwnPropertyNames(parent)
let allPropertyNames = Object.getOwnPropertyNames(parent)
for (let i = 0; i < allPropertyNames.length; i++) {
const propertyName = allPropertyNames[i]
let descriptor = Object.getOwnPropertyDescriptor(parent, propertyName)
Expand Down Expand Up @@ -187,7 +187,7 @@ function __isRegExp (o) {
clone.__isRegExp = __isRegExp

function __getRegExpFlags (re) {
var flags = ''
let flags = ''
if (re.global) flags += 'g'
if (re.ignoreCase) flags += 'i'
if (re.multiline) flags += 'm'
Expand Down
34 changes: 17 additions & 17 deletions packages/app-backend/src/hook.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,12 @@ export function installHook (target) {
}
// maintain two arrays for circular references, where corresponding parents
// and children have the same index
var allParents = []
var allChildren = []
let allParents = []
let allChildren = []

var useBuffer = typeof Buffer !== 'undefined' && typeof Buffer.isBuffer === 'function'
let useBuffer = typeof Buffer !== 'undefined' && typeof Buffer.isBuffer === 'function'

var isBuffer = typeof window !== 'undefined' ? browserIsBuffer : Buffer.isBuffer
let isBuffer = typeof window !== 'undefined' ? browserIsBuffer : Buffer.isBuffer

if (typeof circular === 'undefined') { circular = true }

Expand All @@ -194,8 +194,8 @@ export function installHook (target) {

if (depth === 0) { return parent }

var child
var proto
let child
let proto
if (typeof parent !== 'object') {
return parent
}
Expand Down Expand Up @@ -243,7 +243,7 @@ export function installHook (target) {
}

if (circular) {
var index = allParents.indexOf(parent)
let index = allParents.indexOf(parent)

if (index !== -1) {
return allChildren[index]
Expand All @@ -254,20 +254,20 @@ export function installHook (target) {

if (_instanceof(parent, NativeMap)) {
parent.forEach(function (value, key) {
var keyChild = _clone(key, depth - 1)
var valueChild = _clone(value, depth - 1)
let keyChild = _clone(key, depth - 1)
let valueChild = _clone(value, depth - 1)
child.set(keyChild, valueChild)
})
}
if (_instanceof(parent, NativeSet)) {
parent.forEach(function (value) {
var entryChild = _clone(value, depth - 1)
let entryChild = _clone(value, depth - 1)
child.add(entryChild)
})
}

for (var i in parent) {
var attrs = Object.getOwnPropertyDescriptor(parent, i)
for (let i in parent) {
let attrs = Object.getOwnPropertyDescriptor(parent, i)
if (attrs) {
if (attrs.hasOwnProperty('get') && attrs.get.name === 'computedGetter') {
Object.defineProperty(child, i, attrs)
Expand All @@ -279,12 +279,12 @@ export function installHook (target) {
}

if (Object.getOwnPropertySymbols) {
var symbols = Object.getOwnPropertySymbols(parent)
let symbols = Object.getOwnPropertySymbols(parent)
for (let i = 0; i < symbols.length; i++) {
// Don't need to worry about cloning a symbol because it is a primitive,
// like a number or string.
var symbol = symbols[i]
var descriptor = Object.getOwnPropertyDescriptor(parent, symbol)
let symbol = symbols[i]
let descriptor = Object.getOwnPropertyDescriptor(parent, symbol)
if (descriptor && !descriptor.enumerable && !includeNonEnumerable) {
continue
}
Expand All @@ -294,7 +294,7 @@ export function installHook (target) {
}

if (includeNonEnumerable) {
var allPropertyNames = Object.getOwnPropertyNames(parent)
let allPropertyNames = Object.getOwnPropertyNames(parent)
for (let i = 0; i < allPropertyNames.length; i++) {
const propertyName = allPropertyNames[i]
let descriptor = Object.getOwnPropertyDescriptor(parent, propertyName)
Expand Down Expand Up @@ -335,7 +335,7 @@ export function installHook (target) {
clone.__isRegExp = __isRegExp

function __getRegExpFlags (re) {
var flags = ''
let flags = ''
if (re.global) flags += 'g'
if (re.ignoreCase) flags += 'i'
if (re.multiline) flags += 'm'
Expand Down
6 changes: 3 additions & 3 deletions packages/app-backend/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,7 @@ function processVuexGetters (instance) {
*/

function processFirebaseBindings (instance) {
var refs = instance.$firebaseRefs
const refs = instance.$firebaseRefs
if (refs) {
return Object.keys(refs).map(key => {
return {
Expand All @@ -871,7 +871,7 @@ function processFirebaseBindings (instance) {
*/

function processObservables (instance) {
var obs = instance.$observables
const obs = instance.$observables
if (obs) {
return Object.keys(obs).map(key => {
return {
Expand Down Expand Up @@ -919,7 +919,7 @@ function bindToConsole (instance) {
}

consoleBoundInstances.unshift(id)
for (var i = 0; i < 5; i++) {
for (let i = 0; i < 5; i++) {
window['$vm' + i] = instanceMap.get(consoleBoundInstances[i])
}
window.$vm = instance
Expand Down
2 changes: 1 addition & 1 deletion packages/app-frontend/src/components/DataField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ export default {
} else if (this.valueType.includes('native')) {
return escape(specialTypeRE.exec(value)[2])
} else if (typeof value === 'string') {
var typeMatch = value.match(rawTypeRE)
const typeMatch = value.match(rawTypeRE)
if (typeMatch) {
value = escape(typeMatch[1])
} else {
Expand Down
5 changes: 4 additions & 1 deletion packages/app-frontend/src/components/StateFields.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ export default {
required: true
},
forceCollapse: String
forceCollapse: {
type: String,
default: null
}
},
data () {
Expand Down
2 changes: 1 addition & 1 deletion packages/app-frontend/src/views/routes/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const getters = {
if (typeof state.inspectedIndex === 'string') {
const path = state.inspectedIndex.split('_')
let obj = state.routeChanges[parseInt(path[0])]
for (var i = 1, len = path.length; i < len; ++i) {
for (let i = 1, len = path.length; i < len; ++i) {
obj = obj.children[parseInt(path[i])]
}
return obj
Expand Down
6 changes: 3 additions & 3 deletions packages/shared-utils/src/transfer.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,20 +82,20 @@ export function parse (data, reviver) {
if (Array.isArray(data)) {
data = data.join('')
}
var hasCircular = /^\s/.test(data)
const hasCircular = /^\s/.test(data)
if (!hasCircular) {
return arguments.length === 1
? JSON.parse(data)
: JSON.parse(data, reviver)
} else {
var list = JSON.parse(data)
const list = JSON.parse(data)
decode(list, reviver)
return list[0]
}
}

export function stringifyStrict (data, replacer, space) {
var list = []
const list = []
encode(data, replacer, list, new Map())
return space
? ' ' + JSON.stringify(list, null, space)
Expand Down
6 changes: 3 additions & 3 deletions packages/shared-utils/src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function cached (fn) {
}
}

var classifyRE = /(?:^|[-_/])(\w)/g
const classifyRE = /(?:^|[-_/])(\w)/g
export const classify = cached((str) => {
return str && str.replace(classifyRE, toUpper)
})
Expand Down Expand Up @@ -51,8 +51,8 @@ export function getComponentDisplayName (originalName, style = 'class') {

export function inDoc (node) {
if (!node) return false
var doc = node.ownerDocument.documentElement
var parent = node.parentNode
const doc = node.ownerDocument.documentElement
const parent = node.parentNode
return doc === node ||
doc === parent ||
!!(parent && parent.nodeType === 1 && (doc.contains(parent)))
Expand Down
2 changes: 1 addition & 1 deletion packages/shell-chrome/src/backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function handshake (e) {
let listeners = []
const bridge = new Bridge({
listen (fn) {
var listener = evt => {
const listener = evt => {
if (evt.data.source === 'vue-devtools-proxy' && evt.data.payload) {
fn(evt.data.payload)
}
Expand Down

0 comments on commit edd42a9

Please sign in to comment.