source: trip-planner-front/node_modules/@schematics/angular/migrations/update-10/add-deprecation-rule-tslint.js@ 59329aa

Last change on this file since 59329aa was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.6 KB
Line 
1"use strict";
2/**
3 * @license
4 * Copyright Google LLC All Rights Reserved.
5 *
6 * Use of this source code is governed by an MIT-style license that can be
7 * found in the LICENSE file at https://angular.io/license
8 */
9Object.defineProperty(exports, "__esModule", { value: true });
10const dependencies_1 = require("../../utility/dependencies");
11const json_file_1 = require("../../utility/json-file");
12const TSLINT_CONFIG_PATH = '/tslint.json';
13const RULES_TO_ADD = {
14 deprecation: {
15 severity: 'warning',
16 },
17};
18function default_1() {
19 return (tree, context) => {
20 const logger = context.logger;
21 // Update tslint dependency
22 const current = dependencies_1.getPackageJsonDependency(tree, 'tslint');
23 if (!current) {
24 logger.info('Skipping: "tslint" in not a dependency of this workspace.');
25 return;
26 }
27 // Update tslint config.
28 let json;
29 try {
30 json = new json_file_1.JSONFile(tree, TSLINT_CONFIG_PATH);
31 }
32 catch {
33 const config = ['tslint.js', 'tslint.yaml'].find((c) => tree.exists(c));
34 if (config) {
35 logger.warn(`Expected a JSON configuration file but found "${config}".`);
36 }
37 else {
38 logger.warn('Cannot find "tslint.json" configuration file.');
39 }
40 return;
41 }
42 for (const [name, value] of Object.entries(RULES_TO_ADD)) {
43 const ruleName = ['rules', name];
44 if (json.get(ruleName) === undefined) {
45 json.modify(ruleName, value);
46 }
47 }
48 };
49}
50exports.default = default_1;
Note: See TracBrowser for help on using the repository browser.