Skip to content

Instantly share code, notes, and snippets.

@peterreisz
Last active July 4, 2016 07:32

Revisions

  1. peterreisz revised this gist Jul 4, 2016. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -13,7 +13,7 @@ function u(i) {
    ]
    }
    }).filter(function(item) {
    return i < item.column && item.column <= j;
    return i < item.column && item.column <= j && item.line == 1;
    }).map(function(item) {
    return (s.substring(i + 1, item.column).match(/,/g) || []).length
    });
    @@ -32,7 +32,6 @@ function fn() {
    if ('constant' != i[1] && 'value' != i[1] && d && d[d.length - 1] && !listed[m.name + n]) {
    listed[m.name + n] = true


    var e = u(d[d.length - 1].toString());

    if (e.length > 0) {
  2. peterreisz created this gist Apr 26, 2016.
    65 changes: 65 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,65 @@
    function u(i) {
    var s = 'function fn'+ i.substring(9),
    i = s.indexOf('('),
    j = s.indexOf(')');

    return eslint.verify(s, {
    rules: {
    'no-unused-vars': [
    'error', {
    vars: 'all',
    args: 'all'
    }
    ]
    }
    }).filter(function(item) {
    return i < item.column && item.column <= j;
    }).map(function(item) {
    return (s.substring(i + 1, item.column).match(/,/g) || []).length
    });
    }

    function fn() {
    var p = [];
    var listed = {};

    (function ud(m) {
    var m = angular.module(m),
    q = m._invokeQueue;

    m._invokeQueue.forEach(function(i) {
    var d = i[2][1], n = i[2][0];
    if ('constant' != i[1] && 'value' != i[1] && d && d[d.length - 1] && !listed[m.name + n]) {
    listed[m.name + n] = true


    var e = u(d[d.length - 1].toString());

    if (e.length > 0) {
    p.push({
    module: m.name,
    name: n,
    unused: e.map(function(w) {
    return i[2][1][w];
    }).join(', ')
    });
    }


    }
    });

    m.requires.forEach(ud);
    })(document.querySelector('[ng-app]').attributes.getNamedItem('ng-app').value)

    console.table(p);
    }

    if (window.eslint) {
    fn();
    } else {
    var s=document.createElement('script');
    s.setAttribute('src','http://eslint.org/js/app/eslint.js');
    s.addEventListener('load', fn);
    document.body.appendChild(s);
    }