Skip to content

Commit 2191d08

Browse files
committed
chore(): create utils
1 parent ddc3aea commit 2191d08

File tree

5 files changed

+23
-36
lines changed

5 files changed

+23
-36
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@
5353
"rimraf": "^2.6.2",
5454
"semantic-release": "^15.9.17",
5555
"tslint": "^5.12.0",
56-
"tslint-ionic-rules": "0.0.21"
56+
"tslint-ionic-rules": "0.0.21",
57+
"typescript-tslint-plugin": "0.3.1"
5758
},
5859
"peerDependencies": {
5960
"@angular-devkit/architect": ">=0.7.2",

schematics/component/index.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,9 @@ import { buildDefaultPath, getProject } from '@schematics/angular/utility/projec
88
import { validateHtmlSelector, validateName } from '@schematics/angular/utility/validation';
99
import * as ts from 'typescript';
1010

11-
import { Schema as ComponentOptions } from './schema';
12-
13-
function buildSelector(options: ComponentOptions, projectPrefix: string) {
14-
let selector = strings.dasherize(options.name);
15-
16-
if (options.prefix) {
17-
selector = `${options.prefix}-${selector}`;
18-
} else if (options.prefix === undefined && projectPrefix) {
19-
selector = `${projectPrefix}-${selector}`;
20-
}
11+
import { buildSelector } from '../util';
2112

22-
return selector;
23-
}
13+
import { Schema as ComponentOptions } from './schema';
2414

2515
function readIntoSourceFile(host: Tree, modulePath: string): ts.SourceFile {
2616
const text = host.read(modulePath);

schematics/page/index.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import { buildDefaultPath, getProject } from '@schematics/angular/utility/projec
88
import { validateHtmlSelector, validateName } from '@schematics/angular/utility/validation';
99
import * as ts from 'typescript';
1010

11+
import { buildSelector } from '../util';
12+
1113
import { Schema as PageOptions } from './schema';
1214

1315
function findRoutingModuleFromOptions(host: Tree, options: ModuleOptions): Path | undefined {
@@ -137,18 +139,6 @@ function addRouteToRoutesArray(source: ts.SourceFile, ngModulePath: string, rout
137139
return [];
138140
}
139141

140-
function buildSelector(options: PageOptions, projectPrefix: string) {
141-
let selector = strings.dasherize(options.name);
142-
143-
if (options.prefix) {
144-
selector = `${options.prefix}-${selector}`;
145-
} else if (options.prefix === undefined && projectPrefix) {
146-
selector = `${projectPrefix}-${selector}`;
147-
}
148-
149-
return selector;
150-
}
151-
152142
export default function(options: PageOptions): Rule {
153143
return (host, context) => {
154144
if (!options.project) {

schematics/util/index.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { strings } from '@angular-devkit/architect/node_modules/@angular-devkit/core';
2+
3+
export function buildSelector(options: any, projectPrefix: string) {
4+
let selector = strings.dasherize(options.name);
5+
6+
if (options.prefix) {
7+
selector = `${options.prefix}-${selector}`;
8+
} else if (options.prefix === undefined && projectPrefix) {
9+
selector = `${projectPrefix}-${selector}`;
10+
}
11+
12+
return selector;
13+
}

tsconfig.json

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,9 @@
1010
"pretty": true,
1111
"strict": true,
1212
"target": "es2017",
13-
"lib": [
14-
"es2017"
15-
]
13+
"lib": ["es2017"],
14+
"plugins": [{ "name": "typescript-tslint-plugin" }]
1615
},
17-
"include": [
18-
"**/*.ts"
19-
],
20-
"exclude": [
21-
"node_modules",
22-
"**/__tests__/*.ts",
23-
"schematics/*/files"
24-
]
16+
"include": ["**/*.ts"],
17+
"exclude": ["node_modules", "**/__tests__/*.ts", "schematics/*/files"]
2518
}

0 commit comments

Comments
 (0)