how to do linting using nodemon?

后端 未结 3 1007
醉酒成梦
醉酒成梦 2021-02-07 14:49

Can I use nodemon to lint my javascript? I am not using any build tool e.g. gulp or grunt and want to maximize the use of node and npm.

The output from nodemon can be pi

3条回答
  •  耶瑟儿~
    2021-02-07 14:53

    Linting is purely a development process. Nodemon is a tool used for running server and not connected with build tools, but with running your application. Therefore answer is "NO". You should use proper tool for development automation like grunt, gulp etc. or just pure NPM scripts (in your package.json file).

    I'd recommend using automation tools if your project is complicated, has many stages and a lot of bundling etc. However, for only linting, you could just prepare one-liner in your npm package.json, e.g. like this:

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

    And then run it with command: 'npm run lint'.

    Remember that by using properly configured .eslintrc file, you could lint your code both by console commands, but by editors/IDEs as well (almost every broadly popular IDE has plugin for eslint).

    More info about configuring eslint and creating proper eslintrc file could be found here: http://eslint.org/docs/user-guide/configuring

提交回复
热议问题