Prefer const vs let for variables that are only declared once

Requires that variable declarations use `const` instead of `let` and `var` if possible.

This is mostly for code readability, performance wins are debatable.
This commit is contained in:
Lukas Geiger
2018-05-30 19:47:28 +02:00
parent 4a4a17966a
commit 8989a09853
22 changed files with 153 additions and 152 deletions
+1 -1
View File
@@ -33,7 +33,7 @@ describe('ColorManager', () => {
describe('constructor', () => {
it('should fill all colors with values', () => {
for (let key of Object.keys(cm.colors)) {
for (const key of Object.keys(cm.colors)) {
if (key !== 'ansi') {
// A #rrggbb or rgba(...)
assert.ok(cm.colors[key].css.length >= 7);
+2 -2
View File
@@ -42,7 +42,7 @@ export const DEFAULT_ANSI_COLORS = (() => {
// Fill in the remaining 240 ANSI colors.
// Generate colors (16-231)
let v = [0x00, 0x5f, 0x87, 0xaf, 0xd7, 0xff];
const v = [0x00, 0x5f, 0x87, 0xaf, 0xd7, 0xff];
for (let i = 0; i < 216; i++) {
const r = v[(i / 36) % 6 | 0];
const g = v[(i / 6) % 6 | 0];
@@ -75,7 +75,7 @@ function fromHex(css: string): IColor {
}
function toPaddedHex(c: number): string {
let s = c.toString(16);
const s = c.toString(16);
return s.length < 2 ? '0' + s : s;
}