# Truffle - How to run Linter command before compile or migrate?

**URL:** <https://forum.openzeppelin.com/t/truffle-how-to-run-linter-command-before-compile-or-migrate/1054>\
**Category:** Support\
**Created:** [July 17, 2019, 5:10pm UTC](https://forum.openzeppelin.com/t/truffle-how-to-run-linter-command-before-compile-or-migrate/1054 "2019-07-17T17:10:41Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![abcoathup](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/abcoathup/32/415_2.png) [@abcoathup](https://forum.openzeppelin.com/u/abcoathup)\
**Post date:** [July 18, 2019, 2:38am UTC](https://forum.openzeppelin.com/t/truffle-how-to-run-linter-command-before-compile-or-migrate/1054/3 "2019-07-18T02:38:03Z")

</div>

Hi @lalitbit welcome.

As per @skyge the answer is it depends.  
Some of the potential options are as follows (though @skyge may have a better solution):

You could look at doing linting as part of Continuous Integration.

> [@Test smart contracts like a rockstar](https://forum.openzeppelin.com/t/test-smart-contracts-like-a-rockstar/1001):
>
> [One does not simply](https://pics.me.me/one-does-not-simply-five-oh-my-god-thats-awesome-work-11532882.png) test your dapp. Among many other things while developing a decentralized application, testing it is something you always need to do. What most people still don’t do is automate those tests, which leads to a huge loss of time and drains the energy to code. Automated tests have been around for a while and they have been gaining lots of traction in the last decade. Whilst blockchain and smart contract development are fairly new, we can still automate tests for these. We can, s…

I use Juan Blanco's Solidity extension, so that in VS Code I get errors and warnings about my Solidity formatting and then use linting to catch anything I have missed.

> [@VSC extension recommendations](https://forum.openzeppelin.com/t/vsc-extension-recommendations/606/4):
>
> I find Juan Blanco’s extension a must if you are using VSCode for anything Ethereum. Apart from it, I also use: EditorConfig for VS Code and Prettier extensions for code formatting. Mocha sidebar to run tests. Note that this one doesn’t work with Truffle, but I use it for dapps’ code and [Buidler](https://buidler.dev/) tests.

You could add a [script](https://docs.npmjs.com/cli/run-script) to `package.json` such as the example compile below, which first runs lint and then compiles.

```auto
  "scripts": {
    "compile": "npm run lint && truffle compile",
    "coverage": "solidity-coverage && cat coverage/lcov.info | coveralls",
    "lint": "npm run lint:js && npm run lint:sol",
    "lint:fix": "npm run lint:js:fix",
    "lint:js": "eslint .",
    "lint:js:fix": "eslint . --fix",
    "lint:sol": "solhint --max-warnings 0 \"contracts/**/*.sol\"",
    "test": "truffle test"
  },

```

This is based on the [OpenZeppelin package.json](https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/package.json) scripts.

---

_[View the full topic](https://forum.openzeppelin.com/t/truffle-how-to-run-linter-command-before-compile-or-migrate/1054)._
