How to do linting using nodemon?

Is it possible to use nodemon for javascript overlay? I do not use any build tool, for example. gulp or grunt and want to maximize the use of node and npm.

The output from nodemon can be transmitted over channels . I want to use this to drag and drop a modified file using eslint.

Here is my package.json

{ "name": "app", "version": "0.0.1", "private": true, "scripts": { "start": "nodemon server.js", "lint": "eslint" }, "dependencies": { "MD5": "*", "clean-css": "*", "express": "~4.9.0", "express-handlebars": "~2.0.1", "express-redis-cache": "*", "foundation-sites": "~5.5.3", "fs-extra": "~0.8.1", "node-rest-client": "~1.5.1", "node-sass": "*", "path": "*" }, "devDependencies": { "babel-eslint": "^4.1.6", "eslint": "^1.10.3", "eslint-config-airbnb": "^2.1.1", "eslint-config-airbnb-es5": "^1.0.8", "eslint-plugin-react": "^3.13.1", "nodemon": "~1.8.1", "parallelshell": "~2.0.0", "watch": "~0.17.1" } } 

I have tried this. But it does not work. He gives an error.

  "scripts": { "start": "nodemon({ script: 'server.js' }).on('restart', function () {console.log('nodemon started');}).on('crash', function () {console.log('script crashed for some reason');});", "lint": "eslint" }, 
+7
javascript npm eslint nodemon
source share
3 answers

You can use the exec nodemon option to run tests while saving code. Here is an example:

 nodemon server.js --exec 'npm run test && node' 

This will cause nodemon to run npm run test && node server.js and it will not start the server until all tests have been successfully completed.

+21
source share

I am using Standard.js for casting, and I can get it to work with nodemon using the package.json script below.

 "scripts": { "lint": "standard", "dev": "nodemon ./app --exec \"npm run lint && node\"" "start": "nodemon ./app" } 

When I run npm run dev , any changes that I make will be monitored and routed. I tested this on Windows using PowerShell .

+3
source share

Lint is a purely developmental process. Nodemon is a tool used to start a server and is not related to build tools, but with application launch. Therefore, the answer is NO. You should use the proper development automation tool like grunt, gulp, etc. Or just pure NPM scripts (in your package.json file).

I would recommend using automation tools if your project is complex, has many stages and a lot of kit, etc. However, for casting only, you can simply prepare a single line liner in your npm package.json , for example. eg:

 "scripts": { "lint": "eslint --fix src test", } 

And then run it with the command: "npm run lint".

Remember that with a properly configured .eslintrc file .eslintrc you can use your code both with the help of console commands and with the help of editors / IDEs (almost every widely popular development environment has a plugin for eslint).

More information on configuring eslint and creating an eslintrc file can be found here: http://eslint.org/docs/user-guide/configuring

-4
source share

All Articles