最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to delete all unused variables in WebStorm? - Stack Overflow

programmeradmin7浏览0评论

How to delete all unused variables in a project in WebStorm or other editor?

I have a lot of unused CommonJS imports like this. I'd like to remove them from my project.

var ReactDOM = require('react-dom');

How to delete all unused variables in a project in WebStorm or other editor?

I have a lot of unused CommonJS imports like this. I'd like to remove them from my project.

var ReactDOM = require('react-dom');
Share Improve this question edited May 31, 2017 at 13:31 Stanislav Mayorov asked May 31, 2017 at 10:44 Stanislav MayorovStanislav Mayorov 4,4725 gold badges26 silver badges47 bronze badges 5
  • That notation has nothing to do with ES5, it is CommonJS. What do you mean by "for es6 imports"? Do you want to replace them with the ES6 module syntax? – str Commented May 31, 2017 at 10:49
  • 3 If you have Eslint correctly configured which includes no-unused-* you can easily using the fix mand: blog.jetbrains./webstorm/2016/08/using-external-tools – Hitmands Commented May 31, 2017 at 11:05
  • @Hitmands that's a good idea. thanks. – Stanislav Mayorov Commented May 31, 2017 at 11:10
  • @str No, I want to delete imports which aren't used. I have updated my question. – Stanislav Mayorov Commented May 31, 2017 at 11:15
  • 1 no-unused-vars rule are not fixeble eslint/docs/rules – Stanislav Mayorov Commented Jul 8, 2017 at 19:28
Add a ment  | 

2 Answers 2

Reset to default 9

You can remove all unused variable in current file using quickfix:

  • hit Alt+Enter on unused variable, hit Right
  • Choose 'Fix all 'Unused JavaScript/ActionScript local symbol' problems in file'

If fixing the problem for each file individually is not an option for you, try using ESLint auto-fix per @Hitmands suggestion

You can remove all unused imports in current file using

Ctrl + Alt + O

发布评论

评论列表(0)

  1. 暂无评论