From 246d137c2c4409602003963771de7f8c3bb1c1e6 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Sun, 25 Oct 2020 00:54:32 +0300 Subject: [PATCH] src: lint using putout --- bin/test_api.js | 2 +- src/browser/Terminal2.test.ts | 4 ++-- src/common/Platform.ts | 2 +- src/common/buffer/Buffer.test.ts | 24 ++++++++++++------------ src/common/input/UnicodeV6.test.ts | 2 +- src/common/services/OptionsService.ts | 4 ++-- src/common/tsconfig.json | 2 +- 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/bin/test_api.js b/bin/test_api.js index eb068b891..7afb34bce 100644 --- a/bin/test_api.js +++ b/bin/test_api.js @@ -21,7 +21,7 @@ let flagArgs = []; if (process.argv.length > 2) { const args = process.argv.slice(2); - flagArgs = args.filter(e => e.startsWith('--')).map(arg => arg.split('=')).reduce((arr, val) => arr.concat(val.split(''), [])); + flagArgs = args.filter(e => e.startsWith('--')).map(arg => arg.split('=')).reduce((arr, val) => arr.concat([...val], [])); console.info(flagArgs); // ability to inject particular test files via // yarn test [testFileA testFileB ...] diff --git a/src/browser/Terminal2.test.ts b/src/browser/Terminal2.test.ts index 8f07b953e..7d3fe851a 100644 --- a/src/browser/Terminal2.test.ts +++ b/src/browser/Terminal2.test.ts @@ -32,7 +32,7 @@ if (os.platform() === 'darwin') { ); } // filter skipFilenames -const FILES = TESTFILES.filter(value => SKIP_FILES.indexOf(value.split('/').slice(-1)[0]) === -1); +const FILES = TESTFILES.filter(value => !SKIP_FILES.includes(value.split('/').slice(-1)[0])); describe('Escape Sequence Files', function(): void { this.timeout(1000); @@ -104,7 +104,7 @@ describe('Escape Sequence Files', function(): void { function formatError(input: string, output: string, expected: string): string { function addLineNumber(start: number, color: string): (s: string) => string { let counter = start || 0; - return function(s: string): string { + return (s: string): string => { counter += 1; return '\x1b[33m' + (' ' + counter).slice(-2) + color + s; }; diff --git a/src/common/Platform.ts b/src/common/Platform.ts index aae06c746..ae23c02ed 100644 --- a/src/common/Platform.ts +++ b/src/common/Platform.ts @@ -17,7 +17,7 @@ const isNode = (typeof navigator === 'undefined') ? true : false; const userAgent = (isNode) ? 'node' : navigator.userAgent; const platform = (isNode) ? 'node' : navigator.platform; -export const isFirefox = !!~userAgent.indexOf('Firefox'); +export const isFirefox = userAgent.includes('Firefox'); export const isSafari = /^((?!chrome|android).)*safari/i.test(userAgent); // Find the users platform. We use this to interpret the meta key diff --git a/src/common/buffer/Buffer.test.ts b/src/common/buffer/Buffer.test.ts index 35aade4aa..99db99816 100644 --- a/src/common/buffer/Buffer.test.ts +++ b/src/common/buffer/Buffer.test.ts @@ -700,7 +700,7 @@ describe('Buffer', () => { } const wrappedLines: number[] = []; for (let i = 0; i < buffer.lines.length; i++) { - assert.equal(buffer.lines.get(i)!.isWrapped, wrappedLines.indexOf(i) !== -1, `line ${i} isWrapped must equal ${wrappedLines.indexOf(i) !== -1}`); + assert.equal(buffer.lines.get(i)!.isWrapped, wrappedLines.includes(i), `line ${i} isWrapped must equal ${wrappedLines.includes(i)}`); } }); }); @@ -723,7 +723,7 @@ describe('Buffer', () => { } const wrappedLines: number[] = []; for (let i = 0; i < buffer.lines.length; i++) { - assert.equal(buffer.lines.get(i)!.isWrapped, wrappedLines.indexOf(i) !== -1, `line ${i} isWrapped must equal ${wrappedLines.indexOf(i) !== -1}`); + assert.equal(buffer.lines.get(i)!.isWrapped, wrappedLines.includes(i), `line ${i} isWrapped must equal ${wrappedLines.includes(i)}`); } }); }); @@ -754,7 +754,7 @@ describe('Buffer', () => { } const wrappedLines: number[] = []; for (let i = 0; i < buffer.lines.length; i++) { - assert.equal(buffer.lines.get(i)!.isWrapped, wrappedLines.indexOf(i) !== -1, `line ${i} isWrapped must equal ${wrappedLines.indexOf(i) !== -1}`); + assert.equal(buffer.lines.get(i)!.isWrapped, wrappedLines.includes(i), `line ${i} isWrapped must equal ${wrappedLines.includes(i)}`); } }); }); @@ -777,7 +777,7 @@ describe('Buffer', () => { } const wrappedLines: number[] = []; for (let i = 0; i < buffer.lines.length; i++) { - assert.equal(buffer.lines.get(i)!.isWrapped, wrappedLines.indexOf(i) !== -1, `line ${i} isWrapped must equal ${wrappedLines.indexOf(i) !== -1}`); + assert.equal(buffer.lines.get(i)!.isWrapped, wrappedLines.includes(i), `line ${i} isWrapped must equal ${wrappedLines.includes(i)}`); } }); }); @@ -814,7 +814,7 @@ describe('Buffer', () => { } const wrappedLines: number[] = []; for (let i = 0; i < buffer.lines.length; i++) { - assert.equal(buffer.lines.get(i)!.isWrapped, wrappedLines.indexOf(i) !== -1, `line ${i} isWrapped must equal ${wrappedLines.indexOf(i) !== -1}`); + assert.equal(buffer.lines.get(i)!.isWrapped, wrappedLines.includes(i), `line ${i} isWrapped must equal ${wrappedLines.includes(i)}`); } }); }); @@ -837,7 +837,7 @@ describe('Buffer', () => { } const wrappedLines: number[] = []; for (let i = 0; i < buffer.lines.length; i++) { - assert.equal(buffer.lines.get(i)!.isWrapped, wrappedLines.indexOf(i) !== -1, `line ${i} isWrapped must equal ${wrappedLines.indexOf(i) !== -1}`); + assert.equal(buffer.lines.get(i)!.isWrapped, wrappedLines.includes(i), `line ${i} isWrapped must equal ${wrappedLines.includes(i)}`); } }); }); @@ -891,7 +891,7 @@ describe('Buffer', () => { } const wrappedLines = [1, 3, 5]; for (let i = 0; i < buffer.lines.length; i++) { - assert.equal(buffer.lines.get(i)!.isWrapped, wrappedLines.indexOf(i) !== -1, `line ${i} isWrapped must equal ${wrappedLines.indexOf(i) !== -1}`); + assert.equal(buffer.lines.get(i)!.isWrapped, wrappedLines.includes(i), `line ${i} isWrapped must equal ${wrappedLines.includes(i)}`); } }); }); @@ -917,7 +917,7 @@ describe('Buffer', () => { } const wrappedLines = [1, 3, 5]; for (let i = 0; i < buffer.lines.length; i++) { - assert.equal(buffer.lines.get(i)!.isWrapped, wrappedLines.indexOf(i) !== -1, `line ${i} isWrapped must equal ${wrappedLines.indexOf(i) !== -1}`); + assert.equal(buffer.lines.get(i)!.isWrapped, wrappedLines.includes(i), `line ${i} isWrapped must equal ${wrappedLines.includes(i)}`); } }); }); @@ -950,7 +950,7 @@ describe('Buffer', () => { } const wrappedLines = [11, 13, 15]; for (let i = 0; i < buffer.lines.length; i++) { - assert.equal(buffer.lines.get(i)!.isWrapped, wrappedLines.indexOf(i) !== -1, `line ${i} isWrapped must equal ${wrappedLines.indexOf(i) !== -1}`); + assert.equal(buffer.lines.get(i)!.isWrapped, wrappedLines.includes(i), `line ${i} isWrapped must equal ${wrappedLines.includes(i)}`); } }); }); @@ -975,7 +975,7 @@ describe('Buffer', () => { } const wrappedLines = [11, 13, 15]; for (let i = 0; i < buffer.lines.length; i++) { - assert.equal(buffer.lines.get(i)!.isWrapped, wrappedLines.indexOf(i) !== -1, `line ${i} isWrapped must equal ${wrappedLines.indexOf(i) !== -1}`); + assert.equal(buffer.lines.get(i)!.isWrapped, wrappedLines.includes(i), `line ${i} isWrapped must equal ${wrappedLines.includes(i)}`); } }); }); @@ -1014,7 +1014,7 @@ describe('Buffer', () => { } const wrappedLines = [8, 10, 12]; for (let i = 0; i < buffer.lines.length; i++) { - assert.equal(buffer.lines.get(i)!.isWrapped, wrappedLines.indexOf(i) !== -1, `line ${i} isWrapped must equal ${wrappedLines.indexOf(i) !== -1}`); + assert.equal(buffer.lines.get(i)!.isWrapped, wrappedLines.includes(i), `line ${i} isWrapped must equal ${wrappedLines.includes(i)}`); } }); }); @@ -1040,7 +1040,7 @@ describe('Buffer', () => { } const wrappedLines = [8, 10, 12]; for (let i = 0; i < buffer.lines.length; i++) { - assert.equal(buffer.lines.get(i)!.isWrapped, wrappedLines.indexOf(i) !== -1, `line ${i} isWrapped must equal ${wrappedLines.indexOf(i) !== -1}`); + assert.equal(buffer.lines.get(i)!.isWrapped, wrappedLines.includes(i), `line ${i} isWrapped must equal ${wrappedLines.includes(i)}`); } }); }); diff --git a/src/common/input/UnicodeV6.test.ts b/src/common/input/UnicodeV6.test.ts index 5124a71f8..9a7fe8057 100644 --- a/src/common/input/UnicodeV6.test.ts +++ b/src/common/input/UnicodeV6.test.ts @@ -161,7 +161,7 @@ it('wcwidth should match all values from the old implementation', function(): vo // ==> n = n >> m e.g. m=12 000000000000FFEEDDCCBBAA99887766 // we are only interested in 2 LSBs, cut off higher bits // ==> n = n & 3 e.g. 000000000000000000000000000000XX - return function (num: number): number { + return (num: number): number => { num = num | 0; // get asm.js like optimization under V8 if (num < 32) { return control | 0; diff --git a/src/common/services/OptionsService.ts b/src/common/services/OptionsService.ts index e5f6eaa8d..6c43c3038 100644 --- a/src/common/services/OptionsService.ts +++ b/src/common/services/OptionsService.ts @@ -89,7 +89,7 @@ export class OptionsService implements IOptionsService { if (!(key in DEFAULT_OPTIONS)) { throw new Error('No option with key "' + key + '"'); } - if (CONSTRUCTOR_ONLY_OPTIONS.indexOf(key) !== -1) { + if (CONSTRUCTOR_ONLY_OPTIONS.includes(key)) { throw new Error(`Option "${key}" can only be set in the constructor`); } if (this.options[key] === value) { @@ -123,7 +123,7 @@ export class OptionsService implements IOptionsService { // already valid numeric value break; } - value = FONT_WEIGHT_OPTIONS.indexOf(value) !== -1 ? value : DEFAULT_OPTIONS[key]; + value = FONT_WEIGHT_OPTIONS.includes(value) ? value : DEFAULT_OPTIONS[key]; break; case 'cursorWidth': value = Math.floor(value); diff --git a/src/common/tsconfig.json b/src/common/tsconfig.json index 7f35c80c0..31781983d 100644 --- a/src/common/tsconfig.json +++ b/src/common/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../tsconfig-library-base", "compilerOptions": { "lib": [ - "es2015" + "es2017" ], "outDir": "../../out", "types": [