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

Add prefer-dataset rule #225

Merged
merged 13 commits into from
Sep 16, 2019
Merged

Add prefer-dataset rule #225

merged 13 commits into from
Sep 16, 2019

Conversation

amedora
Copy link
Contributor

@amedora amedora commented Jan 29, 2019

Fix #166

rules/prefer-dataset.js Outdated Show resolved Hide resolved
test/prefer-dataset.js Show resolved Hide resolved
{
code: 'element.setAttribute(\'data-foo\', /* comment */ \'bar\');',
errors,
output: 'element.dataset.foo = \'bar\';'
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we want to delete comments during fixing but it probably doesn't come up that often. @sindresorhus, what's your take on this?

  1. Removing comments is okay
  2. Comments should be preserved (may be non-trivial)
  3. Do not fix if comments are detected

I've done (3) in the past but I think a bunch of different rules current do (1).

Copy link
Owner

Choose a reason for hiding this comment

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

@MrHen I don't think we should do 1., but we need to come up with a guideline that we can apply to all rules. Maybe we could make an utility that just extract all comments to above a node we give it? The comments can require manual formatting and movement. We just shouldn't remove them. Alternatively, 3. if 2. is too complex, but I think we could make something generic that we could apply to many rules. Would you be able to open a new issue about it? We probably need to review all existing rules for this and update the contributing guidelines.

Copy link
Contributor

Choose a reason for hiding this comment

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

@MrHen MrHen requested a review from futpib June 17, 2019 12:05
@sindresorhus sindresorhus merged commit 0910972 into sindresorhus:master Sep 16, 2019
@sindresorhus
Copy link
Owner

Thanks, @amedora :)

@sindresorhus
Copy link
Owner

Note 850b8a1. I missed that during the review.

@MrHen MrHen mentioned this pull request Sep 16, 2019
@amedora amedora deleted the add-prefer-dataset-rule branch September 17, 2019 00:32
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.

Rule proposal: prefer-dataset
4 participants