Giter VIP home page Giter VIP logo

jshint-stylish's Introduction

jshint-stylish

Stylish reporter for JSHint

Compared to the default reporter:

Install

$ npm install --save-dev jshint-stylish

Usage

JSHint CLI

$ jshint --reporter=node_modules/jshint-stylish file.js
gulp.task('default', () =>
	gulp.src(['file.js'])
		.pipe(jshint('.jshintrc'))
		.pipe(jshint.reporter('jshint-stylish'))
);
grunt.initConfig({
	jshint: {
		options: {
			reporter: require('jshint-stylish')
		},
		target: ['file.js']
	}
});

grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.registerTask('default', ['jshint']);

Options

beep

Type: boolean
Default: false

The system bell will make a sound if there were any warnings or errors.

Gulp example
gulp.task('default', () =>
	gulp.src(['file.js'])
		.pipe(jshint('.jshintrc'))
		.pipe(jshint.reporter('jshint-stylish', {beep: true}))
);

License

MIT © Sindre Sorhus

jshint-stylish's People

Contributors

fiftyfactorauthentication avatar jasonkarns avatar jonschlinkert avatar rodneyrehm avatar sindresorhus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jshint-stylish's Issues

Some artifacts in output log file

if i use option reporterOutput, i get some artifacts in output log file.
for example

[4m......\User_Part\Source\htdocs\ps\scc\js\common\login.js�[24m
�[90mline 93�[39m �[90mcol 0�[39m �[36mIdentifier 'get_frame_val' is not in camel case.�[39m
�[90mline 99�[39m �[90mcol 0�[39m �[36mIdentifier 'get_cookie' is not in camel case.�[39m
�[90mline 102�[39m �[90mcol 0�[39m �[36mIdentifier 'set_frame_val' is not in camel case.�[39m

i add this code to file node_modules/grunt-contrib-jshint/tasks/jshint.js:
output += out.replace(/[\d+m/g,"");

Add option to include the full path to file in report

It would be nice to see the option to include the full path in the report, it will allow a single click to view the area of code of interest in dev tools like Intelij.

I can suggest the following change at line 34 (or I can do a pull request if you like?):

      if (el.file !== prevfile) {
        if (options.fullPath) {
          headers[i] = process.cwd() + '/' + el.file + ':' + err.line;
        } else {
          headers[i] = el.file;
        }
      }

See the screenshots below, notice the hyperlink in the full path:

Default:
screen shot 2016-03-03 at 17 33 08

Suggested change:
screen shot 2016-03-03 at 17 31 42

Warning icon

The icon of the warning result I cannot display correctly. Does it have to install other plug-in first?

2.0.1 Usage Issue?

I have the following versions installed:

$ grunt --version
grunt-cli v0.1.13
grunt v0.4.5

$ node --version
v0.12.7

And when I try the following in my Gruntfile:

jshint: {
    options: {
        jshintrc: ".jshintrc",
        reporter: require("jshint-stylish")
    },
    all: [
        "Gruntfile.js",
        "<%= config.app %>/scripts/{,*/}*.js",
        "!<%= config.app %>/scripts/vendor/*",
        "test/spec/{,*/}*.js"
    ]
}

I get:

Running "jshint:all" (jshint) task
Warning: Arguments to path.resolve must be strings Use --force to continue.
TypeError: Arguments to path.resolve must be strings
    at Object.posix.resolve (path.js:439:13)
    at Object.exports.selectReporter (/Volumes/Data/Users/agreco/repos/dm/node_modules/grunt-contrib-jshint/tasks/lib/jshint.js:50:31)
    at Object.exports.lint (/Volumes/Data/Users/agreco/repos/dm/node_modules/grunt-contrib-jshint/tasks/lib/jshint.js:163:28)
    at Object.<anonymous> (/Volumes/Data/Users/agreco/repos/dm/node_modules/grunt-contrib-jshint/tasks/jshint.js:44:12)
    at Object.<anonymous> (/Volumes/Data/Users/agreco/repos/dm/node_modules/grunt/lib/grunt/task.js:264:15)
    at Object.thisTask.fn (/Volumes/Data/Users/agreco/repos/dm/node_modules/grunt/lib/grunt/task.js:82:16)
    at Object.task.fn (/Volumes/Data/Users/agreco/repos/dm/node_modules/jit-grunt/lib/jit-grunt.js:122:30)
    at Object.<anonymous> (/Volumes/Data/Users/agreco/repos/dm/node_modules/grunt/lib/util/task.js:301:30)
    at Task.runTaskFn (/Volumes/Data/Users/agreco/repos/dm/node_modules/grunt/lib/util/task.js:251:24)
    at Task.<anonymous> (/Volumes/Data/Users/agreco/repos/dm/node_modules/grunt/lib/util/task.js:300:12)

After looking at /Volumes/Data/Users/agreco/repos/dm/node_modules/grunt-contrib-jshint/tasks/lib/jshint.js and some logging, I realized I could call toString() on the require("jshint-stylish") and it resolves.

jshint: {
    options: {
        jshintrc: ".jshintrc",
        reporter: require("jshint-stylish").toString()
    },
    all: [
        "Gruntfile.js",
        "<%= config.app %>/scripts/{,*/}*.js",
        "!<%= config.app %>/scripts/vendor/*",
        "test/spec/{,*/}*.js"
    ]
}

Not sure if you'd classify this is a bug or not, but thought I'd share my findings either way.

jshint warnings and errors are not affecting grunt error counters

It seems that when using this reporter, the warnings and errors in jshint are not affecting the grunt error counters (grunt.fail.errorcount, grunt.fail.warncount)

it is possible to check it by adding the following code to the gruntfile.js:

grunt.registerTask('checkfailure', function() {
         grunt.log.write(grunt.fail.errorcount);
}

add that task after the jshint task is executing (make sure to use --force so that the task would run even though the jshint task fails)

when removing the reporter the errorcount changes according to jshint.

Solarized support?

Would you entertain the possibility of a solarized mode? I noticed on my solarized-dark terminal that the initial line numbers and such are base01, I think, and I have background at base02. I could have something wrong on my end, but looks pretty consistent. I can work on an option that looks good for a pull request, but was wondering if there is a modular approach you prefer.

Thanks in advance,
Rob

Include changelog?

Can you please include changelog explaining what's new after each release?

Error on generator function in a class

I'm getting this error:

jshint/jshint#1978

export default class RouteBuilder {
  ...
  renderPage*() {
    this.render(this, this.name, this.appData(this.name));
  }

Running with jshint-stylish

    Unexpected token * at server/routes/route-builder.js :
    25 |  }
    26 |
    27 |  renderPage*() {

Actually I really just want to get the function reference, so I guess I should turn it into a getter and return the generator function from there, thus achieving what I want without error ;)

But still, should this case should not cause a jshint error IMO.
Thanks ;)

Expose colors as options

On Windows, I'm getting unsightly blue-on-black text, which is really hard to read. If the colors were exposed as options, however, I could fix this quite easily!

"Arguments to path.resolve must be strings" error

grunt --version
grunt-cli v0.1.13
grunt v0.4.5

node --version
v0.12.2

module.exports = {
  options: {
    reporter: require('jshint-stylish'),
    force: true
  },
  all: [ 'routes/**/*.js', 'models/**/*.js' ],
  server: [ './keystone.js' ]
}

grunt jshint:server --stack

Running "jshint:server" (jshint) task
Warning: Arguments to path.resolve must be strings Use --force to continue.
TypeError: Arguments to path.resolve must be strings
  at Object.posix.resolve (path.js:439:13)
  at Object.exports.selectReporter (/home/wangxiantong/learning/cms/node_modules/grunt-contrib-jshint/tasks/lib/jshint.js:62:31)
  at Object.exports.lint (/home/wangxiantong/learning/cms/node_modules/grunt-contrib-jshint/tasks/lib/jshint.js:184:28)
  at Object.<anonymous> (/home/wangxiantong/learning/cms/node_modules/grunt-contrib-jshint/tasks/jshint.js:47:12)
  at Object.<anonymous> (/home/wangxiantong/learning/cms/node_modules/grunt/lib/grunt/task.js:264:15)
  at Object.thisTask.fn (/home/wangxiantong/learning/cms/node_modules/grunt/lib/grunt/task.js:82:16)
  at Object.<anonymous> (/home/wangxiantong/learning/cms/node_modules/grunt/lib/util/task.js:301:30)
  at Task.runTaskFn (/home/wangxiantong/learning/cms/node_modules/grunt/lib/util/task.js:251:24)
  at Task.<anonymous> (/home/wangxiantong/learning/cms/node_modules/grunt/lib/util/task.js:300:12)
  at Task.start (/home/wangxiantong/learning/cms/node_modules/grunt/lib/util/task.js:309:5)
  at Object.grunt.tasks (/home/wangxiantong/learning/cms/node_modules/grunt/lib/grunt.js:164:8)
  at Object.module.exports [as cli] (/home/wangxiantong/learning/cms/node_modules/grunt/lib/grunt/cli.js:38:9)
  at Object.<anonymous> (/usr/local/lib/node_modules/grunt-cli/bin/grunt:45:20)
  at Module._compile (module.js:460:26)
  at Object.Module._extensions..js (module.js:478:10)
  at Module.load (module.js:355:32)
  at Function.Module._load (module.js:310:12)
  at Function.Module.runMain (module.js:501:10)
  at startup (node.js:129:16)
  at node.js:814:3
Aborted due to warnings.

Running without reporter: require('jshint-stylish'), worked!

Add support for angular constants

I use Momentjs and lodash as constants in my angular app. Each call to this library in a controller or service throws multiple warnings.

How to show the errorCode?

I can't show the jshint errorCode, so when I need to ignore some error, I need to disable the reporter, in the grunt file, run it, get the errorCode and then run it again after add comment disabling the error warning.

How can I add a flag to display the errorCode?

How to fail gulp build?

I can force exit on failed jshint gulp task using the default reporter

gulp.task('lint', function() {
  gulp.src('example.js')
    .pipe(jshint())
    .pipe(jshint.reporter({
      fail: true
    }));
});

But I do not see a way to fail the build using stylish reporter, trying this

gulp.task('lint', function() {
  gulp.src('example.js')
    .pipe(jshint())
    .pipe(jshint.reporter(stylish, {
      fail: true
    }));
});

Am I not passing the correct reporter function plus options?

Add fullPath option

Hi,

The reporter currently prints relative paths to the console.
In some IDEs, the terminal only converts absolute paths into clickable links, which is really
useful for quickly navigating to the errors.

Could you add a 'fullPath' option to the reporter?

I guess all you would have to do is adding:

var path = require("path");

and replacing line 35 with:

headers[i] = (options.fullPath ? path.resolve(process.cwd(), el.file) : el.file);

Thanks :)

Displaying "? no problems"

Somehow this is displaying incorrectly on my desktop, but not on my laptop. It's probably an error on my side, but got any ideas as to what may cause this?

show jshint rule related to the error in stylish output

Not sure if this would be for here, the jshint team, or the gulp-jshint team, but would it be possible to see the jshint rule related to the thrown error, either by default or as config option?

for example, if the error is
line 16 col 14 'cardPayment' is not defined.

we would also see this as part of the output
/* jshint -W117 */

Thanks and keep up the great work!

When using as reporter for gunt-contrib-jshint it breaks grunt watch

I have a problem using this package as reporter for gunt-contrib-jshint, when I save a js file that has a jshint error in it jshint-stylish causes the whole grunt process to crash so that I manually need to restart it in the terminal. gunt-contrib-jshint without jshint-stylish does not crash the process.

cannot read property 'verbose' of undefined

tried this out with the following setup:

gruntfile:

    // ...
    jshint: {
        options: {
            jshintrc: '.jshintrc',
            reporter: 'node_modules/jshint-stylish/stylish.js'
        },
        all: ['gruntfile.js', 'public/js/**/*.js', 'test/**/*.js', 'app/**/*.js']
    },
    // ...

package.json:

// ...
"devDependencies": {
  // ...
  "grunt-contrib-jshint": "latest",
  "jshint-stylish": "~0.1.0"
}
// ...

either i'm doing something wrong causing options to be undefined, or you shouldn't assume it exists and default it to an empty object?

Hope this helps.
Sander

Problem viewing error message on Windows 8.1

The blue color to display error message on this line are displayed very dark, and if you had black background color on your console(I use Windows 8.1), it will definitely hurt your eyes.

image

I changed mine like this:

var line = [
    '',
    chalk.bgCyan(chalk.gray('line ' + err.line)),
    chalk.bgYellow(chalk.gray('col ' + err.character)),
    isError ? chalk.bgRed(chalk.yellow(err.reason)) :chalk.bgYellow(chalk.blue(err.reason))
];

It looks pretty now.

image

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.