Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: fixed incorrect guide for setting up eslint to work with jessie #607

Merged
merged 1 commit into from
Jan 15, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 35 additions & 8 deletions main/guides/js-programming/hardened-js.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,20 +94,47 @@ recommended style for writing JavaScript smart contracts.
This `eslint` configuration provides tool support.
:::

1. If not already configured, run `yarn add eslint @jessie.js/eslint-plugin`
2. If not already configured, add the following to your `package.json`:
1. If working from an empty directory, a package.json file must first be created by running `yarn init` or `yarn init -y`.
2. From there, we can install eslint into our project along with the jessie.js eslint-plugin by running `yarn add eslint @jessie.js/eslint-plugin`.
3. The final step is to set up our project's eslint configuration inside of the package.json file by adding in the following code block.

```json
"eslintConfig" : {
"parserOptions": {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After doing a final run through, I found that eslint complains about the code using an import statement outside of a module. Adding this parserOptions property resolves this error.

"sourceType": "module",
"ecmaVersion": 6
},
"extends": [
"plugin:@jessie.js/recommended"
]
}
```

Now, the contents of the package.json file should look similiar to the snippet below.

```json
{
"name": "eslint-config-test",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"type": "module",
"devDependencies": {
"@jessie.js/eslint-plugin": "^0.1.3",
"eslint": "^8.6.0"
},
"eslintConfig": {
"extends": [
"@jessie.js"
]
"parserOptions": { "sourceType": "module", "ecmaVersion": 6 },
"extends": ["plugin:@jessie.js/recommended"]
}
}
Comment on lines +115 to +130
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may seem like overkill but IMO seeing the entire contents of the file best ensures the reader avoids any issues.

```

3. Put `// @jessie-check` at the beginning of your `.js` source file.
4. Run `yarn eslint --fix path/to/your-source.js`
5. Follow the linter's advice to edit your file, then go back to step 4.
### Linting jessie.js code

1. Put `// @jessie-check` at the beginning of your `.js` source file.
2. Run `yarn eslint --fix path/to/your-source.js`
3. In the event that eslint finds issues with the code, follow the linter's advice to edit your file, and then repeat the step above.

The details of Jessie have evolved with experience; as a result, here
we use `(count += 1)` where in the video shows `{ return count++; }`.
Expand Down