Skip to content
This repository has been archived by the owner on Jan 19, 2019. It is now read-only.

Add rule array-type #211

Merged
merged 5 commits into from
Dec 12, 2018
Merged

Add rule array-type #211

merged 5 commits into from
Dec 12, 2018

Conversation

armano2
Copy link
Contributor

@armano2 armano2 commented Dec 11, 2018

This is continuation of #117

@armano2
Copy link
Contributor Author

armano2 commented Dec 11, 2018

I falled into small issue while doing this rule, autofix is not working as it should, and i'm still looking for workaround.


eslint is not working correctly when fixer modifies begin and end of node, this prevents fixer of child nodes to be executed.

// input.ts
type foo = Array<Array<Bar>>
// output.ts
type foo = Array<Bar>[]

fixer is going to be applied only to first Array not to both


^ why?

eslint applies fixer in sorted order base on range, when fix return array of fixers output is computed for entire range of all fixers with filled gaps.

If token was already modified new changes are not going to be applied on it.


possible solution:

  • traverse all child nodes and fix all arrays in one fixer
  • ignore this issue

@armano2 armano2 changed the title Array type Add rule array-type Dec 11, 2018
@armano2
Copy link
Contributor Author

armano2 commented Dec 11, 2018

@bradzacher what do you want me to do with fixer?

i did some digging and looks like its working when you run it from cli but not in tests

Copy link
Owner

@bradzacher bradzacher left a comment

Choose a reason for hiding this comment

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

few nits but otherwise looks good.
blocking on parameterised messages.

Is there a reason you chose to use static messages instead?

lib/rules/array-type.js Outdated Show resolved Hide resolved
docs/rules/array-type.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
lib/rules/array-type.js Outdated Show resolved Hide resolved
lib/rules/array-type.js Outdated Show resolved Hide resolved
Copy link
Owner

@bradzacher bradzacher left a comment

Choose a reason for hiding this comment

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

awesome - great work!!

@bradzacher bradzacher merged commit 04d5879 into bradzacher:master Dec 12, 2018
@armano2 armano2 deleted the array-type branch December 12, 2018 06:36
@dannyfritz dannyfritz mentioned this pull request Dec 14, 2018
31 tasks
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.

3 participants