Skip to content

Commit

Permalink
fix(sdk/eslint-config): alternatively look for angular-eslint depen…
Browse files Browse the repository at this point in the history
…dency (#2755)
  • Loading branch information
johnhwhite authored Sep 17, 2024
1 parent bb7c016 commit e1fd53c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,26 @@ describe('ng-add.schematic', () => {
});

await expect(() => runSchematic()).rejects.toThrowError(
"The package '@angular-eslint/schematics' is not installed. " +
"The package 'angular-eslint' is not installed. " +
"Run 'ng add @angular-eslint/schematics' and try this command again.\n" +
'See: https://github.com/angular-eslint/angular-eslint#quick-start',
);
});

it("should not abort if 'angular-eslint' is installed", async () => {
const { runSchematic, tree } = await setupTest({
esLintConfig: {},
packageJson: {
devDependencies: {
'angular-eslint': '*',
},
},
});

await runSchematic();
expect(readJsonFile(tree, ESLINT_CONFIG_PATH)).toEqual({});
});

it('should harden the version of the @skyux-sdk/eslint-config package', async () => {
const { runSchematic, tree } = await setupTest({
esLintConfig: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,12 @@ export default function ngAdd(): Rule {
return (tree) => {
const packageJson = getPackageJson(tree);

if (!packageJson.devDependencies?.['@angular-eslint/schematics']) {
if (
!packageJson.devDependencies?.['@angular-eslint/schematics'] &&
!packageJson.devDependencies?.['angular-eslint']
) {
throw new Error(
"The package '@angular-eslint/schematics' is not installed. " +
"The package 'angular-eslint' is not installed. " +
"Run 'ng add @angular-eslint/schematics' and try this command again.\n" +
'See: https://github.com/angular-eslint/angular-eslint#quick-start',
);
Expand Down

0 comments on commit e1fd53c

Please sign in to comment.