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

Update client monorepo to eslint 7 #3770

Merged
merged 6 commits into from Oct 6, 2020

Conversation

tylerbutler
Copy link
Member

@tylerbutler tylerbutler commented Sep 29, 2020

This PR upgrades the client monorepo to ESLint 7. During the course of doing this, I noted a few rules that are worth discussing more.

@typescript-eslint/strict-boolean-expressions

This rules requires strictNullChecks=true in tsconfig in order to be useful. Many of our packages don't have this enabled (for various reasons). But they really should, no? Anyway, the docs indicate that the rule is useless without this config, so it's ignored in a lot of projects.

@typescript-eslint/restrict-template-expressions

We violate this a lot, but I didn't notice anything terrible in the cases I spot checked. My recommendation is we leave this disabled.

@typescript-eslint/no-unsafe-return

We could improve type-safety by enabling this rule and fixing what it finds. But the violations are numerous...

@typescript-eslint/ban-types

We use the object, {}, and Function types quite a bit, so we aren't getting as much type safety as we could be. From the docs:

  • Avoid the Function type, as it provides little safety for the following reasons:

    • It provides no type safety when calling the value, which means it's easy to provide the wrong arguments.
    • It accepts class declarations, which will fail when called, as they are called without the new keyword.
  • Avoid the Object and {} types, as they mean "any non-nullish value".

    • This is a point of confusion for many developers, who think it means "any object type".
  • Avoid the object type, as it is currently hard to use due to not being able to assert that keys exist.

These do seem worth fixing at some point, but I'm not sure what we should replace Object with.

@tylerbutler tylerbutler force-pushed the eslint/client branch 2 times, most recently from 3e80cd1 to 67277f0 Compare October 2, 2020 21:24
@tylerbutler tylerbutler marked this pull request as ready for review October 2, 2020 21:36
@tylerbutler
Copy link
Member Author

I recognize it's difficult to review so many changes in a single PR, so I am open to suggestions for how to make this easier to review without breaking the monorepo build.

@@ -11,7 +11,9 @@ interface IWindow extends Window {
// Extract the head and body HTML. Remove any <script> tag. And then wrap inside a basic HTML page.
export function createCacheHTML(): void {
const [bodyHTML, headHTML] = [document.body.innerHTML, document.head.innerHTML];
// eslint-disable-next-line unicorn/no-unsafe-regex
Copy link
Member

Choose a reason for hiding this comment

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

This seems scary - potentially exponential-time, according to this? https://github.com/sindresorhus/eslint-plugin-unicorn/blob/master/docs/rules/no-unsafe-regex.md

@@ -37,7 +37,8 @@ export class FluidSerializer implements IFluidSerializer {
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
const handle = !!value && value.IFluidHandle;
// TODO - understand why handle === false in some of our tests
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
// eslint-disable-next-line max-len
Copy link
Member

Choose a reason for hiding this comment

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

lol

Copy link
Member

@markfields markfields left a comment

Choose a reason for hiding this comment

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

🎂 I only reviewed the .ts and .tsx files. All looks pretty reasonable.

I did leave some comments, take a look. And to add to your list from the initial comment, I'm curious about the module-related ones, like no-var-requires etc. I don't know much about how that works and what goes bad with the different syntax options.

@tylerbutler
Copy link
Member Author

/azp run "Build - client"

@azure-pipelines
Copy link

No pipelines are associated with this pull request.

@tylerbutler
Copy link
Member Author

/azp run "repo-policy-check"

@azure-pipelines
Copy link

No pipelines are associated with this pull request.

@tylerbutler
Copy link
Member Author

/azp run "Build - client"

@azure-pipelines
Copy link

No pipelines are associated with this pull request.

@tylerbutler tylerbutler closed this Oct 6, 2020
@tylerbutler tylerbutler reopened this Oct 6, 2020
@tylerbutler tylerbutler merged commit 16f58fc into microsoft:main Oct 6, 2020
@tylerbutler tylerbutler deleted the eslint/client branch October 6, 2020 18:17
@markfields
Copy link
Member

🎉

@tylerbutler tylerbutler mentioned this pull request Jan 20, 2021
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants