Last change
on this file since 8d391a1 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 | */
|
---|
9 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
10 | exports.applyLintFix = void 0;
|
---|
11 | const schematics_1 = require("@angular-devkit/schematics");
|
---|
12 | const tasks_1 = require("@angular-devkit/schematics/tasks");
|
---|
13 | function applyLintFix(path = '/') {
|
---|
14 | return (tree, context) => {
|
---|
15 | // Find the closest tslint.json or tslint.yaml
|
---|
16 | let dir = tree.getDir(path.substr(0, path.lastIndexOf('/')));
|
---|
17 | do {
|
---|
18 | if (dir.subfiles.some((f) => f === 'tslint.json' || f === 'tslint.yaml')) {
|
---|
19 | break;
|
---|
20 | }
|
---|
21 | dir = dir.parent;
|
---|
22 | } while (dir !== null);
|
---|
23 | if (dir === null) {
|
---|
24 | throw new schematics_1.SchematicsException('Asked to run lint fixes, but could not find a tslint.json or tslint.yaml config file.');
|
---|
25 | }
|
---|
26 | // Only include files that have been touched.
|
---|
27 | const files = tree.actions.reduce((acc, action) => {
|
---|
28 | const path = action.path.substr(1); // Remove the starting '/'.
|
---|
29 | if (path.endsWith('.ts') && dir && action.path.startsWith(dir.path)) {
|
---|
30 | acc.add(path);
|
---|
31 | }
|
---|
32 | return acc;
|
---|
33 | }, new Set());
|
---|
34 | context.addTask(new tasks_1.TslintFixTask({
|
---|
35 | ignoreErrors: true,
|
---|
36 | tsConfigPath: 'tsconfig.json',
|
---|
37 | files: [...files],
|
---|
38 | }));
|
---|
39 | };
|
---|
40 | }
|
---|
41 | exports.applyLintFix = applyLintFix;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.