Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(linter): create new workspaces with ESLint v9 and typescript-eslint v8 #27404

Merged
merged 41 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
8977a99
feat(linter): create new workspaces with ESLint v9 and typescript-esl…
JamesHenry Aug 13, 2024
396cab5
cleanup(misc): update pr todos to find them more easily
leosvelperez Aug 21, 2024
468c84e
fix(linter): wrap eslint-plugin-next usages with eslint compat utilit…
leosvelperez Aug 21, 2024
47ee5de
cleanup(linter): update out of date snapshot
leosvelperez Aug 21, 2024
d7c884a
fix(linter): install @eslint/compat only when needed
leosvelperez Aug 21, 2024
235e05c
fix(linter): wrap @nx/react eslint plugin usages with eslint compat u…
leosvelperez Aug 21, 2024
f2b9497
cleanup(next): enable back previously disabled e2e test
leosvelperez Aug 22, 2024
1ade658
cleanup(misc): improve verbose logging of async commands in e2e tests
leosvelperez Aug 22, 2024
77dedbf
cleanup(misc): remove CRACO tests since it's unmaintained, and remove…
jaysoo Aug 28, 2024
2c1c8ab
feat(linter): use flat config entry points from @nx/eslint-plugin
leosvelperez Aug 28, 2024
dbabfb6
fix(react-native): do not check output text since it changes, just as…
jaysoo Sep 4, 2024
66fa7c7
fix(misc): simplify flat config setup
jaysoo Sep 4, 2024
3381ef1
fix(misc): fix up flat configs for react
jaysoo Sep 5, 2024
8c5bbb6
fix(misc): fix up flat configs for nextjs
jaysoo Sep 5, 2024
b8b89f0
fix(misc): fix up flat configs for cypress
jaysoo Sep 5, 2024
59154c4
fix(misc): fix up flat configs for detox
jaysoo Sep 5, 2024
5818432
fix(misc): fix up flat configs for expo
jaysoo Sep 5, 2024
e42d676
fix(misc): fix up flat configs for react-native
jaysoo Sep 5, 2024
4093ba4
fix(misc): fix up flat configs for playwright
jaysoo Sep 5, 2024
b98deaf
fix(misc): resolve lint and test issues
jaysoo Sep 5, 2024
ecfbdbb
fix(misc): fix flat configs for nuxt
jaysoo Sep 6, 2024
1df564e
fix(misc): fix convert-to-flat-config generator to also install depen…
jaysoo Sep 6, 2024
d763bf9
fix(misc): update linter test
jaysoo Sep 6, 2024
5c2dc83
fix(misc): update flat configs for e2e for root projects
jaysoo Sep 6, 2024
223b760
fix(misc): fix up vue flat configs
jaysoo Sep 6, 2024
8e6b2e3
fix(misc): update eslint-plugin-import to support flat configs
jaysoo Sep 6, 2024
95dc85a
fix(misc): ensure that generated plugin/libs do not dep-check eslint …
jaysoo Sep 6, 2024
46ee6b3
fix(misc): fix linter legacy e2e tests
jaysoo Sep 6, 2024
9fcd7b1
fix(misc): update linter tests
jaysoo Sep 6, 2024
fa77071
fix(misc): use --force for expo install
jaysoo Sep 6, 2024
aacce8e
fix(misc): update flat configs for angular
jaysoo Sep 6, 2024
0a2b825
fix(misc): fix jest e2e tests
jaysoo Sep 6, 2024
4ac27d2
fix(misc): enable ESLint flat configs for create-nx-workspace
jaysoo Sep 6, 2024
0fe39d8
fix(misc): add back rootProject to e2e project for root project
jaysoo Sep 6, 2024
f7ba497
chore(misc): update @nuxt/eslint-config version to resolve errors
jaysoo Sep 7, 2024
09b2d8d
fix(misc): add files to flat config overrides
jaysoo Sep 10, 2024
00130f5
fix(misc): handle flat pre-defined flat configs when migrating to mon…
jaysoo Sep 10, 2024
86e4a5d
fix(misc): ensure that eslint.config.js file is ignored for dep-check…
jaysoo Sep 11, 2024
94af427
fix(misc): extacting base eslint config should be resilient from unsu…
jaysoo Sep 11, 2024
9b7456c
fix(misc): using flat config should not cause module boundary errors …
jaysoo Sep 11, 2024
90031d6
fix(misc): also ignore {workspaceRoot}/eslint.config.js in case user …
jaysoo Sep 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion e2e/angular/src/misc.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('Move Angular Project', () => {
expect(moveOutput).toContain(`CREATE ${newPath}/tsconfig.app.json`);
expect(moveOutput).toContain(`CREATE ${newPath}/tsconfig.json`);
expect(moveOutput).toContain(`CREATE ${newPath}/tsconfig.spec.json`);
expect(moveOutput).toContain(`CREATE ${newPath}/.eslintrc.json`);
expect(moveOutput).toContain(`CREATE ${newPath}/eslint.config.js`);
expect(moveOutput).toContain(`CREATE ${newPath}/public/favicon.ico`);
expect(moveOutput).toContain(`CREATE ${newPath}/src/index.html`);
expect(moveOutput).toContain(`CREATE ${newPath}/src/main.ts`);
Expand Down
37 changes: 9 additions & 28 deletions e2e/angular/src/projects.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,7 @@ describe('Angular Projects', () => {

// check e2e tests
if (runE2ETests('playwright')) {
const e2eResults = runCLI(`e2e ${app1}-e2e`);
expect(e2eResults).toContain('Successfully ran target e2e for project');
expect(() => runCLI(`e2e ${app1}-e2e`)).not.toThrow();
expect(await killPort(4200)).toBeTruthy();
}

Expand Down Expand Up @@ -160,10 +159,7 @@ describe('Angular Projects', () => {
);

if (runE2ETests('playwright')) {
const e2eResults = runCLI(`e2e ${app}-e2e`);
expect(e2eResults).toContain(
`Successfully ran target e2e for project ${app}-e2e`
);
expect(() => runCLI(`e2e ${app}-e2e`)).not.toThrow();
expect(await killPort(4200)).toBeTruthy();
}
}, 1000000);
Expand Down Expand Up @@ -495,7 +491,7 @@ describe('Angular Projects', () => {
updateFile(`${lib}/src/lib/${lib}.module.ts`, moduleContent);

// ACT
const buildOutput = runCLI(`build ${lib}`);
const buildOutput = runCLI(`build ${lib}`, { env: { CI: 'false' } });

// ASSERT
expect(buildOutput).toContain(`Building entry point '@${proj}/${lib}'`);
Expand All @@ -516,14 +512,9 @@ describe('Angular Projects', () => {
// check files are generated with the layout directory ("apps/")
checkFilesExist(`apps/${appName}/src/app/app.module.ts`);
// check build works
expect(runCLI(`build ${appName}`)).toContain(
`Successfully ran target build for project ${appName}`
);
expect(() => runCLI(`build ${appName}`)).not.toThrow();
// check tests pass
const appTestResult = runCLI(`test ${appName}`);
expect(appTestResult).toContain(
`Successfully ran target test for project ${appName}`
);
expect(() => runCLI(`test ${appName}`)).not.toThrow();

runCLI(
`generate @nx/angular:lib ${libName} --standalone --buildable --project-name-and-root-format=derived`
Expand All @@ -535,14 +526,9 @@ describe('Angular Projects', () => {
`libs/${libName}/src/lib/${libName}/${libName}.component.ts`
);
// check build works
expect(runCLI(`build ${libName}`)).toContain(
`Successfully ran target build for project ${libName}`
);
expect(() => runCLI(`build ${libName}`)).not.toThrow();
// check tests pass
const libTestResult = runCLI(`test ${libName}`);
expect(libTestResult).toContain(
`Successfully ran target test for project ${libName}`
);
expect(() => runCLI(`test ${libName}`)).not.toThrow();
}, 500_000);

it('should support generating libraries with a scoped name when --project-name-and-root-format=as-provided', () => {
Expand All @@ -568,14 +554,9 @@ describe('Angular Projects', () => {
}.component.ts`
);
// check build works
expect(runCLI(`build ${libName}`)).toContain(
`Successfully ran target build for project ${libName}`
);
expect(() => runCLI(`build ${libName}`)).not.toThrow();
// check tests pass
const libTestResult = runCLI(`test ${libName}`);
expect(libTestResult).toContain(
`Successfully ran target test for project ${libName}`
);
expect(() => runCLI(`test ${libName}`)).not.toThrow();
}, 500_000);

it('should support generating applications with SSR and converting targets with webpack-based executors to use the application executor', async () => {
Expand Down
1 change: 1 addition & 0 deletions e2e/esbuild/src/esbuild.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ describe('EsBuild Plugin', () => {
expect(
readJson(`dist/libs/${parentLib}/package.json`).dependencies
).toEqual({
'jsonc-eslint-parser': expect.any(String),
// Don't care about the versions, just that they exist
rambda: expect.any(String),
lodash: expect.any(String),
Expand Down
44 changes: 32 additions & 12 deletions e2e/eslint/src/linter-legacy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,17 @@ import {
} from '@nx/e2e/utils';

describe('Linter (legacy)', () => {
describe('Integrated', () => {
describe('Integrated (eslintrc config)', () => {
let originalEslintUseFlatConfigVal: string | undefined;
const myapp = uniq('myapp');
const mylib = uniq('mylib');

let projScope;

beforeAll(() => {
projScope = newProject({
// Opt into legacy .eslintrc config format for these tests
originalEslintUseFlatConfigVal = process.env.ESLINT_USE_FLAT_CONFIG;
process.env.ESLINT_USE_FLAT_CONFIG = 'false';

newProject({
packages: ['@nx/react', '@nx/js', '@nx/eslint'],
});
runCLI(`generate @nx/react:app ${myapp} --tags=validtag`, {
Expand All @@ -31,7 +34,10 @@ describe('Linter (legacy)', () => {
env: { NX_ADD_PLUGINS: 'false' },
});
});
afterAll(() => cleanupProject());
afterAll(() => {
process.env.ESLINT_USE_FLAT_CONFIG = originalEslintUseFlatConfigVal;
cleanupProject();
});

describe('linting errors', () => {
let defaultEslintrc;
Expand All @@ -58,8 +64,7 @@ describe('Linter (legacy)', () => {
updateFile('.eslintrc.json', JSON.stringify(eslintrc, null, 2));

// 1. linting should error when rules are not followed
let out = runCLI(`lint ${myapp}`, { silenceError: true });
expect(out).toContain('Unexpected console statement');
expect(() => runCLI(`lint ${myapp}`)).toThrow();

// 2. linting should not error when rules are not followed and the force flag is specified
expect(() => runCLI(`lint ${myapp} --force`)).not.toThrow();
Expand All @@ -72,8 +77,9 @@ describe('Linter (legacy)', () => {
updateFile('.eslintrc.json', JSON.stringify(eslintrc, null, 2));

// 3. linting should not error when all rules are followed
out = runCLI(`lint ${myapp}`, { silenceError: true });
expect(out).toContain('All files pass linting');
expect(() =>
runCLI(`lint ${myapp}`, { silenceError: true })
).not.toThrow();
}, 1000000);

it('should print the effective configuration for a file specified using --print-config', () => {
Expand All @@ -86,16 +92,27 @@ describe('Linter (legacy)', () => {
});
updateFile('.eslintrc.json', JSON.stringify(eslint, null, 2));
const out = runCLI(`lint ${myapp} --print-config src/index.ts`, {
env: { CI: 'false' }, // We don't want to show the summary table from cloud runner
silenceError: true,
});
expect(out).toContain('"specific-rule": [');
}, 1000000);
});
});

describe('Flat config', () => {
describe('eslintrc convert to flat config', () => {
let originalEslintUseFlatConfigVal: string | undefined;
const packageManager = getSelectedPackageManager() || 'pnpm';

beforeAll(() => {
// Opt into legacy .eslintrc config format for these tests
originalEslintUseFlatConfigVal = process.env.ESLINT_USE_FLAT_CONFIG;
process.env.ESLINT_USE_FLAT_CONFIG = 'false';
});
afterAll(() => {
process.env.ESLINT_USE_FLAT_CONFIG = originalEslintUseFlatConfigVal;
});

beforeEach(() => {
process.env.NX_ADD_PLUGINS = 'false';
});
Expand Down Expand Up @@ -162,7 +179,9 @@ describe('Linter (legacy)', () => {
const outFlat = runCLI(`affected -t lint`, {
silenceError: true,
});
expect(outFlat).toContain('ran target lint');
expect(outFlat).toContain(`${myapp}:lint`);
expect(outFlat).toContain(`${mylib}:lint`);
expect(outFlat).toContain(`${mylib2}:lint`);
}, 1000000);

it('should convert standalone to flat config', () => {
Expand Down Expand Up @@ -199,7 +218,8 @@ describe('Linter (legacy)', () => {
const outFlat = runCLI(`affected -t lint`, {
silenceError: true,
});
expect(outFlat).toContain('ran target lint');
expect(outFlat).toContain(`${myapp}:lint`);
expect(outFlat).toContain(`${mylib}:lint`);
}, 1000000);
});
});
Loading