Skip to content
This repository has been archived by the owner on Jul 2, 2024. It is now read-only.

EVG-20048: Introduce check-file plugin #2109

Merged
merged 33 commits into from
Nov 30, 2023
Merged

Conversation

SupaJoon
Copy link
Contributor

@SupaJoon SupaJoon commented Oct 18, 2023

@SupaJoon SupaJoon requested a review from a team October 18, 2023 17:39
@cypress
Copy link

cypress bot commented Oct 18, 2023

Passing run #14216 ↗︎

0 605 7 0 Flakiness 0
⚠️ You've recorded test results over your free plan limit.
Upgrade your plan to view test results.

Details:

eslint:fix
Project: Spruce Commit: 5defa1c375
Status: Passed Duration: 18:52 💡
Started: Nov 27, 2023 4:26 PM Ended: Nov 27, 2023 4:45 PM

Review all test suite changes for PR #2109 ↗︎

.eslintrc.js Outdated
@@ -96,6 +96,18 @@ module.exports = {
// Rules for prettier.
"prettier/prettier": errorIfStrict, // Makes Prettier issues warnings rather than errors.
"sort-destructure-keys/sort-destructure-keys": errorIfStrict,
"check-file/filename-naming-convention": [
"warn",
Copy link
Contributor

Choose a reason for hiding this comment

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

Use our constant.

Suggested change
"warn",
WARN,

Copy link
Contributor

Choose a reason for hiding this comment

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

or alternatively errorIfStrict is there any reason we wouldn't want to enforce files are consistently named?

Copy link
Contributor Author

@SupaJoon SupaJoon Oct 20, 2023

Choose a reason for hiding this comment

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

What do you think about using the WARN flag until all of the problems are resolved and then apply errorIfStrict? Alternatively we can do them at once but there will be over 42 renamed files and imports.

.eslintrc.js Outdated
"**/*.graphql": "KEBAB_CASE",
"cypress/integration/**/*.ts": "SNAKE_CASE",
"scripts/**/*.{js,ts}": "KEBAB_CASE",
"src/**/*.{js,ts}": "CAMEL_CASE",
Copy link
Contributor

Choose a reason for hiding this comment

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

You can use !(something) syntax to not match on values that can be hooks.

e.g.
src/**/!(use)*.ts Will match all ts files that do not have the use keyword aka are not hooks.

Checkout for an easy way to test out glob match rules.
https://www.digitalocean.com/community/tools/glob?comments=true&glob=src/**/!(use)*.tsx&matches=false&tests=src/hooks/useTestFile.ts&tests=src/components/SomeRandomComponent.tsx

@SupaJoon SupaJoon requested a review from khelif96 October 20, 2023 18:42
@SupaJoon SupaJoon marked this pull request as draft October 30, 2023 14:18
@SupaJoon
Copy link
Contributor Author

converting to draft to resolve the lint errors

@khelif96 khelif96 removed their request for review October 30, 2023 16:26
@khelif96
Copy link
Contributor

Removed my review request, please retag me when it's ready.

Copy link
Contributor Author

@SupaJoon SupaJoon Nov 1, 2023

Choose a reason for hiding this comment

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

This doesn't actually need the .tsx extension because they don't contain any tsx but I changed it to tsx because to match the current pattern. I see how tsx could make sense since the file exports the entry to a page which has a bunch of tsx.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this change is necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we change this back to .ts then I will either need to add an exception since it's currently pascal case, or convert it into camelcase. I prefer converting it into camel case.

@@ -108,34 +101,7 @@ const ExpandedBlock = styled.pre`
padding: ${size.s} ${size.l};
`;

export const getResourceRoute = (
Copy link
Contributor Author

@SupaJoon SupaJoon Nov 1, 2023

Choose a reason for hiding this comment

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

Moved this function so this file exports the hook only.

@SupaJoon SupaJoon requested a review from khelif96 November 1, 2023 18:22
@SupaJoon SupaJoon marked this pull request as ready for review November 1, 2023 18:24
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this change is necessary.

Copy link
Contributor

Choose a reason for hiding this comment

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

Good call

@@ -1,6 +1,6 @@
import { Divider } from "./Divider";
Copy link
Contributor

Choose a reason for hiding this comment

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

This file should be lower case and doesn't need the TSX extension. Divider.tsx

"PASCAL_CASE",
// tsx exceptions
"src/**/(use|getFormSchema|index)*.tsx": "CAMEL_CASE",
},
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we further trim these down? So we don't have 4 different conventions.

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 smallest set that makes sense to me. Let me know what you want to trim and why.

.eslintrc.js Outdated
// JS and TS with exceptions
"src/**/!(vite-env.d|custom-queries)*.{js,ts}": "CAMEL_CASE",
// All tsx with exceptions
"src/**/!(use|getFormSchema|index|test-utils|toast-decorator|schemaFields|getColumnsTemplate|githubPRLinkify|jiraLinkify)*.tsx":
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we hardcode all of these exceptions or can we update these to match the pattern we have established?
e.g. jiraLinkify -> JiraLinkify.tsx

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I reviewed these and think these makes sense as is because I think pascal case should be used to represent react components only. Although these files use JSX, they aren't really React components.

  • githubPRLinkify and jiraLinkify shouldn't be React components so they are easily composable.
  • use represents hooks
  • getFormSchema sometimes uses JSX but is always destructured
  • index isn't generally capitalized
  • test-utils and toast-decorator use JSX but are utils and not components
  • getColumnsTemplate has the same reasoning as getFormSchema

@SupaJoon SupaJoon requested a review from khelif96 November 15, 2023 16:39
@SupaJoon SupaJoon removed the request for review from khelif96 November 15, 2023 17:46
@SupaJoon SupaJoon requested a review from khelif96 November 27, 2023 16:31
@SupaJoon SupaJoon merged commit 89a3583 into evergreen-ci:main Nov 30, 2023
5 checks passed
@SupaJoon SupaJoon deleted the EVG-20048 branch November 30, 2023 17:03
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants