Skip to content

Commit 5a59f09

Browse files
authored
fix(linter): fix exclude pattern for tslint and eslint schematics (#3113)
1 parent 1f90080 commit 5a59f09

File tree

23 files changed

+274
-35
lines changed

23 files changed

+274
-35
lines changed

docs/angular/migration/migration-angular.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ If you are using `Protractor` for E2E testing:
286286
"builder": "@angular-devkit/build-angular:tslint",
287287
"options": {
288288
"tsConfig": "apps/<app name>-e2e/tsconfig.e2e.json",
289-
"exclude": ["**/node_modules/**", "!apps/<app name>-e2e/**"]
289+
"exclude": ["**/node_modules/**", "!apps/<app name>-e2e/**/*"]
290290
}
291291
}
292292
}

jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module.exports = {
33
transform: {
44
'^.+\\.(ts|js|html)$': 'ts-jest',
55
},
6-
resolver: '@nrwl/jest/plugins/resolver',
6+
resolver: '../../scripts/patched-jest-resolver.js',
77
moduleFileExtensions: ['ts', 'js', 'html'],
88
coverageReporters: ['html'],
99
maxWorkers: 2,

packages/angular/src/schematics/application/application.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ describe('app', () => {
2424

2525
expect(
2626
workspaceJson.projects['my-app'].architect.lint.options.exclude
27-
).toEqual(['**/node_modules/**', '!apps/my-app/**']);
27+
).toEqual(['**/node_modules/**', '!apps/my-app/**/*']);
2828
expect(
2929
workspaceJson.projects['my-app-e2e'].architect.lint.options.exclude
30-
).toEqual(['**/node_modules/**', '!apps/my-app-e2e/**']);
30+
).toEqual(['**/node_modules/**', '!apps/my-app-e2e/**/*']);
3131
});
3232

3333
it('should remove the e2e target on the application', async () => {
@@ -175,11 +175,11 @@ describe('app', () => {
175175

176176
expect(
177177
workspaceJson.projects['my-dir-my-app'].architect.lint.options.exclude
178-
).toEqual(['**/node_modules/**', '!apps/my-dir/my-app/**']);
178+
).toEqual(['**/node_modules/**', '!apps/my-dir/my-app/**/*']);
179179
expect(
180180
workspaceJson.projects['my-dir-my-app-e2e'].architect.lint.options
181181
.exclude
182-
).toEqual(['**/node_modules/**', '!apps/my-dir/my-app-e2e/**']);
182+
).toEqual(['**/node_modules/**', '!apps/my-dir/my-app-e2e/**/*']);
183183
});
184184

185185
it('should update nx.json', async () => {
@@ -456,7 +456,7 @@ describe('app', () => {
456456
builder: '@angular-devkit/build-angular:tslint',
457457
options: {
458458
tsConfig: 'apps/my-app-e2e/tsconfig.e2e.json',
459-
exclude: ['**/node_modules/**', '!apps/my-app-e2e/**'],
459+
exclude: ['**/node_modules/**', '!apps/my-app-e2e/**/*'],
460460
},
461461
},
462462
},

packages/angular/src/schematics/application/application.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ function updateProject(options: NormalizedSchema): Rule {
510510
join(normalize(options.appProjectRoot), 'e2e/tsconfig.json')
511511
);
512512
fixedProject.architect.lint.options.exclude.push(
513-
'!' + join(normalize(options.appProjectRoot), '**')
513+
'!' + join(normalize(options.appProjectRoot), '**/*')
514514
);
515515

516516
if (options.e2eTestRunner === 'none') {
@@ -618,7 +618,7 @@ function updateE2eProject(options: NormalizedSchema): Rule {
618618
tsConfig: `${options.e2eProjectRoot}/tsconfig.e2e.json`,
619619
exclude: [
620620
'**/node_modules/**',
621-
'!' + join(normalize(options.e2eProjectRoot), '**'),
621+
'!' + join(normalize(options.e2eProjectRoot), '**/*'),
622622
],
623623
},
624624
},

packages/angular/src/schematics/library/lib/update-project.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ export function updateProject(options: NormalizedSchema): Rule {
137137
path !== join(normalize(options.projectRoot), 'tsconfig.spec.json')
138138
);
139139
fixedProject.architect.lint.options.exclude.push(
140-
'!' + join(normalize(options.projectRoot), '**')
140+
'!' + join(normalize(options.projectRoot), '**/*')
141141
);
142142

143143
json.projects[options.name] = fixedProject;

packages/angular/src/schematics/library/library.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ describe('lib', () => {
9898
]);
9999
expect(
100100
workspaceJson.projects['my-lib'].architect.lint.options.exclude
101-
).toEqual(['**/node_modules/**', '!libs/my-lib/**']);
101+
).toEqual(['**/node_modules/**', '!libs/my-lib/**/*']);
102102
});
103103

104104
it('should remove "build" target from workspace.json when a library is not publishable', async () => {
@@ -452,7 +452,7 @@ describe('lib', () => {
452452
]);
453453
expect(
454454
workspaceJson.projects['my-dir-my-lib'].architect.lint.options.exclude
455-
).toEqual(['**/node_modules/**', '!libs/my-dir/my-lib/**']);
455+
).toEqual(['**/node_modules/**', '!libs/my-dir/my-lib/**/*']);
456456
});
457457

458458
it('should update tsconfig.json', async () => {
@@ -969,7 +969,7 @@ describe('lib', () => {
969969
]);
970970
expect(
971971
workspaceJson.projects['my-lib'].architect.lint.options.exclude
972-
).toEqual(['**/node_modules/**', '!libs/my-lib/**']);
972+
).toEqual(['**/node_modules/**', '!libs/my-lib/**/*']);
973973
});
974974

975975
it('should generate module spec when addModuleSpec is specified', async () => {

packages/cypress/src/schematics/cypress-project/cypress-project.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ describe('schematic:cypress-project', () => {
5151
builder: '@angular-devkit/build-angular:tslint',
5252
options: {
5353
tsConfig: ['apps/my-app-e2e/tsconfig.e2e.json'],
54-
exclude: ['**/node_modules/**', '!apps/my-app-e2e/**'],
54+
exclude: ['**/node_modules/**', '!apps/my-app-e2e/**/*'],
5555
},
5656
});
5757
expect(project.architect.e2e).toEqual({
@@ -83,7 +83,7 @@ describe('schematic:cypress-project', () => {
8383
options: {
8484
linter: 'eslint',
8585
tsConfig: ['apps/my-app-e2e/tsconfig.e2e.json'],
86-
exclude: ['**/node_modules/**', '!apps/my-app-e2e/**'],
86+
exclude: ['**/node_modules/**', '!apps/my-app-e2e/**/*'],
8787
},
8888
});
8989
});
@@ -160,7 +160,7 @@ describe('schematic:cypress-project', () => {
160160
builder: '@angular-devkit/build-angular:tslint',
161161
options: {
162162
tsConfig: ['apps/my-dir/my-app-e2e/tsconfig.e2e.json'],
163-
exclude: ['**/node_modules/**', '!apps/my-dir/my-app-e2e/**'],
163+
exclude: ['**/node_modules/**', '!apps/my-dir/my-app-e2e/**/*'],
164164
},
165165
});
166166

packages/nest/src/schematics/library/library.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ describe('lib', () => {
2121
expect(workspaceJson.projects['my-lib'].architect.lint).toEqual({
2222
builder: '@angular-devkit/build-angular:tslint',
2323
options: {
24-
exclude: ['**/node_modules/**', '!libs/my-lib/**'],
24+
exclude: ['**/node_modules/**', '!libs/my-lib/**/*'],
2525
tsConfig: [
2626
'libs/my-lib/tsconfig.lib.json',
2727
'libs/my-lib/tsconfig.spec.json',
@@ -268,7 +268,7 @@ describe('lib', () => {
268268
expect(workspaceJson.projects['my-dir-my-lib'].architect.lint).toEqual({
269269
builder: '@angular-devkit/build-angular:tslint',
270270
options: {
271-
exclude: ['**/node_modules/**', '!libs/my-dir/my-lib/**'],
271+
exclude: ['**/node_modules/**', '!libs/my-dir/my-lib/**/*'],
272272
tsConfig: [
273273
'libs/my-dir/my-lib/tsconfig.lib.json',
274274
'libs/my-dir/my-lib/tsconfig.spec.json',

packages/node/src/schematics/application/application.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ describe('app', () => {
5959
'apps/my-node-app/tsconfig.app.json',
6060
'apps/my-node-app/tsconfig.spec.json',
6161
],
62-
exclude: ['**/node_modules/**', '!apps/my-node-app/**'],
62+
exclude: ['**/node_modules/**', '!apps/my-node-app/**/*'],
6363
},
6464
});
6565
expect(workspaceJson.projects['my-node-app-e2e']).toBeUndefined();
@@ -127,7 +127,7 @@ describe('app', () => {
127127
'apps/my-dir/my-node-app/tsconfig.app.json',
128128
'apps/my-dir/my-node-app/tsconfig.spec.json',
129129
],
130-
exclude: ['**/node_modules/**', '!apps/my-dir/my-node-app/**'],
130+
exclude: ['**/node_modules/**', '!apps/my-dir/my-node-app/**/*'],
131131
},
132132
});
133133

packages/node/src/schematics/library/library.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ describe('lib', () => {
2121
expect(workspaceJson.projects['my-lib'].architect.lint).toEqual({
2222
builder: '@angular-devkit/build-angular:tslint',
2323
options: {
24-
exclude: ['**/node_modules/**', '!libs/my-lib/**'],
24+
exclude: ['**/node_modules/**', '!libs/my-lib/**/*'],
2525
tsConfig: [
2626
'libs/my-lib/tsconfig.lib.json',
2727
'libs/my-lib/tsconfig.spec.json',
@@ -159,7 +159,7 @@ describe('lib', () => {
159159
expect(workspaceJson.projects['my-dir-my-lib'].architect.lint).toEqual({
160160
builder: '@angular-devkit/build-angular:tslint',
161161
options: {
162-
exclude: ['**/node_modules/**', '!libs/my-dir/my-lib/**'],
162+
exclude: ['**/node_modules/**', '!libs/my-dir/my-lib/**/*'],
163163
tsConfig: [
164164
'libs/my-dir/my-lib/tsconfig.lib.json',
165165
'libs/my-dir/my-lib/tsconfig.spec.json',

packages/nx-plugin/src/schematics/plugin/plugin.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ describe('NxPlugin plugin', () => {
4444
expect(project.architect.lint).toEqual({
4545
builder: '@angular-devkit/build-angular:tslint',
4646
options: {
47-
exclude: ['**/node_modules/**', '!libs/my-plugin/**'],
47+
exclude: ['**/node_modules/**', '!libs/my-plugin/**/*'],
4848
tsConfig: [
4949
'libs/my-plugin/tsconfig.lib.json',
5050
'libs/my-plugin/tsconfig.spec.json',

packages/react/src/schematics/application/application.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ describe('app', () => {
294294
expect(workspaceJson.projects['my-app'].architect.lint).toEqual({
295295
builder: '@angular-devkit/build-angular:tslint',
296296
options: {
297-
exclude: ['**/node_modules/**', '!apps/my-app/**'],
297+
exclude: ['**/node_modules/**', '!apps/my-app/**/*'],
298298
tsConfig: [
299299
'apps/my-app/tsconfig.app.json',
300300
'apps/my-app/tsconfig.spec.json',

packages/react/src/schematics/library/library.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ describe('lib', () => {
2020
expect(workspaceJson.projects['my-lib'].architect.lint).toEqual({
2121
builder: '@angular-devkit/build-angular:tslint',
2222
options: {
23-
exclude: ['**/node_modules/**', '!libs/my-lib/**'],
23+
exclude: ['**/node_modules/**', '!libs/my-lib/**/*'],
2424
tsConfig: [
2525
'libs/my-lib/tsconfig.lib.json',
2626
'libs/my-lib/tsconfig.spec.json',
@@ -184,7 +184,7 @@ describe('lib', () => {
184184
expect(workspaceJson.projects['my-dir-my-lib'].architect.lint).toEqual({
185185
builder: '@angular-devkit/build-angular:tslint',
186186
options: {
187-
exclude: ['**/node_modules/**', '!libs/my-dir/my-lib/**'],
187+
exclude: ['**/node_modules/**', '!libs/my-dir/my-lib/**/*'],
188188
tsConfig: [
189189
'libs/my-dir/my-lib/tsconfig.lib.json',
190190
'libs/my-dir/my-lib/tsconfig.spec.json',

packages/web/src/schematics/application/application.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ describe('app', () => {
282282
expect(workspaceJson.projects['my-app'].architect.lint).toEqual({
283283
builder: '@angular-devkit/build-angular:tslint',
284284
options: {
285-
exclude: ['**/node_modules/**', '!apps/my-app/**'],
285+
exclude: ['**/node_modules/**', '!apps/my-app/**/*'],
286286
tsConfig: [
287287
'apps/my-app/tsconfig.app.json',
288288
'apps/my-app/tsconfig.spec.json',

packages/workspace/migrations.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@
7979
"version": "9.4.0-beta.1",
8080
"description": "Remove config builder option when using eslint to enable automatic detection",
8181
"factory": "./src/migrations/update-9-4-0/update-eslint-config"
82+
},
83+
"update-linters-exclude": {
84+
"version": "9.4.0-beta.1",
85+
"description": "Fix exclude patterns in tslint and eslint to ensure it does not break linting when a files option is defined",
86+
"factory": "./src/migrations/update-9-4-0/update-linters-exclude"
8287
}
8388
},
8489
"packageJsonUpdates": {

packages/workspace/src/migrations/update-8-2-0/update-8-2-0.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ describe('Update 8.2.0', () => {
4040
builder: '@angular-devkit/build-angular:tslint',
4141
options: {
4242
tsConfig: ['my-app/tsconfig.json'],
43-
exclude: ['**/node_modules/**', '!my-app/**'],
43+
exclude: ['**/node_modules/**', '!my-app/**/*'],
4444
},
4545
});
4646
});

packages/workspace/src/migrations/update-8-2-0/update-8-2-0.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const addExcludes = updateWorkspace((workspace) => {
99
if (target.builder !== '@angular-devkit/build-angular:tslint') {
1010
return;
1111
}
12-
const exceptRootGlob = '!' + join(normalize(project.root), '**');
12+
const exceptRootGlob = '!' + join(normalize(project.root), '**/*');
1313

1414
if (!target.options.exclude) {
1515
target.options.exclude = [];

0 commit comments

Comments
 (0)