Giter VIP home page Giter VIP logo

jshint-mode's Introduction

jshint-mode

Integrate JSHint into Emacs via a node.js server.

example

jshint-mode was heavily inspired by Kevin Turners lintnode.

Dependencies

Building

download or clone

$ git clone git://github.com/daleharvey/jshint-mode.git

Usage

Add the configuration to your .emacs config file:

$jshint-emacs-conf >> ~/.emacs  // or
$npm explore jshint-mode
Exploring /Users/yourname/node_modules/jshint-mode
Type 'exit' or ^D when finished

bash-3.2$ exit

or if you downloaded manually:

(add-to-list 'load-path "~/path/to/jshint-mode")
(require 'flymake-jshint)
(add-hook 'javascript-mode-hook
     (lambda () (flymake-mode t)))

Becareful: If you emacs can't find node program, maybe you should add some config to .emacs like this:

(setenv "PATH" (concat "/usr/local/bin:" (getenv "PATH")))
(setq exec-path
      '(
	"/usr/local/bin"
	"/usr/bin"
	))

You can use M-x flymake-mode to turn flymake of and on, if you want to turn it on be fault, add the following to your .emacs

;; Turns on flymake for all files which have a flymake mode
(add-hook 'find-file-hook 'flymake-find-file-hook)

Using .jshintrc

By default, jshint-mode will search for the nearest .jshintrc file up the directory tree from the location of each JS file you edit.

Alternatively, you can customize the jshint-mode-jshintrc variable to set the location of a .jshintrc file that will always be used (and will be the only one used).

Note to Emacs.app users

If use Emacs.app on OS X, you need to set the following environment variables:

  • PATH - Add path to your node executable

jshint-mode's People

Contributors

carljm avatar daleharvey avatar diasjorge avatar jmalonzo avatar theotheo 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jshint-mode's Issues

[instructions] jshint-emacs-conf changed name

The Usage section immediately follows the git clone instructions, presumably leaving the user in the directory into which git created the jshint-mode directory. The instructions are

$jshint-emacs-conf >> ~/.emacs

The current conf script appears to be named jshint-emacs.js; I think the following instructions would make it trivial for newbies:

  • before pre section add ", (presuming you are in the directory where git created the jshint-mode directory)"
  • change the instruction to $ ./jshint-mode/jshint-emacs.js >> ~/.emacs

nvm

jshint-mode doesn't play nice with nvm, since it won't find node.
It should be fixable by adding defining jshint-mode-node as $NVM_BIN outside of jshint, but before I thought of it, I already used the fallback - install node via homebrew brew install node, so I won't figure things out today.

Missing fs.existsSync

Running on a relatively old node instance (0.6.12), I am missing fs.existsSync

/home/foo/src/jshint-mode/jshint-mode.js:69
  return filePath && fs.existsSync(filePath) ?
                        ^
TypeError: Object #<Object> has no method 'existsSync'
    at _loadAndParseConfig (/home/foo/src/jshint-mode/jshint-mode.js:69:25)
    at _getConfig (/home/foo/src/jshint-mode/jshint-mode.js:77:31)
    at /home/foo/src/jshint-mode/jshint-mode.js:93:20
    at IncomingForm.<anonymous> (/home/foo/src/jshint-mode/node_modules/formidable/lib/incoming_form.js:118:9)
    at IncomingForm.emit (events.js:67:17)
    at IncomingForm._error (/home/foo/src/jshint-mode/node_modules/formidable/lib/incoming_form.js:248:8)
    at IncomingMessage.<anonymous> (/home/foo/src/jshint-mode/node_modules/formidable/lib/incoming_form.js:104:14)
    at IncomingMessage.emit (events.js:64:17)
    at HTTPParser.onMessageComplete (http.js:137:23)
    at Socket.ondata (http.js:1410:22)

A question about Windows support

Hello. Does this mode support Windows? I've set it up and I can clearly see that it's working (by means of the Flymake indicator on the status bar), but the problem is that it doesn't highlight lines at all.

formidable dependency

When following the manual install instructions, the npm package for formidable isn't installed. Would be nice if that was documented as well because there isn't a clear error message in emacs if formidable is missing.

globals is not used from .jshintrc

I tried to add the following configuration in my .jshintrc but it does not work. jshint still hightlight with define is not defined

"globals" : { "define" : true,
              "require" : true,
              "ok": true,
              "module": true,
              "expect": true,
              "test": true,
              "equals": true }

Any idea ?

jshint.js could use an update.

I use .jshintrc and the "globals" options. I get warnings about this option because it used to be called "predef". I suggest simply updating jshint.js to the current version to fix this.

First option in Usage is not clear

The option to automatically add it to your config ("Add the configuration to your .emacs config file:") is not clear.

After cloning, it doesn't explain how to get a runnable jshint-emacs-conf.

Any way to get this working with .jsm files

This is the relevant stuff from my .emacs:

;; jshint
(add-to-list 'load-path "~/.emacs.d/jshint-mode")
(require 'flymake-jshint)
(setq jshint-mode-jshintrc "~/.jshintrc")
 (add-hook 'js3-mode-hook
     (lambda () (flymake-mode t)))

;; Turns on flymake for all files which have a flymake mode
(add-hook 'find-file-hook 'flymake-find-file-hook)

;; Set up JS3 mode
(add-to-list 'auto-mode-alist '("\\.js$" . js3-mode));
(add-to-list 'auto-mode-alist '("\\.jsm$" . js3-mode));

where is jshint-emacs-path?

git clone git://github.com/daleharvey/jshint-mode.gitj cd jshint-mode jshint-emacs-path >> ~/.emacs -bash: jshint-emacs-path: command not found

what/where is it?

.jshintrc file?

So I'm not very familiar with all of this, and I'm really just sort of hacking at it to get it running, which I've managed to do. What I'm curious about is if there a way to set up a .jshintrc file that will contain all of the defaults that I want rather than placing them at the top of each .js file?

Can this be done? Can someone tell me how it would be done?

Sorry if this is a boneheaded question, (Or the incorrect place to ask)

Thanks
Matt

Support for browser: true in .jshintrc?

I'm not real familiar with JSHint etc, so apologies in advance if this is a dumb question (and thanks for jshint-mode, in general its working great!). The project I'm working on has a .jshintrc that looks like this (in part):

{
    "predef": {
        "mixpanel": true,
        "ich": true,
        "Pusher": true,
    },

    "browser": true,
    "jquery": true
}

I know that the .jshintrc is being read (at least the predef section), since I'm using e.g. mixpanel as a global and not getting any warning. As far as I'm aware, browser: true should mean that things like document and window are also accepted by JSHint as global vars, but I do get warnings on those.

Am I wrong about how browser: true is supposed to work? Or am I doing something else wrong? Or is this an issue with jshint-mode?

Bad option: -W065

This beautiful mode throughs an ugly error when my .jshintrc file (or a jshint header) contains the "-W065" flag to allow parseInt() without radix.
Note: I am able to run jshint from a terminal without problems.

TypeError: Cannot call method 'indexOf' of undefined

I installed jshint-mode following the instructions on the front page and using npm. Whenever jshint-mode runs I see the following on the jshint-mode buffer and do not receive any expected errors.

node.js:201
        throw e; // process.nextTick error, or 'error' event on first tick
              ^
TypeError: Cannot call method 'indexOf' of undefined
    at getOpt (/usr/local/lib/node_modules/jshint-mode/jshint-mode.js:22:28)
    at Object.<anonymous> (/usr/local/lib/node_modules/jshint-mode/jshint-mode.js:51:12)
    at Module._compile (module.js:432:26)
    at Object..js (module.js:450:10)
    at Module.load (module.js:351:31)
    at Function._load (module.js:310:12)
    at Array.0 (module.js:470:10)
    at EventEmitter._tickCallback (node.js:192:40)

Process jshint-mode-server exited abnormally with code 1

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.