diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 00000000..4f6ed763 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,2 @@ +**/node_modules +proto/ diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 00000000..78215349 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/package.json b/package.json index 5b0c1722..651c894d 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "@types/tmp": "0.2.0", "codecov": "^3.0.0", "deep-copy": "^1.4.2", - "gts": "^1.0.0", + "gts": "^2.0.0", "js-green-licenses": "^2.0.0", "linkinator": "^2.0.0", "mocha": "^8.0.0", diff --git a/system-test/busybench-js/src/busybench.js b/system-test/busybench-js/src/busybench.js index d7a49ffc..99318ba6 100644 --- a/system-test/busybench-js/src/busybench.js +++ b/system-test/busybench-js/src/busybench.js @@ -46,8 +46,11 @@ function benchmark(durationSeconds) { busyLoop(durationSeconds); } -async function collectAndSaveTimeProfile(durationSeconds, sourceMapper, - lineNumbers) { +async function collectAndSaveTimeProfile( + durationSeconds, + sourceMapper, + lineNumbers +) { const profile = await pprof.time.profile({ durationMillis: 1000 * durationSeconds, lineNumbers: lineNumbers, @@ -64,13 +67,19 @@ async function collectAndSaveHeapProfile(sourceMapper) { } async function collectAndSaveProfiles(collectLineNumberTimeProfile) { - const sourceMapper = await pprof.SourceMapper.create([process.cwd()]); + const sourceMapper = await pprof.SourceMapper.create([process.cwd()]); collectAndSaveHeapProfile(sourceMapper); - collectAndSaveTimeProfile(durationSeconds/2, sourceMapper, collectLineNumberTimeProfile); + collectAndSaveTimeProfile( + durationSeconds / 2, + sourceMapper, + collectLineNumberTimeProfile + ); } const durationSeconds = Number(process.argv.length > 2 ? process.argv[2] : 30); -const collectLineNumberTimeProfile = Boolean(process.argv.length > 3 ? process.argv[3] : false); +const collectLineNumberTimeProfile = Boolean( + process.argv.length > 3 ? process.argv[3] : false +); pprof.heap.start(512 * 1024, 64); benchmark(durationSeconds); diff --git a/system-test/busybench/src/busybench.ts b/system-test/busybench/src/busybench.ts index 73bd318b..ac8e3b34 100644 --- a/system-test/busybench/src/busybench.ts +++ b/system-test/busybench/src/busybench.ts @@ -14,9 +14,9 @@ * limitations under the License. */ -import {writeFile} from 'fs'; +import { writeFile } from 'fs'; import * as pify from 'pify'; -import {encode, heap, SourceMapper, time} from 'pprof'; +import { encode, heap, SourceMapper, time } from 'pprof'; const writeFilePromise = pify(writeFile); @@ -47,15 +47,20 @@ function benchmark(durationSeconds: number) { } async function collectAndSaveTimeProfile( - durationSeconds: number, sourceMapper: SourceMapper): Promise { - const profile = await time.profile( - {durationMillis: 1000 * durationSeconds, sourceMapper}); + durationSeconds: number, + sourceMapper: SourceMapper +): Promise { + const profile = await time.profile({ + durationMillis: 1000 * durationSeconds, + sourceMapper, + }); const buf = await encode(profile); await writeFilePromise('time.pb.gz', buf); } -async function collectAndSaveHeapProfile(sourceMapper: SourceMapper): - Promise { +async function collectAndSaveHeapProfile( + sourceMapper: SourceMapper +): Promise { const profile = await heap.profile(undefined, sourceMapper); const buf = await encode(profile); await writeFilePromise('heap.pb.gz', buf); diff --git a/ts/src/sourcemapper/sourcemapper.ts b/ts/src/sourcemapper/sourcemapper.ts index bb9759a5..c53774fb 100644 --- a/ts/src/sourcemapper/sourcemapper.ts +++ b/ts/src/sourcemapper/sourcemapper.ts @@ -120,7 +120,7 @@ export class SourceMapper { for (const dir of searchDirs) { try { const mf = await getMapFiles(dir); - mf.forEach(mapFile => { + mf.forEach((mapFile) => { mapFiles.push(path.resolve(dir, mapFile)); }); } catch (e) { @@ -224,7 +224,7 @@ export class SourceMapper { async function createFromMapFiles(mapFiles: string[]): Promise { const limit = pLimit(CONCURRENCY); const mapper = new SourceMapper(); - const promises: Array> = mapFiles.map(mapPath => + const promises: Array> = mapFiles.map((mapPath) => limit(() => processSourceMap(mapper.infoMap, mapPath)) ); try { diff --git a/ts/test/test-time-profiler.ts b/ts/test/test-time-profiler.ts index c00ef8b9..0627fe29 100644 --- a/ts/test/test-time-profiler.ts +++ b/ts/test/test-time-profiler.ts @@ -44,7 +44,7 @@ describe('Time Profiler', () => { describe('profile (w/ stubs)', () => { // tslint:disable-next-line: no-any - const sinonStubs: Array> = new Array(); + const sinonStubs: Array> = []; before(() => { sinonStubs.push(sinon.stub(v8TimeProfiler, 'startProfiling')); sinonStubs.push( @@ -55,7 +55,7 @@ describe('Time Profiler', () => { }); after(() => { - sinonStubs.forEach(stub => { + sinonStubs.forEach((stub) => { stub.restore(); }); }); diff --git a/ts/third_party/cloud-debug-nodejs/src/agent/io/scanner.ts b/ts/third_party/cloud-debug-nodejs/src/agent/io/scanner.ts index 8b8ca64b..c1fc8da2 100644 --- a/ts/third_party/cloud-debug-nodejs/src/agent/io/scanner.ts +++ b/ts/third_party/cloud-debug-nodejs/src/agent/io/scanner.ts @@ -90,10 +90,10 @@ class ScanResultsImpl implements ScanResults { // ensure the base directory has only a single trailing path separator baseDir = path.normalize(baseDir + path.sep); return Object.keys(this.stats) - .filter(file => { + .filter((file) => { return file && regex.test(file); }) - .map(file => { + .map((file) => { return path.normalize(file).replace(baseDir, ''); }); } @@ -152,10 +152,7 @@ function computeStats( // Sort the hashes to get a deterministic order as the files may // not be in the same order each time we scan the disk. const buffer = hashes.sort().join(); - const sha1 = crypto - .createHash('sha1') - .update(buffer) - .digest('hex'); + const sha1 = crypto.createHash('sha1').update(buffer).digest('hex'); hash = 'SHA1-' + sha1; } resolve(new ScanResultsImpl(statistics, errors, hash)); @@ -224,7 +221,7 @@ function statsForFile( ): Promise { return new Promise((resolve, reject) => { const reader = fs.createReadStream(filename); - reader.on('error', err => { + reader.on('error', (err) => { reject(err); }); reader.on('open', () => {