Skip to content

Commit cea1cb5

Browse files
authored
docs: Adds docs on linting contracts (#3731)
Small doc contribution for local development. Helps with running lints on contracts locally.
1 parent 85dfc13 commit cea1cb5

File tree

1 file changed

+100
-0
lines changed

1 file changed

+100
-0
lines changed

docs/src/guides/launch.md

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,3 +200,103 @@ Ensure that the necessary containers have been started and are functioning corre
200200
```bash
201201
zkstack containers
202202
```
203+
204+
### `zkstack dev lint --check -t contracts` fails
205+
206+
#### Problem
207+
208+
```
209+
zkstack dev lint --check -t contracts 138ms 13:13:01
210+
211+
┌ ZK Stack CLI
212+
213+
● Running linters for targets: [".contracts"]
214+
215+
◒ Running contracts linter.. │
216+
■ Command failed to run
217+
218+
■ Status:
219+
│ exit status: 2
220+
│ Stdout:
221+
│ yarn run v1.22.22
222+
│ $ yarn lint:md && yarn lint:sol && yarn lint:ts && yarn prettier:check
223+
│ $ markdownlint "**/*.md"
224+
│ $ solhint "**/*.sol"
225+
│ A new version of Solhint is available: 5.0.5
226+
│ Please consider updating your Solhint package.
227+
228+
│ system-contracts/contracts/ContractDeployer.sol
229+
│ 171:27 warning Avoid to use tx.origin avoid-tx-origin
230+
231+
│ ✖ 1 problem (0 errors, 1 warning)
232+
233+
│ $ eslint .
234+
│ info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
235+
│ info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
236+
237+
238+
│ Stderr:
239+
240+
│ Oops! Something went wrong! :(
241+
242+
│ ESLint: 8.57.0
243+
244+
│ EslintPluginImportResolveError: typescript with invalid interface loaded as resolver
245+
│ Occurred while linting /home/evl/code/zksync-era/contracts/system-contracts/scripts/utils.ts:19
246+
│ Rule: "import/default"
247+
│ at requireResolver (/home/evl/code/zksync-era/node_modules/eslint-module-utils/resolve.js:204:17)
248+
│ at fullResolve (/home/evl/code/zksync-era/node_modules/eslint-module-utils/resolve.js:141:22)
249+
│ at Function.relative (/home/evl/code/zksync-era/node_modules/eslint-module-utils/resolve.js:158:10)
250+
│ at remotePath (/home/evl/code/zksync-era/contracts/node_modules/eslint-plugin-import/lib/ExportMap.js:811:381)
251+
│ at captureDependency (/home/evl/code/zksync-era/contracts/node_modules/eslint-plugin-import/lib/ExportMap.js:817:463)
252+
│ at captureDependencyWithSpecifiers
253+
│ (/home/evl/code/zksync-era/contracts/node_modules/eslint-plugin-import/lib/ExportMap.js:817:144)
254+
│ at /home/evl/code/zksync-era/contracts/node_modules/eslint-plugin-import/lib/ExportMap.js:822:42
255+
│ at Array.forEach (<anonymous>)
256+
│ at ExportMap.parse (/home/evl/code/zksync-era/contracts/node_modules/eslint-plugin-import/lib/ExportMap.js:821:427)
257+
│ at ExportMap.for (/home/evl/code/zksync-era/contracts/node_modules/eslint-plugin-import/lib/ExportMap.js:807:201)
258+
│ error Command failed with exit code 2.
259+
│ error Command failed with exit code 2.
260+
261+
262+
■ Command failed to run: yarn --cwd contracts lint:check
263+
264+
│ Oops! Something went wrong! :(
265+
266+
│ ESLint: 8.57.0
267+
268+
│ EslintPluginImportResolveError: typescript with invalid interface loaded as resolver
269+
│ Occurred while linting /home/evl/code/zksync-era/contracts/system-contracts/scripts/utils.ts:19
270+
│ Rule: "import/default"
271+
│ at requireResolver (/home/evl/code/zksync-era/node_modules/eslint-module-utils/resolve.js:204:17)
272+
│ at fullResolve (/home/evl/code/zksync-era/node_modules/eslint-module-utils/resolve.js:141:22)
273+
│ at Function.relative (/home/evl/code/zksync-era/node_modules/eslint-module-utils/resolve.js:158:10)
274+
│ at remotePath (/home/evl/code/zksync-era/contracts/node_modules/eslint-plugin-import/lib/ExportMap.js:811:381)
275+
│ at captureDependency (/home/evl/code/zksync-era/contracts/node_modules/eslint-plugin-import/lib/ExportMap.js:817:463)
276+
│ at captureDependencyWithSpecifiers (/home/evl/code/zksync-era/contracts/node_modules/eslint-plugin-import/lib/ExportMap.js:817:144)
277+
│ at /home/evl/code/zksync-era/contracts/node_modules/eslint-plugin-import/lib/ExportMap.js:822:42
278+
│ at Array.forEach (<anonymous>)
279+
│ at ExportMap.parse (/home/evl/code/zksync-era/contracts/node_modules/eslint-plugin-import/lib/ExportMap.js:821:427)
280+
│ at ExportMap.for (/home/evl/code/zksync-era/contracts/node_modules/eslint-plugin-import/lib/ExportMap.js:807:201)
281+
│ error Command failed with exit code 2.
282+
│ error Command failed with exit code 2.
283+
284+
285+
▲ 0: Command failed to run: yarn --cwd contracts lint:check
286+
287+
└ Failed to run command
288+
```
289+
290+
#### Description
291+
292+
`npm` setup is nested within our codebase. Contracts has it & so does the core codebase. The 2 can be incompatible,
293+
therefore running `yarn install` in core ends up with a set of dependencies, with `yarn install` in contracts having a
294+
different set of dependencies.
295+
296+
#### Solution
297+
298+
```
299+
cd contracts && yarn install
300+
```
301+
302+
> NOTE: This may cause integration tests to fail in core. If so, run `yarn install` inside core repo.

0 commit comments

Comments
 (0)