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

[Conversation]: Improve Linter Settings #469

Closed
andrewballantyne opened this issue Aug 31, 2022 · 5 comments · Fixed by #969
Closed

[Conversation]: Improve Linter Settings #469

andrewballantyne opened this issue Aug 31, 2022 · 5 comments · Fixed by #969
Assignees
Labels
infrastructure Anything non feature/* related that improves general working of the Dashboard kind/documentation Improvements or additions to documentation priority/low An issue with the product that doesn't impact the user much or not at all (ie tech debt) quality An issue to improve the quality of our code -- e2e or unit test related
Milestone

Comments

@andrewballantyne
Copy link
Member

andrewballantyne commented Aug 31, 2022

We should look at improving our linter to maybe get prettier to format things to our preference.

Topics I think we can talk about (feel free to add more)


Unnecessary braces { in a directly returned function

const foo = () => {
  return 'bar';
};
// vs
const foo = () => 'bar';

Braces around straight returns

const foo = (bar: string | null) => {
  if (!bar) return null;
  // vs
  if (!bar) {
    return null;
  }

  return 'baz';
};

Auto sort imports

Get them so all our 3rd party libs are at the top

.. sorting so that the items further away go under 3rd party imports, working down to local files ./some-file


Support more tsconfig paths

Have it so alias paths can snap us back to the root to grab types/constants/utils/services/etc

import { } from '../../../utilities/useSomeHook';
// vs
import { } from '~/utilities/useSomeHook';

Note: When it's 1 file -- it can get confusing. import { } from 'k8sTypes' looks weird. We need a leading character to signify it's a special import.


Reassigning variables passed to you

#693 (comment)


Stop console logs of any kind

We can ignore the ones we need for stability/error reporting -- but we should stop all logs from accidentally allowing debug code from slipping in.


No else return

Prevent if () { return } else { return } so that the code structure is more malleable in the future.

https://eslint.org/docs/latest/rules/no-else-return


Always type argumentless variables

let icon;

What is icon? Is icon the string? the JSX? We should force typing here so it has more contextual usage.

let icon: React.ReactNode;
@andrewballantyne andrewballantyne added kind/documentation Improvements or additions to documentation needs-info Further information is requested from the reporter or from another source infrastructure Anything non feature/* related that improves general working of the Dashboard priority/low An issue with the product that doesn't impact the user much or not at all (ie tech debt) quality An issue to improve the quality of our code -- e2e or unit test related labels Aug 31, 2022
@andrewballantyne andrewballantyne self-assigned this Aug 31, 2022
@lucferbux
Copy link
Contributor

I'm inclined to use the styles used by other RedHatters (i.e. Patternfly or OpenShift core teams). I guess @andrewballantyne is well versed in that matter, so if all these changes are inclined to reach that I'm on board.

@dlabaj
Copy link
Contributor

dlabaj commented Aug 31, 2022

I know where those are setup in other projects i can pull them over.

@lucferbux
Copy link
Contributor

I know where those are setup in other projects i can pull them over.

Perfect! Sounds great.

@andrewballantyne andrewballantyne removed the needs-info Further information is requested from the reporter or from another source label Feb 17, 2023
@andrewballantyne andrewballantyne added this to the Next Release milestone Feb 17, 2023
@andrewballantyne andrewballantyne linked a pull request Feb 28, 2023 that will close this issue
3 tasks
@andrewballantyne
Copy link
Member Author

@DaoDaoNoCode was there more you wanted to do with this issue or can we assume it was covered by #969 ?

I know we only touched the frontend, and tbh, overly rewriting the backend for a bunch of linter changes seems a bit excessive. Thoughts? The goal is to get rid of it, and styling on the backend isn't super important imo -- none of these are really going to impact us a lot as we don't do a lot of node development anymore.

@DaoDaoNoCode
Copy link
Member

@andrewballantyne I think we can close this one. Most of the backend code will be gone one day anyway so I guess it doesn't worth the effort to do a large refactor to the backend. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
infrastructure Anything non feature/* related that improves general working of the Dashboard kind/documentation Improvements or additions to documentation priority/low An issue with the product that doesn't impact the user much or not at all (ie tech debt) quality An issue to improve the quality of our code -- e2e or unit test related
Projects
No open projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants