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

feat: Add Eslint to sentry-javascript #2786

Merged
merged 14 commits into from
Aug 3, 2020
Merged

feat: Add Eslint to sentry-javascript #2786

merged 14 commits into from
Aug 3, 2020

Conversation

AbhiPrasad
Copy link
Member

@AbhiPrasad AbhiPrasad commented Jul 30, 2020

Total changes after disregarding yarn.lock: +295 -510.

See Asana ticket: https://app.asana.com/0/1159797622087522/1186701350284441/f

This PR adds an initial implementation of an eslint-config to the mono-repo. It also adds a eslint-plugin-sentry-sdks, a local npm package we use to write our own custom eslint rules, and converts @sentry/browser from eslint to tslint.

Here is how this works. I've created an .eslintignore that has all the packages that we ignore (everything except @sentry/browser right now). As I convert packages, I'll be updating and eventually deleting that file.

The heart of the matter is in the .eslintrc.js file located at the heart of the repo. This specifies all the rules that will eventually go into eslint-config-sentry-sdks. I've commented each rule with justification, so go take a look. This maps fairly 1 to 1 with our old tslint config, but I took the liberty with changing some rules.

This eslintrc.js file in the root of the repo also relies on a new eslint-plugin-sentry-sdks. This plugin currently only implements one rule, to prevent async await usage, but I expect to add more as I convert the rest of the packages.

The plan for conversion is that I'll address all the packages in the mono-repo, and then move the config out of the repo.

In terms of @sentry/browser changes:

  1. You'll notice some class methods moved around. This is based on using the default from https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/member-ordering.md which I think is better suited to organize classes than what we had before.

  2. I typed any -> unknown where I was 100% confident, but for the rest I just slammed the eslint-disable-next-line @typescript-eslint/no-explicit-any. We should add a task after this is done to review all our no-explicit-any usage.

  3. I changed some regex because it eslint warned about unnecessary escape.

  4. I removed all instances of tslint, and the tslint.json in favour of an .eslintrc.js file

@github-actions
Copy link
Contributor

github-actions bot commented Jul 30, 2020

size-limit report

Path Size
@sentry/browser - CDN Bundle (gzipped) 17.66 KB (0%)
@sentry/browser - Webpack 18.42 KB (-0.03% 🔽)
@sentry/react - Webpack 18.42 KB (-0.03% 🔽)
@sentry/browser + @sentry/tracing - CDN Bundle (gzipped) 22.64 KB (0%)

@getsentry-bot
Copy link
Contributor

getsentry-bot commented Jul 30, 2020

Messages
📖

@sentry/browser bundle gzip'ed minified size: (ES5: 17.251 kB) (ES6: 16.3525 kB)

📖 ✅ TSLint passed

Generated by 🚫 dangerJS against 9dca0d8

"eslint": "^7.5.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-jsdoc": "^30.0.3",
"eslint-plugin-sentry-sdk": "file:./eslint-plugin-sentry-sdk",
Copy link
Member Author

Choose a reason for hiding this comment

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

All of these dependencies are temporary. When we move the main eslint config out of this repo, we should be able to replace this (at the package level) with just a single eslint-config-sentry-sdks

@AbhiPrasad AbhiPrasad marked this pull request as ready for review August 3, 2020 13:39
@AbhiPrasad AbhiPrasad requested a review from HazAT August 3, 2020 13:40
"chai": "^4.1.2",
"codecov": "^3.6.5",
"danger": "^7.1.3",
"danger-plugin-eslint": "^0.1.0",
"danger-plugin-tslint": "^2.0.0",
Copy link
Member

Choose a reason for hiding this comment

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

Do we still need this?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, because the other packages still use tslint. We can remove after we are done.

@HazAT
Copy link
Member

HazAT commented Aug 3, 2020

Sooooooooo good, thank you!

@AbhiPrasad AbhiPrasad merged commit d44a1d9 into master Aug 3, 2020
@AbhiPrasad AbhiPrasad deleted the abhi/feat/eslint branch August 3, 2020 15:33
kamilogorek pushed a commit that referenced this pull request Aug 10, 2020
This PR adds an initial implementation of an eslint-config to the mono-repo. It also adds a eslint-plugin-sentry-sdks, a local npm package we use to write our own custom eslint rules, and converts @sentry/browser from eslint to tslint.
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.

3 participants