Fred Tingaud 16f6c0aecf
Inline adoc when include has no additional value (#1940)
Inline adoc files when they are included exactly once.

Also fix language tags because this inlining gives us better information
on what language the code is written in.
2023-05-25 14:18:12 +02:00

48 lines
963 B
Plaintext

== Why is this an issue?
Destructuring is a convenient way of extracting multiple values from data stored in (possibly nested) objects and arrays. However, it is possible to create an empty pattern that has no effect. When empty curly braces or brackets are used to the right of a property name most of the time the intent was to use a default value instead.
This rule raises an issue when empty destructuring pattern is used.
=== Noncompliant code example
[source,javascript]
----
var {a: {}, b} = myObj; // Noncompliant
function foo({first: [], second}) { // Noncompliant
// ...
}
----
=== Compliant solution
[source,javascript]
----
var {a = {}, b} = myObj;
function foo({first = [], second}) {
// ...
}
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Change this pattern to not be empty.
=== Highlighting
empty destructuring pattern
endif::env-github,rspecator-view[]