Giter VIP home page Giter VIP logo

grunt-amdcheck's Issues

Only log files with unused dependencies

I'm trying to use this grunt plugin but cannot find the right config settings to remove some of the verbose output.
Currently if I run grunt amdcheck in our project, I get about 317 lines of results:

app/scripts/head/boot.js (no module)
app/scripts/head/start.js (no module)
app/scripts/head/startup-styles.js (1 module)
Unused paths: lib/environment
app/scripts/lib/able.js (1 module)
app/scripts/lib/app-start.js (1 module)
app/scripts/lib/assertion.js (1 module)
app/scripts/lib/auth-errors.js (1 module)
...

I'm trying to find the right config combination to only show results for files with unused paths:

app/scripts/head/startup-styles.js (1 module)
Unused paths: lib/environment

Currently I'm hacking using something like this (which reduces my output to 132 lines):

$ grunt amdcheck | grep "Unused paths:" -B 1 | grep -v '\-\-'
app/scripts/head/startup-styles.js (1 module)
Unused paths: lib/environment
app/scripts/lib/channels/fx-desktop.js (1 module)
Unused paths: lib/auth-errors
app/scripts/lib/config-loader.js (1 module)
Unused paths: underscore
app/scripts/lib/fxa-client.js (1 module)
Unused paths: underscore, lib/xhr
app/scripts/lib/mailcheck.js (1 module)
Unused paths: mailcheck
app/scripts/lib/oauth-client.js (1 module)
Unused paths: lib/promise, lib/session
...

My current config looks like this:

module.exports = function (grunt) {
  'use strict';

  grunt.config('amdcheck', {
    app: {
      options: {
        removeUnusedDependencies: false,
        logFilePath: true
        // logUnusedDependencyPaths: true
      },
      files: [{
        expand: true,
        cwd: 'app/',
        src: [
          '**/*.js',
          '!bower_components/**'
        ]
      }]
    }
  });
}

Better Error Logging

I think this repo is a great idea, I implemented it in our code base and ran into an error

source/javascripts/modules/add-button.js (1 module)
Unused paths: jquery.mobile
Unused dependencies: __mobile

Warning: Line 56: Unexpected token < Use --force to continue.

Aborted due to warnings.

Which tells me nothing about the file that it failed on to go fix the file it is having trouble parsing.

Would be good to have better error logging.

Can't install from npm

Typo in the version field?

npm ERR! Error: Invalid version: "1.2.3 "
npm ERR!     at Object.module.exports.fixVersionField (/usr/local/lib/node_modules/npm/node_modules/read-package-json/node_modules/normalize-package-data/lib/fixer.js:178:13)
npm ERR!     at /usr/local/lib/node_modules/npm/node_modules/read-package-json/node_modules/normalize-package-data/lib/normalize.js:29:38
npm ERR!     at Array.forEach (native)
npm ERR!     at normalize (/usr/local/lib/node_modules/npm/node_modules/read-package-json/node_modules/normalize-package-data/lib/normalize.js:28:15)
npm ERR!     at final (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:310:33)
npm ERR!     at then (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:124:33)
npm ERR!     at /usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:299:40
npm ERR!     at fs.js:266:14
npm ERR!     at /usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:103:5
npm ERR!     at Object.oncomplete (fs.js:107:15)
npm ERR! If you need help, you may report this log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <[email protected]>

npm ERR! System Darwin 13.1.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "grunt-amdcheck"
npm ERR! cwd /Users/scottnonnenberg/Development/thehelp/thehelp-core
npm ERR! node -v v0.10.26
npm ERR! npm -v 1.3.11
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/scottnonnenberg/Development/thehelp/thehelp-core/npm-debug.log
npm ERR! not ok code 0

Strange through, because this is what I get from 'npm info grunt-amdcheck'

{ name: 'grunt-amdcheck',
  description: 'Finds and removes unused dependencies in AMD modules.',
  'dist-tags': { latest: '0.2.3' },
  versions: 
   [ '0.2.0',
     '0.2.1',
     '0.2.2',
     '0.2.3' ],
  maintainers: 'mehdishojaei <[email protected]>',
  time: 
   { modified: '2014-03-27T21:39:48.409Z',
     created: '2014-01-18T16:11:00.889Z',
     '0.2.0': '2014-01-18T16:11:00.889Z',
     '0.2.1': '2014-01-21T21:10:51.570Z',
     '0.2.2': '2014-03-19T13:24:03.680Z',
     '0.2.3': '2014-03-27T21:39:48.409Z' },
  readmeFilename: 'README.md',
  users: { mehdishojaei: true },
  homepage: 'https://github.com/mehdishojaei/grunt-amdcheck',
  keywords: 
   [ 'gruntplugin',
     'AMD',
     'dependency',
     'unused',
     'useless',
     'excess',
     'requirejs' ],
  repository: 
   { type: 'git',
     url: 'https://github.com/mehdishojaei/grunt-amdcheck.git' },
  contributors: 'Mehdi Shojaei <[email protected]>',
  author: 'Mehdi Shojaei',
  bugs: { url: 'https://github.com/mehdishojaei/grunt-amdcheck/issues' },
  version: '0.2.3',
  licenses: 
   { type: 'MIT',
     url: 'https://github.com/mehdishojaei/grunt-amdcheck/blob/master/LICENSE-MIT' },
  main: 'Gruntfile.js',
  engines: { node: '>= 0.8.0' },
  scripts: {},
  dependencies: { amdextract: '~1.0.0' },
  devDependencies: { grunt: '~0.4.0' },
  peerDependencies: { grunt: '~0.4.0' },
  dist: 
   { shasum: '778e794843be4930a7a65639bf74365fd63af0e1',
     tarball: 'http://registry.npmjs.org/grunt-amdcheck/-/grunt-amdcheck-0.2.3.tgz' },
  directories: {} }

Unused variables without pathes

I think there should be flag to check if there are variables that has no path, I've tried to run amdcheck and at first it gave me a error Warning: Cannot read property 'path' of undefined because there was a variable without a path in the file.

Add `strict` option to warn/fail on unused dependencies

Currently, if I run grunt amdcheck against our large-ish project, I get the following output:

...

Total unused dependencies: 89 in 64 files.
Total processed files: 251

Done, without errors.

It may be nice to have some option (for example, strict: true or allowUnusedDependencies: false) which will fail the Grunt task if I have any unused dependencies in my project. This would let us break the build if a developer adds an unused dependency in a commit.

We could/should keep the current behavior the same, but it'd be nice to have a stricter option.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.