From 948000d7f69dc262b102709df1a9647d1c1c5989 Mon Sep 17 00:00:00 2001 From: Romain Marcadier-Muller Date: Tue, 12 Nov 2019 10:13:19 +0100 Subject: [PATCH] chore: add @typescript-eslint/semi rule (#970) To enforce the presence of the semicolons. --- eslint-config.yaml | 4 ++++ packages/codemaker/lib/filebuff.ts | 4 ++-- packages/codemaker/lib/index.ts | 4 ++-- packages/jsii-kernel/test/kernel.test.ts | 4 ++-- packages/jsii-pacmak/bin/jsii-pacmak.ts | 4 ++-- packages/jsii-pacmak/lib/generator.ts | 18 +++++++++--------- packages/jsii-runtime/lib/host.ts | 2 +- packages/jsii-runtime/lib/in-out.ts | 6 +++--- packages/jsii-runtime/lib/sync-stdio.ts | 2 +- 9 files changed, 26 insertions(+), 22 deletions(-) diff --git a/eslint-config.yaml b/eslint-config.yaml index 1620846368..e5425648d7 100644 --- a/eslint-config.yaml +++ b/eslint-config.yaml @@ -105,6 +105,10 @@ rules: '@typescript-eslint/require-await': - error + '@typescript-eslint/semi': + - error + - 'always' + '@typescript-eslint/type-annotation-spacing': - error diff --git a/packages/codemaker/lib/filebuff.ts b/packages/codemaker/lib/filebuff.ts index 1a290ef033..133a5b9f47 100644 --- a/packages/codemaker/lib/filebuff.ts +++ b/packages/codemaker/lib/filebuff.ts @@ -1,5 +1,5 @@ -import * as fs from 'fs-extra' -import * as path from 'path' +import * as fs from 'fs-extra'; +import * as path from 'path'; /** * Buffers the text of a file for later saving. diff --git a/packages/codemaker/lib/index.ts b/packages/codemaker/lib/index.ts index b50cc3de5d..2cd8c07819 100644 --- a/packages/codemaker/lib/index.ts +++ b/packages/codemaker/lib/index.ts @@ -1,2 +1,2 @@ -export * from './codemaker' -export * from './case-utils' \ No newline at end of file +export * from './codemaker'; +export * from './case-utils'; \ No newline at end of file diff --git a/packages/jsii-kernel/test/kernel.test.ts b/packages/jsii-kernel/test/kernel.test.ts index 44579a73f8..475f8962ee 100644 --- a/packages/jsii-kernel/test/kernel.test.ts +++ b/packages/jsii-kernel/test/kernel.test.ts @@ -44,7 +44,7 @@ function defineTest(name: string, method: (sandbox: Kernel) => Promise | an defineTest.skip = function (name: string, method: (sandbox: Kernel) => Promise | any) { return defineTest(name, method, test.skip); -} +}; defineTest('stats() return sandbox statistics', (sandbox) => { const stats = sandbox.stats({ }); @@ -842,7 +842,7 @@ defineTest('loading a module twice idepotently succeeds', async (sandbox) => { defineTest('fails if trying to load two different versions of the same module', async (sandbox) => { const tarball = await preparePackage('jsii-calc', false); return expect(() => sandbox.load({ tarball, name: 'jsii-calc', version: '99.999.9' })) - .toThrow(/Multiple versions .+ and .+ of the package 'jsii-calc' cannot be loaded together/) + .toThrow(/Multiple versions .+ and .+ of the package 'jsii-calc' cannot be loaded together/); }); defineTest('node.js standard library', async (sandbox) => { diff --git a/packages/jsii-pacmak/bin/jsii-pacmak.ts b/packages/jsii-pacmak/bin/jsii-pacmak.ts index 969d7dd4f6..028af791e8 100644 --- a/packages/jsii-pacmak/bin/jsii-pacmak.ts +++ b/packages/jsii-pacmak/bin/jsii-pacmak.ts @@ -120,7 +120,7 @@ import { ALL_BUILDERS, TargetName } from '../lib/targets'; }); try { - const requestedTargets = argv.targets && argv.targets.map(t => `${t}`) + const requestedTargets = argv.targets && argv.targets.map(t => `${t}`); const targetSets = sliceTargets(modulesToPackage, requestedTargets, argv['force-target']); if (targetSets.every(s => s.modules.length === 0)) { @@ -202,7 +202,7 @@ function allAvailableTargets(modules: JsiiModule[]) { const ret = new Set(); for (const module of modules) { for (const target of module.availableTargets) { - ret.add(target) + ret.add(target); } } return Array.from(ret); diff --git a/packages/jsii-pacmak/lib/generator.ts b/packages/jsii-pacmak/lib/generator.ts index d235149fa9..14eddc3553 100644 --- a/packages/jsii-pacmak/lib/generator.ts +++ b/packages/jsii-pacmak/lib/generator.ts @@ -122,7 +122,7 @@ export abstract class Generator implements IGenerator { throw new Error('Malformed assembly name. Expecting either or @/'); } - return `${name}@${this.assembly.version}.jsii.tgz` + return `${name}@${this.assembly.version}.jsii.tgz`; } /** @@ -208,9 +208,9 @@ export abstract class Generator implements IGenerator { protected onBeginMethods(_cls: spec.ClassType) { /* noop */ } protected abstract onMethod(cls: spec.ClassType, method: spec.Method): void; - protected abstract onMethodOverload(cls: spec.ClassType, overload: spec.Method, originalMethod: spec.Method): void + protected abstract onMethodOverload(cls: spec.ClassType, overload: spec.Method, originalMethod: spec.Method): void; protected abstract onStaticMethod(cls: spec.ClassType, method: spec.Method): void; - protected abstract onStaticMethodOverload(cls: spec.ClassType, overload: spec.Method, originalMethod: spec.Method): void + protected abstract onStaticMethodOverload(cls: spec.ClassType, overload: spec.Method, originalMethod: spec.Method): void; protected onEndMethods(_cls: spec.ClassType) { /* noop */ } // @@ -240,8 +240,8 @@ export abstract class Generator implements IGenerator { const visitChildren = () => { Object.keys(node.children).sort().forEach(name => { this.visit(node.children[name], names.concat(name)); - }) - } + }); + }; if (node.fqn) { const type = this.assembly.types && this.assembly.types[node.fqn]; @@ -262,7 +262,7 @@ export abstract class Generator implements IGenerator { this.onEndClass(classSpec); break; case spec.TypeKind.Enum: - const enumSpec = type as spec.EnumType + const enumSpec = type as spec.EnumType; this.onBeginEnum(enumSpec); this.visitEnum(enumSpec); visitChildren(); @@ -331,7 +331,7 @@ export abstract class Generator implements IGenerator { // const remaining: spec.Parameter[] = clone(method.parameters); - let next: spec.Parameter | undefined + let next: spec.Parameter | undefined; next = remaining.pop(); // Parameter is optional if it's type is optional, and all subsequent parameters are optional/variadic @@ -352,7 +352,7 @@ export abstract class Generator implements IGenerator { if (ifc.properties) { ifc.properties.forEach(prop => { this.onInterfaceProperty(ifc, prop); - }) + }); } if (ifc.methods) { @@ -406,7 +406,7 @@ export abstract class Generator implements IGenerator { if (this.hasField(cls, prop)) { this.onField(cls, prop, spec.isUnionTypeReference(prop.type) ? prop.type : undefined); } - }) + }); cls.properties.forEach(prop => { if (!spec.isUnionTypeReference(prop.type)) { diff --git a/packages/jsii-runtime/lib/host.ts b/packages/jsii-runtime/lib/host.ts index e8b396b1fc..9fbc13cf67 100644 --- a/packages/jsii-runtime/lib/host.ts +++ b/packages/jsii-runtime/lib/host.ts @@ -20,7 +20,7 @@ export class KernelHost { this.processRequest(req, () => { // Schedule the call to run on the next event loop iteration to // avoid recursion. - setImmediate(() => this.run()) + setImmediate(() => this.run()); }); } diff --git a/packages/jsii-runtime/lib/in-out.ts b/packages/jsii-runtime/lib/in-out.ts index 304502dd87..799969daa1 100644 --- a/packages/jsii-runtime/lib/in-out.ts +++ b/packages/jsii-runtime/lib/in-out.ts @@ -1,5 +1,5 @@ -import { SyncStdio } from './sync-stdio' -import { api } from 'jsii-kernel' +import { SyncStdio } from './sync-stdio'; +import { api } from 'jsii-kernel'; export type Output = { hello: string } | @@ -13,7 +13,7 @@ export type Input = { complete: api.CompleteRequest }; export class InputOutput { - public debug = false + public debug = false; private readonly stdio = new SyncStdio(); diff --git a/packages/jsii-runtime/lib/sync-stdio.ts b/packages/jsii-runtime/lib/sync-stdio.ts index 4d36d600d6..a4a9e8d1e8 100644 --- a/packages/jsii-runtime/lib/sync-stdio.ts +++ b/packages/jsii-runtime/lib/sync-stdio.ts @@ -1,4 +1,4 @@ -import * as fs from 'fs' +import * as fs from 'fs'; const STDIN_FD = 0; const STDOUT_FD = 1;