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

chore: bump typescript-eslint to v8 #1936

Merged
merged 6 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 1 addition & 6 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,7 @@ const config = {
ecmaVersion: "latest",
sourceType: "module",
tsconfigRootDir: __dirname,
project: [
"./tsconfig.json",
"./cli/tsconfig.eslint.json", // separate eslint config for the CLI since we want to lint and typecheck differently due to template files
"./upgrade/tsconfig.json",
"./www/tsconfig.json",
],
projectService: true,
Copy link
Contributor Author

@JoshuaKGoldberg JoshuaKGoldberg Jul 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://typescript-eslint.io/blog/announcing-typescript-eslint-v8-beta#project-service: this is our snazzy new way of enabling typed linting. It should be faster and require less configuration.

I couldn't tell from quickly reading the code: what is the tsconfig.eslint.json doing differently? Is it still necessary?


Btw, I ran hyperfine measurements, and they showed promising performance improvements on my M1 Max Mac Studio:

  • ~10% faster bumping to typescript-eslint from v7 to v8
  • ~20% faster again switching from project to projectService
# baseline: typescript-eslint@v7 with project
Benchmark 1: npx turbo lint --no-cache
  Time (mean ± σ):      7.464 s ±  0.094 s    [User: 32.604 s, System: 2.431 s]
  Range (min … max):    7.346 s …  7.665 s    10 runs
# typescript-eslint@v8 with project
Benchmark 1: npx turbo lint --no-cache
  Time (mean ± σ):      6.662 s ±  0.235 s    [User: 29.944 s, System: 2.253 s]
  Range (min … max):    6.501 s …  7.254 s    10 runs
# typescript-eslint@v8 with projectService
Benchmark 1: npx turbo lint --no-cache
  Time (mean ± σ):      5.344 s ±  0.126 s    [User: 25.637 s, System: 1.683 s]
  Range (min … max):    5.204 s …  5.554 s    10 runs

...for an overall performance improvement of roughly 28%.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't tell from quickly reading the code: what is the tsconfig.eslint.json doing differently? Is it still necessary?

I can't remember why it's there but from guessing it sounds like projectService does it for us :)

},
overrides: [
// Template files don't have reliable type information
Expand Down
6 changes: 3 additions & 3 deletions cli/src/helpers/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const isGitInstalled = (dir: string): boolean => {
try {
execSync("git --version", { cwd: dir });
return true;
} catch (_e) {
} catch {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As of typescript-eslint/typescript-eslint#8971, these are now flagged by default by @typescript-eslint/no-unused-vars. They were unused before.

return false;
}
};
Expand All @@ -31,7 +31,7 @@ export const isInsideGitRepo = async (dir: string): Promise<boolean> => {
stdout: "ignore",
});
return true;
} catch (_e) {
} catch {
// Else, it will throw a git-error and we return false
return false;
}
Expand Down Expand Up @@ -125,7 +125,7 @@ export const initializeGit = async (projectDir: string) => {
"git"
)}\n`
);
} catch (error) {
} catch {
// Safeguard, should be unreachable
spinner.fail(
`${chalk.bold.red(
Expand Down
4 changes: 3 additions & 1 deletion cli/src/helpers/logNextSteps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ export const logNextSteps = async ({
const pkgManager = getUserPkgManager();

logger.info("Next steps:");
projectName !== "." && logger.info(` cd ${projectName}`);
if (projectName !== ".") {
logger.info(` cd ${projectName}`);
}
Copy link
Contributor Author

@JoshuaKGoldberg JoshuaKGoldberg Jul 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (noInstall) {
// To reflect yarn's default behavior of installing packages when no additional args provided
if (pkgManager === "yarn") {
Expand Down
4 changes: 3 additions & 1 deletion cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ const main = async () => {
const npmVersion = await getNpmVersion();
const pkgManager = getUserPkgManager();
renderTitle();
npmVersion && renderVersionWarning(npmVersion);
if (npmVersion) {
renderVersionWarning(npmVersion);
}

const {
appName,
Expand Down
2 changes: 2 additions & 0 deletions cli/src/utils/renderVersionWarning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,14 @@ function checkForLatestVersion(): Promise<string> {
resolve((JSON.parse(body) as DistTagsBody).latest);
});
} else {
// eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors
reject();
}
}
)
.on("error", () => {
// logger.error("Unable to check for latest version.");
// eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors
reject();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the first time I can remember seeing reject() called with no argument. Interesting!

@typescript-eslint/prefer-promise-reject-errors was promoted to the strict-type-checked config in v8.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably should reject with a descriptive error xd

});
});
Expand Down
4 changes: 2 additions & 2 deletions cli/template/base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
"@types/node": "^20.11.20",
"@types/react": "^18.2.57",
"@types/react-dom": "^18.2.19",
"@typescript-eslint/eslint-plugin": "^7.1.1",
"@typescript-eslint/parser": "^7.1.1",
"@typescript-eslint/eslint-plugin": "8.0.0-alpha.39",
"@typescript-eslint/parser": "8.0.0-alpha.39",
JoshuaKGoldberg marked this conversation as resolved.
Show resolved Hide resolved
"eslint": "^8.57.0",
"eslint-config-next": "^14.1.3",
"typescript": "^5.4.2"
Expand Down
4 changes: 0 additions & 4 deletions cli/tsconfig.eslint.json

This file was deleted.

8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
"@total-typescript/ts-reset": "^0.3.7",
"@types/eslint": "^8.56.10",
"@types/node": "^20.12.12",
"@typescript-eslint/eslint-plugin": "^7.10.0",
"@typescript-eslint/parser": "^7.10.0",
"@typescript-eslint/eslint-plugin": "8.0.0-alpha.39",
"@typescript-eslint/parser": "8.0.0-alpha.39",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.29.1",
Expand All @@ -63,5 +63,9 @@
"prettier": "^3.2.5",
"turbo": "1.13.3-canary.3",
"typescript": "^5.4.5"
},
"resolutions": {
"@typescript-eslint/eslint-plugin": "8.0.0-alpha.39",
"@typescript-eslint/parser": "8.0.0-alpha.39"
}
}
Loading
Loading