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

V7: Migrate all lint tooling to ESLint #644

Merged
merged 7 commits into from Nov 14, 2019
Merged

V7: Migrate all lint tooling to ESLint #644

merged 7 commits into from Nov 14, 2019

Conversation

bengourley
Copy link
Contributor

@bengourley bengourley commented Nov 12, 2019

TSLint is deprecated. ESLint was already being used under the hood by standard JS. This PR updates the entire linting setup so that common ESLint dependecies are used for both JS and TS lint, just with different parsers/presets.

The changeset in this PR can be summarised as follows:

Add and remove tooling

  • Remove tslint everywhere it was included
  • Remove standard
  • Add eslint as a direct dependency and the modules required to get an equivalent-ish standardjs setup
  • Add TypeScript plugins and rulesets from the @typescript/eslint-* namespace
  • Remove tslint.json (multiple locations)
  • Add .eslintrc.js and .eslintrs.ts.js which set up different rules for each kind of source file
  • Update the linting commands in package.json

Run eslint --fix on existing code

Although we used the same "standard" preset, it hadn't been updated in a while so there were some violations sprinkled around – mostly relating to whitespace or unnecessary quoting of object keys.

Manually fix remaining lint errors

A few JS violations had to be resolved by hand – mostly telling ESLint to ignore the next line for things that needed to be "just so".

Since the TypeScript rules changed quite a lot from TSLint to @typescript/eslint-*, a few tweaks were required, including removing the I* prefix from interface names.


This PR is split off from work that was done in the spec-refactor branch.

@bengourley bengourley changed the title V7: Migrate all lint tooling to ESlint V7: Migrate all lint tooling to ESLint Nov 12, 2019
@bugsnagbot
Copy link
Collaborator

bugsnagbot commented Nov 12, 2019

@bugsnag/browser bundle size diff

Minified Minfied + Gzipped
Before 40.89 kB 12.24 kB
After 40.88 kB 12.24 kB
± -9 bytes -2 bytes

Generated by 🚫 dangerJS against 6cddc13

TSLint is deprecated. ESlint was already being used under the hood by standard JS. This updates the
entire linting setup so that common ESLint dependecies are used for both JS and TS lint, just with
different presets.
TSlint was removed via the last commit, a clean and rebootstrap removes this from the
package-lock.json files.
.eslintrc.ts.js Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
@@ -102,7 +102,7 @@ module.exports = {
'Notification', 'SVGElementInstance', 'Screen', 'TextTrack', 'TextTrackCue', 'TextTrackList',
'WebSocket', 'WebSocketWorker', 'Worker', 'XMLHttpRequest', 'XMLHttpRequestEventTarget', 'XMLHttpRequestUpload'
], o => {
if (!win[o] || !win[o].prototype || !win[o].prototype.hasOwnProperty || !win[o].prototype.hasOwnProperty('addEventListener')) return
if (!win[o] || !win[o].prototype || !Object.prototype.hasOwnProperty.call(win[o].prototype, 'addEventListener')) return
Copy link
Contributor

@djskinner djskinner Nov 14, 2019

Choose a reason for hiding this comment

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

A quick search suggests Object.prototype.hasOwnProperty.call is supported and preferred whereas hasOwnProperty doesn't exist for "host" objects such as window in IE8. Possibly a slight change in behaviour to be aware of.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I presume this was the reason the linter told me change it!

@@ -2,21 +2,21 @@ import * as BugsnagCore from "@bugsnag/core";

// overwrite config interface, adding browser-specific options
declare module "@bugsnag/core" {
interface IConfig {
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess these changes to the external type names constitute a breaking change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍 yup this will be shipped in a major release with a whole bunch more breaking changes. Stay tuned!

Copy link
Contributor

Choose a reason for hiding this comment

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

@bengourley @djskinner should we have an UPGRADING.md or whatever as part of this change that highlights that this is required? Should this be in the CHANGELOG as part of this PR?

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 PR is already merged but I'm happy to include changelog entries for subsequent PRs. Upgrading guide-wise I think that should be done once everything has landed on the `v71 integration branch.

@bengourley bengourley merged commit b892a6e into v7 Nov 14, 2019
@bengourley bengourley deleted the v7-lint-tooling branch November 14, 2019 10:46
@bengourley bengourley mentioned this pull request Apr 14, 2020
Merged
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.

None yet

4 participants