-
Notifications
You must be signed in to change notification settings - Fork 39
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
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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": { | ||
"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
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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++; }`. | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.