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

mgr/dashboard: Migrate from tslint to eslint #45767

Closed

Conversation

adithyaakrishna
Copy link

@adithyaakrishna adithyaakrishna commented Apr 4, 2022

Signed-off-by: Adithya Krishna aadithya794@gmail.com

Fixes: https://tracker.ceph.com/issues/48258

Checklist

  • Tracker (select at least one)
    • References tracker ticket
  • Component impact
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • No doc update is needed
  • Tests (select at least one)
    • No tests
Show available Jenkins commands
  • jenkins retest this please
  • jenkins test classic perf
  • jenkins test crimson perf
  • jenkins test signed
  • jenkins test make check
  • jenkins test make check arm64
  • jenkins test submodules
  • jenkins test dashboard
  • jenkins test dashboard cephadm
  • jenkins test api
  • jenkins test docs
  • jenkins render docs
  • jenkins test ceph-volume all
  • jenkins test ceph-volume tox
  • jenkins test windows

Signed-off-by: Adithya Krishna <aadithya794@gmail.com>
Signed-off-by: Adithya Krishna <aadithya794@gmail.com>
@adithyaakrishna
Copy link
Author

jenkins test dashboard

Comment on lines +58 to +68
// TODO: Change to error - From L58 to L67
"@typescript-eslint/no-empty-function": "error",
"@typescript-eslint/member-ordering": "warn",
"no-underscore-dangle": "warn",
"@typescript-eslint/ban-types": "warn",
"prefer-arrow/prefer-arrow-functions": "warn",
"@typescript-eslint/consistent-type-assertions": "warn",
"@typescript-eslint/no-unused-expressions": "warn",
"max-len": "warn",
"@typescript-eslint/prefer-for-of": "warn",
"prefer-const": "warn",
Copy link
Author

Choose a reason for hiding this comment

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

@epuertat @nizamial09 As these eslint rules involved a lot of changes, I thought to take it in a separate PR once this is migration is done so that we can focus on not breaking anything when doing them. Hence I have added a TODO comment and made the rules to warn us

Copy link
Member

Choose a reason for hiding this comment

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

Make sense!

Copy link
Member

@epuertat epuertat left a comment

Choose a reason for hiding this comment

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

Thanks a lot @adithyaakrishna for your work here! Plz let me know what you think about my suggestions!

Comment on lines +58 to +68
// TODO: Change to error - From L58 to L67
"@typescript-eslint/no-empty-function": "error",
"@typescript-eslint/member-ordering": "warn",
"no-underscore-dangle": "warn",
"@typescript-eslint/ban-types": "warn",
"prefer-arrow/prefer-arrow-functions": "warn",
"@typescript-eslint/consistent-type-assertions": "warn",
"@typescript-eslint/no-unused-expressions": "warn",
"max-len": "warn",
"@typescript-eslint/prefer-for-of": "warn",
"prefer-const": "warn",
Copy link
Member

Choose a reason for hiding this comment

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

Make sense!

"**/node_modules/**"
"lintFilePatterns": [
"src/**/*.ts",
"src/**/*.html"
Copy link
Member

Choose a reason for hiding this comment

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

Are JSON files linted by default?

@@ -72,7 +72,7 @@ export class StartCaseBreadcrumbsResolver extends BreadcrumbsResolver {
resolve(route: ActivatedRouteSnapshot) {
const path = route.params.name;
const text = _.startCase(path);
return [{ text: `${text}/Edit`, path: path }];
return [{ text: `${text}/Edit`, path }];
Copy link
Member

Choose a reason for hiding this comment

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

We already discussed this in the original PR... While this is perfectly valid ES6 syntactic sugar, I think it's an ugly one, that may lead to future bugs as it creates tight coupling between internal variable names and external interfaces (e.g: if someone refactors this code and renames path to pathname, the resulting object will have a new interface). I'd vote for disabling this rule.

Comment on lines +36 to +38
import { SharedModule } from '~/app/shared/shared.module';
import { FeatureTogglesGuardService } from '~/app/shared/services/feature-toggles-guard.service';
import { ActionLabels, URLVerbs } from '~/app/shared/constants/app.constants';
Copy link
Member

Choose a reason for hiding this comment

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

Any clue why these are moved to the bottom? Usually absolute imports come before than relative imports, and in this case they're reversed... 🤔 I'd suggest tuning this rule to keep absolute import firsts.

@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/naming-convention */
Copy link
Member

Choose a reason for hiding this comment

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

Why is that?

Comment on lines +67 to +72
onNodeSelected(tree: TreeModel, node: TreeNode) {
TREE_ACTIONS.ACTIVATE(tree, node, true);
if (node.data.cdId) {
this.title = node.data.name;
const tempData = this.metadata[node.data.cdId] || {};

Copy link
Member

Choose a reason for hiding this comment

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

Why this? Some method name reordering? It'd be great to know which rule is enforcing this...

The main risk with a linter or a static checker is that it may produce lots of changes that don't necessarily bring value (increased readability, code quality, etc), but cause a lot of code shuffling. And code shuffling will be a nightmare the next time we find a bug, we fix it in master and we realize that backporting that to a previous branch will require a lot of manual conflict solving because codebases diverged.

My suggestion would be to replace tslint with eslint disabling these cosmetic rules and ensuring that the amount of changes introduced is minimal (e.g.: 400 files vs. just 10).

From the eslint rules, I see there are: "possible problems", "suggestions" and "layout". Probably we can start focusing on the 1st category, and checking what changes that outputs. Additionally, I'd compare the other categories with the equivalent ones defined by tslint, and ensure equivalent rules are enabled. If you needed it you can create a doc/etherpad/etc., where you list the tslint vs eslint rules, and we can help you there if needed.

Comment on lines +307 to +312
let deepFlatten: any;
let layering: any;
let exclusiveLock: any;
let objectMap: any;
let journaling: any;
let fastDiff: any;
Copy link
Member

Choose a reason for hiding this comment

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

since each variable is defined separately, shouldn't they be aligned?

@nizamial09
Copy link
Member

jenkins test dashboard cephadm

@epuertat epuertat added this to In progress in Dashboard via automation Apr 22, 2022
@github-actions
Copy link

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

@djgalloway djgalloway changed the base branch from master to main May 25, 2022 20:01
Dashboard automation moved this from In progress to Done Sep 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Dashboard
  
Done
3 participants