-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(angular): install jsonc-eslint-parser only when @nx/dependency-ch…
- Loading branch information
1 parent
208d496
commit 689d9cc
Showing
3 changed files
with
46 additions
and
35 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
38 changes: 23 additions & 15 deletions
38
packages/angular/src/generators/add-linting/lib/add-angular-eslint-dependencies.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 |
---|---|---|
@@ -1,19 +1,27 @@ | ||
import type { GeneratorCallback, Tree } from '@nx/devkit'; | ||
import { addDependenciesToPackageJson } from '@nx/devkit'; | ||
import { | ||
addDependenciesToPackageJson, | ||
type GeneratorCallback, | ||
type Tree, | ||
} from '@nx/devkit'; | ||
import { versions } from '../../utils/version-utils'; | ||
import { isBuildableLibraryProject } from './buildable-project'; | ||
|
||
export function addAngularEsLintDependencies(tree: Tree): GeneratorCallback { | ||
export function addAngularEsLintDependencies( | ||
tree: Tree, | ||
projectName: string | ||
): GeneratorCallback { | ||
const angularEslintVersionToInstall = versions(tree).angularEslintVersion; | ||
const jsoncEslintParserVersionToInstall = | ||
versions(tree).jsoncEslintParserVersion; | ||
return addDependenciesToPackageJson( | ||
tree, | ||
{}, | ||
{ | ||
'@angular-eslint/eslint-plugin': angularEslintVersionToInstall, | ||
'@angular-eslint/eslint-plugin-template': angularEslintVersionToInstall, | ||
'@angular-eslint/template-parser': angularEslintVersionToInstall, | ||
'jsonc-eslint-parser': jsoncEslintParserVersionToInstall, | ||
} | ||
); | ||
const devDependencies = { | ||
'@angular-eslint/eslint-plugin': angularEslintVersionToInstall, | ||
'@angular-eslint/eslint-plugin-template': angularEslintVersionToInstall, | ||
'@angular-eslint/template-parser': angularEslintVersionToInstall, | ||
}; | ||
|
||
if (isBuildableLibraryProject(tree, projectName)) { | ||
const jsoncEslintParserVersionToInstall = | ||
versions(tree).jsoncEslintParserVersion; | ||
devDependencies['jsonc-eslint-parser'] = jsoncEslintParserVersionToInstall; | ||
} | ||
|
||
return addDependenciesToPackageJson(tree, {}, devDependencies); | ||
} |
12 changes: 12 additions & 0 deletions
12
packages/angular/src/generators/add-linting/lib/buildable-project.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,12 @@ | ||
import { readProjectConfiguration, type Tree } from '@nx/devkit'; | ||
|
||
export function isBuildableLibraryProject( | ||
tree: Tree, | ||
projectName: string | ||
): boolean { | ||
const projectConfig = readProjectConfiguration(tree, projectName); | ||
|
||
return ( | ||
projectConfig.projectType === 'library' && !!projectConfig.targets?.build | ||
); | ||
} |