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

Establish lint config and use across repo #9501

Open
tylerbutler opened this issue Mar 15, 2022 · 11 comments
Open

Establish lint config and use across repo #9501

tylerbutler opened this issue Mar 15, 2022 · 11 comments
Assignees
Labels
ado Issue is tracked in the internal Azure DevOps backlog area: repo Repo related work epic An issue that is a parent to several other issues
Milestone

Comments

@tylerbutler
Copy link
Member

tylerbutler commented Mar 15, 2022

Our lint config used through most of the repo is insufficient. We need to establish a baseline config that is stricter to maintain overall code quality in the repo.

The plan

For each of the rules to be enabled, we'll make (a) a PR that enables the rule in the shared config and pre-applies fixes for the rule. Once that is merged, then (b) a pre-release shared config package is released, and then we can (c) update the version of the shared config used in the repo.

Step (a) might happen several times before (b) or (c), effectively 'batching' the config changes when it comes time to apply them to the repo.

This approach requires more bookkeeping but helps keep each individual PR focused and makes them easier to review, because all the code changes in a PR should be similar. Also, because each PR is a single rule, it's easy to have "should this rule even be turned on?" discussions without completely derailing the review.

Rules not yet done are listed first so they're easier to find. They're listed in the order we'll create PRs, and the order will be adjusted as needed.

If a rule you want to enabled is missing from the list, leave a comment. If you want to see a rule enabled sooner, leave a comment. If you have any feedback about the plan, leave a comment. 😄

Note on the unicorn rules: they are mostly from the unicorn/recommended config.

Remaining rules

See https://github.com/microsoft/FluidFramework/wiki/ESLint for how to create a PR to enable any of the rules below.

Formatting only

  • unicorn/number-literal-case

Code-impacting

Documentation

Strict

These rules are very strict and may make sense to enable on a package-by-package basis, rather than repo-wide like with the other rules. For that reason, I suggest we enable these in a separate strict config. I'm leaving them until last because applying them will be time consuming.

  • @typescript-eslint/explicit-function-return-type
  • @typescript-eslint/explicit-member-accessibility
  • @typescript-eslint/explicit-module-boundary-types
  • @typescript-eslint/no-unsafe-argument
  • @typescript-eslint/no-unsafe-assignment
  • @typescript-eslint/no-unsafe-call
  • @typescript-eslint/no-unsafe-member-access

Done

Formatting round 1 (#10056)

  • @typescript-eslint/brace-style
  • @typescript-eslint/comma-spacing
  • @typescript-eslint/func-call-spacing
  • @typescript-eslint/keyword-spacing
  • @typescript-eslint/object-curly-spacing
  • @typescript-eslint/space-before-function-paren
  • @typescript-eslint/space-infix-ops
  • @typescript-eslint/type-annotation-spacing
  • array-bracket-spacing
  • arrow-spacing
  • block-spacing
  • key-spacing

Other formatting

Phase 1

Other

Notes

  • If possible, avoid project level overrides. Prefer line-level overrides, then block-level, then file-level.
@ghost ghost added the triage label Mar 15, 2022
@tylerbutler tylerbutler self-assigned this Mar 15, 2022
@tylerbutler tylerbutler added area: repo Repo related work and removed triage labels Mar 15, 2022
@tylerbutler tylerbutler added the epic An issue that is a parent to several other issues label Apr 5, 2022
@heliocliu heliocliu moved this to Todo in Fluid DevX Apr 5, 2022
@heliocliu heliocliu moved this from Todo to In Progress in Fluid DevX Apr 5, 2022
@skylerjokiel skylerjokiel added this to the Next milestone Apr 5, 2022
@tylerbutler tylerbutler modified the milestones: Next, April 2022 Apr 12, 2022
@skylerjokiel skylerjokiel modified the milestones: April 2022, Next Apr 30, 2022
@Josmithr
Copy link
Contributor

Personally, I would be in favor of adding no-implicit-coercion to the list as well, as I think it greatly enhances readability.

@tylerbutler
Copy link
Member Author

Personally, I would be in favor of adding no-implicit-coercion to the list as well, as I think it greatly enhances readability.

Nice! I didn't know about that rule. I added it towards the top of the list, but I'd like to also do a check to see if we have a ton of violations in the current code. I need to write down how to do that in the wiki, so this is a good opportunity to document it as I go.

@Josmithr
Copy link
Contributor

Josmithr commented May 19, 2022

I'm also curious what folks' opinions are on adding the "ignoreUrls": true exception to our max line-length rule, for the cases where we add links to our code docs. Not really a new rule per se, but it came to mind as I was working in the codebase.

@Josmithr
Copy link
Contributor

Josmithr commented Jun 7, 2022

@tylerbutler What do you think about adding this rule to our strict config?
https://www.npmjs.com/package/eslint-plugin-jsdoc#user-content-eslint-plugin-jsdoc-rules-require-description

Would require that tsdoc comments always include the description field. For generated API docs in particular, I think this would be useful to enforce.

@Josmithr
Copy link
Contributor

Josmithr commented Jun 9, 2022

I was also going to suggest multiline-blocks with noSingleLineBlocks and noZeroLineText. Consitent formatting enhances readability. Probably add to recommended rather than minimal?

@tylerbutler
Copy link
Member Author

@Josmithr I love these additions. I think we should chat about the minimal/recommended/strict configs and how we envision them being used long-term. @ChumpChief has made good points in the past of the value of having a single config that is quite strict. If that's our end-goal, we might change how we stage the changes. I'll spin up a separate conversation about this.

Would require that tsdoc comments always include the description field. For generated API docs in particular, I think this would be useful to enforce.

I do like the intention here, but I want to be careful to not reward "useless docs" that meet the 'requirements' but don't help developers. I.e. I don't want to incentivize people to write bad docs just to make the linter happy.

That said, that's no reason not to turn on the rule. Rather, we should monitor the quality of the docs and adjust accordingly.

@Josmithr
Copy link
Contributor

@Josmithr Joshua Smithrud (HE/HIM) FTE I love these additions. I think we should chat about the minimal/recommended/strict configs and how we envision them being used long-term. @ChumpChief Matt Rakow FTE has made good points in the past of the value of having a single config that is quite strict. If that's our end-goal, we might change how we stage the changes. I'll spin up a separate conversation about this.

Would require that tsdoc comments always include the description field. For generated API docs in particular, I think this would be useful to enforce.

I do like the intention here, but I want to be careful to not reward "useless docs" that meet the 'requirements' but don't help developers. I.e. I don't want to incentivize people to write bad docs just to make the linter happy.

That said, that's no reason not to turn on the rule. Rather, we should monitor the quality of the docs and adjust accordingly.

100% agree. I see the linter rule as a nudge to the dev to think about the need to write docs. We need to leverage best practices and code reviews to ensure what is produced is quality.

@curtisman curtisman added the ado Issue is tracked in the internal Azure DevOps backlog label Jun 15, 2022
@Josmithr
Copy link
Contributor

I think we may want to reconsider unicorn/prefer-negative-index - it reduces code size a bit, but I think the result is much less immediately understandable.

@tylerbutler
Copy link
Member Author

I think we may want to reconsider unicorn/prefer-negative-index - it reduces code size a bit, but I think the result is much less immediately understandable.

Hmm, this may be something that I like because Python has it, and it fits my mental model better. I could go either way.

@Josmithr
Copy link
Contributor

I think we may want to reconsider unicorn/prefer-negative-index - it reduces code size a bit, but I think the result is much less immediately understandable.

Hmm, this may be something that I like because Python has it, and it fits my mental model better. I could go either way.

It could definitely be that I am in the minority for this too, and my opinion on this one isn't a super strong. Maybe worth getting more opinions on.

@Josmithr
Copy link
Contributor

Another rule worth considering: https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/consistent-type-imports.md

Preferring type imports whenever possible will likely help us reduce bundle sizes pretty effectively, and I think it's a good habit for devs to get into.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ado Issue is tracked in the internal Azure DevOps backlog area: repo Repo related work epic An issue that is a parent to several other issues
Projects
Status: In Progress
Development

No branches or pull requests

4 participants