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

Use eslint-config-xo-typescript #1740

Merged
merged 9 commits into from Jan 31, 2019
Merged

Use eslint-config-xo-typescript #1740

merged 9 commits into from Jan 31, 2019

Conversation

sindresorhus
Copy link
Member

No description provided.

package.json Outdated Show resolved Hide resolved
package.json Outdated
}
]
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-type-alias": "off",
Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

In regards to a type vs. Interface, a type is just an alias.

The implications of that are that you can't use declaration merging with a type that is defined with the "type" keyword. So if you expose it in your declaration files, devs won't be able to enhance that particular type. So in that case prefer an interface.

See https://twitter.com/nickytonline/status/1114351742945247234

package.json Outdated
"varsIgnorePattern": "^React$"
}
]
"@typescript-eslint/explicit-function-return-type": "off",
Copy link
Member Author

Choose a reason for hiding this comment

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

@bfred-it Are you ok with making all void functions explicit?

Meaning async function init() { => async function init(): void {

This will prevent us from accidentally return something.

Copy link
Member

Choose a reason for hiding this comment

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

: void sounds fine

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, I'll leave that for a separate PR. It's quite a big change.

Copy link
Member

Choose a reason for hiding this comment

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

@nickytonline do you have time to drop this rule?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'll look at it later tonight.

Copy link
Member

@fregante fregante left a comment

Choose a reason for hiding this comment

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

Also suggested: b6f6c97

package.json Outdated Show resolved Hide resolved
package-lock.json Outdated Show resolved Hide resolved
test/fixtures/window.js Outdated Show resolved Hide resolved
@sindresorhus
Copy link
Member Author

@bfred-it This is ready for another look.

package.json Outdated Show resolved Hide resolved
source/libs/features.tsx Outdated Show resolved Hide resolved
source/libs/features.tsx Show resolved Hide resolved
@fregante
Copy link
Member

Thoughts on 6b3200a?

@sindresorhus
Copy link
Member Author

Why the _ => error change?

@fregante
Copy link
Member

fregante commented Jan 31, 2019

Because we prefer self-explanatory variable names. Why have a custom rule when we can just use the regular name (regulated by a third rule nonetheless)

@sindresorhus
Copy link
Member Author

I use _ to indicate that the error is not used:

This option lets you specify a regex pattern for matches to ignore. Default is ^_$.
- https://github.com/sindresorhus/eslint-plugin-unicorn/blob/master/docs/rules/catch-error-name.md#caughterrorsignorepattern

@sindresorhus
Copy link
Member Author

But doesn't matter. Soon we can just remove the variable all together.

http://2ality.com/2017/08/optional-catch-binding.html

@sindresorhus sindresorhus merged commit e90b58c into master Jan 31, 2019
@sindresorhus sindresorhus deleted the xo-ts branch January 31, 2019 17:18
@sindresorhus
Copy link
Member Author

Thanks for reviewing :)

@fregante
Copy link
Member

Oh, didn’t realize that it was a default in xo as well 😅

@fregante
Copy link
Member

fregante commented Jan 31, 2019

I think TypeScript, Firefox and Chrome all already support the optional catch binding:
http://kangax.github.io/compat-table/es2016plus/

Build passes too:
https://travis-ci.org/sindresorhus/refined-github/builds/487189044

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants