fix(angular): keep dependency-checks enabled for buildable libraries (#19047)
This commit is contained in:
parent
f487929a9e
commit
bcb5965ec5
@ -9,13 +9,6 @@ exports[`addLinting generator should correctly generate the .eslintrc.json file
|
|||||||
"!**/*",
|
"!**/*",
|
||||||
],
|
],
|
||||||
"overrides": [
|
"overrides": [
|
||||||
{
|
|
||||||
"files": [
|
|
||||||
"*.json",
|
|
||||||
],
|
|
||||||
"parser": "jsonc-eslint-parser",
|
|
||||||
"rules": {},
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"extends": [
|
"extends": [
|
||||||
"plugin:@nx/angular",
|
"plugin:@nx/angular",
|
||||||
@ -65,13 +58,6 @@ exports[`addLinting generator support angular v14 should correctly generate the
|
|||||||
"!**/*",
|
"!**/*",
|
||||||
],
|
],
|
||||||
"overrides": [
|
"overrides": [
|
||||||
{
|
|
||||||
"files": [
|
|
||||||
"*.json",
|
|
||||||
],
|
|
||||||
"parser": "jsonc-eslint-parser",
|
|
||||||
"rules": {},
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"extends": [
|
"extends": [
|
||||||
"plugin:@nx/angular",
|
"plugin:@nx/angular",
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import {
|
|||||||
formatFiles,
|
formatFiles,
|
||||||
GeneratorCallback,
|
GeneratorCallback,
|
||||||
joinPathFragments,
|
joinPathFragments,
|
||||||
|
readProjectConfiguration,
|
||||||
runTasksInSerial,
|
runTasksInSerial,
|
||||||
Tree,
|
Tree,
|
||||||
} from '@nx/devkit';
|
} from '@nx/devkit';
|
||||||
@ -47,11 +48,6 @@ export async function addLintingGenerator(
|
|||||||
.includes(`${options.projectRoot}/tsconfig.*?.json`);
|
.includes(`${options.projectRoot}/tsconfig.*?.json`);
|
||||||
|
|
||||||
replaceOverridesInLintConfig(tree, options.projectRoot, [
|
replaceOverridesInLintConfig(tree, options.projectRoot, [
|
||||||
{
|
|
||||||
files: ['*.json'],
|
|
||||||
parser: 'jsonc-eslint-parser',
|
|
||||||
rules: {},
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
files: ['*.ts'],
|
files: ['*.ts'],
|
||||||
...(hasParserOptions
|
...(hasParserOptions
|
||||||
@ -93,6 +89,17 @@ export async function addLintingGenerator(
|
|||||||
*/
|
*/
|
||||||
rules: {},
|
rules: {},
|
||||||
},
|
},
|
||||||
|
...(isBuildableLibraryProject(tree, options.projectName)
|
||||||
|
? [
|
||||||
|
{
|
||||||
|
files: ['*.json'],
|
||||||
|
parser: 'jsonc-eslint-parser',
|
||||||
|
rules: {
|
||||||
|
'@nx/dependency-checks': 'error',
|
||||||
|
} as any,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
: []),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,4 +115,13 @@ export async function addLintingGenerator(
|
|||||||
return runTasksInSerial(...tasks);
|
return runTasksInSerial(...tasks);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isBuildableLibraryProject(tree: Tree, projectName: string): boolean {
|
||||||
|
const projectConfig = readProjectConfiguration(tree, projectName);
|
||||||
|
return (
|
||||||
|
projectConfig.projectType === 'library' &&
|
||||||
|
projectConfig.targets?.build &&
|
||||||
|
!!projectConfig.targets.build
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
export default addLintingGenerator;
|
export default addLintingGenerator;
|
||||||
|
|||||||
@ -512,13 +512,6 @@ describe('app', () => {
|
|||||||
"!**/*",
|
"!**/*",
|
||||||
],
|
],
|
||||||
"overrides": [
|
"overrides": [
|
||||||
{
|
|
||||||
"files": [
|
|
||||||
"*.json",
|
|
||||||
],
|
|
||||||
"parser": "jsonc-eslint-parser",
|
|
||||||
"rules": {},
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"extends": [
|
"extends": [
|
||||||
"plugin:@nx/angular",
|
"plugin:@nx/angular",
|
||||||
|
|||||||
@ -253,13 +253,6 @@ exports[`convert-tslint-to-eslint should not override .eslint config if migratio
|
|||||||
"!**/*",
|
"!**/*",
|
||||||
],
|
],
|
||||||
"overrides": [
|
"overrides": [
|
||||||
{
|
|
||||||
"files": [
|
|
||||||
"*.json",
|
|
||||||
],
|
|
||||||
"parser": "jsonc-eslint-parser",
|
|
||||||
"rules": {},
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"extends": [
|
"extends": [
|
||||||
"plugin:@nx/angular",
|
"plugin:@nx/angular",
|
||||||
@ -851,13 +844,6 @@ exports[`convert-tslint-to-eslint should work for Angular applications 4`] = `
|
|||||||
"!**/*",
|
"!**/*",
|
||||||
],
|
],
|
||||||
"overrides": [
|
"overrides": [
|
||||||
{
|
|
||||||
"files": [
|
|
||||||
"*.json",
|
|
||||||
],
|
|
||||||
"parser": "jsonc-eslint-parser",
|
|
||||||
"rules": {},
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"extends": [
|
"extends": [
|
||||||
"plugin:@nx/angular",
|
"plugin:@nx/angular",
|
||||||
@ -1211,13 +1197,6 @@ exports[`convert-tslint-to-eslint should work for Angular libraries 4`] = `
|
|||||||
"!**/*",
|
"!**/*",
|
||||||
],
|
],
|
||||||
"overrides": [
|
"overrides": [
|
||||||
{
|
|
||||||
"files": [
|
|
||||||
"*.json",
|
|
||||||
],
|
|
||||||
"parser": "jsonc-eslint-parser",
|
|
||||||
"rules": {},
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"extends": [
|
"extends": [
|
||||||
"plugin:@nx/angular",
|
"plugin:@nx/angular",
|
||||||
|
|||||||
@ -597,11 +597,6 @@ describe('lib', () => {
|
|||||||
"extends": ["../../.eslintrc.json"],
|
"extends": ["../../.eslintrc.json"],
|
||||||
"ignorePatterns": ["!**/*"],
|
"ignorePatterns": ["!**/*"],
|
||||||
"overrides": [
|
"overrides": [
|
||||||
{
|
|
||||||
"files": ["*.json"],
|
|
||||||
"parser": "jsonc-eslint-parser",
|
|
||||||
"rules": {}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"files": ["*.ts"],
|
"files": ["*.ts"],
|
||||||
"extends": [
|
"extends": [
|
||||||
@ -631,6 +626,13 @@ describe('lib', () => {
|
|||||||
"files": ["*.html"],
|
"files": ["*.html"],
|
||||||
"extends": ["plugin:@nx/angular-template"],
|
"extends": ["plugin:@nx/angular-template"],
|
||||||
"rules": {}
|
"rules": {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"files": ["*.json"],
|
||||||
|
"parser": "jsonc-eslint-parser",
|
||||||
|
"rules": {
|
||||||
|
"@nx/dependency-checks": "error"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@ -1158,12 +1160,65 @@ describe('lib', () => {
|
|||||||
],
|
],
|
||||||
"overrides": [
|
"overrides": [
|
||||||
{
|
{
|
||||||
"files": [
|
"extends": [
|
||||||
"*.json",
|
"plugin:@nx/angular",
|
||||||
|
"plugin:@angular-eslint/template/process-inline-templates",
|
||||||
|
],
|
||||||
|
"files": [
|
||||||
|
"*.ts",
|
||||||
|
],
|
||||||
|
"rules": {
|
||||||
|
"@angular-eslint/component-selector": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
"prefix": "proj",
|
||||||
|
"style": "kebab-case",
|
||||||
|
"type": "element",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"@angular-eslint/directive-selector": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
"prefix": "proj",
|
||||||
|
"style": "camelCase",
|
||||||
|
"type": "attribute",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"extends": [
|
||||||
|
"plugin:@nx/angular-template",
|
||||||
|
],
|
||||||
|
"files": [
|
||||||
|
"*.html",
|
||||||
],
|
],
|
||||||
"parser": "jsonc-eslint-parser",
|
|
||||||
"rules": {},
|
"rules": {},
|
||||||
},
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should add dependency checks to buildable libs', async () => {
|
||||||
|
// ACT
|
||||||
|
await runLibraryGeneratorWithOpts({
|
||||||
|
linter: Linter.EsLint,
|
||||||
|
buildable: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
// ASSERT
|
||||||
|
|
||||||
|
const eslintConfig = readJson(tree, 'my-lib/.eslintrc.json');
|
||||||
|
expect(eslintConfig).toMatchInlineSnapshot(`
|
||||||
|
{
|
||||||
|
"extends": [
|
||||||
|
"../.eslintrc.json",
|
||||||
|
],
|
||||||
|
"ignorePatterns": [
|
||||||
|
"!**/*",
|
||||||
|
],
|
||||||
|
"overrides": [
|
||||||
{
|
{
|
||||||
"extends": [
|
"extends": [
|
||||||
"plugin:@nx/angular",
|
"plugin:@nx/angular",
|
||||||
@ -1200,6 +1255,15 @@ describe('lib', () => {
|
|||||||
],
|
],
|
||||||
"rules": {},
|
"rules": {},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"files": [
|
||||||
|
"*.json",
|
||||||
|
],
|
||||||
|
"parser": "jsonc-eslint-parser",
|
||||||
|
"rules": {
|
||||||
|
"@nx/dependency-checks": "error",
|
||||||
|
},
|
||||||
|
},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
`);
|
`);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user