fix(angular): fix standalone eslint config generation (#20885)
This commit is contained in:
parent
18ddc74f4f
commit
fc176d3eec
@ -687,11 +687,12 @@ describe('Linter', () => {
|
|||||||
let e2eEslint = readJson('e2e/.eslintrc.json');
|
let e2eEslint = readJson('e2e/.eslintrc.json');
|
||||||
|
|
||||||
// should have plugin extends
|
// should have plugin extends
|
||||||
expect(appEslint.overrides[0].extends).toBeDefined();
|
let appOverrides = JSON.stringify(appEslint.overrides);
|
||||||
expect(appEslint.overrides[1].extends).toBeDefined();
|
expect(appOverrides).toContain('plugin:@nx/javascript');
|
||||||
expect(
|
expect(appOverrides).toContain('plugin:@nx/typescript');
|
||||||
e2eEslint.overrides.some((override) => override.extends)
|
let e2eOverrides = JSON.stringify(e2eEslint.overrides);
|
||||||
).toBeTruthy();
|
expect(e2eOverrides).toContain('plugin:@nx/javascript');
|
||||||
|
expect(e2eOverrides).toContain('plugin:@nx/typescript');
|
||||||
|
|
||||||
runCLI(`generate @nx/js:lib ${mylib} --unitTestRunner=jest`);
|
runCLI(`generate @nx/js:lib ${mylib} --unitTestRunner=jest`);
|
||||||
verifySuccessfulMigratedSetup(myapp, mylib);
|
verifySuccessfulMigratedSetup(myapp, mylib);
|
||||||
@ -700,11 +701,12 @@ describe('Linter', () => {
|
|||||||
e2eEslint = readJson('e2e/.eslintrc.json');
|
e2eEslint = readJson('e2e/.eslintrc.json');
|
||||||
|
|
||||||
// should have no plugin extends
|
// should have no plugin extends
|
||||||
expect(appEslint.overrides[0].extends).toBeUndefined();
|
appOverrides = JSON.stringify(appEslint.overrides);
|
||||||
expect(appEslint.overrides[1].extends).toBeUndefined();
|
expect(appOverrides).not.toContain('plugin:@nx/javascript');
|
||||||
expect(
|
expect(appOverrides).not.toContain('plugin:@nx/typescript');
|
||||||
e2eEslint.overrides.some((override) => override.extends)
|
e2eOverrides = JSON.stringify(e2eEslint.overrides);
|
||||||
).toBeFalsy();
|
expect(e2eOverrides).not.toContain('plugin:@nx/javascript');
|
||||||
|
expect(e2eOverrides).not.toContain('plugin:@nx/typescript');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('(Angular standalone) should set root project config to app and e2e app and migrate when another lib is added', () => {
|
it('(Angular standalone) should set root project config to app and e2e app and migrate when another lib is added', () => {
|
||||||
@ -720,10 +722,10 @@ describe('Linter', () => {
|
|||||||
let e2eEslint = readJson('e2e/.eslintrc.json');
|
let e2eEslint = readJson('e2e/.eslintrc.json');
|
||||||
|
|
||||||
// should have plugin extends
|
// should have plugin extends
|
||||||
expect(appEslint.overrides[1].extends).toBeDefined();
|
let appOverrides = JSON.stringify(appEslint.overrides);
|
||||||
expect(
|
expect(appOverrides).toContain('plugin:@nx/typescript');
|
||||||
e2eEslint.overrides.some((override) => override.extends)
|
let e2eOverrides = JSON.stringify(e2eEslint.overrides);
|
||||||
).toBeTruthy();
|
expect(e2eOverrides).toContain('plugin:@nx/typescript');
|
||||||
|
|
||||||
runCLI(`generate @nx/js:lib ${mylib} --no-interactive`);
|
runCLI(`generate @nx/js:lib ${mylib} --no-interactive`);
|
||||||
verifySuccessfulMigratedSetup(myapp, mylib);
|
verifySuccessfulMigratedSetup(myapp, mylib);
|
||||||
@ -732,12 +734,10 @@ describe('Linter', () => {
|
|||||||
e2eEslint = readJson('e2e/.eslintrc.json');
|
e2eEslint = readJson('e2e/.eslintrc.json');
|
||||||
|
|
||||||
// should have no plugin extends
|
// should have no plugin extends
|
||||||
expect(appEslint.overrides[1].extends).toEqual([
|
appOverrides = JSON.stringify(appEslint.overrides);
|
||||||
'plugin:@nx/angular-template',
|
expect(appOverrides).not.toContain('plugin:@nx/typescript');
|
||||||
]);
|
e2eOverrides = JSON.stringify(e2eEslint.overrides);
|
||||||
expect(
|
expect(e2eOverrides).not.toContain('plugin:@nx/typescript');
|
||||||
e2eEslint.overrides.some((override) => override.extends)
|
|
||||||
).toBeFalsy();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('(Node standalone) should set root project config to app and e2e app and migrate when another lib is added', async () => {
|
it('(Node standalone) should set root project config to app and e2e app and migrate when another lib is added', async () => {
|
||||||
@ -754,9 +754,12 @@ describe('Linter', () => {
|
|||||||
let e2eEslint = readJson('e2e/.eslintrc.json');
|
let e2eEslint = readJson('e2e/.eslintrc.json');
|
||||||
|
|
||||||
// should have plugin extends
|
// should have plugin extends
|
||||||
expect(appEslint.overrides[0].extends).toBeDefined();
|
let appOverrides = JSON.stringify(appEslint.overrides);
|
||||||
expect(appEslint.overrides[1].extends).toBeDefined();
|
expect(appOverrides).toContain('plugin:@nx/javascript');
|
||||||
expect(e2eEslint.overrides[0].extends).toBeDefined();
|
expect(appOverrides).toContain('plugin:@nx/typescript');
|
||||||
|
let e2eOverrides = JSON.stringify(e2eEslint.overrides);
|
||||||
|
expect(e2eOverrides).toContain('plugin:@nx/javascript');
|
||||||
|
expect(e2eOverrides).toContain('plugin:@nx/typescript');
|
||||||
|
|
||||||
runCLI(`generate @nx/js:lib ${mylib} --no-interactive`);
|
runCLI(`generate @nx/js:lib ${mylib} --no-interactive`);
|
||||||
verifySuccessfulMigratedSetup(myapp, mylib);
|
verifySuccessfulMigratedSetup(myapp, mylib);
|
||||||
@ -765,9 +768,13 @@ describe('Linter', () => {
|
|||||||
e2eEslint = readJson('e2e/.eslintrc.json');
|
e2eEslint = readJson('e2e/.eslintrc.json');
|
||||||
|
|
||||||
// should have no plugin extends
|
// should have no plugin extends
|
||||||
expect(appEslint.overrides[0].extends).toBeUndefined();
|
// should have no plugin extends
|
||||||
expect(appEslint.overrides[1].extends).toBeUndefined();
|
appOverrides = JSON.stringify(appEslint.overrides);
|
||||||
expect(e2eEslint.overrides[0].extends).toBeUndefined();
|
expect(appOverrides).not.toContain('plugin:@nx/javascript');
|
||||||
|
expect(appOverrides).not.toContain('plugin:@nx/typescript');
|
||||||
|
e2eOverrides = JSON.stringify(e2eEslint.overrides);
|
||||||
|
expect(e2eOverrides).not.toContain('plugin:@nx/javascript');
|
||||||
|
expect(e2eOverrides).not.toContain('plugin:@nx/typescript');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -15,6 +15,10 @@ import {
|
|||||||
replaceOverridesInLintConfig,
|
replaceOverridesInLintConfig,
|
||||||
} from '@nx/eslint/src/generators/utils/eslint-file';
|
} from '@nx/eslint/src/generators/utils/eslint-file';
|
||||||
import { camelize, dasherize } from '@nx/devkit/src/utils/string-utils';
|
import { camelize, dasherize } from '@nx/devkit/src/utils/string-utils';
|
||||||
|
import {
|
||||||
|
javaScriptOverride,
|
||||||
|
typeScriptOverride,
|
||||||
|
} from '@nx/eslint/src/generators/init/global-eslint-config';
|
||||||
|
|
||||||
export async function addLintingGenerator(
|
export async function addLintingGenerator(
|
||||||
tree: Tree,
|
tree: Tree,
|
||||||
@ -43,6 +47,7 @@ export async function addLintingGenerator(
|
|||||||
.includes(`${options.projectRoot}/tsconfig.*?.json`);
|
.includes(`${options.projectRoot}/tsconfig.*?.json`);
|
||||||
|
|
||||||
replaceOverridesInLintConfig(tree, options.projectRoot, [
|
replaceOverridesInLintConfig(tree, options.projectRoot, [
|
||||||
|
...(rootProject ? [typeScriptOverride, javaScriptOverride] : []),
|
||||||
{
|
{
|
||||||
files: ['*.ts'],
|
files: ['*.ts'],
|
||||||
...(hasParserOptions
|
...(hasParserOptions
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user