Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

[no-object-literal-type-assertion] New option: "allow-arguments" #4521

Conversation

karol-majewski
Copy link
Contributor

@karol-majewski karol-majewski commented Feb 17, 2019

PR checklist

Overview of change:

This option allows using a type assertion when an object literal is used as an argument. A common use case is the second parameter for Array.prototype.reduce, where an empty object is often used as the initial value.

CHANGELOG.md entry:

[new-rule-option] no-object-literal-type-assertion rule accepts an option called allow-arguments. It allows using type assertions on object literals used inside call expressions.

@palantirtech
Copy link
Member

Thanks for your interest in palantir/tslint, @karol-majewski! Before we can accept your pull request, you need to sign our contributor license agreement - just visit https://cla.palantir.com/ and follow the instructions. Once you sign, I'll automatically update this pull request.

@karol-majewski karol-majewski force-pushed the no-object-literal-type-assertion/allow-arguments branch from 083ee70 to d0f19c6 Compare February 17, 2019 17:28
Copy link
Contributor

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Choose a reason for hiding this comment

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

Mostly looks good! Just a couple of touchups.

Copy link
Contributor

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Choose a reason for hiding this comment

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

Awesome, thanks for this @karol-majewski! The implementation LGTM.

I'd like to get feedback from someone from @palantirtech on the design addition here, since it wasn't explicitly stated in the issue.

@adidahiya adidahiya self-assigned this Feb 18, 2019
@luixo
Copy link

luixo commented Mar 4, 2019

@adidahiya
Hey! I couldn't find any info about the review routine in palantir and I hope it's not a very rude question to ask, but is there any evaluated timing for the review? :)

Copy link
Contributor

@adidahiya adidahiya left a comment

Choose a reason for hiding this comment

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

lgtm otherwise


* \`${OPTION_ALLOW_ARGUMENTS}\` allows type assertions to be used on object literals inside call expressions.`,
options: {
type: "array",
Copy link
Contributor

Choose a reason for hiding this comment

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

you don't need to wrap the object in an array, you can just bring the object out as the top level options value

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done! Thank you.

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

Successfully merging this pull request may close these issues.

None yet

5 participants