diff --git a/src/constants.js b/build/constants.js similarity index 65% rename from src/constants.js rename to build/constants.js index 29f2bca..61aa234 100644 --- a/src/constants.js +++ b/build/constants.js @@ -1,5 +1,5 @@ +"use strict"; const LOCAL_FILE_MISSING = 'Local file missing'; - module.exports = { - LOCAL_FILE_MISSING, + LOCAL_FILE_MISSING, }; diff --git a/build/github.js b/build/github.js new file mode 100644 index 0000000..a326d4e --- /dev/null +++ b/build/github.js @@ -0,0 +1,73 @@ +'use strict'; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const core_1 = __importDefault(require("@actions/core")); +const github_1 = __importDefault(require("@actions/github")); +require("lodash/partition"); +const yaml_1 = __importDefault(require("yaml")); +function fetch_config() { + return __awaiter(this, void 0, void 0, function* () { + const context = get_context(); + const octokit = get_octokit(); + const config_path = get_config_path(); + const { data: response_body } = yield octokit.repos.getContent({ + owner: context.repo.owner, + repo: context.repo.repo, + path: config_path, + ref: context.ref, + }); + return yaml_1.default.parse(response_body.content); + }); +} +function get_reviews() { + return __awaiter(this, void 0, void 0, function* () { + const context = get_context(); + const octokit = get_octokit(); + let reviewsResult = yield octokit.pulls.listReviews({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: context.payload.pull_request.number + }); + return reviewsResult.data; + }); +} +/* Private */ +let octokit_cache; +let context_cache; +let token_cache; +let config_path_cache; +function get_context() { + return context_cache || (context_cache = github_1.default.context); +} +function get_token() { + return token_cache || (token_cache = core_1.default.getInput('token')); +} +function get_config_path() { + return config_path_cache || (config_path_cache = core_1.default.getInput('config')); +} +function get_octokit() { + const token = get_token(); + return octokit_cache = github_1.default.getOctokit(token); +} +function clear_cache() { + context_cache = undefined; + token_cache = undefined; + config_path_cache = undefined; + octokit_cache = undefined; +} +exports.default = { + fetch_config, + get_reviews, + clear_cache, +}; diff --git a/build/index.js b/build/index.js new file mode 100644 index 0000000..c882d97 --- /dev/null +++ b/build/index.js @@ -0,0 +1,64 @@ +'use strict'; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const core_1 = __importDefault(require("@actions/core")); +const github_1 = __importDefault(require("./github")); +function run() { + return __awaiter(this, void 0, void 0, function* () { + core_1.default.info('Fetching configuration file from input "config"...'); + let config; + try { + config = yield github_1.default.fetch_config(); + } + catch (error) { + if (error.status === 404) { + core_1.default.warning('No configuration file is found in the base branch; terminating the process'); + return; + } + throw error; + } + let reviews = yield github_1.default.get_reviews(); + let requirementCounts = {}; + let requirementMembers = {}; + for (let req in config.groups) { + requirementCounts[req] = config.groups[req].required; + requirementMembers[req] = config.groups[req].members; + } + let processedReviewers = []; + for (let i = 0; i < reviews.length; i++) { + let review = reviews[i]; + let userName = review.user.login; + if (!processedReviewers.includes(userName)) { + processedReviewers.push(userName); + for (let req in requirementMembers) { + if (requirementMembers[req].includes(userName)) { + requirementCounts[req]--; + } + } + } + } + for (let req in requirementCounts) { + if (requirementCounts[req] > 0) { + core_1.default.setFailed('Missing one or more required approvers.'); + } + } + }); +} +module.exports = { + run, +}; +// Run the action if it's not running in an automated testing environment +if (process.env.NODE_ENV !== 'automated-testing') { + run().catch((error) => core_1.default.setFailed(error)); +} diff --git a/dist/index.js b/dist/index.js index 8b31a70..f98a8db 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1,6 +1,159 @@ /******/ (() => { // webpackBootstrap /******/ var __webpack_modules__ = ({ +/***/ 7295: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + +"use strict"; + +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +const core_1 = __importDefault(__nccwpck_require__(2186)); +const github_1 = __importDefault(__nccwpck_require__(5438)); +__nccwpck_require__(2539); +const yaml_1 = __importDefault(__nccwpck_require__(4603)); +function fetch_config() { + return __awaiter(this, void 0, void 0, function* () { + const context = get_context(); + const octokit = get_octokit(); + const config_path = get_config_path(); + const { data: response_body } = yield octokit.repos.getContent({ + owner: context.repo.owner, + repo: context.repo.repo, + path: config_path, + ref: context.ref, + }); + return yaml_1.default.parse(response_body.content); + }); +} +function get_reviews() { + return __awaiter(this, void 0, void 0, function* () { + const context = get_context(); + const octokit = get_octokit(); + let reviewsResult = yield octokit.pulls.listReviews({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: context.payload.pull_request.number + }); + return reviewsResult.data; + }); +} +/* Private */ +let octokit_cache; +let context_cache; +let token_cache; +let config_path_cache; +function get_context() { + return context_cache || (context_cache = github_1.default.context); +} +function get_token() { + return token_cache || (token_cache = core_1.default.getInput('token')); +} +function get_config_path() { + return config_path_cache || (config_path_cache = core_1.default.getInput('config')); +} +function get_octokit() { + const token = get_token(); + return octokit_cache = github_1.default.getOctokit(token); +} +function clear_cache() { + context_cache = undefined; + token_cache = undefined; + config_path_cache = undefined; + octokit_cache = undefined; +} +exports["default"] = { + fetch_config, + get_reviews, + clear_cache, +}; + + +/***/ }), + +/***/ 1667: +/***/ (function(module, exports, __nccwpck_require__) { + +"use strict"; + +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +const core_1 = __importDefault(__nccwpck_require__(2186)); +const github_1 = __importDefault(__nccwpck_require__(7295)); +function run() { + return __awaiter(this, void 0, void 0, function* () { + core_1.default.info('Fetching configuration file from input "config"...'); + let config; + try { + config = yield github_1.default.fetch_config(); + } + catch (error) { + if (error.status === 404) { + core_1.default.warning('No configuration file is found in the base branch; terminating the process'); + return; + } + throw error; + } + let reviews = yield github_1.default.get_reviews(); + let requirementCounts = {}; + let requirementMembers = {}; + for (let req in config.groups) { + requirementCounts[req] = config.groups[req].required; + requirementMembers[req] = config.groups[req].members; + } + let processedReviewers = []; + for (let i = 0; i < reviews.length; i++) { + let review = reviews[i]; + let userName = review.user.login; + if (!processedReviewers.includes(userName)) { + processedReviewers.push(userName); + for (let req in requirementMembers) { + if (requirementMembers[req].includes(userName)) { + requirementCounts[req]--; + } + } + } + } + for (let req in requirementCounts) { + if (requirementCounts[req] > 0) { + core_1.default.setFailed('Missing one or more required approvers.'); + } + } + }); +} +module.exports = { + run, +}; +// Run the action if it's not running in an automated testing environment +if (process.env.NODE_ENV !== 'automated-testing') { + run().catch((error) => core_1.default.setFailed(error)); +} + + +/***/ }), + /***/ 7351: /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { @@ -14103,186 +14256,6 @@ function wrappy (fn, cb) { } -/***/ }), - -/***/ 4438: -/***/ ((module) => { - -const LOCAL_FILE_MISSING = 'Local file missing'; - -module.exports = { - LOCAL_FILE_MISSING, -}; - - -/***/ }), - -/***/ 8396: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -"use strict"; - - -const core = __nccwpck_require__(2186); -const fs = __nccwpck_require__(7147); -const github = __nccwpck_require__(5438); -const partition = __nccwpck_require__(2539); -const yaml = __nccwpck_require__(4603); -const { LOCAL_FILE_MISSING } = __nccwpck_require__(4438); - -async function fetch_config() { - const context = get_context(); - const octokit = get_octokit(); - const config_path = get_config_path(); - let content = ''; - - const { data: response_body } = await octokit.repos.getContent({ - owner: context.repo.owner, - repo: context.repo.repo, - path: config_path, - ref: context.ref, - }); - - content = Buffer.from(response_body.content, response_body.encoding).toString(); - - return yaml.parse(content); -} - -function get_pull_request() { - const context = get_context(); - - return new PullRequest(context.payload.pull_request); -} - - -async function get_reviews() { - const context = get_context(); - const octokit = get_octokit(); - - let reviewsResult = await octokit.pulls.listReviews({ - owner: context.repo.owner, - repo: context.repo.repo, - pull_number: context.payload.pull_request.number - }); - return reviewsResult.data; -} - -/* Private */ - -let context_cache; -let token_cache; -let config_path_cache; - -function get_context() { - return context_cache || (context_cache = github.context); -} - -function get_token() { - return token_cache || (token_cache = core.getInput('token')); -} - -function get_config_path() { - return config_path_cache || (config_path_cache = core.getInput('config')); -} - - -function get_octokit() { - // if (octokit_cache) { - // return octokit_cache; - // } - - const token = get_token(); - return octokit_cache = github.getOctokit(token); -} - -function clear_cache() { - context_cache = undefined; - token_cache = undefined; - config_path_cache = undefined; - octokit_cache = undefined; -} - -module.exports = { - get_pull_request, - fetch_config, - get_reviews, - clear_cache, -}; - - -/***/ }), - -/***/ 4351: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -"use strict"; - - -const core = __nccwpck_require__(2186); -const { LOCAL_FILE_MISSING } = __nccwpck_require__(4438); -const github = __nccwpck_require__(8396); // Don't destructure this object to stub with sinon in tests - - -async function run() { - core.info('Fetching configuration file from input "config"...'); - - let config; - - try { - config = await github.fetch_config(); - } catch (error) { - if (error.status === 404) { - core.warning('No configuration file is found in the base branch; terminating the process'); - return; - } - throw error; - } - - const { title, is_draft, author } = github.get_pull_request(); - - let reviews = await github.get_reviews(); - - let requirementCounts = {}; - let requirementMembers = {}; - - for (let req in config.groups) { - requirementCounts[req] = config.groups[req].required; - requirementMembers[req] = config.groups[req].members; - } - - let processedReviewers = []; - - for (let i = 0; i < reviews.length; i++) { - let review = reviews[i]; - let userName = review.user.login; - if (!processedReviewers.includes(userName)) - { - processedReviewers.push(userName); - for (let req in requirementMembers) { - if (requirementMembers[req].includes(userName)) { - requirementCounts[req]--; - } - } - } - } - - for (let req in requirementCounts) { - if (requirementCounts[req] > 0) { - core.setFailed('Missing one or more required approvers.'); - } - } -} - -module.exports = { - run, -}; - -// Run the action if it's not running in an automated testing environment -if (process.env.NODE_ENV !== 'automated-testing') { - run().catch((error) => core.setFailed(error)); -} - - /***/ }), /***/ 2877: @@ -21051,7 +21024,7 @@ module.exports = JSON.parse('[[[0,44],"disallowed_STD3_valid"],[[45,46],"valid"] /******/ // startup /******/ // Load entry module and return exports /******/ // This entry module is referenced by other modules so it can't be inlined -/******/ var __webpack_exports__ = __nccwpck_require__(4351); +/******/ var __webpack_exports__ = __nccwpck_require__(1667); /******/ module.exports = __webpack_exports__; /******/ /******/ })() diff --git a/package-lock.json b/package-lock.json index 245d269..b7eb227 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,12 +16,14 @@ "yaml": "^1.10.0" }, "devDependencies": { + "@types/node": "^18.15.2", "@vercel/ncc": "^0.33.3", "chai": "^4.3.6", "eslint": "^8.9.0", "mocha": "^9.2.1", "nyc": "^15.1.0", - "sinon": "^13.0.1" + "sinon": "^13.0.1", + "typescript": "^4.9.5" } }, "node_modules/@actions/core": { @@ -626,9 +628,9 @@ "dev": true }, "node_modules/@types/node": { - "version": "14.6.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-14.6.0.tgz", - "integrity": "sha512-mikldZQitV94akrc4sCcSjtJfsTKt4p+e/s0AGscVA6XArQ9kFclP+ZiYUMnq987rc6QlYxXv/EivqlfSLxpKA==" + "version": "18.15.2", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.15.2.tgz", + "integrity": "sha512-sDPHm2wfx2QhrMDK0pOt2J4KLJMAcerqWNvnED0itPRJWvI+bK+uNHzcH1dFsBlf7G3u8tqXmRF3wkvL9yUwMw==" }, "node_modules/@ungap/promise-all-settled": { "version": "1.1.2", @@ -3358,6 +3360,19 @@ "is-typedarray": "^1.0.0" } }, + "node_modules/typescript": { + "version": "4.9.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", + "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + }, "node_modules/universal-user-agent": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.0.tgz", @@ -4153,9 +4168,9 @@ "dev": true }, "@types/node": { - "version": "14.6.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-14.6.0.tgz", - "integrity": "sha512-mikldZQitV94akrc4sCcSjtJfsTKt4p+e/s0AGscVA6XArQ9kFclP+ZiYUMnq987rc6QlYxXv/EivqlfSLxpKA==" + "version": "18.15.2", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.15.2.tgz", + "integrity": "sha512-sDPHm2wfx2QhrMDK0pOt2J4KLJMAcerqWNvnED0itPRJWvI+bK+uNHzcH1dFsBlf7G3u8tqXmRF3wkvL9yUwMw==" }, "@ungap/promise-all-settled": { "version": "1.1.2", @@ -6203,6 +6218,12 @@ "is-typedarray": "^1.0.0" } }, + "typescript": { + "version": "4.9.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", + "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", + "dev": true + }, "universal-user-agent": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.0.tgz", diff --git a/package.json b/package.json index 10769ae..1d1fb28 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,10 @@ { "name": "require-user-approval", - "version": "0.0.1", + "version": "0.0.2", "description": "GitHub Action that automatically checks if a set of required users have approved the pull request.", "main": "index.js", "scripts": { - "build": "ncc build src/index.js", + "build": "npx tsc; ncc build build/index.js", "lint": "eslint src test" }, "keywords": [], @@ -18,11 +18,13 @@ "yaml": "^1.10.0" }, "devDependencies": { + "@types/node": "^18.15.2", "@vercel/ncc": "^0.33.3", "chai": "^4.3.6", "eslint": "^8.9.0", "mocha": "^9.2.1", "nyc": "^15.1.0", - "sinon": "^13.0.1" + "sinon": "^13.0.1", + "typescript": "^4.9.5" } } diff --git a/src/github.js b/src/github.ts similarity index 65% rename from src/github.js rename to src/github.ts index a812064..e314b6c 100644 --- a/src/github.js +++ b/src/github.ts @@ -1,17 +1,15 @@ 'use strict'; -const core = require('@actions/core'); -const fs = require('fs'); -const github = require('@actions/github'); -const partition = require('lodash/partition'); -const yaml = require('yaml'); -const { LOCAL_FILE_MISSING } = require('./constants'); +import core from '@actions/core'; +import github from '@actions/github'; +import 'lodash/partition'; +import yaml from 'yaml'; + async function fetch_config() { const context = get_context(); const octokit = get_octokit(); const config_path = get_config_path(); - let content = ''; const { data: response_body } = await octokit.repos.getContent({ owner: context.repo.owner, @@ -20,15 +18,7 @@ async function fetch_config() { ref: context.ref, }); - content = Buffer.from(response_body.content, response_body.encoding).toString(); - - return yaml.parse(content); -} - -function get_pull_request() { - const context = get_context(); - - return new PullRequest(context.payload.pull_request); + return yaml.parse(response_body.content); } @@ -45,10 +35,10 @@ async function get_reviews() { } /* Private */ - -let context_cache; -let token_cache; -let config_path_cache; +let octokit_cache: any; +let context_cache: any; +let token_cache: any; +let config_path_cache: any; function get_context() { return context_cache || (context_cache = github.context); @@ -64,10 +54,6 @@ function get_config_path() { function get_octokit() { - // if (octokit_cache) { - // return octokit_cache; - // } - const token = get_token(); return octokit_cache = github.getOctokit(token); } @@ -79,8 +65,7 @@ function clear_cache() { octokit_cache = undefined; } -module.exports = { - get_pull_request, +export default { fetch_config, get_reviews, clear_cache, diff --git a/src/index.js b/src/index.ts similarity index 77% rename from src/index.js rename to src/index.ts index e2276eb..93ac900 100644 --- a/src/index.js +++ b/src/index.ts @@ -1,9 +1,7 @@ 'use strict'; -const core = require('@actions/core'); -const { LOCAL_FILE_MISSING } = require('./constants'); -const github = require('./github'); // Don't destructure this object to stub with sinon in tests - +import core from '@actions/core'; +import github from './github'; async function run() { core.info('Fetching configuration file from input "config"...'); @@ -12,7 +10,7 @@ async function run() { try { config = await github.fetch_config(); - } catch (error) { + } catch (error: any) { if (error.status === 404) { core.warning('No configuration file is found in the base branch; terminating the process'); return; @@ -20,19 +18,17 @@ async function run() { throw error; } - const { title, is_draft, author } = github.get_pull_request(); - let reviews = await github.get_reviews(); - let requirementCounts = {}; - let requirementMembers = {}; + let requirementCounts: { [key: string]: number } = {}; + let requirementMembers: { [key: string]: string[] } = {}; for (let req in config.groups) { requirementCounts[req] = config.groups[req].required; requirementMembers[req] = config.groups[req].members; } - let processedReviewers = []; + let processedReviewers: string[] = []; for (let i = 0; i < reviews.length; i++) { let review = reviews[i]; diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..1b3e3c3 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,103 @@ +{ + "compilerOptions": { + /* Visit https://aka.ms/tsconfig to read more about this file */ + + /* Projects */ + // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ + // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ + // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ + // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ + // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ + // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ + + /* Language and Environment */ + "target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ + // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ + // "jsx": "preserve", /* Specify what JSX code is generated. */ + // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */ + // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ + // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */ + // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ + // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */ + // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */ + // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ + // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ + // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ + + /* Modules */ + "module": "commonjs", /* Specify what module code is generated. */ + "rootDir": "src", /* Specify the root folder within your source files. */ + // "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */ + // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ + // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ + // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ + "typeRoots": ["./node_modules/@types"], /* Specify multiple folders that act like './node_modules/@types'. */ + // "types": [], /* Specify type package names to be included without being referenced in a source file. */ + // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ + // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ + // "resolveJsonModule": true, /* Enable importing .json files. */ + // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ + + /* JavaScript Support */ + // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */ + // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ + // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ + + /* Emit */ + // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ + // "declarationMap": true, /* Create sourcemaps for d.ts files. */ + // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ + // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ + // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ + "outDir": "build", /* Specify an output folder for all emitted files. */ + // "removeComments": true, /* Disable emitting comments. */ + // "noEmit": true, /* Disable emitting files from a compilation. */ + // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ + // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */ + // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ + // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ + // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ + // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ + // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ + // "newLine": "crlf", /* Set the newline character for emitting files. */ + // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */ + // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ + // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ + // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */ + // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ + // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */ + + /* Interop Constraints */ + // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ + // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ + "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */ + // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ + "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ + + /* Type Checking */ + "strict": true, /* Enable all strict type-checking options. */ + // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ + // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ + // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ + // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ + // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ + // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ + // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ + // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ + // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ + // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ + // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ + // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ + // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ + // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ + // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ + // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ + // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ + // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ + + /* Completeness */ + // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ + "skipLibCheck": true /* Skip type checking all .d.ts files. */ + } +}