-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
31 changed files
with
155 additions
and
123 deletions.
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
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Cyclomatic Complexity | ||
|
||
Checks if the cyclomatic complexity of a component is too high. The default threshold is 5. Between 5 and 10 you get a warning, above 10 you get an error. | ||
|
||
## 📖 What is cyclomatic complexity? | ||
|
||
Complexity is determined by the number of decision points in a component's `script` block. The decision points are `if`, `else`, `while`, `for`, `while` and `case`. If the complexity is between 5 and 10, you get a warning. If it's above 10, you get an error. | ||
|
||
The more decision points a component has, the more complex it is. High complexity can make your code harder to read, test, maintain, and debug. Components in general should be small, simple and focused. | ||
|
||
## Why it's good to follow this rule? | ||
|
||
- **Readability:** Components with high complexity are harder to read and understand. By keeping complexity low, you make your code easier to maintain and debug. | ||
- **Testability:** Components with high complexity are harder to test. By keeping complexity low, you make your code easier to test. | ||
- **Maintainability:** Components with high complexity are harder to maintain. By keeping complexity low, you make your code easier to maintain. | ||
- **Scalability:** As your application grows, keeping complexity low helps manage complexity. | ||
- **Performance:** Components with high complexity can be slower to render. By keeping complexity low, you can improve performance. |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Deep Indentation | ||
|
||
Checks if the indentation of the component is too deep. The default for `tabs` is 5, for `spaces` is 15. |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# `else` conditions | ||
|
||
Checks if there are any `else` condition in the `script` block. This is a code smell because it can be hard to read and understand. |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Function Size | ||
|
||
Checks if functions inside `script setup` block are less than 20 lines of code. It handles regular and arrow functions. |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# 💻 rrd Rules | ||
|
||
These ruleset is the most opinionated with rules that are not part of the *offical* Vue style guide. They are based on the experience of this repo owner and are meant to help you write better Vue code. | ||
|
||
## Why it's good to follow this ruleset? | ||
|
||
Opinionated means that there is a clear path to follow. This is good for teams because it helps to have a consistent codebase. It also helps to avoid common pitfalls and bugs. |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Parameter Count | ||
|
||
Checks if functions inside `script setup` block have less than 4 parameters. It handles regular and arrow functions. |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Plain Script | ||
|
||
Checks if the script section of a Vue component is not using `<script setup>` |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Script Length | ||
|
||
Checks if the script section of a Vue component is too long. The default threshold is 100 lines. Between 100 and 200 lines you get a warning, above 200 lines you get an error. |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Short Variable Name | ||
|
||
Checks if variable names inside `<script setup>` block have less than 4 chars. |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## Too many props | ||
|
||
Checks if the component got more then 5 props. |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
## Global Styles | ||
|
||
Checks if the component is using global styles instead of `scoped` styles. <br /> | ||
👉 https://vuejs.org/style-guide/rules-essential.html#use-component-scoped-styling |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# ⭐ Vue Essential Rules | ||
|
||
These rules help prevent errors, so learn and abide by them at all costs. Exceptions *may* exist, but should be *very rare* and only be made by those with *expert* knowledge of both JavaScript and Vue. |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Keyed `v-for` | ||
|
||
Checks if the component is using `v-for` without a `key` property. <br /> | ||
👉 https://vuejs.org/style-guide/rules-essential.html#use-keyed-v-for | ||
|
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Simple Props Definitions | ||
|
||
Checks if the component is using simple props definitions. <br /> | ||
👉 https://vuejs.org/style-guide/rules-essential.html#use-detailed-prop-definitions |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Single Name Component | ||
|
||
Checks if the component name is a single word. <br /> | ||
👉 https://vuejs.org/style-guide/rules-essential.html#use-multi-word-component-names |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# `v-if` With `v-for` | ||
|
||
Checks if the component is using `v-if` with `v-for`. <br /> | ||
👉 https://vuejs.org/style-guide/rules-essential.html#avoid-v-if-with-v-for |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# ✅ Vue Recommended Rules | ||
|
||
Where multiple, equally good options exist, an arbitrary choice can be made to ensure consistency. In these rules, we describe each acceptable option and suggest a default choice. That means you can feel free to make a different choice in your own codebase, as long as you're consistent and have a good reason. |
6 changes: 2 additions & 4 deletions
6
docs/rules/vue-recommended.md → ...ecommended/sfc-top-level-element-order.md
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
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Component File Name Casing | ||
|
||
Checks if the component file name is in PascalCase or kebab-case. <br /> | ||
👉 https://vuejs.org/style-guide/rules-strongly-recommended.html#single-file-component-filename-casing |
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Directive Shorthands | ||
|
||
Checks if the template is using directive shorthands. <br /> | ||
👉 https://vuejs.org/style-guide/rules-strongly-recommended.html#directive-shorthands | ||
|
||
::: warning | ||
This rule enforces using directive shorthands for better readability. While the official style guide allows using shorthands "**always** or **never**", this rule will flag non-shorthands as code smell. | ||
::: |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# 👍 Vue Strongly Recommended Rules | ||
|
||
These rules have been found to improve readability and/or developer experience in most projects. Your code will still run if you violate them, but violations should be rare and well-justified. |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Prop Name Casing | ||
|
||
Checks if the props name is in camelCase. <br /> | ||
👉 https://vuejs.org/style-guide/rules-strongly-recommended.html#prop-name-casing |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Quoted Attribute Values | ||
|
||
Checks if the template is using quoted attribute values. <br /> | ||
👉 https://vuejs.org/style-guide/rules-strongly-recommended.html#quoted-attribute-values |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Self Closing Components | ||
|
||
Checks if the template is using self-closing components. <br /> | ||
👉 https://vuejs.org/style-guide/rules-strongly-recommended.html#self-closing-components |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Simple computed properties | ||
|
||
Checks if any computed properties are bigger than 5 lines. <br /> | ||
👉 https://vuejs.org/style-guide/rules-strongly-recommended.html#simple-computed-properties |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Template Simple Expressions | ||
|
||
Checks if the template is using only simple expressions. <br /> | ||
👉 https://vuejs.org/style-guide/rules-strongly-recommended.html#simple-expressions-in-templates |
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