grunt-import-clean
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -32,2 +32,3 @@ /* | ||
array: [ 'test/array/*-0.js' , 'test/array/*-1.js' ], | ||
wildcard: 'test/wildcard/*.js', | ||
options: { test: true } | ||
@@ -56,3 +57,4 @@ }, | ||
'jshint', | ||
'test' | ||
'test', | ||
'clean' | ||
]); | ||
@@ -64,4 +66,3 @@ | ||
'import-clean', | ||
'nodeunit', | ||
'clean' | ||
'nodeunit' | ||
]); | ||
@@ -68,0 +69,0 @@ |
{ | ||
"name": "grunt-import-clean", | ||
"description": "identify unused imports in es6 modules", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"homepage": "https://github.com/elnarddogg/grunt-import-clean", | ||
@@ -6,0 +6,0 @@ "author": { |
@@ -48,3 +48,4 @@ module.exports = function( grunt ) { | ||
file.unused = file.imports.filter(function( name ) { | ||
var re = shared.escRegExp( name ); | ||
name = shared.escRegExp( name ); | ||
var re = new RegExp( '(^|\\W)' + name + '(\\W?|$)' ); | ||
return !re.test( file.input ); | ||
@@ -51,0 +52,0 @@ }); |
@@ -14,3 +14,3 @@ module.exports = (function() { | ||
var RE_END = /from.*('|"|;)$/i; | ||
var RE_CLEAN = /'|"|\s|\t/gi; | ||
var RE_CLEAN = /\s\*\sas\s|'|"|\s|\t/gi; | ||
var RE_PARSE1 = /import(.*)from/i; | ||
@@ -17,0 +17,0 @@ var RE_PARSE2 = /\{(.*)\}/i; |
@@ -15,5 +15,4 @@ module.exports = (function() { | ||
escRegExp: function( str , mods ) { | ||
str = str.replace( /[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g , '\\$&' ); | ||
return new RegExp( str , mods ); | ||
escRegExp: function( str ) { | ||
return str.replace( /[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g , '\\$&' ); | ||
} | ||
@@ -20,0 +19,0 @@ |
import E$ from 'main'; | ||
import { isPrivate , getPublic } from 'event'; | ||
import when from 'when'; | ||
import * as something from 'somewhere'; | ||
import isE$ from 'static/is-emoney'; | ||
@@ -5,0 +6,0 @@ import construct from 'static/construct'; |
{ | ||
"unused": { | ||
"array-0.js": [ | ||
"E$", | ||
"something", | ||
"$Error", | ||
@@ -16,3 +18,3 @@ "$_delete", | ||
"foundFiles": 2, | ||
"foundImports": 6 | ||
"foundImports": 8 | ||
} |
import E$ from 'main'; | ||
import { isPrivate , getPublic } from 'event'; | ||
import when from 'when'; | ||
import * as something from 'somewhere'; | ||
import isE$ from 'static/is-emoney'; | ||
@@ -5,0 +6,0 @@ import construct from 'static/construct'; |
{ | ||
"unused": { | ||
"basic.js": [ | ||
"E$", | ||
"something", | ||
"$Error", | ||
@@ -13,3 +15,3 @@ "$_delete", | ||
"foundFiles": 1, | ||
"foundImports": 5 | ||
"foundImports": 7 | ||
} |
import E$ from 'main'; | ||
import { isPrivate , getPublic } from 'event'; | ||
import when from 'when'; | ||
import * as something from 'somewhere'; | ||
import isE$ from 'static/is-emoney'; | ||
@@ -5,0 +6,0 @@ import construct from 'static/construct'; |
{ | ||
"unused": { | ||
"multi-0.js": [ | ||
"E$", | ||
"something", | ||
"$Error", | ||
@@ -16,3 +18,3 @@ "$_delete", | ||
"foundFiles": 2, | ||
"foundImports": 6 | ||
"foundImports": 8 | ||
} |
@@ -53,2 +53,13 @@ (function() { | ||
test.done(); | ||
}, | ||
wildcard: function( test ) { | ||
test.expect( 1 ); | ||
var actual = grunt.file.read( 'tmp/wildcard.json' ); | ||
var expected = grunt.file.read( 'test/wildcard/output.json' ); | ||
test.equal( actual , expected , 'should describe wildcard behavior.' ); | ||
test.done(); | ||
} | ||
@@ -55,0 +66,0 @@ |
25751
25
848