-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(linter): remove
config
builder option for @nrwl/linter:lint whe…
…n using eslint (#3093) - eslint automatically detects .eslintrc files already - removing the config option also enables nested configs - provide a migration to remove config as long as users didn't customize it
- Loading branch information
Showing
9 changed files
with
127 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
packages/next/src/schematics/application/files/index.d.ts__tmpl__
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
packages/workspace/src/migrations/update-9-4-0/update-eslint-config.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import { Tree } from '@angular-devkit/schematics'; | ||
import { readWorkspace } from '@nrwl/workspace'; | ||
import { createEmptyWorkspace } from '@nrwl/workspace/testing'; | ||
import { callRule, runMigration } from '../../utils/testing'; | ||
import { updateWorkspace } from '@nrwl/workspace/src/utils/workspace'; | ||
|
||
describe('Update eslint config for 9.4.0', () => { | ||
let tree: Tree; | ||
|
||
beforeEach(async () => { | ||
tree = Tree.empty(); | ||
tree = createEmptyWorkspace(tree); | ||
tree = await callRule( | ||
updateWorkspace((workspace) => { | ||
workspace.projects.add({ | ||
name: 'proj1', | ||
root: 'proj1', | ||
architect: { | ||
lint: { | ||
builder: '@angular-devkit/build-angular:tslint', | ||
options: { | ||
config: 'proj1/tslint.json', | ||
}, | ||
}, | ||
}, | ||
}); | ||
workspace.projects.add({ | ||
name: 'proj2', | ||
root: 'proj2', | ||
architect: { | ||
lint: { | ||
builder: '@nrwl/linter:lint', | ||
options: { | ||
linter: 'eslint', | ||
config: 'proj2/.eslintrc', | ||
}, | ||
}, | ||
}, | ||
}); | ||
workspace.projects.add({ | ||
name: 'proj3', | ||
root: 'proj3', | ||
architect: { | ||
lint: { | ||
builder: '@nrwl/linter:lint', | ||
options: { | ||
linter: 'tslint', | ||
config: 'proj3/tslint.json', | ||
}, | ||
}, | ||
}, | ||
}); | ||
workspace.projects.add({ | ||
name: 'proj4', | ||
root: 'proj4', | ||
architect: { | ||
lint: { | ||
builder: '@nrwl/linter:lint', | ||
options: { | ||
linter: 'eslint', | ||
config: 'proj4/.eslintrc.custom', | ||
}, | ||
}, | ||
}, | ||
}); | ||
}), | ||
tree | ||
); | ||
}); | ||
|
||
it('should remove config builder option when using eslint', async () => { | ||
const result = await runMigration('update-eslint-config', {}, tree); | ||
|
||
const json = readWorkspace(result); | ||
|
||
expect(json.projects.proj1.architect.lint.options.config).toMatch( | ||
'proj1/tslint.json' | ||
); | ||
expect(json.projects.proj2.architect.lint.options.config).toBeUndefined(); | ||
expect(json.projects.proj3.architect.lint.options.config).toMatch( | ||
'proj3/tslint.json' | ||
); | ||
expect(json.projects.proj4.architect.lint.options.config).toMatch( | ||
'proj4/.eslintrc.custom' | ||
); | ||
}); | ||
}); |
21 changes: 21 additions & 0 deletions
21
packages/workspace/src/migrations/update-9-4-0/update-eslint-config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { chain, SchematicContext, Tree } from '@angular-devkit/schematics'; | ||
import { formatFiles, updateWorkspaceInTree } from '@nrwl/workspace'; | ||
|
||
function removeEslintConfigOption(host: Tree, context: SchematicContext) { | ||
return updateWorkspaceInTree((json) => { | ||
Object.keys(json.projects).forEach((name) => { | ||
const p = json.projects[name]; | ||
if ( | ||
p.architect?.lint.builder === '@nrwl/linter:lint' && | ||
p.architect?.lint.options?.config === `${p.root}/.eslintrc` | ||
) { | ||
delete p.architect.lint.options.config; | ||
} | ||
}); | ||
return json; | ||
}); | ||
} | ||
|
||
export default function () { | ||
return chain([removeEslintConfigOption, formatFiles()]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters