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 | */
|
---|
9 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
10 | const dependencies_1 = require("../../utility/dependencies");
|
---|
11 | const json_file_1 = require("../../utility/json-file");
|
---|
12 | const TSLINT_CONFIG_PATH = '/tslint.json';
|
---|
13 | const RULES_TO_ADD = {
|
---|
14 | deprecation: {
|
---|
15 | severity: 'warning',
|
---|
16 | },
|
---|
17 | };
|
---|
18 | function 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 | }
|
---|
50 | exports.default = default_1;
|
---|