diff --git a/lib/decorators/element.js b/lib/decorators/element.js index ded7e79b..273d9c39 100644 --- a/lib/decorators/element.js +++ b/lib/decorators/element.js @@ -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 @@ -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 }) } diff --git a/lib/decorators/include.js b/lib/decorators/include.js index ffa4a500..54b6c533 100644 --- a/lib/decorators/include.js +++ b/lib/decorators/include.js @@ -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) }) } diff --git a/lib/mixins/canvas-drawer.js b/lib/mixins/canvas-drawer.js index 91df46d1..9ac58b16 100644 --- a/lib/mixins/canvas-drawer.js +++ b/lib/mixins/canvas-drawer.js @@ -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, @@ -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 }) @@ -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, @@ -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 @@ -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 @@ -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) } @@ -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] || [] : [] ) @@ -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) } @@ -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 diff --git a/lib/mixins/decoration-management.js b/lib/mixins/decoration-management.js index 0ae20769..cfbca0ca 100644 --- a/lib/mixins/decoration-management.js +++ b/lib/mixins/decoration-management.js @@ -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. */ @@ -74,10 +73,10 @@ module.exports = class DecorationManagement { * @return {Array} 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 } @@ -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 @@ -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] = {} } @@ -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}` } @@ -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, @@ -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 @@ -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] = [] @@ -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]) @@ -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, @@ -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] @@ -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) @@ -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) @@ -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() } diff --git a/lib/mixins/dom-styles-reader.js b/lib/mixins/dom-styles-reader.js index d3a978c9..4fb1503f 100644 --- a/lib/mixins/dom-styles-reader.js +++ b/lib/mixins/dom-styles-reader.js @@ -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] } @@ -39,8 +39,8 @@ 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) } @@ -48,8 +48,8 @@ module.exports = class DOMStylesReader extends Mixin { 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) { @@ -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\)/) @@ -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 diff --git a/lib/mixins/plugin-management.js b/lib/mixins/plugin-management.js index 94ceee47..152522d6 100644 --- a/lib/mixins/plugin-management.js +++ b/lib/mixins/plugin-management.js @@ -76,7 +76,7 @@ module.exports = class PluginManagement extends Mixin { this.plugins[name] = plugin this.pluginsSubscriptions[name] = new CompositeDisposable() - let event = { name: name, plugin: plugin } + const event = { name: name, plugin: plugin } this.emitter.emit('did-add-plugin', event) if (atom.config.get('minimap-plus.displayPluginsControls')) { @@ -94,7 +94,7 @@ module.exports = class PluginManagement extends Mixin { * to the added plugin. */ unregisterPlugin (name) { - let plugin = this.plugins[name] + const plugin = this.plugins[name] if (atom.config.get('minimap-plus.displayPluginsControls')) { this.unregisterPluginControls(name) @@ -102,7 +102,7 @@ module.exports = class PluginManagement extends Mixin { delete this.plugins[name] - let event = { name: name, plugin: plugin } + const event = { name: name, plugin: plugin } this.emitter.emit('did-remove-plugin', event) } @@ -118,7 +118,7 @@ module.exports = class PluginManagement extends Mixin { * @emits {did-deactivate-plugin} if the plugin was deactivated by the call. */ togglePluginActivation (name, boolean) { - let settingsKey = `minimap.plugins.${name}` + const settingsKey = `minimap.plugins.${name}` if (boolean !== undefined && boolean !== null) { atom.config.set(settingsKey, boolean) @@ -135,7 +135,7 @@ module.exports = class PluginManagement extends Mixin { * @emits {did-deactivate-plugin} for each plugin deactivated by the call. */ deactivateAllPlugins () { - for (let [name, plugin] of this.eachPlugin()) { + for (const [name, plugin] of this.eachPlugin()) { plugin.deactivatePlugin() this.emitter.emit('did-deactivate-plugin', { name: name, plugin: plugin }) } @@ -148,7 +148,7 @@ module.exports = class PluginManagement extends Mixin { * as an array in each iteration. */ * eachPlugin () { - for (let name in this.plugins) { + for (const name in this.plugins) { yield [name, this.plugins[name]] } }