Skip to content

Commit b884295

Browse files
devversionjelbourn
authored andcommitted
refactor(schematics): resolve rule directories automatically (#12958)
* Instead of hard-coding the rule directories and potentially forgetting about adding directories if new rules have been created, we automatically resolve the directories through `glob`. Glob is already used in various schematic parts, and can be used here as well.
1 parent 0ab720a commit b884295

File tree

1 file changed

+2
-14
lines changed

1 file changed

+2
-14
lines changed

src/lib/schematics/update/tslint-update.ts

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {join} from 'path';
9+
import {sync as globSync} from 'glob';
1010
import {TargetVersion} from './index';
1111

1212
/** List of rules that need to be enabled when running the TSLint fix task. */
@@ -54,19 +54,7 @@ const upgradeRules = [
5454
];
5555

5656
/** List of absolute paths that refer to directories that contain the upgrade rules. */
57-
const rulesDirectory = [
58-
// TODO(devversion): consider automatically resolving rule directories.
59-
join(__dirname, 'rules/'),
60-
join(__dirname, 'rules/attribute-selectors'),
61-
join(__dirname, 'rules/class-names'),
62-
join(__dirname, 'rules/class-inheritance'),
63-
join(__dirname, 'rules/input-names'),
64-
join(__dirname, 'rules/output-names'),
65-
join(__dirname, 'rules/css-selectors'),
66-
join(__dirname, 'rules/element-selectors'),
67-
join(__dirname, 'rules/property-names'),
68-
join(__dirname, 'rules/method-calls'),
69-
];
57+
const rulesDirectory = globSync('rules/**/', {cwd: __dirname, absolute: true});
7058

7159
/**
7260
* Creates a TSLint configuration object that can be passed to the schematic `TSLintFixTask`.

0 commit comments

Comments
 (0)