jsii 5.4.16-dev.2 → 5.4.16-dev.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/lib/case.d.ts +1 -0
  2. package/lib/case.js +2 -1
  3. package/lib/case.js.map +1 -1
  4. package/lib/compiler.d.ts +38 -14
  5. package/lib/compiler.js +114 -108
  6. package/lib/compiler.js.map +1 -1
  7. package/lib/jsii-diagnostic.d.ts +3 -0
  8. package/lib/jsii-diagnostic.js +15 -1
  9. package/lib/jsii-diagnostic.js.map +1 -1
  10. package/lib/main.js +45 -2
  11. package/lib/main.js.map +1 -1
  12. package/lib/project-info.d.ts +5 -0
  13. package/lib/project-info.js +13 -0
  14. package/lib/project-info.js.map +1 -1
  15. package/lib/tsconfig/compiler-options.d.ts +54 -0
  16. package/lib/tsconfig/compiler-options.js +136 -0
  17. package/lib/tsconfig/compiler-options.js.map +1 -0
  18. package/lib/tsconfig/index.d.ts +18 -0
  19. package/lib/tsconfig/index.js +11 -0
  20. package/lib/tsconfig/index.js.map +1 -0
  21. package/lib/tsconfig/rulesets/configurable.d.ts +4 -0
  22. package/lib/tsconfig/rulesets/configurable.js +22 -0
  23. package/lib/tsconfig/rulesets/configurable.js.map +1 -0
  24. package/lib/tsconfig/rulesets/generated.public.d.ts +4 -0
  25. package/lib/tsconfig/rulesets/generated.public.js +28 -0
  26. package/lib/tsconfig/rulesets/generated.public.js.map +1 -0
  27. package/lib/tsconfig/rulesets/incompatible-options.d.ts +4 -0
  28. package/lib/tsconfig/rulesets/incompatible-options.js +11 -0
  29. package/lib/tsconfig/rulesets/incompatible-options.js.map +1 -0
  30. package/lib/tsconfig/rulesets/minimal.public.d.ts +4 -0
  31. package/lib/tsconfig/rulesets/minimal.public.js +11 -0
  32. package/lib/tsconfig/rulesets/minimal.public.js.map +1 -0
  33. package/lib/tsconfig/rulesets/strict.public.d.ts +4 -0
  34. package/lib/tsconfig/rulesets/strict.public.js +29 -0
  35. package/lib/tsconfig/rulesets/strict.public.js.map +1 -0
  36. package/lib/tsconfig/tsconfig-validator.d.ts +16 -0
  37. package/lib/tsconfig/tsconfig-validator.js +46 -0
  38. package/lib/tsconfig/tsconfig-validator.js.map +1 -0
  39. package/lib/tsconfig/validator.d.ts +155 -0
  40. package/lib/tsconfig/validator.js +301 -0
  41. package/lib/tsconfig/validator.js.map +1 -0
  42. package/lib/version.d.ts +2 -2
  43. package/lib/version.js +2 -2
  44. package/lib/version.js.map +1 -1
  45. package/package.json +2 -1
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TypeScriptConfigValidationRuleSet = void 0;
4
+ var TypeScriptConfigValidationRuleSet;
5
+ (function (TypeScriptConfigValidationRuleSet) {
6
+ TypeScriptConfigValidationRuleSet["STRICT"] = "strict";
7
+ TypeScriptConfigValidationRuleSet["GENERATED"] = "generated";
8
+ TypeScriptConfigValidationRuleSet["MINIMAL"] = "minimal";
9
+ TypeScriptConfigValidationRuleSet["NONE"] = "off";
10
+ })(TypeScriptConfigValidationRuleSet || (exports.TypeScriptConfigValidationRuleSet = TypeScriptConfigValidationRuleSet = {}));
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tsconfig/index.ts"],"names":[],"mappings":";;;AAaA,IAAY,iCAKX;AALD,WAAY,iCAAiC;IAC3C,sDAAiB,CAAA;IACjB,4DAAuB,CAAA;IACvB,wDAAmB,CAAA;IACnB,iDAAY,CAAA;AACd,CAAC,EALW,iCAAiC,iDAAjC,iCAAiC,QAK5C","sourcesContent":["import * as ts from 'typescript';\n\nexport interface TypeScriptConfig {\n files?: string[];\n extends?: string | string[];\n include?: string[];\n exclude?: string[];\n references?: ts.ProjectReference[];\n compilerOptions: ts.CompilerOptions;\n watchOptions?: ts.WatchOptions;\n typeAcquisition?: ts.TypeAcquisition;\n}\n\nexport enum TypeScriptConfigValidationRuleSet {\n STRICT = 'strict',\n GENERATED = 'generated',\n MINIMAL = 'minimal',\n NONE = 'off',\n}\n"]}
@@ -0,0 +1,4 @@
1
+ import { RuleSet } from '../validator';
2
+ declare const configurable: RuleSet;
3
+ export default configurable;
4
+ //# sourceMappingURL=configurable.d.ts.map
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const validator_1 = require("../validator");
4
+ // A rule set defining all compilerOptions that can be configured by users with or without constraints.
5
+ // This is an internal rule set, that may be used by other rule sets.
6
+ // Settings previously configurable via the jsii field in package.json
7
+ // We accept all value for these
8
+ const configurable = new validator_1.RuleSet();
9
+ configurable.shouldPass('outdir', validator_1.Match.ANY);
10
+ configurable.shouldPass('rootDir', validator_1.Match.ANY);
11
+ configurable.shouldPass('forceConsistentCasingInFileNames', validator_1.Match.ANY);
12
+ configurable.shouldPass('declarationMap', validator_1.Match.ANY);
13
+ configurable.shouldPass('inlineSourceMap', validator_1.Match.ANY);
14
+ configurable.shouldPass('inlineSources', validator_1.Match.ANY);
15
+ configurable.shouldPass('sourceMap', validator_1.Match.ANY);
16
+ configurable.shouldPass('types', validator_1.Match.ANY);
17
+ configurable.shouldPass('baseUrl', validator_1.Match.ANY);
18
+ configurable.shouldPass('paths', validator_1.Match.ANY);
19
+ configurable.shouldPass('composite', validator_1.Match.ANY); // configured via projectReferences
20
+ configurable.shouldPass('tsBuildInfoFile', validator_1.Match.ANY);
21
+ exports.default = configurable;
22
+ //# sourceMappingURL=configurable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configurable.js","sourceRoot":"","sources":["../../../src/tsconfig/rulesets/configurable.ts"],"names":[],"mappings":";;AAAA,4CAA8C;AAE9C,uGAAuG;AACvG,qEAAqE;AAErE,sEAAsE;AACtE,gCAAgC;AAChC,MAAM,YAAY,GAAG,IAAI,mBAAO,EAAE,CAAC;AACnC,YAAY,CAAC,UAAU,CAAC,QAAQ,EAAE,iBAAK,CAAC,GAAG,CAAC,CAAC;AAC7C,YAAY,CAAC,UAAU,CAAC,SAAS,EAAE,iBAAK,CAAC,GAAG,CAAC,CAAC;AAC9C,YAAY,CAAC,UAAU,CAAC,kCAAkC,EAAE,iBAAK,CAAC,GAAG,CAAC,CAAC;AACvE,YAAY,CAAC,UAAU,CAAC,gBAAgB,EAAE,iBAAK,CAAC,GAAG,CAAC,CAAC;AACrD,YAAY,CAAC,UAAU,CAAC,iBAAiB,EAAE,iBAAK,CAAC,GAAG,CAAC,CAAC;AACtD,YAAY,CAAC,UAAU,CAAC,eAAe,EAAE,iBAAK,CAAC,GAAG,CAAC,CAAC;AACpD,YAAY,CAAC,UAAU,CAAC,WAAW,EAAE,iBAAK,CAAC,GAAG,CAAC,CAAC;AAChD,YAAY,CAAC,UAAU,CAAC,OAAO,EAAE,iBAAK,CAAC,GAAG,CAAC,CAAC;AAC5C,YAAY,CAAC,UAAU,CAAC,SAAS,EAAE,iBAAK,CAAC,GAAG,CAAC,CAAC;AAC9C,YAAY,CAAC,UAAU,CAAC,OAAO,EAAE,iBAAK,CAAC,GAAG,CAAC,CAAC;AAC5C,YAAY,CAAC,UAAU,CAAC,WAAW,EAAE,iBAAK,CAAC,GAAG,CAAC,CAAC,CAAC,mCAAmC;AACpF,YAAY,CAAC,UAAU,CAAC,iBAAiB,EAAE,iBAAK,CAAC,GAAG,CAAC,CAAC;AAEtD,kBAAe,YAAY,CAAC","sourcesContent":["import { Match, RuleSet } from '../validator';\n\n// A rule set defining all compilerOptions that can be configured by users with or without constraints.\n// This is an internal rule set, that may be used by other rule sets.\n\n// Settings previously configurable via the jsii field in package.json\n// We accept all value for these\nconst configurable = new RuleSet();\nconfigurable.shouldPass('outdir', Match.ANY);\nconfigurable.shouldPass('rootDir', Match.ANY);\nconfigurable.shouldPass('forceConsistentCasingInFileNames', Match.ANY);\nconfigurable.shouldPass('declarationMap', Match.ANY);\nconfigurable.shouldPass('inlineSourceMap', Match.ANY);\nconfigurable.shouldPass('inlineSources', Match.ANY);\nconfigurable.shouldPass('sourceMap', Match.ANY);\nconfigurable.shouldPass('types', Match.ANY);\nconfigurable.shouldPass('baseUrl', Match.ANY);\nconfigurable.shouldPass('paths', Match.ANY);\nconfigurable.shouldPass('composite', Match.ANY); // configured via projectReferences\nconfigurable.shouldPass('tsBuildInfoFile', Match.ANY);\n\nexport default configurable;\n"]}
@@ -0,0 +1,4 @@
1
+ import { RuleSet } from '../validator';
2
+ declare const generated: RuleSet;
3
+ export default generated;
4
+ //# sourceMappingURL=generated.public.d.ts.map
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const configurable_1 = require("./configurable");
4
+ const compiler_options_1 = require("../compiler-options");
5
+ const validator_1 = require("../validator");
6
+ // The public rule set used for the "generated" tsconfig validation setting.\
7
+ // The goal of this rule set is to ensure a tsconfig is compatible to the one jsii would generate for the user.
8
+ // It is explicitly enforcing option values that are used for the generated tsconfig,
9
+ // as well as options that can be configured via jsii settings. All other options are disallowed.
10
+ const generated = new validator_1.RuleSet({
11
+ unexpectedFields: validator_1.RuleType.FAIL,
12
+ });
13
+ // import all options that are configurable via jsii settings
14
+ generated.import(configurable_1.default);
15
+ // ... and all generated options
16
+ for (const [field, value] of Object.entries((0, compiler_options_1.convertForJson)(compiler_options_1.BASE_COMPILER_OPTIONS))) {
17
+ if (typeof value === 'string') {
18
+ generated.shouldPass(field, validator_1.Match.strEq(value, true));
19
+ continue;
20
+ }
21
+ if (Array.isArray(value)) {
22
+ generated.shouldPass(field, validator_1.Match.arrEq(value));
23
+ continue;
24
+ }
25
+ generated.shouldPass(field, validator_1.Match.eq(value));
26
+ }
27
+ exports.default = generated;
28
+ //# sourceMappingURL=generated.public.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generated.public.js","sourceRoot":"","sources":["../../../src/tsconfig/rulesets/generated.public.ts"],"names":[],"mappings":";;AAAA,iDAA0C;AAC1C,0DAA4E;AAC5E,4CAAwD;AAExD,6EAA6E;AAC7E,+GAA+G;AAC/G,qFAAqF;AACrF,iGAAiG;AACjG,MAAM,SAAS,GAAG,IAAI,mBAAO,CAAC;IAC5B,gBAAgB,EAAE,oBAAQ,CAAC,IAAI;CAChC,CAAC,CAAC;AAEH,6DAA6D;AAC7D,SAAS,CAAC,MAAM,CAAC,sBAAY,CAAC,CAAC;AAE/B,gCAAgC;AAChC,KAAK,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAA,iCAAc,EAAC,wCAAqB,CAAC,CAAC,EAAE,CAAC;IACnF,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,SAAS,CAAC,UAAU,CAAC,KAAK,EAAE,iBAAK,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;QACtD,SAAS;IACX,CAAC;IAED,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,SAAS,CAAC,UAAU,CAAC,KAAK,EAAE,iBAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;QAChD,SAAS;IACX,CAAC;IAED,SAAS,CAAC,UAAU,CAAC,KAAK,EAAE,iBAAK,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;AAC/C,CAAC;AAED,kBAAe,SAAS,CAAC","sourcesContent":["import configurable from './configurable';\nimport { BASE_COMPILER_OPTIONS, convertForJson } from '../compiler-options';\nimport { Match, RuleSet, RuleType } from '../validator';\n\n// The public rule set used for the \"generated\" tsconfig validation setting.\\\n// The goal of this rule set is to ensure a tsconfig is compatible to the one jsii would generate for the user.\n// It is explicitly enforcing option values that are used for the generated tsconfig,\n// as well as options that can be configured via jsii settings. All other options are disallowed.\nconst generated = new RuleSet({\n unexpectedFields: RuleType.FAIL,\n});\n\n// import all options that are configurable via jsii settings\ngenerated.import(configurable);\n\n// ... and all generated options\nfor (const [field, value] of Object.entries(convertForJson(BASE_COMPILER_OPTIONS))) {\n if (typeof value === 'string') {\n generated.shouldPass(field, Match.strEq(value, true));\n continue;\n }\n\n if (Array.isArray(value)) {\n generated.shouldPass(field, Match.arrEq(value));\n continue;\n }\n\n generated.shouldPass(field, Match.eq(value));\n}\n\nexport default generated;\n"]}
@@ -0,0 +1,4 @@
1
+ import { RuleSet } from '../validator';
2
+ declare const incompatibleOptions: RuleSet;
3
+ export default incompatibleOptions;
4
+ //# sourceMappingURL=incompatible-options.d.ts.map
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const validator_1 = require("../validator");
4
+ // A rule set defining all compilerOptions that are explicitly known to be incompatible with jsii
5
+ // This is an internal rule set, that may be used by other rule sets.
6
+ const incompatibleOptions = new validator_1.RuleSet();
7
+ incompatibleOptions.shouldFail('noEmit', validator_1.Match.TRUE);
8
+ incompatibleOptions.shouldFail('noLib', validator_1.Match.TRUE);
9
+ incompatibleOptions.shouldFail('declaration', validator_1.Match.FALSE);
10
+ exports.default = incompatibleOptions;
11
+ //# sourceMappingURL=incompatible-options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"incompatible-options.js","sourceRoot":"","sources":["../../../src/tsconfig/rulesets/incompatible-options.ts"],"names":[],"mappings":";;AAAA,4CAA8C;AAE9C,iGAAiG;AACjG,qEAAqE;AACrE,MAAM,mBAAmB,GAAG,IAAI,mBAAO,EAAE,CAAC;AAC1C,mBAAmB,CAAC,UAAU,CAAC,QAAQ,EAAE,iBAAK,CAAC,IAAI,CAAC,CAAC;AACrD,mBAAmB,CAAC,UAAU,CAAC,OAAO,EAAE,iBAAK,CAAC,IAAI,CAAC,CAAC;AACpD,mBAAmB,CAAC,UAAU,CAAC,aAAa,EAAE,iBAAK,CAAC,KAAK,CAAC,CAAC;AAE3D,kBAAe,mBAAmB,CAAC","sourcesContent":["import { Match, RuleSet } from '../validator';\n\n// A rule set defining all compilerOptions that are explicitly known to be incompatible with jsii\n// This is an internal rule set, that may be used by other rule sets.\nconst incompatibleOptions = new RuleSet();\nincompatibleOptions.shouldFail('noEmit', Match.TRUE);\nincompatibleOptions.shouldFail('noLib', Match.TRUE);\nincompatibleOptions.shouldFail('declaration', Match.FALSE);\n\nexport default incompatibleOptions;\n"]}
@@ -0,0 +1,4 @@
1
+ import { RuleSet } from '../validator';
2
+ declare const minimal: RuleSet;
3
+ export default minimal;
4
+ //# sourceMappingURL=minimal.public.d.ts.map
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const incompatible_options_1 = require("./incompatible-options");
4
+ const validator_1 = require("../validator");
5
+ // The public rule set used for the "minimal" tsconfig validation setting
6
+ // To goal of this rule set is to only prevent obvious misconfigurations,
7
+ // while leaving everything else up to the user.
8
+ const minimal = new validator_1.RuleSet();
9
+ minimal.import(incompatible_options_1.default);
10
+ exports.default = minimal;
11
+ //# sourceMappingURL=minimal.public.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"minimal.public.js","sourceRoot":"","sources":["../../../src/tsconfig/rulesets/minimal.public.ts"],"names":[],"mappings":";;AAAA,iEAAkD;AAClD,4CAAuC;AAEvC,yEAAyE;AACzE,yEAAyE;AACzE,gDAAgD;AAChD,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAC9B,OAAO,CAAC,MAAM,CAAC,8BAAY,CAAC,CAAC;AAE7B,kBAAe,OAAO,CAAC","sourcesContent":["import incompatible from './incompatible-options';\nimport { RuleSet } from '../validator';\n\n// The public rule set used for the \"minimal\" tsconfig validation setting\n// To goal of this rule set is to only prevent obvious misconfigurations,\n// while leaving everything else up to the user.\nconst minimal = new RuleSet();\nminimal.import(incompatible);\n\nexport default minimal;\n"]}
@@ -0,0 +1,4 @@
1
+ import { RuleSet } from '../validator';
2
+ declare const strict: RuleSet;
3
+ export default strict;
4
+ //# sourceMappingURL=strict.public.d.ts.map
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const configurable_1 = require("./configurable");
4
+ const incompatible_options_1 = require("./incompatible-options");
5
+ const validator_1 = require("../validator");
6
+ // The public rule set used for the "strict" tsconfig validation setting.
7
+ // The goal of this rule set is to ensure a tsconfig that is following best practices for jsii.
8
+ // In practice, this is a combination of known incompatible options, known configurable options and additional best practices.
9
+ // The rule set also explicitly disallows unknown options.
10
+ const strict = new validator_1.RuleSet({
11
+ unexpectedFields: validator_1.RuleType.FAIL,
12
+ });
13
+ // import all options that are configurable
14
+ strict.import(configurable_1.default);
15
+ // import all options that are definitely incompatible
16
+ strict.import(incompatible_options_1.default);
17
+ // Best practice rules
18
+ strict.shouldPass('target', validator_1.Match.eq('es2022')); // node18
19
+ strict.shouldPass('lib', validator_1.Match.arrEq(['es2022'])); // node18
20
+ strict.shouldPass('module', validator_1.Match.oneOf('node16', 'commonjs'));
21
+ strict.shouldPass('moduleResolution', validator_1.Match.optional(validator_1.Match.oneOf('node', 'node16')));
22
+ strict.shouldPass('esModuleInterop', validator_1.Match.TRUE);
23
+ strict.shouldPass('skipLibCheck', validator_1.Match.TRUE);
24
+ strict.shouldPass('strict', validator_1.Match.eq(true));
25
+ strict.shouldPass('incremental', validator_1.Match.ANY);
26
+ // Deprecated ts options that should not be used with jsii
27
+ strict.shouldPass('prepend', validator_1.Match.MISSING);
28
+ exports.default = strict;
29
+ //# sourceMappingURL=strict.public.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"strict.public.js","sourceRoot":"","sources":["../../../src/tsconfig/rulesets/strict.public.ts"],"names":[],"mappings":";;AAAA,iDAA0C;AAC1C,iEAAkD;AAClD,4CAAwD;AAExD,yEAAyE;AACzE,+FAA+F;AAC/F,8HAA8H;AAC9H,0DAA0D;AAC1D,MAAM,MAAM,GAAG,IAAI,mBAAO,CAAC;IACzB,gBAAgB,EAAE,oBAAQ,CAAC,IAAI;CAChC,CAAC,CAAC;AAEH,2CAA2C;AAC3C,MAAM,CAAC,MAAM,CAAC,sBAAY,CAAC,CAAC;AAE5B,sDAAsD;AACtD,MAAM,CAAC,MAAM,CAAC,8BAAY,CAAC,CAAC;AAE5B,sBAAsB;AACtB,MAAM,CAAC,UAAU,CAAC,QAAQ,EAAE,iBAAK,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS;AAC1D,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,iBAAK,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS;AAC5D,MAAM,CAAC,UAAU,CAAC,QAAQ,EAAE,iBAAK,CAAC,KAAK,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC;AAC/D,MAAM,CAAC,UAAU,CAAC,kBAAkB,EAAE,iBAAK,CAAC,QAAQ,CAAC,iBAAK,CAAC,KAAK,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;AACrF,MAAM,CAAC,UAAU,CAAC,iBAAiB,EAAE,iBAAK,CAAC,IAAI,CAAC,CAAC;AACjD,MAAM,CAAC,UAAU,CAAC,cAAc,EAAE,iBAAK,CAAC,IAAI,CAAC,CAAC;AAC9C,MAAM,CAAC,UAAU,CAAC,QAAQ,EAAE,iBAAK,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;AAC5C,MAAM,CAAC,UAAU,CAAC,aAAa,EAAE,iBAAK,CAAC,GAAG,CAAC,CAAC;AAE5C,0DAA0D;AAC1D,MAAM,CAAC,UAAU,CAAC,SAAS,EAAE,iBAAK,CAAC,OAAO,CAAC,CAAC;AAE5C,kBAAe,MAAM,CAAC","sourcesContent":["import configurable from './configurable';\nimport incompatible from './incompatible-options';\nimport { Match, RuleSet, RuleType } from '../validator';\n\n// The public rule set used for the \"strict\" tsconfig validation setting.\n// The goal of this rule set is to ensure a tsconfig that is following best practices for jsii.\n// In practice, this is a combination of known incompatible options, known configurable options and additional best practices.\n// The rule set also explicitly disallows unknown options.\nconst strict = new RuleSet({\n unexpectedFields: RuleType.FAIL,\n});\n\n// import all options that are configurable\nstrict.import(configurable);\n\n// import all options that are definitely incompatible\nstrict.import(incompatible);\n\n// Best practice rules\nstrict.shouldPass('target', Match.eq('es2022')); // node18\nstrict.shouldPass('lib', Match.arrEq(['es2022'])); // node18\nstrict.shouldPass('module', Match.oneOf('node16', 'commonjs'));\nstrict.shouldPass('moduleResolution', Match.optional(Match.oneOf('node', 'node16')));\nstrict.shouldPass('esModuleInterop', Match.TRUE);\nstrict.shouldPass('skipLibCheck', Match.TRUE);\nstrict.shouldPass('strict', Match.eq(true));\nstrict.shouldPass('incremental', Match.ANY);\n\n// Deprecated ts options that should not be used with jsii\nstrict.shouldPass('prepend', Match.MISSING);\n\nexport default strict;\n"]}
@@ -0,0 +1,16 @@
1
+ import { TypeScriptConfig, TypeScriptConfigValidationRuleSet } from '.';
2
+ export declare class TypeScriptConfigValidator {
3
+ ruleSet: TypeScriptConfigValidationRuleSet;
4
+ private readonly validator;
5
+ private readonly compilerOptions;
6
+ constructor(ruleSet: TypeScriptConfigValidationRuleSet);
7
+ /**
8
+ * Validated the provided config against the set of rules.
9
+ *
10
+ * @throws when the config is invalid
11
+ *
12
+ * @param tsconfig the tsconfig to be validated, this MUST be a tsconfig as a user would have written it in tsconfig.
13
+ */
14
+ validate(tsconfig: TypeScriptConfig): void;
15
+ }
16
+ //# sourceMappingURL=tsconfig-validator.d.ts.map
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TypeScriptConfigValidator = void 0;
4
+ const generated_public_1 = require("./rulesets/generated.public");
5
+ const minimal_public_1 = require("./rulesets/minimal.public");
6
+ const strict_public_1 = require("./rulesets/strict.public");
7
+ const validator_1 = require("./validator");
8
+ const RuleSets = {
9
+ generated: generated_public_1.default,
10
+ strict: strict_public_1.default,
11
+ minimal: minimal_public_1.default,
12
+ off: new validator_1.RuleSet(),
13
+ };
14
+ class TypeScriptConfigValidator {
15
+ constructor(ruleSet) {
16
+ this.ruleSet = ruleSet;
17
+ const topLevelRules = new validator_1.RuleSet({
18
+ unexpectedFields: validator_1.RuleType.PASS,
19
+ });
20
+ topLevelRules.shouldPass('files', validator_1.Match.ANY);
21
+ topLevelRules.shouldPass('extends', validator_1.Match.ANY);
22
+ topLevelRules.shouldPass('include', validator_1.Match.ANY);
23
+ topLevelRules.shouldPass('exclude', validator_1.Match.ANY);
24
+ topLevelRules.shouldPass('references', validator_1.Match.ANY);
25
+ topLevelRules.shouldPass('watchOptions', validator_1.Match.ANY);
26
+ topLevelRules.shouldPass('typeAcquisition', validator_1.Match.MISSING);
27
+ this.compilerOptions = new validator_1.ObjectValidator(RuleSets[ruleSet], 'compilerOptions');
28
+ topLevelRules.shouldPass('compilerOptions', (compilerOptions) => {
29
+ this.compilerOptions.validate(compilerOptions);
30
+ return true;
31
+ });
32
+ this.validator = new validator_1.ObjectValidator(topLevelRules, 'tsconfig');
33
+ }
34
+ /**
35
+ * Validated the provided config against the set of rules.
36
+ *
37
+ * @throws when the config is invalid
38
+ *
39
+ * @param tsconfig the tsconfig to be validated, this MUST be a tsconfig as a user would have written it in tsconfig.
40
+ */
41
+ validate(tsconfig) {
42
+ this.validator.validate(tsconfig);
43
+ }
44
+ }
45
+ exports.TypeScriptConfigValidator = TypeScriptConfigValidator;
46
+ //# sourceMappingURL=tsconfig-validator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tsconfig-validator.js","sourceRoot":"","sources":["../../src/tsconfig/tsconfig-validator.ts"],"names":[],"mappings":";;;AACA,kEAAoD;AACpD,8DAAgD;AAChD,4DAA8C;AAC9C,2CAAwE;AAExE,MAAM,QAAQ,GAEV;IACF,SAAS,EAAT,0BAAS;IACT,MAAM,EAAN,uBAAM;IACN,OAAO,EAAP,wBAAO;IACP,GAAG,EAAE,IAAI,mBAAO,EAAE;CACnB,CAAC;AAEF,MAAa,yBAAyB;IAIpC,YAA0B,OAA0C;QAA1C,YAAO,GAAP,OAAO,CAAmC;QAClE,MAAM,aAAa,GAAG,IAAI,mBAAO,CAAC;YAChC,gBAAgB,EAAE,oBAAQ,CAAC,IAAI;SAChC,CAAC,CAAC;QACH,aAAa,CAAC,UAAU,CAAC,OAAO,EAAE,iBAAK,CAAC,GAAG,CAAC,CAAC;QAC7C,aAAa,CAAC,UAAU,CAAC,SAAS,EAAE,iBAAK,CAAC,GAAG,CAAC,CAAC;QAC/C,aAAa,CAAC,UAAU,CAAC,SAAS,EAAE,iBAAK,CAAC,GAAG,CAAC,CAAC;QAC/C,aAAa,CAAC,UAAU,CAAC,SAAS,EAAE,iBAAK,CAAC,GAAG,CAAC,CAAC;QAC/C,aAAa,CAAC,UAAU,CAAC,YAAY,EAAE,iBAAK,CAAC,GAAG,CAAC,CAAC;QAClD,aAAa,CAAC,UAAU,CAAC,cAAc,EAAE,iBAAK,CAAC,GAAG,CAAC,CAAC;QACpD,aAAa,CAAC,UAAU,CAAC,iBAAiB,EAAE,iBAAK,CAAC,OAAO,CAAC,CAAC;QAE3D,IAAI,CAAC,eAAe,GAAG,IAAI,2BAAe,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,iBAAiB,CAAC,CAAC;QACjF,aAAa,CAAC,UAAU,CAAC,iBAAiB,EAAE,CAAC,eAAe,EAAE,EAAE;YAC9D,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;YAC/C,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,SAAS,GAAG,IAAI,2BAAe,CAAC,aAAa,EAAE,UAAU,CAAC,CAAC;IAClE,CAAC;IAED;;;;;;OAMG;IACI,QAAQ,CAAC,QAA0B;QACxC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACpC,CAAC;CACF;AAnCD,8DAmCC","sourcesContent":["import { TypeScriptConfig, TypeScriptConfigValidationRuleSet } from '.';\nimport generated from './rulesets/generated.public';\nimport minimal from './rulesets/minimal.public';\nimport strict from './rulesets/strict.public';\nimport { Match, ObjectValidator, RuleSet, RuleType } from './validator';\n\nconst RuleSets: {\n [name in TypeScriptConfigValidationRuleSet]: RuleSet;\n} = {\n generated,\n strict,\n minimal,\n off: new RuleSet(),\n};\n\nexport class TypeScriptConfigValidator {\n private readonly validator: ObjectValidator;\n private readonly compilerOptions: ObjectValidator;\n\n public constructor(public ruleSet: TypeScriptConfigValidationRuleSet) {\n const topLevelRules = new RuleSet({\n unexpectedFields: RuleType.PASS,\n });\n topLevelRules.shouldPass('files', Match.ANY);\n topLevelRules.shouldPass('extends', Match.ANY);\n topLevelRules.shouldPass('include', Match.ANY);\n topLevelRules.shouldPass('exclude', Match.ANY);\n topLevelRules.shouldPass('references', Match.ANY);\n topLevelRules.shouldPass('watchOptions', Match.ANY);\n topLevelRules.shouldPass('typeAcquisition', Match.MISSING);\n\n this.compilerOptions = new ObjectValidator(RuleSets[ruleSet], 'compilerOptions');\n topLevelRules.shouldPass('compilerOptions', (compilerOptions) => {\n this.compilerOptions.validate(compilerOptions);\n return true;\n });\n\n this.validator = new ObjectValidator(topLevelRules, 'tsconfig');\n }\n\n /**\n * Validated the provided config against the set of rules.\n *\n * @throws when the config is invalid\n *\n * @param tsconfig the tsconfig to be validated, this MUST be a tsconfig as a user would have written it in tsconfig.\n */\n public validate(tsconfig: TypeScriptConfig) {\n this.validator.validate(tsconfig);\n }\n}\n"]}
@@ -0,0 +1,155 @@
1
+ /**
2
+ * A function that receives 3 arguments and validates if the provided value matches.
3
+ * @param value The value to validate
4
+ * @params options Additional options to influence the matcher behavior.
5
+ * @returns true if the value matches
6
+ */
7
+ type Matcher = (value: any, options?: MatcherOptions) => boolean;
8
+ interface MatcherOptions {
9
+ /**
10
+ * A function that will be called by the matcher with a a violation message.
11
+ * This function is always called, regardless of the outcome of the matcher.
12
+ * It is up to the caller of the matcher to decide if the message should be used or not.
13
+ *
14
+ * @param message The message describing the possible failure.
15
+ */
16
+ reporter?: (message: string) => void;
17
+ /**
18
+ * A function that might receive explicitly allowed values.
19
+ * This can be used to generate synthetics values that would match the matcher.
20
+ * It is not guaranteed that hints are received or that hints are complete.
21
+ *
22
+ * @param allowed The list values that a matcher offers as definitely allowed.
23
+ */
24
+ hints?: (allowed: any[]) => void;
25
+ }
26
+ export declare enum RuleType {
27
+ PASS = 0,
28
+ FAIL = 1
29
+ }
30
+ export interface RuleSetOptions {
31
+ /**
32
+ * Defines the behavior for any encountered fields for which no rules are defined.
33
+ * The default is to pass these fields without validation,
34
+ * but this can also be set to fail any unexpected fields.
35
+ *
36
+ * @default RuleType.PASS
37
+ */
38
+ readonly unexpectedFields: RuleType;
39
+ }
40
+ interface Rule {
41
+ field: string;
42
+ type: RuleType;
43
+ matcher: Matcher;
44
+ }
45
+ export declare class RuleSet {
46
+ readonly options: RuleSetOptions;
47
+ private _rules;
48
+ get rules(): Array<Rule>;
49
+ /**
50
+ * Return all fields for which a rule exists
51
+ */
52
+ get fields(): Array<string>;
53
+ /**
54
+ * Return a list of fields that are allowed, or undefined if all are allowed.
55
+ */
56
+ get allowedFields(): Array<string> | undefined;
57
+ /**
58
+ * Find all required fields by evaluating every rule in th set against undefined.
59
+ * If the rule fails, the key must be required.
60
+ *
61
+ * @returns A list of keys that must be included or undefined
62
+ */
63
+ get requiredFields(): Array<string>;
64
+ constructor(options?: RuleSetOptions);
65
+ /**
66
+ * Requires the matcher to pass for the given field.
67
+ * Otherwise a violation is detected.
68
+ *
69
+ * @param field The field the rule applies to
70
+ * @param matcher The matcher function
71
+ */
72
+ shouldPass(field: string, matcher: Matcher): void;
73
+ /**
74
+ * Detects a violation if the matcher is matching for a certain field.
75
+ *
76
+ * @param field The field the rule applies to
77
+ * @param matcher The matcher function
78
+ */
79
+ shouldFail(field: string, matcher: Matcher): void;
80
+ /**
81
+ * Imports all rules from an other rule set.
82
+ * Note that any options from the other rule set will be ignored.
83
+ *
84
+ * @param other The other rule set to import rules from.
85
+ */
86
+ import(other: RuleSet): void;
87
+ /**
88
+ * Records the field hints for the given rule set.
89
+ * Hints are values that are guaranteed to pass the rule.
90
+ * The list of hints is not guaranteed to be complete nor does it guarantee to return any values.
91
+ * This can be used to create synthetic values for testing for error messages.
92
+ *
93
+ * @returns A record of fields and allowed values
94
+ */
95
+ getFieldHints(): Record<string, any[]>;
96
+ }
97
+ export declare class Match {
98
+ /**
99
+ * Value is optional, but if present should match
100
+ */
101
+ static optional(matcher: Matcher): Matcher;
102
+ /**
103
+ * Value must be one of the allowed options
104
+ */
105
+ static oneOf(...allowed: Array<string | number>): Matcher;
106
+ /**
107
+ * Value must be loosely equal to the expected value
108
+ * Arrays are compared by elements
109
+ */
110
+ static eq(expected: any): Matcher;
111
+ /**
112
+ * Value must be loosely equal to the expected value
113
+ * Arrays are compared by elements
114
+ */
115
+ static arrEq(expected: any[]): Matcher;
116
+ /**
117
+ * Compare strings, allows setting cases sensitivity
118
+ */
119
+ static strEq(expected: string, caseSensitive?: boolean): Matcher;
120
+ /**
121
+ * Allows any value
122
+ */
123
+ static ANY: Matcher;
124
+ static TRUE: Matcher;
125
+ static FALSE: Matcher;
126
+ /**
127
+ * Missing (undefined) value
128
+ */
129
+ static MISSING: Matcher;
130
+ }
131
+ export interface Violation {
132
+ field: string;
133
+ message: string;
134
+ }
135
+ export declare class ValidationError extends Error {
136
+ readonly violations: Violation[];
137
+ constructor(violations: Violation[]);
138
+ }
139
+ export declare class ObjectValidator {
140
+ ruleSet: RuleSet;
141
+ private readonly dataName;
142
+ constructor(ruleSet: RuleSet, dataName?: string);
143
+ /**
144
+ * Validated the provided data against the set of rules.
145
+ *
146
+ * @throws when the data is invalid
147
+ *
148
+ * @param data the data to be validated
149
+ */
150
+ validate(data: {
151
+ [field: string]: any;
152
+ }): void;
153
+ }
154
+ export {};
155
+ //# sourceMappingURL=validator.d.ts.map