summaryrefslogtreecommitdiff
path: root/runtime/queries/ecma/README.md
diff options
context:
space:
mode:
authorGammut2023-07-09 16:35:32 +0000
committerGitHub2023-07-09 16:35:32 +0000
commit607b426e269b17f4ad32dca9c612c4a9f8541766 (patch)
treef9e57fa45041c066bf2ea4ecca692986f66291c1 /runtime/queries/ecma/README.md
parent28452e1f2a63fe4806078da0f854d01506fc0c0c (diff)
Refactor queries for ecma based languages (#7207)
Diffstat (limited to 'runtime/queries/ecma/README.md')
-rw-r--r--runtime/queries/ecma/README.md14
1 files changed, 14 insertions, 0 deletions
diff --git a/runtime/queries/ecma/README.md b/runtime/queries/ecma/README.md
new file mode 100644
index 00000000..b891f24b
--- /dev/null
+++ b/runtime/queries/ecma/README.md
@@ -0,0 +1,14 @@
+# Inheritance model for ecma-based languages
+
+Ecma-based languages share many traits. Because of this we want to share as many queries as possible while avoiding nested inheritance that can make query behaviour unpredictable due to unexpected precedence.
+
+To achieve that, there are "public" and "private" versions for javascript, jsx, and typescript query files, that share the same name, but the "private" version name starts with an underscore (with the exception of ecma, that already exists as a sort of base "private" language). This allows the "private" versions to host the specific queries of the language excluding any `; inherits` statement, in order to make them safe to be inherited by the "public" version of the same language and other languages as well. The tsx language doesn't have a "private" version given that currently it doesn't need to be inherited by other languages.
+
+| Language | Inherits from |
+| ---------- | ----------------------- |
+| javascript | _javascript, ecma |
+| jsx | _jsx, _javascript, ecma |
+| typescript | _typescript, ecma |
+| tsx | _jsx, _typescript, ecma |
+
+If you intend to add queries to any of the ecma-based languages above, make sure you add them to the correct private language they belong to, so that other languages down the line can benefit from them.