UNPKG

@nxext/stencil

Version:

Nx plugin for stenciljs

47 lines 2.1 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.updateLintConfig = updateLintConfig; const devkit_1 = require("@nx/devkit"); const path_1 = require("path"); /** * When adding storybook we need to inform ESLint * of the additional tsconfig.json file which will be the only tsconfig * which includes *.stories files. * * For ESLint this is done within the .eslintrc.json file. */ function updateLintConfig(tree, schema) { const { name: projectName } = schema; const { root } = (0, devkit_1.readProjectConfiguration)(tree, projectName); if (tree.exists((0, path_1.join)(root, '.eslintrc.json'))) { (0, devkit_1.updateJson)(tree, (0, path_1.join)(root, '.eslintrc.json'), (json) => { var _a, _b, _c, _d; if (typeof ((_a = json.parserOptions) === null || _a === void 0 ? void 0 : _a.project) === 'string') { json.parserOptions.project = [json.parserOptions.project]; } if (Array.isArray((_b = json.parserOptions) === null || _b === void 0 ? void 0 : _b.project)) { json.parserOptions.project = dedupe([ ...json.parserOptions.project, (0, path_1.join)(root, '.storybook/tsconfig.json'), ]); } const overrides = json.overrides || []; for (const o of overrides) { if (typeof ((_c = o.parserOptions) === null || _c === void 0 ? void 0 : _c.project) === 'string') { o.parserOptions.project = [o.parserOptions.project]; } if (Array.isArray((_d = o.parserOptions) === null || _d === void 0 ? void 0 : _d.project)) { o.parserOptions.project = dedupe([ ...o.parserOptions.project, (0, path_1.join)(root, '.storybook/tsconfig.json'), ]); } } return json; }); } } function dedupe(arr) { return Array.from(new Set(arr)); } //# sourceMappingURL=update-lint-config.js.map