Skip to content

Commit

Permalink
fix(linter): fix exclude pattern for tslint and eslint schematics (#3113
Browse files Browse the repository at this point in the history
)
  • Loading branch information
rarmatei authored Jun 5, 2020
1 parent 1f90080 commit 5a59f09
Show file tree
Hide file tree
Showing 23 changed files with 274 additions and 35 deletions.
2 changes: 1 addition & 1 deletion docs/angular/migration/migration-angular.md
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ If you are using `Protractor` for E2E testing:
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": "apps/<app name>-e2e/tsconfig.e2e.json",
"exclude": ["**/node_modules/**", "!apps/<app name>-e2e/**"]
"exclude": ["**/node_modules/**", "!apps/<app name>-e2e/**/*"]
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module.exports = {
transform: {
'^.+\\.(ts|js|html)$': 'ts-jest',
},
resolver: '@nrwl/jest/plugins/resolver',
resolver: '../../scripts/patched-jest-resolver.js',
moduleFileExtensions: ['ts', 'js', 'html'],
coverageReporters: ['html'],
maxWorkers: 2,
Expand Down
10 changes: 5 additions & 5 deletions packages/angular/src/schematics/application/application.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ describe('app', () => {

expect(
workspaceJson.projects['my-app'].architect.lint.options.exclude
).toEqual(['**/node_modules/**', '!apps/my-app/**']);
).toEqual(['**/node_modules/**', '!apps/my-app/**/*']);
expect(
workspaceJson.projects['my-app-e2e'].architect.lint.options.exclude
).toEqual(['**/node_modules/**', '!apps/my-app-e2e/**']);
).toEqual(['**/node_modules/**', '!apps/my-app-e2e/**/*']);
});

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

expect(
workspaceJson.projects['my-dir-my-app'].architect.lint.options.exclude
).toEqual(['**/node_modules/**', '!apps/my-dir/my-app/**']);
).toEqual(['**/node_modules/**', '!apps/my-dir/my-app/**/*']);
expect(
workspaceJson.projects['my-dir-my-app-e2e'].architect.lint.options
.exclude
).toEqual(['**/node_modules/**', '!apps/my-dir/my-app-e2e/**']);
).toEqual(['**/node_modules/**', '!apps/my-dir/my-app-e2e/**/*']);
});

it('should update nx.json', async () => {
Expand Down Expand Up @@ -456,7 +456,7 @@ describe('app', () => {
builder: '@angular-devkit/build-angular:tslint',
options: {
tsConfig: 'apps/my-app-e2e/tsconfig.e2e.json',
exclude: ['**/node_modules/**', '!apps/my-app-e2e/**'],
exclude: ['**/node_modules/**', '!apps/my-app-e2e/**/*'],
},
},
},
Expand Down
4 changes: 2 additions & 2 deletions packages/angular/src/schematics/application/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ function updateProject(options: NormalizedSchema): Rule {
join(normalize(options.appProjectRoot), 'e2e/tsconfig.json')
);
fixedProject.architect.lint.options.exclude.push(
'!' + join(normalize(options.appProjectRoot), '**')
'!' + join(normalize(options.appProjectRoot), '**/*')
);

if (options.e2eTestRunner === 'none') {
Expand Down Expand Up @@ -618,7 +618,7 @@ function updateE2eProject(options: NormalizedSchema): Rule {
tsConfig: `${options.e2eProjectRoot}/tsconfig.e2e.json`,
exclude: [
'**/node_modules/**',
'!' + join(normalize(options.e2eProjectRoot), '**'),
'!' + join(normalize(options.e2eProjectRoot), '**/*'),
],
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export function updateProject(options: NormalizedSchema): Rule {
path !== join(normalize(options.projectRoot), 'tsconfig.spec.json')
);
fixedProject.architect.lint.options.exclude.push(
'!' + join(normalize(options.projectRoot), '**')
'!' + join(normalize(options.projectRoot), '**/*')
);

json.projects[options.name] = fixedProject;
Expand Down
6 changes: 3 additions & 3 deletions packages/angular/src/schematics/library/library.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ describe('lib', () => {
]);
expect(
workspaceJson.projects['my-lib'].architect.lint.options.exclude
).toEqual(['**/node_modules/**', '!libs/my-lib/**']);
).toEqual(['**/node_modules/**', '!libs/my-lib/**/*']);
});

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

it('should update tsconfig.json', async () => {
Expand Down Expand Up @@ -969,7 +969,7 @@ describe('lib', () => {
]);
expect(
workspaceJson.projects['my-lib'].architect.lint.options.exclude
).toEqual(['**/node_modules/**', '!libs/my-lib/**']);
).toEqual(['**/node_modules/**', '!libs/my-lib/**/*']);
});

it('should generate module spec when addModuleSpec is specified', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe('schematic:cypress-project', () => {
builder: '@angular-devkit/build-angular:tslint',
options: {
tsConfig: ['apps/my-app-e2e/tsconfig.e2e.json'],
exclude: ['**/node_modules/**', '!apps/my-app-e2e/**'],
exclude: ['**/node_modules/**', '!apps/my-app-e2e/**/*'],
},
});
expect(project.architect.e2e).toEqual({
Expand Down Expand Up @@ -83,7 +83,7 @@ describe('schematic:cypress-project', () => {
options: {
linter: 'eslint',
tsConfig: ['apps/my-app-e2e/tsconfig.e2e.json'],
exclude: ['**/node_modules/**', '!apps/my-app-e2e/**'],
exclude: ['**/node_modules/**', '!apps/my-app-e2e/**/*'],
},
});
});
Expand Down Expand Up @@ -160,7 +160,7 @@ describe('schematic:cypress-project', () => {
builder: '@angular-devkit/build-angular:tslint',
options: {
tsConfig: ['apps/my-dir/my-app-e2e/tsconfig.e2e.json'],
exclude: ['**/node_modules/**', '!apps/my-dir/my-app-e2e/**'],
exclude: ['**/node_modules/**', '!apps/my-dir/my-app-e2e/**/*'],
},
});

Expand Down
4 changes: 2 additions & 2 deletions packages/nest/src/schematics/library/library.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('lib', () => {
expect(workspaceJson.projects['my-lib'].architect.lint).toEqual({
builder: '@angular-devkit/build-angular:tslint',
options: {
exclude: ['**/node_modules/**', '!libs/my-lib/**'],
exclude: ['**/node_modules/**', '!libs/my-lib/**/*'],
tsConfig: [
'libs/my-lib/tsconfig.lib.json',
'libs/my-lib/tsconfig.spec.json',
Expand Down Expand Up @@ -268,7 +268,7 @@ describe('lib', () => {
expect(workspaceJson.projects['my-dir-my-lib'].architect.lint).toEqual({
builder: '@angular-devkit/build-angular:tslint',
options: {
exclude: ['**/node_modules/**', '!libs/my-dir/my-lib/**'],
exclude: ['**/node_modules/**', '!libs/my-dir/my-lib/**/*'],
tsConfig: [
'libs/my-dir/my-lib/tsconfig.lib.json',
'libs/my-dir/my-lib/tsconfig.spec.json',
Expand Down
4 changes: 2 additions & 2 deletions packages/node/src/schematics/application/application.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ describe('app', () => {
'apps/my-node-app/tsconfig.app.json',
'apps/my-node-app/tsconfig.spec.json',
],
exclude: ['**/node_modules/**', '!apps/my-node-app/**'],
exclude: ['**/node_modules/**', '!apps/my-node-app/**/*'],
},
});
expect(workspaceJson.projects['my-node-app-e2e']).toBeUndefined();
Expand Down Expand Up @@ -127,7 +127,7 @@ describe('app', () => {
'apps/my-dir/my-node-app/tsconfig.app.json',
'apps/my-dir/my-node-app/tsconfig.spec.json',
],
exclude: ['**/node_modules/**', '!apps/my-dir/my-node-app/**'],
exclude: ['**/node_modules/**', '!apps/my-dir/my-node-app/**/*'],
},
});

Expand Down
4 changes: 2 additions & 2 deletions packages/node/src/schematics/library/library.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('lib', () => {
expect(workspaceJson.projects['my-lib'].architect.lint).toEqual({
builder: '@angular-devkit/build-angular:tslint',
options: {
exclude: ['**/node_modules/**', '!libs/my-lib/**'],
exclude: ['**/node_modules/**', '!libs/my-lib/**/*'],
tsConfig: [
'libs/my-lib/tsconfig.lib.json',
'libs/my-lib/tsconfig.spec.json',
Expand Down Expand Up @@ -159,7 +159,7 @@ describe('lib', () => {
expect(workspaceJson.projects['my-dir-my-lib'].architect.lint).toEqual({
builder: '@angular-devkit/build-angular:tslint',
options: {
exclude: ['**/node_modules/**', '!libs/my-dir/my-lib/**'],
exclude: ['**/node_modules/**', '!libs/my-dir/my-lib/**/*'],
tsConfig: [
'libs/my-dir/my-lib/tsconfig.lib.json',
'libs/my-dir/my-lib/tsconfig.spec.json',
Expand Down
2 changes: 1 addition & 1 deletion packages/nx-plugin/src/schematics/plugin/plugin.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe('NxPlugin plugin', () => {
expect(project.architect.lint).toEqual({
builder: '@angular-devkit/build-angular:tslint',
options: {
exclude: ['**/node_modules/**', '!libs/my-plugin/**'],
exclude: ['**/node_modules/**', '!libs/my-plugin/**/*'],
tsConfig: [
'libs/my-plugin/tsconfig.lib.json',
'libs/my-plugin/tsconfig.spec.json',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ describe('app', () => {
expect(workspaceJson.projects['my-app'].architect.lint).toEqual({
builder: '@angular-devkit/build-angular:tslint',
options: {
exclude: ['**/node_modules/**', '!apps/my-app/**'],
exclude: ['**/node_modules/**', '!apps/my-app/**/*'],
tsConfig: [
'apps/my-app/tsconfig.app.json',
'apps/my-app/tsconfig.spec.json',
Expand Down
4 changes: 2 additions & 2 deletions packages/react/src/schematics/library/library.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('lib', () => {
expect(workspaceJson.projects['my-lib'].architect.lint).toEqual({
builder: '@angular-devkit/build-angular:tslint',
options: {
exclude: ['**/node_modules/**', '!libs/my-lib/**'],
exclude: ['**/node_modules/**', '!libs/my-lib/**/*'],
tsConfig: [
'libs/my-lib/tsconfig.lib.json',
'libs/my-lib/tsconfig.spec.json',
Expand Down Expand Up @@ -184,7 +184,7 @@ describe('lib', () => {
expect(workspaceJson.projects['my-dir-my-lib'].architect.lint).toEqual({
builder: '@angular-devkit/build-angular:tslint',
options: {
exclude: ['**/node_modules/**', '!libs/my-dir/my-lib/**'],
exclude: ['**/node_modules/**', '!libs/my-dir/my-lib/**/*'],
tsConfig: [
'libs/my-dir/my-lib/tsconfig.lib.json',
'libs/my-dir/my-lib/tsconfig.spec.json',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ describe('app', () => {
expect(workspaceJson.projects['my-app'].architect.lint).toEqual({
builder: '@angular-devkit/build-angular:tslint',
options: {
exclude: ['**/node_modules/**', '!apps/my-app/**'],
exclude: ['**/node_modules/**', '!apps/my-app/**/*'],
tsConfig: [
'apps/my-app/tsconfig.app.json',
'apps/my-app/tsconfig.spec.json',
Expand Down
5 changes: 5 additions & 0 deletions packages/workspace/migrations.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@
"version": "9.4.0-beta.1",
"description": "Remove config builder option when using eslint to enable automatic detection",
"factory": "./src/migrations/update-9-4-0/update-eslint-config"
},
"update-linters-exclude": {
"version": "9.4.0-beta.1",
"description": "Fix exclude patterns in tslint and eslint to ensure it does not break linting when a files option is defined",
"factory": "./src/migrations/update-9-4-0/update-linters-exclude"
}
},
"packageJsonUpdates": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe('Update 8.2.0', () => {
builder: '@angular-devkit/build-angular:tslint',
options: {
tsConfig: ['my-app/tsconfig.json'],
exclude: ['**/node_modules/**', '!my-app/**'],
exclude: ['**/node_modules/**', '!my-app/**/*'],
},
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const addExcludes = updateWorkspace((workspace) => {
if (target.builder !== '@angular-devkit/build-angular:tslint') {
return;
}
const exceptRootGlob = '!' + join(normalize(project.root), '**');
const exceptRootGlob = '!' + join(normalize(project.root), '**/*');

if (!target.options.exclude) {
target.options.exclude = [];
Expand Down
Loading

0 comments on commit 5a59f09

Please sign in to comment.