@testgorilla/tgo-linting 1.0.2 → 1.0.3
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/package.json
CHANGED
|
@@ -1,25 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const DEFAULT_TAGS = [
|
|
4
|
-
'button',
|
|
5
|
-
'mat-checkbox',
|
|
6
4
|
'input',
|
|
7
|
-
'mat-radio-button',
|
|
8
|
-
'mat-radio-group',
|
|
9
|
-
'h1',
|
|
10
5
|
'table',
|
|
11
6
|
'header-table',
|
|
12
7
|
'mat-table',
|
|
13
|
-
'img',
|
|
14
|
-
'textarea',
|
|
15
|
-
'ng-select',
|
|
16
8
|
'video',
|
|
17
9
|
'app-tgo-choice',
|
|
18
10
|
'testgorilla-confirm-dialog',
|
|
19
|
-
'mat-form-field',
|
|
20
11
|
'tgo-checkout-message',
|
|
21
12
|
'mat-dialog-actions',
|
|
22
|
-
'ui-button',
|
|
23
13
|
];
|
|
24
14
|
const rule = {
|
|
25
15
|
meta: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"require-data-testid.js","sourceRoot":"","sources":["../../../../../packages/tgo-linting/src/rules/require-data-testid.ts"],"names":[],"mappings":";;AAUA,MAAM,YAAY,GAAG;IACnB,
|
|
1
|
+
{"version":3,"file":"require-data-testid.js","sourceRoot":"","sources":["../../../../../packages/tgo-linting/src/rules/require-data-testid.ts"],"names":[],"mappings":";;AAUA,MAAM,YAAY,GAAG;IACnB,OAAO;IACP,OAAO;IACP,cAAc;IACd,WAAW;IACX,OAAO;IACP,gBAAgB;IAChB,4BAA4B;IAC5B,sBAAsB;IACtB,oBAAoB;CACrB,CAAA;AAED,MAAM,IAAI,GAA6C;IACrD,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE;YACJ,WAAW,EAAE,sDAAsD;SACpE;QACD,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AAA;IACH,CAAC;CACF,CAAA;AAED,kBAAe,IAAI,CAAA","sourcesContent":["import { TSESLint, TSESTree } from '@typescript-eslint/utils'\n\ntype Options = [\n {\n tags?: string[]\n }?\n]\n\ntype MessageIds = 'missingTestId'\n\nconst DEFAULT_TAGS = [\n 'input',\n 'table',\n 'header-table',\n 'mat-table',\n 'video',\n 'app-tgo-choice',\n 'testgorilla-confirm-dialog',\n 'tgo-checkout-message',\n 'mat-dialog-actions',\n]\n\nconst rule: TSESLint.RuleModule<MessageIds, Options> = {\n meta: {\n type: 'suggestion',\n docs: {\n description: 'Ensures specific elements have data-testid attribute',\n },\n schema: [\n {\n type: 'object',\n properties: {\n tags: {\n type: 'array',\n items: { type: 'string' },\n uniqueItems: true,\n },\n },\n additionalProperties: false,\n },\n ],\n messages: {\n missingTestId: \"<{{tag}}> must have 'data-testid' attribute\",\n },\n },\n\n create(context) {\n const configuration = context.options[0] ?? {}\n const tagsToCheck = configuration.tags ?? DEFAULT_TAGS\n\n return {\n Element(node: TSESLint.RuleListener['Element'] & { name: string; attributes?: Array<{ name: string }>; inputs?: Array<{ name: string }> }) {\n if (!tagsToCheck.includes(node.name)) {\n return\n }\n\n const hasTestId =\n node.attributes?.some((attr) => attr.name === 'data-testid') ||\n node.inputs?.some((attr) => attr.name === 'data-testid') ||\n node.inputs?.some((attr) => attr.name === 'attr.data-testid')\n\n if (!hasTestId) {\n context.report({\n node: node as unknown as TSESTree.Node,\n messageId: 'missingTestId',\n data: {\n tag: node.name,\n },\n })\n }\n },\n }\n },\n}\n\nexport default rule\n"]}
|