Skip to content

Commit 8894706

Browse files
dgp1130josephperrott
authored andcommitted
fix(core): use single quotes for relative link resolution migration to align with style guide (angular#39070)
This updates the migration to align with the style guide and work with default lint rules. It avoids a lint error on newly migrated projects and fixes a test in the CLI repo. PR Close angular#39070
1 parent ac54019 commit 8894706

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

packages/core/schematics/migrations/relative-link-resolution/transform.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ export class RelativeLinkResolutionTransform {
4444
// literal already defines a value for relativeLinkResolution. Skip it
4545
return literal;
4646
}
47-
const legacyExpression =
48-
ts.createPropertyAssignment(RELATIVE_LINK_RESOLUTION, ts.createStringLiteral('legacy'));
47+
const legacyExpression = ts.createPropertyAssignment(
48+
RELATIVE_LINK_RESOLUTION, ts.createStringLiteral('legacy', true /* singleQuotes */));
4949
return ts.updateObjectLiteral(literal, [...literal.properties, legacyExpression]);
5050
}
5151

packages/core/schematics/test/google3/relative_link_resolution_default_spec.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ describe('Google3 relativeLinkResolution TSLint rule', () => {
8585

8686
runTSLint(true);
8787
expect(getFile('/index.ts'))
88-
.toContain(`RouterModule.forRoot([], { relativeLinkResolution: "legacy" })`);
88+
.toContain(`RouterModule.forRoot([], { relativeLinkResolution: 'legacy' })`);
8989
});
9090

9191
it('should migrate options without relativeLinkResolution', () => {
@@ -103,7 +103,7 @@ describe('Google3 relativeLinkResolution TSLint rule', () => {
103103

104104
runTSLint(true);
105105
expect(getFile('/index.ts'))
106-
.toContain(`RouterModule.forRoot([], { useHash: true, relativeLinkResolution: "legacy" })`);
106+
.toContain(`RouterModule.forRoot([], { useHash: true, relativeLinkResolution: 'legacy' })`);
107107
});
108108

109109
it('should not migrate options containing relativeLinkResolution', () => {
@@ -133,7 +133,7 @@ describe('Google3 relativeLinkResolution TSLint rule', () => {
133133
runTSLint(true);
134134
expect(getFile('/index.ts'))
135135
.toContain(
136-
`const options = { useHash: true, relativeLinkResolution: "legacy" } as ExtraOptions;`);
136+
`const options = { useHash: true, relativeLinkResolution: 'legacy' } as ExtraOptions;`);
137137
});
138138

139139
it('should migrate when options is a variable', () => {
@@ -145,7 +145,7 @@ describe('Google3 relativeLinkResolution TSLint rule', () => {
145145
runTSLint(true);
146146
expect(getFile('/index.ts'))
147147
.toContain(
148-
`const options: ExtraOptions = { useHash: true, relativeLinkResolution: "legacy" };`);
148+
`const options: ExtraOptions = { useHash: true, relativeLinkResolution: 'legacy' };`);
149149
});
150150

151151
it('should migrate when options is a variable with no type', () => {
@@ -166,7 +166,7 @@ describe('Google3 relativeLinkResolution TSLint rule', () => {
166166

167167
runTSLint(true);
168168
expect(getFile('/index.ts'))
169-
.toContain(`const options = { useHash: true, relativeLinkResolution: "legacy" };`);
169+
.toContain(`const options = { useHash: true, relativeLinkResolution: 'legacy' };`);
170170
expect(getFile('/index.ts')).toContain(`RouterModule.forRoot([], options)`);
171171
});
172172

@@ -179,7 +179,7 @@ describe('Google3 relativeLinkResolution TSLint rule', () => {
179179
runTSLint(true);
180180
expect(getFile('/index.ts'))
181181
.toContain(
182-
`const options: RouterExtraOptions = { useHash: true, relativeLinkResolution: "legacy" };`);
182+
`const options: RouterExtraOptions = { useHash: true, relativeLinkResolution: 'legacy' };`);
183183
});
184184

185185
it('should migrate aliased RouterModule.forRoot', () => {
@@ -197,6 +197,6 @@ describe('Google3 relativeLinkResolution TSLint rule', () => {
197197

198198
runTSLint(true);
199199
expect(getFile('/index.ts'))
200-
.toContain(`AngularRouterModule.forRoot([], { relativeLinkResolution: "legacy" }),`);
200+
.toContain(`AngularRouterModule.forRoot([], { relativeLinkResolution: 'legacy' }),`);
201201
});
202202
});

packages/core/schematics/test/relative_link_resolution_spec.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ describe('initial navigation migration', () => {
6161

6262
await runMigration();
6363
expect(tree.readContent('/index.ts'))
64-
.toContain(`RouterModule.forRoot([], { relativeLinkResolution: "legacy" })`);
64+
.toContain(`RouterModule.forRoot([], { relativeLinkResolution: 'legacy' })`);
6565
});
6666

6767
it('should migrate options without relativeLinkResolution', async () => {
@@ -79,7 +79,7 @@ describe('initial navigation migration', () => {
7979

8080
await runMigration();
8181
expect(tree.readContent('/index.ts'))
82-
.toContain(`RouterModule.forRoot([], { useHash: true, relativeLinkResolution: "legacy" })`);
82+
.toContain(`RouterModule.forRoot([], { useHash: true, relativeLinkResolution: 'legacy' })`);
8383
});
8484

8585
it('should not migrate options containing relativeLinkResolution', async () => {
@@ -109,7 +109,7 @@ describe('initial navigation migration', () => {
109109
await runMigration();
110110
expect(tree.readContent('/index.ts'))
111111
.toContain(
112-
`const options = { useHash: true, relativeLinkResolution: "legacy" } as ExtraOptions;`);
112+
`const options = { useHash: true, relativeLinkResolution: 'legacy' } as ExtraOptions;`);
113113
});
114114

115115
it('should migrate when options is a variable', async () => {
@@ -121,7 +121,7 @@ describe('initial navigation migration', () => {
121121
await runMigration();
122122
expect(tree.readContent('/index.ts'))
123123
.toContain(
124-
`const options: ExtraOptions = { useHash: true, relativeLinkResolution: "legacy" };`);
124+
`const options: ExtraOptions = { useHash: true, relativeLinkResolution: 'legacy' };`);
125125
});
126126

127127
it('should migrate when options is a variable with no type', async () => {
@@ -142,7 +142,7 @@ describe('initial navigation migration', () => {
142142

143143
await runMigration();
144144
expect(tree.readContent('/index.ts'))
145-
.toContain(`const options = { useHash: true, relativeLinkResolution: "legacy" };`);
145+
.toContain(`const options = { useHash: true, relativeLinkResolution: 'legacy' };`);
146146
expect(tree.readContent('/index.ts')).toContain(`RouterModule.forRoot([], options)`);
147147
});
148148

@@ -155,7 +155,7 @@ describe('initial navigation migration', () => {
155155
await runMigration();
156156
expect(tree.readContent('/index.ts'))
157157
.toContain(
158-
`const options: RouterExtraOptions = { useHash: true, relativeLinkResolution: "legacy" };`);
158+
`const options: RouterExtraOptions = { useHash: true, relativeLinkResolution: 'legacy' };`);
159159
});
160160

161161
it('should migrate aliased RouterModule.forRoot', async () => {
@@ -173,7 +173,7 @@ describe('initial navigation migration', () => {
173173

174174
await runMigration();
175175
expect(tree.readContent('/index.ts'))
176-
.toContain(`AngularRouterModule.forRoot([], { relativeLinkResolution: "legacy" }),`);
176+
.toContain(`AngularRouterModule.forRoot([], { relativeLinkResolution: 'legacy' }),`);
177177
});
178178

179179
function writeFile(filePath: string, contents: string) {

0 commit comments

Comments
 (0)