You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What feature(s) would you like to see in RepoSense
Standardize the style used for arrays to be T[] or Array<T>, based on the complexity of T.
Is the feature request related to a problem?
During the TypeScript migration of the front-end, both of these styles were used interchangeably. Since the 2 styles are functionally equivalent, we can use the same style consistently across the codebase to make it easier for developers to read and understand array types.
We can consider using the array-simple option as this allows us to use the shorter, modern T[] or readonly T[] for simple types (i.e. types that are just primitive names or type references), and Array<T> or ReadonlyArray<T> for all other types (union types, intersection types, object types, function types, etc) where the shorter syntax could get confusing.
Make edits to the codebase such that the newly introduced lint rule is followed. Most of the changes will be in the props and data() sections of the .vue files.
If applicable, describe alternatives you've considered
We could also consider using the array or generic options for the lint rule if we want to stick to a single style at all times, no matter the complexity of the type.
Array<T> and T[] can be used interchangeably in TypeScript. We can use
the same style consistently across the codebase to make it easier for
developers to read and understand array types.
In Vue, using T[] in defineComponent requires casting in the form of
"Array as PropType<T[]>", while Array<T> can be used as is. Therefore,
it would be more consistent to use Array<T> for .vue files.
Additionally, such a rule can be enforced more easily with eslint.
Let's include a rule for eslint to check array usage and change the
code to follow this rule.
What feature(s) would you like to see in RepoSense
Standardize the style used for arrays to be
T[]
orArray<T>
, based on the complexity of T.Is the feature request related to a problem?
During the TypeScript migration of the front-end, both of these styles were used interchangeably. Since the 2 styles are functionally equivalent, we can use the same style consistently across the codebase to make it easier for developers to read and understand array types.
If possible, describe the solution
Add a lint rule to enforce that the same array style is used across the code base. This should be in the global
.eslintrc.json
.We can consider using the
array-simple
option as this allows us to use the shorter, modernT[]
orreadonly T[]
for simple types (i.e. types that are just primitive names or type references), andArray<T>
orReadonlyArray<T>
for all other types (union types, intersection types, object types, function types, etc) where the shorter syntax could get confusing.props
anddata()
sections of the.vue
files.If applicable, describe alternatives you've considered
We could also consider using the
array
orgeneric
options for the lint rule if we want to stick to a single style at all times, no matter the complexity of the type.Additional context
Discussed in #1976
The text was updated successfully, but these errors were encountered: