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

Migrate from TSLint to ESLint #1250

Merged
merged 37 commits into from
Apr 26, 2024

Conversation

MadLamprey
Copy link
Contributor

@MadLamprey MadLamprey commented Feb 21, 2024

Summary:

Fixes #1247

Changes Made:

  • Migrate to ESLint from TSLint
    • See: https://github.com/angular-eslint/angular-eslint/blob/main/docs/MIGRATING_FROM_TSLINT.md
    • All changes mentioned have been reviewed
    • Each rule mentioned in `tslint.json` has been reviewed and its ESLint counterpart has been defined in `.eslintrc.json`.
    • There are a few rules that have not been mapped due to huge changes to the codebase or errors produced as a result of the translation. These include:
      • `deprecation/depreciation`
      • `prefer-const`
      • `dot-notation`
      • `import-spacing`
    • Few changes have been made to prevent errors that were not earlier raised with the TSLint configuration

Proposed Commit Message:

Migrate to ESLint

TSLint is now deprecated in favour of ESLint. We should keep our dependencies up-to-date.

Let's migrate to ESLint to ensure that our linter is up-to-date.

@codecov-commenter
Copy link

codecov-commenter commented Feb 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 58.27%. Comparing base (e319865) to head (44dc8eb).
Report is 9 commits behind head on master.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1250      +/-   ##
==========================================
+ Coverage   54.84%   58.27%   +3.43%     
==========================================
  Files         105      105              
  Lines        2859     2598     -261     
  Branches      503      291     -212     
==========================================
- Hits         1568     1514      -54     
- Misses       1030     1033       +3     
+ Partials      261       51     -210     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@cheehongw cheehongw left a comment

Choose a reason for hiding this comment

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

I tried this PR and it didn't catch some of the lint mistakes that I introduced. For exampl,e, i tried importing some unused components in a file, and the old linter caught it while the new linter passed all the files.

Perhaps it failed to convert the lint rules in tslint.json to those in .eslintrc.json?

@cheehongw cheehongw mentioned this pull request Mar 4, 2024
@MadLamprey MadLamprey requested a review from cheehongw March 18, 2024 05:51
Copy link
Contributor

@cheehongw cheehongw left a comment

Choose a reason for hiding this comment

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

image

i feel not all the lint changes are for the best. for example the changes in app-routing.module.ts makes it harder to read.

Also another personal preference would be to not change code en masse for the sake of styling as it makes it harder to trace code changes.

please revert the changes in the repository, then check the arrow-body-style rule again

.eslintrc.json Outdated
"type": "attribute"
}
],
"arrow-body-style": ["error", "always"],
Copy link
Contributor

Choose a reason for hiding this comment

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

return { headers: { Authorization: `Token ${this.authService.accessToken.getValue()}` } };
});
const basic = setContext(() => ({ headers: { Accept: 'charset=utf-8' } }));
const auth = setContext(() => ({ headers: { Authorization: `Token ${this.authService.accessToken.getValue()}` } }));
Copy link
Contributor

Choose a reason for hiding this comment

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

ok i think these changes are good for readability

@cheehongw cheehongw self-requested a review April 18, 2024 03:14
@cheehongw cheehongw force-pushed the 1247-upgradeTSLint branch from 5deb705 to a243ae7 Compare April 26, 2024 08:59
I cannot identify the issue. It is failing on github ci but not locally.
On Github CI, it is identifying lint errors where it shouldnt be as
well.
@cheehongw
Copy link
Contributor

For some unknown reason, the arrow-body-style keeps failing CI at 2 specific lines even though it passes linting locally.

One of the instances is below, in issue.service.ts. The first function body passes the lint check on github CI, but the one on the bottom doesn't, even though they are exactly the same.

image

Copy link
Contributor

@cheehongw cheehongw left a comment

Choose a reason for hiding this comment

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

I will merge this PR without the arrow-body-style rule for now.

I don't think it is worth the effort to figure out why it doesn't work for eslint v7 when official documentation only exists for eslint v8 and v9. We should revisit this when eslint is upgraded to its latest version.

@cheehongw cheehongw merged commit 5a91541 into CATcher-org:master Apr 26, 2024
3 of 5 checks passed
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.

Migrate to ESLint
3 participants