@gitlab/eslint-plugin 20.4.1 → 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,17 @@
|
|
|
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
|
+
|
|
8
|
+
# [20.5.0](https://gitlab.com/gitlab-org/frontend/eslint-plugin/compare/v20.4.1...v20.5.0) (2024-10-29)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* make the package compatible with ESLint 9 ([350a8c1](https://gitlab.com/gitlab-org/frontend/eslint-plugin/commit/350a8c12abffae3072e6ad57b3ea918767906bc5))
|
|
14
|
+
|
|
1
15
|
## [20.4.1](https://gitlab.com/gitlab-org/frontend/eslint-plugin/compare/v20.4.0...v20.4.1) (2024-10-11)
|
|
2
16
|
|
|
3
17
|
|
|
@@ -18,7 +18,7 @@ module.exports = {
|
|
|
18
18
|
},
|
|
19
19
|
create(context) {
|
|
20
20
|
const vues = [];
|
|
21
|
-
const { getDocumentFragment } = context.parserServices;
|
|
21
|
+
const { getDocumentFragment } = context?.sourceCode?.parserServices ?? context.parserServices;
|
|
22
22
|
const documentFragment = getDocumentFragment ? getDocumentFragment() : null;
|
|
23
23
|
|
|
24
24
|
const hasTemplateTag = () =>
|
|
@@ -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/lib/utils/index.js
CHANGED
|
@@ -21,7 +21,9 @@ module.exports = {
|
|
|
21
21
|
* @returns {Object} The merged visitor.
|
|
22
22
|
*/
|
|
23
23
|
defineTemplateBodyVisitor(context, templateBodyVisitor, scriptVisitor) {
|
|
24
|
-
|
|
24
|
+
const parserServices = context.sourceCode?.parserServices ?? context.parserServices;
|
|
25
|
+
|
|
26
|
+
if (parserServices.defineTemplateBodyVisitor == null) {
|
|
25
27
|
context.report({
|
|
26
28
|
loc: { line: 1, column: 0 },
|
|
27
29
|
message:
|
|
@@ -29,6 +31,6 @@ module.exports = {
|
|
|
29
31
|
});
|
|
30
32
|
return {};
|
|
31
33
|
}
|
|
32
|
-
return
|
|
34
|
+
return parserServices.defineTemplateBodyVisitor(templateBodyVisitor, scriptVisitor);
|
|
33
35
|
},
|
|
34
36
|
};
|