Skip to content
This repository has been archived by the owner on May 13, 2021. It is now read-only.

Commit

Permalink
fix: npm run lint
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Jul 10, 2020
1 parent 5431cef commit 4d60713
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 65 deletions.
4 changes: 2 additions & 2 deletions lib/decorators/element.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

const {registerOrUpdateElement} = require('atom-utils')
const { registerOrUpdateElement } = require('atom-utils')

/**
* Generates a decorator function to convert a class into a custom element
Expand Down Expand Up @@ -35,5 +35,5 @@ const {registerOrUpdateElement} = require('atom-utils')
* }
*/
module.exports = function element (cls, elementName) {
return registerOrUpdateElement(elementName, {class: cls})
return registerOrUpdateElement(elementName, { class: cls })
}
4 changes: 2 additions & 2 deletions lib/decorators/include.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ function includeMixin (target, source) {
Object.getOwnPropertyNames(source).forEach((k) => {
if (['length', 'name', 'arguments', 'caller', 'prototype', 'includeInto'].indexOf(k) >= 0) { return }

let descriptor = Object.getOwnPropertyDescriptor(source, k)
const descriptor = Object.getOwnPropertyDescriptor(source, k)
Object.defineProperty(target, k, descriptor)
})

Object.getOwnPropertyNames(source.prototype).forEach((k) => {
if (k === 'constructor') { return }

let descriptor = Object.getOwnPropertyDescriptor(source.prototype, k)
const descriptor = Object.getOwnPropertyDescriptor(source.prototype, k)
Object.defineProperty(target.prototype, k, descriptor)
})
}
20 changes: 10 additions & 10 deletions lib/mixins/canvas-drawer.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ module.exports = class CanvasDrawer extends Mixin {
const charHeight = this.minimap.getCharHeight() * devicePixelRatio
const charWidth = this.minimap.getCharWidth() * devicePixelRatio
const decorations = this.minimap.decorationsByTypeThenRows(firstRow, lastRow)
const {width: canvasWidth, height: canvasHeight} = this.tokensLayer.getSize()
const { width: canvasWidth, height: canvasHeight } = this.tokensLayer.getSize()
const renderData = {
context: this.backLayer.context,
canvasWidth: canvasWidth,
Expand All @@ -346,7 +346,7 @@ module.exports = class CanvasDrawer extends Mixin {
renderData.screenRow = screenRow

this.drawDecorations(screenRow, decorations, renderData, {
'line': this.drawLineDecoration,
line: this.drawLineDecoration,
'highlight-under': this.drawHighlightDecoration,
'background-custom': this.drawCustomDecoration
})
Expand Down Expand Up @@ -375,7 +375,7 @@ module.exports = class CanvasDrawer extends Mixin {
const charHeight = this.minimap.getCharHeight() * devicePixelRatio
const charWidth = this.minimap.getCharWidth() * devicePixelRatio
const decorations = this.minimap.decorationsByTypeThenRows(firstRow, lastRow)
const {width: canvasWidth, height: canvasHeight} = this.tokensLayer.getSize()
const { width: canvasWidth, height: canvasHeight } = this.tokensLayer.getSize()
const renderData = {
context: this.frontLayer.context,
canvasWidth: canvasWidth,
Expand All @@ -392,7 +392,7 @@ module.exports = class CanvasDrawer extends Mixin {
renderData.screenRow = screenRow

this.drawDecorations(screenRow, decorations, renderData, {
'gutter': this.drawGutterDecoration,
gutter: this.drawGutterDecoration,
'highlight-over': this.drawHighlightDecoration,
'highlight-outline': this.drawHighlightOutlineDecoration,
'foreground-custom': this.drawCustomDecoration
Expand Down Expand Up @@ -446,7 +446,7 @@ module.exports = class CanvasDrawer extends Mixin {
const charWidth = this.minimap.getCharWidth() * devicePixelRatio
const displayCodeHighlights = this.displayCodeHighlights
const context = this.tokensLayer.context
const {width: canvasWidth} = this.tokensLayer.getSize()
const { width: canvasWidth } = this.tokensLayer.getSize()

let lastLine, x
let y = (offsetRow * lineHeight) - lineHeight
Expand Down Expand Up @@ -482,8 +482,8 @@ module.exports = class CanvasDrawer extends Mixin {
* @access private
*/
getInvisibleRegExp () {
let invisibles = this.getTextEditor().getInvisibles()
let regexp = []
const invisibles = this.getTextEditor().getInvisibles()
const regexp = []
if (invisibles.cr != null) { regexp.push(invisibles.cr) }
if (invisibles.eol != null) { regexp.push(invisibles.eol) }
if (invisibles.space != null) { regexp.push(invisibles.space) }
Expand Down Expand Up @@ -558,7 +558,7 @@ module.exports = class CanvasDrawer extends Mixin {
renderData.canvasWidth, renderData.lineHeight
)

for (let i in types) {
for (const i in types) {
decorationsToRender = decorationsToRender.concat(
decorations[i] != null ? decorations[i][screenRow] || [] : []
)
Expand All @@ -568,7 +568,7 @@ module.exports = class CanvasDrawer extends Mixin {
(renderData.orders[a.properties.plugin] || 0) - (renderData.orders[b.properties.plugin] || 0)
)

if (decorationsToRender != null ? decorationsToRender.length : void 0) {
if (decorationsToRender != null ? decorationsToRender.length : undefined) {
for (let i = 0, len = decorationsToRender.length; i < len; i++) {
types[decorationsToRender[i].properties.type].call(this, decorationsToRender[i], renderData)
}
Expand Down Expand Up @@ -640,7 +640,7 @@ module.exports = class CanvasDrawer extends Mixin {
*/
drawHighlightOutlineDecoration (decoration, data) {
let bottomWidth, colSpan, width, xBottomStart, xEnd, xStart
const {lineHeight, charWidth, canvasWidth, screenRow} = data
const { lineHeight, charWidth, canvasWidth, screenRow } = data
const range = decoration.getMarker().getScreenRange()
const rowSpan = range.end.row - range.start.row
const yStart = data.yRow
Expand Down
73 changes: 36 additions & 37 deletions lib/mixins/decoration-management.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ let _, path, Emitter, Decoration
* in this file will be available on any `Minimap` instance.
*/
module.exports = class DecorationManagement {

/**
* Initializes the decorations related properties.
*/
Expand Down Expand Up @@ -74,10 +73,10 @@ module.exports = class DecorationManagement {
* @return {Array<Decoration>} all the decorations in this `Minimap`
*/
getDecorations () {
let decorations = this.decorationsById
let results = []
const decorations = this.decorationsById
const results = []

for (let id in decorations) { results.push(decorations[id]) }
for (const id in decorations) { results.push(decorations[id]) }

return results
}
Expand Down Expand Up @@ -185,14 +184,14 @@ module.exports = class DecorationManagement {
* range
*/
decorationsForScreenRowRange (startScreenRow, endScreenRow) {
let decorationsByMarkerId = {}
let markers = this.findMarkers({
const decorationsByMarkerId = {}
const markers = this.findMarkers({
intersectsScreenRowRange: [startScreenRow, endScreenRow]
})

for (let i = 0, len = markers.length; i < len; i++) {
let marker = markers[i]
let decorations = this.decorationsByMarkerId[marker.id]
const marker = markers[i]
const decorations = this.decorationsByMarkerId[marker.id]

if (decorations != null) {
decorationsByMarkerId[marker.id] = decorations
Expand Down Expand Up @@ -234,11 +233,11 @@ module.exports = class DecorationManagement {
return this.decorationsByTypeThenRowsCache
}

let cache = {}
for (let id in this.decorationsById) {
let decoration = this.decorationsById[id]
let range = decoration.marker.getScreenRange()
let type = decoration.getProperties().type
const cache = {}
for (const id in this.decorationsById) {
const decoration = this.decorationsById[id]
const range = decoration.marker.getScreenRange()
const type = decoration.getProperties().type

if (cache[type] == null) { cache[type] = {} }

Expand Down Expand Up @@ -326,20 +325,20 @@ module.exports = class DecorationManagement {

if (!Decoration) { Decoration = require('../decoration') }

let {id} = marker
const { id } = marker

if (decorationParams.type === 'highlight') {
decorationParams.type = 'highlight-over'
}

const {type, plugin} = decorationParams
const { type, plugin } = decorationParams

if (plugin == null) {
decorationParams.plugin = this.getOriginatorPackageName()
}

if (decorationParams.scope == null && decorationParams['class'] != null) {
let cls = decorationParams['class'].split(' ').join('.')
if (decorationParams.scope == null && decorationParams.class != null) {
const cls = decorationParams.class.split(' ').join('.')
decorationParams.scope = `.minimap .${cls}`
}

Expand All @@ -360,7 +359,7 @@ module.exports = class DecorationManagement {

if (decorations != null) {
for (let i = 0, len = decorations.length; i < len; i++) {
let decoration = decorations[i]
const decoration = decorations[i]
this.emitter.emit('did-change-decoration', {
marker: marker,
decoration: decoration,
Expand All @@ -383,13 +382,13 @@ module.exports = class DecorationManagement {
[newStart, newEnd] = [newEnd, newStart]
}

let rangesDiffs = this.computeRangesDiffs(
const rangesDiffs = this.computeRangesDiffs(
oldStart, oldEnd,
newStart, newEnd
)

for (let i = 0, len = rangesDiffs.length; i < len; i++) {
let [start, end] = rangesDiffs[i]
const [start, end] = rangesDiffs[i]
this.emitRangeChanges(type, {
start: start,
end: end
Expand All @@ -398,7 +397,7 @@ module.exports = class DecorationManagement {
})
}

let decoration = new Decoration(marker, this, decorationParams)
const decoration = new Decoration(marker, this, decorationParams)

if (this.decorationsByMarkerId[id] == null) {
this.decorationsByMarkerId[id] = []
Expand Down Expand Up @@ -453,7 +452,7 @@ module.exports = class DecorationManagement {
* @access private
*/
computeRangesDiffs (oldStart, oldEnd, newStart, newEnd) {
let diffs = []
const diffs = []

if (oldStart.isLessThan(newStart)) {
diffs.push([oldStart, newStart])
Expand Down Expand Up @@ -499,17 +498,17 @@ module.exports = class DecorationManagement {
* @access private
*/
emitRangeChanges (type, range, screenDelta) {
let startScreenRow = range.start.row
let endScreenRow = range.end.row
let lastRenderedScreenRow = this.getLastVisibleScreenRow()
let firstRenderedScreenRow = this.getFirstVisibleScreenRow()
const startScreenRow = range.start.row
const endScreenRow = range.end.row
const lastRenderedScreenRow = this.getLastVisibleScreenRow()
const firstRenderedScreenRow = this.getFirstVisibleScreenRow()

if (screenDelta == null) {
screenDelta = (lastRenderedScreenRow - firstRenderedScreenRow) -
(endScreenRow - startScreenRow)
}

let changeEvent = {
const changeEvent = {
start: startScreenRow,
end: endScreenRow,
screenDelta: screenDelta,
Expand All @@ -529,7 +528,7 @@ module.exports = class DecorationManagement {
removeDecoration (decoration) {
if (decoration == null) { return }

let marker = decoration.marker
const marker = decoration.marker
let subscription

delete this.decorationsById[decoration.id]
Expand All @@ -543,12 +542,12 @@ module.exports = class DecorationManagement {
delete this.decorationUpdatedSubscriptions[decoration.id]
delete this.decorationDestroyedSubscriptions[decoration.id]

let decorations = this.decorationsByMarkerId[marker.id]
const decorations = this.decorationsByMarkerId[marker.id]
if (!decorations) { return }

this.emitDecorationChanges(decoration.getProperties().type, decoration)

let index = decorations.indexOf(decoration)
const index = decorations.indexOf(decoration)
if (index > -1) {
decorations.splice(index, 1)

Expand All @@ -573,11 +572,11 @@ module.exports = class DecorationManagement {
removeAllDecorationsForMarker (marker) {
if (marker == null) { return }

let decorations = this.decorationsByMarkerId[marker.id]
const decorations = this.decorationsByMarkerId[marker.id]
if (!decorations) { return }

for (let i = 0, len = decorations.length; i < len; i++) {
let decoration = decorations[i]
const decoration = decorations[i]

if (!this.adapter.editorDestroyed()) {
this.emitDecorationChanges(decoration.getProperties().type, decoration)
Expand Down Expand Up @@ -612,23 +611,23 @@ module.exports = class DecorationManagement {
* Removes all the decorations that was created in the current `Minimap`.
*/
removeAllDecorations () {
for (let id in this.decorationMarkerChangedSubscriptions) {
for (const id in this.decorationMarkerChangedSubscriptions) {
this.decorationMarkerChangedSubscriptions[id].dispose()
}

for (let id in this.decorationMarkerDestroyedSubscriptions) {
for (const id in this.decorationMarkerDestroyedSubscriptions) {
this.decorationMarkerDestroyedSubscriptions[id].dispose()
}

for (let id in this.decorationUpdatedSubscriptions) {
for (const id in this.decorationUpdatedSubscriptions) {
this.decorationUpdatedSubscriptions[id].dispose()
}

for (let id in this.decorationDestroyedSubscriptions) {
for (const id in this.decorationDestroyedSubscriptions) {
this.decorationDestroyedSubscriptions[id].dispose()
}

for (let id in this.decorationsById) {
for (const id in this.decorationsById) {
this.decorationsById[id].destroy()
}

Expand Down
16 changes: 8 additions & 8 deletions lib/mixins/dom-styles-reader.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ module.exports = class DOMStylesReader extends Mixin {
retrieveStyleFromDom (scopes, property, cache = true) {
this.ensureCache()

let key = scopes.join(' ')
const key = scopes.join(' ')
let cachedData = this.constructor.domStylesCache[key]

if (cache && (cachedData ? cachedData[property] : void 0) != null) {
if (cache && (cachedData ? cachedData[property] : undefined) != null) {
return cachedData[property]
}

Expand All @@ -39,17 +39,17 @@ module.exports = class DOMStylesReader extends Mixin {

let parent = this.dummyNode
for (let i = 0, len = scopes.length; i < len; i++) {
let scope = scopes[i]
let node = document.createElement('span')
const scope = scopes[i]
const node = document.createElement('span')
node.className = scope.replace(/\.+/g, ' ')

if (parent != null) { parent.appendChild(node) }

parent = node
}

let style = window.getComputedStyle(parent)
let filter = style.getPropertyValue('-webkit-filter')
const style = window.getComputedStyle(parent)
const filter = style.getPropertyValue('-webkit-filter')
let value = style.getPropertyValue(property)

if (filter.indexOf('hue-rotate') > -1) {
Expand Down Expand Up @@ -120,7 +120,7 @@ module.exports = class DOMStylesReader extends Mixin {
* @access private
*/
rotateHue (value, filter) {
let match = value.match(/rgb(a?)\((\d+), (\d+), (\d+)(, (\d+(\.\d+)?))?\)/)
const match = value.match(/rgb(a?)\((\d+), (\d+), (\d+)(, (\d+(\.\d+)?))?\)/)
let [, , r, g, b, , a] = match

let [, hue] = filter.match(/hue-rotate\((\d+)deg\)/)
Expand Down Expand Up @@ -156,7 +156,7 @@ module.exports = class DOMStylesReader extends Mixin {
* @access private
*/
function rotate (r, g, b, angle) {
let matrix = [1, 0, 0, 0, 1, 0, 0, 0, 1]
const matrix = [1, 0, 0, 0, 1, 0, 0, 0, 1]
const lumR = 0.2126
const lumG = 0.7152
const lumB = 0.0722
Expand Down
Loading

0 comments on commit 4d60713

Please sign in to comment.