-
Notifications
You must be signed in to change notification settings - Fork 2.6k
[DOCS][OV JS] Add js codestyle rules #25523
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
Merged
mlukasze
merged 4 commits into
openvinotoolkit:master
from
vishniakov-nikolai:feature/codestyle-doc
Jul 16, 2024
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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 hidden or 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 |
---|---|---|
@@ -0,0 +1,95 @@ | ||
# Code Style Guide | ||
|
||
This document outlines the coding standards and guidelines of javascript and typescript part of **openvino-node** package. These rules help maintain code quality and consistency throughout the codebase. | ||
|
||
Please, make sure that eslint activated in your IDE. | ||
Rules specified in [.eslint-global.js file](../.eslintrc-global.js). Pay attention that PR wont get approve without following these rules. | ||
vishniakov-nikolai marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## General Rules | ||
|
||
### 1. Semicolons | ||
- **Rule**: Always use semicolons at the end of statements. | ||
- **Enforced By**: `semi: ['error']` | ||
|
||
### 2. Variable Declarations | ||
- **Rule**: Use `let` or `const` instead of `var`. | ||
- **Enforced By**: `no-var: ['error']` | ||
|
||
### 3. Line Length | ||
- **Rule**: Lines should not exceed the maximum length. | ||
vishniakov-nikolai marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- **Enforced By**: `max-len: ['error']` | ||
|
||
### 4. End of Line | ||
- **Rule**: Ensure that files end with a newline. | ||
vishniakov-nikolai marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- **Enforced By**: `eol-last: ['error']` | ||
|
||
### 5. Indentation | ||
- **Rule**: Use 2 spaces for indentation. | ||
vishniakov-nikolai marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- **Enforced By**: `indent: ['error', 2]` | ||
|
||
### 6. Naming Conventions | ||
- **Rule**: Use camelCase for variable and function names. | ||
- **Enforced By**: `camelcase: ['error']` | ||
|
||
### 7. Semicolon Spacing | ||
- **Rule**: Enforce spacing around semicolons. | ||
vishniakov-nikolai marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- **Enforced By**: `semi-spacing: ['error']` | ||
|
||
### 8. Arrow Function Spacing | ||
- **Rule**: Enforce spacing around arrow functions. | ||
vishniakov-nikolai marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- **Enforced By**: `arrow-spacing: ['error']` | ||
|
||
### 9. Comma Spacing | ||
- **Rule**: Enforce spacing around commas. | ||
vishniakov-nikolai marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- **Enforced By**: `comma-spacing: ['error']` | ||
|
||
### 10. Multiple Spaces | ||
- **Rule**: Disallow multiple spaces except for indentation. | ||
vishniakov-nikolai marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- **Enforced By**: `no-multi-spaces: ['error']` | ||
|
||
### 11. Quotes | ||
- **Rule**: Use single quotes for strings. | ||
vishniakov-nikolai marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- **Enforced By**: `quotes: ['error', 'single']` | ||
|
||
### 12. Trailing Spaces | ||
- **Rule**: Disallow trailing spaces at the end of lines. | ||
vishniakov-nikolai marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- **Enforced By**: `no-trailing-spaces: ['error']` | ||
|
||
### 13. Space Before Blocks | ||
vishniakov-nikolai marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- **Rule**: Require space before blocks. | ||
vishniakov-nikolai marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- **Enforced By**: `space-before-blocks: ['error']` | ||
|
||
### 14. Newline Before Return | ||
vishniakov-nikolai marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- **Rule**: Enforce newline before return statements. | ||
vishniakov-nikolai marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- **Enforced By**: `newline-before-return: ['error']` | ||
|
||
### 15. Comma Dangle | ||
- **Rule**: Require trailing commas in multiline object literals. | ||
vishniakov-nikolai marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- **Enforced By**: `comma-dangle: ['error', 'always-multiline']` | ||
|
||
### 16. Space Before Function Parentheses | ||
vishniakov-nikolai marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- **Rule**: Enforce consistent spacing before function parentheses. | ||
vishniakov-nikolai marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- Named functions: No space | ||
- Anonymous functions: No space | ||
- Async arrow functions: Space | ||
- **Enforced By**: `space-before-function-paren: ['error', { named: 'never', anonymous: 'never', asyncArrow: 'always' }]` | ||
|
||
### 17. Key Spacing in Object Literals | ||
- **Rule**: Enforce consistent spacing between keys and values in object literals. | ||
vishniakov-nikolai marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- **Enforced By**: `key-spacing: ['error', { beforeColon: false }]` | ||
|
||
### 18. Multiple Empty Lines | ||
- **Rule**: Disallow multiple empty lines. | ||
vishniakov-nikolai marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- Maximum empty lines: 1 | ||
- Maximum at the beginning of file: 0 | ||
- Maximum at the end of file: 0 | ||
- **Enforced By**: `no-multiple-empty-lines: ['error', { max: 1, maxBOF: 0, maxEOF: 0 }]` | ||
|
||
### 19. Keyword Spacing | ||
- **Rule**: Enforce consistent spacing around keywords. | ||
vishniakov-nikolai marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- Special case for `catch` keyword: No space after `catch` | ||
vishniakov-nikolai marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- **Enforced By**: `keyword-spacing: ['error', { overrides: { catch: { after: false } } }]` | ||
|
||
## Additional Resources | ||
|
||
For further details on each rule, please refer to the [ESLint documentation](https://eslint.org/docs/rules/). | ||
vishniakov-nikolai marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or 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
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.
Uh oh!
There was an error while loading. Please reload this page.