@gitlab/eslint-plugin 20.5.0 → 20.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # [20.6.0](https://gitlab.com/gitlab-org/frontend/eslint-plugin/compare/v20.5.0...v20.6.0) (2024-11-11)
2
+
3
+
4
+ ### Features
5
+
6
+ * **i18n:** Ignore typenames in rule ([07c67d8](https://gitlab.com/gitlab-org/frontend/eslint-plugin/commit/07c67d8ef85594bcb2ba18fbe92749548fc6a0e7))
7
+
1
8
  # [20.5.0](https://gitlab.com/gitlab-org/frontend/eslint-plugin/compare/v20.4.1...v20.5.0) (2024-10-29)
2
9
 
3
10
 
@@ -192,6 +192,25 @@ module.exports = {
192
192
  return node.callee && node.callee.name === 'RegExp';
193
193
  }
194
194
 
195
+ /**
196
+ *
197
+ * In Objects like { __typename: 'Foobar' } for GraphQL mutations /
198
+ * optimistic responses, etc. We don't need to translate the type name.
199
+ *
200
+ * @param node
201
+ * @returns {boolean}
202
+ */
203
+ function isGraphQLTypeName(node) {
204
+ // For object definitions
205
+ if (node.parent?.type === 'Property') {
206
+ return node.parent?.key?.name === '__typename';
207
+ }
208
+ return (
209
+ node.parent?.left?.type === 'MemberExpression' &&
210
+ node.parent?.left?.property?.name === '__typename'
211
+ );
212
+ }
213
+
195
214
  function canSkipLiteral(node) {
196
215
  return (
197
216
  isNewRegExp(node.parent) ||
@@ -199,6 +218,7 @@ module.exports = {
199
218
  (node.parent.left && isHtmlProperty(node.parent.left)) ||
200
219
  (node.parent.id && isHtmlProperty(node.parent.id)) ||
201
220
  (node.parent.key && isHtmlProperty(node.parent.key)) ||
221
+ isGraphQLTypeName(node) ||
202
222
  isTrueConstant(node.parent.parent, node.parent) ||
203
223
  isKeyList(node.parent.parent, node.parent) ||
204
224
  isMemberExpressionIdentifier(node.parent)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/eslint-plugin",
3
- "version": "20.5.0",
3
+ "version": "20.6.0",
4
4
  "description": "GitLab package for our custom eslint rules",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {