unused
Report unused ES6 imports in JS / JSX files. Supports output of vim commands that highlight all unused imports. unused
exits with code 1 when unused imports were found.
Sample output:
$ cat test.js
;; //fooz.execute(foo);//foo.fooz();fooz;
$ unused test.jsfoo total 1
There is also a raw mode which outputs json:
$ unused --raw=true test.js
start: line: 1 column: 7 end: line: 1 column: 10 name: 'foo'
Vim output mode:
$ unused -v true test.js
:call matchadd('Error', '\%1l\%<11v.\%>8v')
Usage
Install via npm:
npm install -g unused-es6
Add the following to your ~/.vimrc file:
"" Highlight unused imports, first saves, clears previous matchesnnoremap <leader>ji :w<CR>:call clearmatches()<CR>:let cmd = system('unused -v true ' . expand('%'))<CR>:exec cmd<CR>
Press <leader>ji
to highlight all unused imports in your current file.