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

`eslint --fix` for javascript #851

Merged
merged 1 commit into from Sep 22, 2017

Conversation

Projects
None yet
2 participants
@zhujinxuan
Contributor

zhujinxuan commented Sep 17, 2017

eslint --fix can auto fix common linting problems and style the javascript code. I think it would be good if we turn on it by default rather than forcing users calling them by !eslint --fix % by hand.

Here I contribute a config in my init.vim to turn on the eslint --fix; and for anyone who want to disable eslint --fix, they can add let g:spacevim_javascript_autofix = 0 before loading the javascript layer.

Thanks a lot for SpaceVim~

@wsdjeg

This comment has been minimized.

Show comment
Hide comment
@wsdjeg

wsdjeg Sep 20, 2017

Member

@zhujinxuan I think this is same feature as I used in markdow layer, in markdown layer, we use remark as the default text format tools, it can format the content of current file, also it can fix style.

so I think maybe add a new feature: fix content when formatting current file will better.

BTW I am not sure if eslint --fix will make any unwanted changes.

Member

wsdjeg commented Sep 20, 2017

@zhujinxuan I think this is same feature as I used in markdow layer, in markdown layer, we use remark as the default text format tools, it can format the content of current file, also it can fix style.

so I think maybe add a new feature: fix content when formatting current file will better.

BTW I am not sure if eslint --fix will make any unwanted changes.

@zhujinxuan

This comment has been minimized.

Show comment
Hide comment
@zhujinxuan

zhujinxuan Sep 20, 2017

Contributor

eslint --fix sometimes makes unwanted changes, unfortunately. The reason is that some js symbols are reused for different meanings, like {} for code block and for object. However, it is useful when write js scripts.

I think we can turn off with g:spacevim_javascript_autofix = 0 by default and add document that: you can turn on it by g:spacevim_javascript_autofix = 1 before loading the layer.

Contributor

zhujinxuan commented Sep 20, 2017

eslint --fix sometimes makes unwanted changes, unfortunately. The reason is that some js symbols are reused for different meanings, like {} for code block and for object. However, it is useful when write js scripts.

I think we can turn off with g:spacevim_javascript_autofix = 0 by default and add document that: you can turn on it by g:spacevim_javascript_autofix = 1 before loading the layer.

@wsdjeg

This comment has been minimized.

Show comment
Hide comment
@wsdjeg

wsdjeg Sep 20, 2017

Member

How about use lang specifed option? then we can load this layer via:

call SpaceVim#layers#load('lang#javascript', {
       \ 'autofix' : 1,
       \ })
Member

wsdjeg commented Sep 20, 2017

How about use lang specifed option? then we can load this layer via:

call SpaceVim#layers#load('lang#javascript', {
       \ 'autofix' : 1,
       \ })
@zhujinxuan

This comment has been minimized.

Show comment
Hide comment
@zhujinxuan

zhujinxuan Sep 20, 2017

Contributor
Contributor

zhujinxuan commented Sep 20, 2017

@wsdjeg

This comment has been minimized.

Show comment
Hide comment
@wsdjeg

wsdjeg Sep 21, 2017

Member

ok, I will implement the feature base on this PR.

Member

wsdjeg commented Sep 21, 2017

ok, I will implement the feature base on this PR.

@zhujinxuan

This comment has been minimized.

Show comment
Hide comment
@zhujinxuan

zhujinxuan Sep 21, 2017

Contributor
Contributor

zhujinxuan commented Sep 21, 2017

@wsdjeg wsdjeg merged commit 9417d5c into SpaceVim:dev Sep 22, 2017

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
license/cla Contributor License Agreement is signed.
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment