Skip to content

feat!: update to eslint 9 and typescript-eslint 8 #1845

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

Merged
merged 4 commits into from
May 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ jobs:
# We use --ignore-scripts to skip automatic postinstall and give us more control to distribute tasks
run: |
yarn --ignore-engines --frozen-lockfile --prefer-offline --ignore-scripts
yarn patch-package --patch-dir ./tools/patches

- name: Run build targets on Node ${{ matrix.node }} (not distributable)
env:
Expand Down
2 changes: 2 additions & 0 deletions .nx/workflows/agents.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,7 @@ launch-templates:
uses: 'nrwl/nx-cloud-workflows/main/workflow-steps/install-node-modules/main.yaml'
env:
SKIP_POSTINSTALL: 'true'
- name: Apply patches
script: 'yarn patch-package --patch-dir ./tools/patches'
- name: Clear Jest Cache
script: 'npx jest --clearCache'
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`new-workspace-create-application-false-ng-add-then-project it should pass linting when adding a project before running ng-add 1`] = `
exports[`new-workspace-create-application-false-ng-add-then-project it should pass linting when adding a project before running ng-add -> with eslint v8 and typescript-eslint v7 1`] = `
{
"@angular-devkit/build-angular": "^18.X.X",
"@angular-eslint/builder": "0.0.0-e2e",
Expand All @@ -11,8 +11,8 @@ exports[`new-workspace-create-application-false-ng-add-then-project it should pa
"@angular/cli": "^18.X.X",
"@angular/compiler-cli": "^18.X.X",
"@types/jasmine": "~5.1.0",
"@typescript-eslint/eslint-plugin": "7.10.0",
"@typescript-eslint/parser": "7.10.0",
"@typescript-eslint/eslint-plugin": "^7.10.0",
"@typescript-eslint/parser": "^7.10.0",
"eslint": "^8.57.0",
"jasmine-core": "~5.1.0",
"karma": "~6.4.0",
Expand All @@ -24,6 +24,38 @@ exports[`new-workspace-create-application-false-ng-add-then-project it should pa
}
`;

exports[`new-workspace-create-application-false-ng-add-then-project it should pass linting when adding a project before running ng-add -> with eslint v8 and typescript-eslint v7 2`] = `
"
Linting \\"app-project\\"...

All files pass linting.
"
`;

exports[`new-workspace-create-application-false-ng-add-then-project it should pass linting when adding a project before running ng-add 1`] = `
{
"@angular-devkit/build-angular": "^18.X.X",
"@angular-eslint/builder": "0.0.0-e2e",
"@angular-eslint/eslint-plugin": "0.0.0-e2e",
"@angular-eslint/eslint-plugin-template": "0.0.0-e2e",
"@angular-eslint/schematics": "0.0.0-e2e",
"@angular-eslint/template-parser": "0.0.0-e2e",
"@angular/cli": "^18.X.X",
"@angular/compiler-cli": "^18.X.X",
"@types/jasmine": "~5.1.0",
"@typescript-eslint/eslint-plugin": "8.0.0-alpha.16",
"@typescript-eslint/parser": "8.0.0-alpha.16",
"eslint": "^9.3.0",
"jasmine-core": "~5.1.0",
"karma": "~6.4.0",
"karma-chrome-launcher": "~3.2.0",
"karma-coverage": "~2.2.0",
"karma-jasmine": "~5.1.0",
"karma-jasmine-html-reporter": "~2.1.0",
"typescript": "~5.X.X"
}
`;

exports[`new-workspace-create-application-false-ng-add-then-project it should pass linting when adding a project before running ng-add 2`] = `
"{
\\"root\\": true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`new-workspace-create-application-false-project-then-ng-add it should pass linting when ng-add is run before adding a project 1`] = `
exports[`new-workspace-create-application-false-project-then-ng-add it should pass linting when adding a project before running ng-add -> with eslint v8 and typescript-eslint v7 1`] = `
{
"@angular-devkit/build-angular": "^18.X.X",
"@angular-eslint/builder": "0.0.0-e2e",
Expand All @@ -11,8 +11,8 @@ exports[`new-workspace-create-application-false-project-then-ng-add it should pa
"@angular/cli": "^18.X.X",
"@angular/compiler-cli": "^18.X.X",
"@types/jasmine": "~5.1.0",
"@typescript-eslint/eslint-plugin": "7.10.0",
"@typescript-eslint/parser": "7.10.0",
"@typescript-eslint/eslint-plugin": "^7.10.0",
"@typescript-eslint/parser": "^7.10.0",
"eslint": "^8.57.0",
"jasmine-core": "~5.1.0",
"karma": "~6.4.0",
Expand All @@ -24,6 +24,38 @@ exports[`new-workspace-create-application-false-project-then-ng-add it should pa
}
`;

exports[`new-workspace-create-application-false-project-then-ng-add it should pass linting when adding a project before running ng-add -> with eslint v8 and typescript-eslint v7 2`] = `
"
Linting \\"app-project\\"...

All files pass linting.
"
`;

exports[`new-workspace-create-application-false-project-then-ng-add it should pass linting when ng-add is run before adding a project 1`] = `
{
"@angular-devkit/build-angular": "^18.X.X",
"@angular-eslint/builder": "0.0.0-e2e",
"@angular-eslint/eslint-plugin": "0.0.0-e2e",
"@angular-eslint/eslint-plugin-template": "0.0.0-e2e",
"@angular-eslint/schematics": "0.0.0-e2e",
"@angular-eslint/template-parser": "0.0.0-e2e",
"@angular/cli": "^18.X.X",
"@angular/compiler-cli": "^18.X.X",
"@types/jasmine": "~5.1.0",
"@typescript-eslint/eslint-plugin": "8.0.0-alpha.16",
"@typescript-eslint/parser": "8.0.0-alpha.16",
"eslint": "^9.3.0",
"jasmine-core": "~5.1.0",
"karma": "~6.4.0",
"karma-chrome-launcher": "~3.2.0",
"karma-coverage": "~2.2.0",
"karma-jasmine": "~5.1.0",
"karma-jasmine-html-reporter": "~2.1.0",
"typescript": "~5.X.X"
}
`;

exports[`new-workspace-create-application-false-project-then-ng-add it should pass linting when ng-add is run before adding a project 2`] = `
"{
\\"root\\": true,
Expand Down
49 changes: 46 additions & 3 deletions e2e/src/__snapshots__/new-workspace.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ exports[`new-workspace it should pass linting after creating a new workspace fro
"@angular/cli": "^18.X.X",
"@angular/compiler-cli": "^18.X.X",
"@types/jasmine": "~5.1.0",
"@typescript-eslint/eslint-plugin": "7.10.0",
"@typescript-eslint/parser": "7.10.0",
"eslint": "^8.57.0",
"@typescript-eslint/eslint-plugin": "8.0.0-alpha.16",
"@typescript-eslint/parser": "8.0.0-alpha.16",
"eslint": "^9.3.0",
"jasmine-core": "~5.1.0",
"karma": "~6.4.0",
"karma-chrome-launcher": "~3.2.0",
Expand Down Expand Up @@ -206,6 +206,49 @@ Linting \\"another-app\\"...
All files pass linting.


Linting \\"another-lib\\"...

All files pass linting.
"
`;

exports[`new-workspace it should pass linting when adding a project before running ng-add -> with eslint v8 and typescript-eslint v7 1`] = `
{
"@angular-devkit/build-angular": "^18.X.X",
"@angular-eslint/builder": "0.0.0-e2e",
"@angular-eslint/eslint-plugin": "0.0.0-e2e",
"@angular-eslint/eslint-plugin-template": "0.0.0-e2e",
"@angular-eslint/schematics": "0.0.0-e2e",
"@angular-eslint/template-parser": "0.0.0-e2e",
"@angular/cli": "^18.X.X",
"@angular/compiler-cli": "^18.X.X",
"@types/jasmine": "~5.1.0",
"@typescript-eslint/eslint-plugin": "^7.10.0",
"@typescript-eslint/parser": "^7.10.0",
"eslint": "^8.57.0",
"jasmine-core": "~5.1.0",
"karma": "~6.4.0",
"karma-chrome-launcher": "~3.2.0",
"karma-coverage": "~2.2.0",
"karma-jasmine": "~5.1.0",
"karma-jasmine-html-reporter": "~2.1.0",
"ng-packagr": "^18.X.X",
"typescript": "~5.X.X"
}
`;

exports[`new-workspace it should pass linting when adding a project before running ng-add -> with eslint v8 and typescript-eslint v7 2`] = `
"
Linting \\"new-workspace\\"...

All files pass linting.


Linting \\"another-app\\"...

All files pass linting.


Linting \\"another-lib\\"...

All files pass linting.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { execSync } from 'node:child_process';
import path from 'node:path';
import { setWorkspaceRoot } from 'nx/src/utils/workspace-root';
import { FIXTURES_DIR, Fixture } from '../utils/fixtures';
Expand All @@ -19,7 +20,7 @@ let fixture: Fixture;
describe('new-workspace-create-application-false-ng-add-then-project', () => {
jest.setTimeout(LONG_TIMEOUT_MS);

beforeEach(async () => {
beforeAll(async () => {
process.chdir(FIXTURES_DIR);
await runNgNew(fixtureDirectory, false);

Expand Down Expand Up @@ -60,4 +61,22 @@ describe('new-workspace-create-application-false-ng-add-then-project', () => {
const lintOutput = await runLint(fixtureDirectory);
expect(lintOutput).toMatchSnapshot();
});

it('it should pass linting when adding a project before running ng-add -> with eslint v8 and typescript-eslint v7', async () => {
// Downgrade eslint to v8 and typescript-eslint to v7
execSync(
'npm install eslint@8 @typescript-eslint/eslint-plugin@7 @typescript-eslint/parser@7 --force',
{
stdio: 'inherit',
cwd: fixture.root,
},
);

expect(
JSON.stringify(fixture.readJson('package.json').devDependencies, null, 2),
).toMatchSnapshot();

const lintOutput = await runLint(fixtureDirectory);
expect(lintOutput).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { execSync } from 'node:child_process';
import path from 'node:path';
import { setWorkspaceRoot } from 'nx/src/utils/workspace-root';
import { FIXTURES_DIR, Fixture } from '../utils/fixtures';
Expand All @@ -19,7 +20,7 @@ let fixture: Fixture;
describe('new-workspace-create-application-false-project-then-ng-add', () => {
jest.setTimeout(LONG_TIMEOUT_MS);

beforeEach(async () => {
beforeAll(async () => {
process.chdir(FIXTURES_DIR);
await runNgNew(fixtureDirectory, false);

Expand Down Expand Up @@ -60,4 +61,22 @@ describe('new-workspace-create-application-false-project-then-ng-add', () => {
const lintOutput = await runLint(fixtureDirectory);
expect(lintOutput).toMatchSnapshot();
});

it('it should pass linting when adding a project before running ng-add -> with eslint v8 and typescript-eslint v7', async () => {
// Downgrade eslint to v8 and typescript-eslint to v7
execSync(
'npm install eslint@8 @typescript-eslint/eslint-plugin@7 @typescript-eslint/parser@7 --force',
{
stdio: 'inherit',
cwd: fixture.root,
},
);

expect(
JSON.stringify(fixture.readJson('package.json').devDependencies, null, 2),
).toMatchSnapshot();

const lintOutput = await runLint(fixtureDirectory);
expect(lintOutput).toMatchSnapshot();
});
});
21 changes: 20 additions & 1 deletion e2e/src/new-workspace.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { execSync } from 'node:child_process';
import path from 'node:path';
import { setWorkspaceRoot } from 'nx/src/utils/workspace-root';
import { FIXTURES_DIR, Fixture } from '../utils/fixtures';
Expand All @@ -18,7 +19,7 @@ let fixture: Fixture;
describe('new-workspace', () => {
jest.setTimeout(LONG_TIMEOUT_MS);

beforeEach(async () => {
beforeAll(async () => {
process.chdir(FIXTURES_DIR);
await runNgNew(fixtureDirectory);

Expand Down Expand Up @@ -74,4 +75,22 @@ describe('new-workspace', () => {
const lintOutput = await runLint(fixtureDirectory);
expect(lintOutput).toMatchSnapshot();
});

it('it should pass linting when adding a project before running ng-add -> with eslint v8 and typescript-eslint v7', async () => {
// Downgrade eslint to v8 and typescript-eslint to v7
execSync(
'npm install eslint@8 @typescript-eslint/eslint-plugin@7 @typescript-eslint/parser@7 --force',
{
stdio: 'inherit',
cwd: fixture.root,
},
);

expect(
JSON.stringify(fixture.readJson('package.json').devDependencies, null, 2),
).toMatchSnapshot();

const lintOutput = await runLint(fixtureDirectory);
expect(lintOutput).toMatchSnapshot();
});
});
2 changes: 1 addition & 1 deletion e2e/utils/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export async function recreateFixturesDir(): Promise<void> {
}

export class Fixture {
constructor(private root: string) {}
constructor(public root: string) {}

directoryExists(filePath: string): boolean {
try {
Expand Down
3 changes: 2 additions & 1 deletion e2e/utils/start-and-publish-to-local-registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ export default async () => {
cwd: workspaceRoot,
});

execNx(['release', 'version', E2E_VERSION]);
// Do not stage the changed package.json files
execNx(['release', 'version', E2E_VERSION, '--stage-changes=false']);

// startLocalRegistry automatically configures the registry to point at the local registry
execNx(['release', 'publish', '--tag', 'e2e']);
Expand Down
24 changes: 13 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@
"@angular/compiler": "18.0.0",
"@commitlint/cli": "19.3.0",
"@commitlint/config-conventional": "19.2.2",
"@nx/devkit": "19.0.6",
"@nx/eslint": "19.0.6",
"@nx/eslint-plugin": "19.0.6",
"@nx/jest": "19.0.6",
"@nx/js": "19.0.6",
"@nx/plugin": "19.0.6",
"@nx/workspace": "19.0.6",
"@nx/devkit": "19.1.0",
"@nx/eslint": "19.1.0",
"@nx/eslint-plugin": "19.1.0",
"@nx/jest": "19.1.0",
"@nx/js": "19.1.0",
"@nx/plugin": "19.1.0",
"@nx/workspace": "19.1.0",
"@rollup/plugin-commonjs": "^25.0.0",
"@rollup/plugin-node-resolve": "^15.0.2",
"@rollup/plugin-typescript": "^11.1.0",
Expand All @@ -76,12 +76,13 @@
"@types/jest": "29.4.4",
"@types/node": "20.12.12",
"@types/prettier": "2.7.3",
"@typescript-eslint/eslint-plugin": "7.10.0",
"@typescript-eslint/parser": "7.10.0",
"@typescript-eslint/eslint-plugin": "8.0.0-alpha.16",
"@typescript-eslint/parser": "8.0.0-alpha.16",
"@typescript-eslint/rule-tester": "8.0.0-alpha.16",
"commitizen": "4.3.0",
"cz-conventional-changelog": "3.3.0",
"env-cmd": "10.1.0",
"eslint": "8.57.0",
"eslint": "9.3.0",
"eslint-config-prettier": "9.1.0",
"execa": "5.1.1",
"husky": "9.0.11",
Expand All @@ -91,7 +92,8 @@
"jsonc-eslint-parser": "^2.1.0",
"lint-staged": "15.2.4",
"ncp": "2.0.0",
"nx": "19.0.6",
"nx": "19.1.0",
"patch-package": "^8.0.0",
"prettier": "3.1.1",
"prettier-v2-for-jest-inline-snapshots": "npm:prettier@^2",
"rimraf": "5.0.7",
Expand Down
6 changes: 5 additions & 1 deletion packages/bundled-angular-compiler/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
"options": {
"cwd": "packages/bundled-angular-compiler",
"parallel": false,
"commands": ["npx rimraf ./dist", "npx rollup -c"]
"commands": [
"npx rimraf ./dist",
"npx rimraf ./.rollup.cache",
"npx rollup -c"
]
}
}
},
Expand Down
Loading