From ddc9765fdb79198d89860626ccd964f43fb56cf9 Mon Sep 17 00:00:00 2001 From: NetaNir Date: Thu, 8 Apr 2021 22:59:19 -0700 Subject: [PATCH 1/7] chore(awslint): ban @expiremental --- packages/awslint/lib/rules/docs.ts | 17 ++++++++++++++++- tools/cfn2ts/lib/codegen.ts | 1 - 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/packages/awslint/lib/rules/docs.ts b/packages/awslint/lib/rules/docs.ts index fda92170bd80a..aab8deb3259d3 100644 --- a/packages/awslint/lib/rules/docs.ts +++ b/packages/awslint/lib/rules/docs.ts @@ -1,3 +1,4 @@ +import { Stability } from '@jsii/spec'; import * as reflect from 'jsii-reflect'; import { Linter } from '../linter'; import { CoreTypes } from './core-types'; @@ -55,7 +56,7 @@ docsLinter.add({ if (CoreTypes.isCfnType(e.ctx.containingType)) { return; } const property = e.ctx.documentable; - e.assert(!property.optional || property.docs.docs.default !== undefined, e.ctx.errorKey); + e.assert(!property.optional || property.docs.docs.stability !== undefined, e.ctx.errorKey); }, }); @@ -71,6 +72,20 @@ docsLinter.add({ }, }); +docsLinter.add({ + code: 'no-experimental-apis', + message: 'The use of @experimental in not allowed (either directly or via parent class)', + eval: e => { + const property = e.ctx.documentable; + // eslint-disable-next-line no-console + if (isCfnType(e.ctx)) { + // eslint-disable-next-line no-console + console.log(''); + } + e.assert(property.docs.docs.stability !== Stability.Experimental, e.ctx.errorKey); + }, +}); + function isPublic(ctx: DocsLinterContext) { switch (ctx.kind) { case 'class-property': diff --git a/tools/cfn2ts/lib/codegen.ts b/tools/cfn2ts/lib/codegen.ts index c06fce32e10ff..f952bb34a832e 100644 --- a/tools/cfn2ts/lib/codegen.ts +++ b/tools/cfn2ts/lib/codegen.ts @@ -439,7 +439,6 @@ export default class CodeGenerator { this.code.line(' *'); this.code.line(' * @param inspector - tree inspector to collect and process attributes'); this.code.line(' *'); - this.code.line(' * @stability experimental'); this.code.line(' */'); this.code.openBlock(`public inspect(inspector: ${CORE}.TreeInspector)`); this.code.line(`inspector.addAttribute("${TreeAttributes.CFN_TYPE}", ${resource.className}.CFN_RESOURCE_TYPE_NAME);`); From 227ef2649d3c972a7ed702cdef2e93af4533deb6 Mon Sep 17 00:00:00 2001 From: NetaNir Date: Thu, 8 Apr 2021 23:25:13 -0700 Subject: [PATCH 2/7] hide --- packages/awslint/lib/rules/docs.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/packages/awslint/lib/rules/docs.ts b/packages/awslint/lib/rules/docs.ts index aab8deb3259d3..661ce64c3efcb 100644 --- a/packages/awslint/lib/rules/docs.ts +++ b/packages/awslint/lib/rules/docs.ts @@ -56,7 +56,7 @@ docsLinter.add({ if (CoreTypes.isCfnType(e.ctx.containingType)) { return; } const property = e.ctx.documentable; - e.assert(!property.optional || property.docs.docs.stability !== undefined, e.ctx.errorKey); + e.assert(!property.optional || property.docs.docs.default !== undefined, e.ctx.errorKey); }, }); @@ -77,11 +77,6 @@ docsLinter.add({ message: 'The use of @experimental in not allowed (either directly or via parent class)', eval: e => { const property = e.ctx.documentable; - // eslint-disable-next-line no-console - if (isCfnType(e.ctx)) { - // eslint-disable-next-line no-console - console.log(''); - } e.assert(property.docs.docs.stability !== Stability.Experimental, e.ctx.errorKey); }, }); From dff055936b1dea282b1bbc2f3cb4918956bda052 Mon Sep 17 00:00:00 2001 From: NetaNir Date: Fri, 9 Apr 2021 00:02:14 -0700 Subject: [PATCH 3/7] execlude experimental --- packages/awslint/lib/rules/docs.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/packages/awslint/lib/rules/docs.ts b/packages/awslint/lib/rules/docs.ts index 661ce64c3efcb..9fce284d76437 100644 --- a/packages/awslint/lib/rules/docs.ts +++ b/packages/awslint/lib/rules/docs.ts @@ -76,6 +76,12 @@ docsLinter.add({ code: 'no-experimental-apis', message: 'The use of @experimental in not allowed (either directly or via parent class)', eval: e => { + if (!isPublic(e.ctx)) { return; } + // technically we should ban the use of @experimental in the codebase, but since jsii will marks all properties + // of experimental modules as experimental we can't. + if (isModuleExperimental(e.ctx.assembly)) { + return; + } const property = e.ctx.documentable; e.assert(property.docs.docs.stability !== Stability.Experimental, e.ctx.errorKey); }, @@ -107,6 +113,13 @@ function isCfnType(ctx: DocsLinterContext) { } } +function isModuleExperimental(assembly: reflect.Assembly) { + if (assembly.spec.docs?.stability === Stability.Experimental) { + return true; + } + return false; +} + function flatMap(array: readonly T[], callbackfn: (value: T, index: number, array: readonly T[]) => U[]): U[] { return Array.prototype.concat(...array.map(callbackfn)); } From 0e6577487f3b88a84d692c7a36f7e04853572d44 Mon Sep 17 00:00:00 2001 From: Neta Nir Date: Wed, 14 Apr 2021 22:03:04 -0700 Subject: [PATCH 4/7] Update packages/awslint/lib/rules/docs.ts Co-authored-by: Niranjan Jayakar --- packages/awslint/lib/rules/docs.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/awslint/lib/rules/docs.ts b/packages/awslint/lib/rules/docs.ts index 9fce284d76437..9639e930b90fb 100644 --- a/packages/awslint/lib/rules/docs.ts +++ b/packages/awslint/lib/rules/docs.ts @@ -77,7 +77,7 @@ docsLinter.add({ message: 'The use of @experimental in not allowed (either directly or via parent class)', eval: e => { if (!isPublic(e.ctx)) { return; } - // technically we should ban the use of @experimental in the codebase, but since jsii will marks all properties + // technically we should ban the use of @experimental in the codebase. Since jsii marks all symbols // of experimental modules as experimental we can't. if (isModuleExperimental(e.ctx.assembly)) { return; From f91529189e616cadf7cb3a71ea22e2fdc7ac8ce8 Mon Sep 17 00:00:00 2001 From: Neta Nir Date: Wed, 14 Apr 2021 22:03:19 -0700 Subject: [PATCH 5/7] Update packages/awslint/lib/rules/docs.ts Co-authored-by: Niranjan Jayakar --- packages/awslint/lib/rules/docs.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/awslint/lib/rules/docs.ts b/packages/awslint/lib/rules/docs.ts index 9639e930b90fb..89a705a43812b 100644 --- a/packages/awslint/lib/rules/docs.ts +++ b/packages/awslint/lib/rules/docs.ts @@ -114,10 +114,7 @@ function isCfnType(ctx: DocsLinterContext) { } function isModuleExperimental(assembly: reflect.Assembly) { - if (assembly.spec.docs?.stability === Stability.Experimental) { - return true; - } - return false; + return assembly.spec.docs?.stability === Stability.Experimental; } function flatMap(array: readonly T[], callbackfn: (value: T, index: number, array: readonly T[]) => U[]): U[] { From 969704b91c84f3a40dc207bf711a4e61be1a7878 Mon Sep 17 00:00:00 2001 From: Neta Nir Date: Wed, 14 Apr 2021 22:03:26 -0700 Subject: [PATCH 6/7] Update packages/awslint/lib/rules/docs.ts Co-authored-by: Niranjan Jayakar --- packages/awslint/lib/rules/docs.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/awslint/lib/rules/docs.ts b/packages/awslint/lib/rules/docs.ts index 89a705a43812b..5e51911bf5e95 100644 --- a/packages/awslint/lib/rules/docs.ts +++ b/packages/awslint/lib/rules/docs.ts @@ -82,7 +82,7 @@ docsLinter.add({ if (isModuleExperimental(e.ctx.assembly)) { return; } - const property = e.ctx.documentable; + const sym = e.ctx.documentable; e.assert(property.docs.docs.stability !== Stability.Experimental, e.ctx.errorKey); }, }); From b8f35dd6da34a8b115d861346d951df9675edf4a Mon Sep 17 00:00:00 2001 From: NetaNir Date: Thu, 15 Apr 2021 01:11:31 -0700 Subject: [PATCH 7/7] cr feedback --- packages/awslint/lib/rules/docs.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/awslint/lib/rules/docs.ts b/packages/awslint/lib/rules/docs.ts index 5e51911bf5e95..8c5107d8450ac 100644 --- a/packages/awslint/lib/rules/docs.ts +++ b/packages/awslint/lib/rules/docs.ts @@ -74,7 +74,7 @@ docsLinter.add({ docsLinter.add({ code: 'no-experimental-apis', - message: 'The use of @experimental in not allowed (either directly or via parent class)', + message: 'The use of @experimental in not allowed', eval: e => { if (!isPublic(e.ctx)) { return; } // technically we should ban the use of @experimental in the codebase. Since jsii marks all symbols @@ -83,7 +83,7 @@ docsLinter.add({ return; } const sym = e.ctx.documentable; - e.assert(property.docs.docs.stability !== Stability.Experimental, e.ctx.errorKey); + e.assert(sym.docs.docs.stability !== Stability.Experimental, e.ctx.errorKey); }, });