@testgorilla/tgo-linting 1.0.0 → 1.0.1

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/Readme.md CHANGED
@@ -5,16 +5,31 @@ Linting rules and code quality standards for TestGorilla projects.
5
5
  ## Installation
6
6
 
7
7
  ```bash
8
- npm install @testgorilla/tgo-linting --save-dev
8
+ npm install @testgorilla/tgo-linting @angular-eslint/template-parser --save-dev
9
9
  ```
10
10
 
11
11
  ## Usage
12
12
 
13
- Add the plugin to your ESLint configuration:
13
+ This package supports both modern flat config (ESLint 9+) and legacy config formats (ESLint 8.x and below).
14
14
 
15
15
  ### Flat Config (ESLint 9+)
16
16
 
17
+ **Recommended approach:**
18
+
17
19
  ```javascript
20
+ // eslint.config.js
21
+ import tgoPlugin from '@testgorilla/tgo-linting';
22
+
23
+ export default [
24
+ tgoPlugin.configs.recommended,
25
+ // Your other configurations
26
+ ];
27
+ ```
28
+
29
+ **Manual configuration:**
30
+
31
+ ```javascript
32
+ // eslint.config.js
18
33
  import tgoPlugin from '@testgorilla/tgo-linting';
19
34
 
20
35
  export default [
@@ -29,24 +44,65 @@ export default [
29
44
  ];
30
45
  ```
31
46
 
32
- ### Or use the recommended configuration:
47
+ ### Legacy Config (ESLint 8.x and below)
48
+
49
+ **Using the legacy preset:**
33
50
 
34
51
  ```javascript
35
- import tgoPlugin from '@testgorilla/tgo-linting';
52
+ // .eslintrc.js
53
+ const { legacy } = require('@testgorilla/tgo-linting');
54
+
55
+ module.exports = {
56
+ // Your base config
57
+ extends: [
58
+ // Your other extends
59
+ ],
60
+ plugins: ['tgo'],
61
+ overrides: [
62
+ {
63
+ files: ['*.html'],
64
+ parser: '@angular-eslint/template-parser',
65
+ ...legacy,
66
+ },
67
+ ],
68
+ };
69
+ ```
36
70
 
37
- export default [
38
- tgoPlugin.configs.recommended,
39
- // Your other configurations
40
- ];
71
+ **Manual configuration:**
72
+
73
+ ```javascript
74
+ // .eslintrc.js
75
+ module.exports = {
76
+ plugins: ['tgo'],
77
+ extends: [
78
+ // Your other extends
79
+ ],
80
+ overrides: [
81
+ {
82
+ files: ['*.html'],
83
+ parser: '@angular-eslint/template-parser',
84
+ rules: {
85
+ 'tgo/require-data-testid': 'warn',
86
+ },
87
+ },
88
+ ],
89
+ };
41
90
  ```
42
91
 
92
+ ## Important Notes
93
+
94
+ - **Template Parser Required:** The `tgo/require-data-testid` rule only works with HTML/Angular templates. You must configure `@angular-eslint/template-parser` for `.html` files.
95
+ - **Angular Projects:** If you're using `@angular-eslint`, the template parser is usually already configured for HTML files in your overrides.
96
+
43
97
  ## Rules
44
98
 
45
99
  ### `tgo/require-data-testid`
46
100
 
47
- Ensures that specific HTML elements have a `data-testid` attribute for testing purposes.
101
+ Ensures that specific HTML elements have a `data-testid` attribute for testing purposes. This makes it easier to write stable E2E tests by providing consistent selectors.
102
+
103
+ **Severity:** `warn` (in recommended config)
48
104
 
49
- **Note:** This rule requires an ESLint setup that parses template ASTs (e.g., `@angular-eslint/template-parser` for Angular projects). It will not run against plain JS/TS ASTs.
105
+ **Category:** Testing Best Practices
50
106
 
51
107
  #### Default Elements
52
108
 
package/package.json CHANGED
@@ -1,42 +1,40 @@
1
1
  {
2
2
  "name": "@testgorilla/tgo-linting",
3
- "version": "1.0.0",
4
- "description": "Linting rules and code quality standards for TestGorilla projects",
5
- "keywords": [
6
- "eslint",
7
- "eslintplugin",
8
- "eslint-plugin",
9
- "testgorilla",
10
- "angular",
11
- "testing",
12
- "linting",
13
- "code-quality",
14
- "accessibility"
15
- ],
16
- "author": "TestGorilla",
17
- "license": "PROPRIETARY",
18
- "main": "./src/index.js",
19
- "types": "./src/index.d.ts",
20
- "files": [
21
- "**/*"
22
- ],
23
- "sideEffects": false,
24
- "private": false,
25
- "publishConfig": {
26
- "access": "public",
27
- "registry": "https://registry.npmjs.org/"
28
- },
3
+ "version": "1.0.1",
29
4
  "peerDependencies": {
5
+ "@angular-eslint/template-parser": ">= 17.0.0 < 20.0.0",
30
6
  "eslint": "^8 || ^9",
31
7
  "tslib": "^2.0.0"
32
8
  },
33
9
  "dependencies": {
34
10
  "@typescript-eslint/utils": "^8.54.0"
35
11
  },
12
+ "sideEffects": false,
13
+ "private": false,
14
+ "license": "PROPRIETARY",
15
+ "publishConfig": {
16
+ "access": "public",
17
+ "registry": "https://registry.npmjs.org/"
18
+ },
36
19
  "displayName": "TGO Linting",
37
- "repository": {
38
- "type": "git",
39
- "url": "https://github.com/testgorilla/tgo-fe-libraries"
20
+ "description": "Linting rules and code quality standards for TestGorilla projects",
21
+ "author": "TestGorilla",
22
+ "main": "./src/index.js",
23
+ "types": "./src/index.d.ts",
24
+ "exports": {
25
+ ".": {
26
+ "import": "./src/index.js",
27
+ "require": "./src/index.js",
28
+ "types": "./src/index.d.ts"
29
+ },
30
+ "./legacy": {
31
+ "import": "./src/configs/legacy.js",
32
+ "require": "./src/configs/legacy.js",
33
+ "types": "./src/configs/legacy.d.ts"
34
+ }
40
35
  },
36
+ "files": [
37
+ "**/*"
38
+ ],
41
39
  "type": "commonjs"
42
40
  }
@@ -0,0 +1,7 @@
1
+ declare const _default: {
2
+ plugins: string[];
3
+ rules: {
4
+ 'tgo/require-data-testid': string;
5
+ };
6
+ };
7
+ export default _default;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = {
4
+ plugins: ['tgo'],
5
+ rules: {
6
+ 'tgo/require-data-testid': 'warn',
7
+ },
8
+ };
9
+ //# sourceMappingURL=legacy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"legacy.js","sourceRoot":"","sources":["../../../../../packages/tgo-linting/src/configs/legacy.ts"],"names":[],"mappings":";;AAAA,kBAAe;IACb,OAAO,EAAE,CAAC,KAAK,CAAC;IAChB,KAAK,EAAE;QACL,yBAAyB,EAAE,MAAM;KAClC;CACF,CAAA","sourcesContent":["export default {\n plugins: ['tgo'],\n rules: {\n 'tgo/require-data-testid': 'warn',\n },\n}\n"]}
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = {
4
4
  plugins: ['tgo'],
5
5
  rules: {
6
- 'tgo/require-data-testid': 'error',
6
+ 'tgo/require-data-testid': 'warn',
7
7
  },
8
8
  };
9
9
  //# sourceMappingURL=recommended.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"recommended.js","sourceRoot":"","sources":["../../../../../packages/tgo-linting/src/configs/recommended.ts"],"names":[],"mappings":";;AAAA,kBAAe;IACb,OAAO,EAAE,CAAC,KAAK,CAAC;IAChB,KAAK,EAAE;QACL,yBAAyB,EAAE,OAAO;KACnC;CACF,CAAA","sourcesContent":["export default {\n plugins: ['tgo'],\n rules: {\n 'tgo/require-data-testid': 'error',\n },\n}"]}
1
+ {"version":3,"file":"recommended.js","sourceRoot":"","sources":["../../../../../packages/tgo-linting/src/configs/recommended.ts"],"names":[],"mappings":";;AAAA,kBAAe;IACb,OAAO,EAAE,CAAC,KAAK,CAAC;IAChB,KAAK,EAAE;QACL,yBAAyB,EAAE,MAAM;KAClC;CACF,CAAA","sourcesContent":["export default {\n plugins: ['tgo'],\n rules: {\n 'tgo/require-data-testid': 'warn',\n },\n}"]}
package/src/index.d.ts CHANGED
@@ -1,4 +1,11 @@
1
- declare const _default: {
1
+ import { rules } from './rules';
2
+ import recommended from './configs/recommended';
3
+ import legacy from './configs/legacy';
4
+ declare const plugin: {
5
+ meta: {
6
+ name: string;
7
+ version: string;
8
+ };
2
9
  rules: {
3
10
  'require-data-testid': import("@typescript-eslint/utils/dist/ts-eslint").RuleModule<"missingTestId", [{
4
11
  tags?: string[];
@@ -13,4 +20,5 @@ declare const _default: {
13
20
  };
14
21
  };
15
22
  };
16
- export = _default;
23
+ export default plugin;
24
+ export { rules, recommended, legacy };
package/src/index.js CHANGED
@@ -1,10 +1,22 @@
1
1
  "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.legacy = exports.recommended = exports.rules = void 0;
2
4
  const rules_1 = require("./rules");
5
+ Object.defineProperty(exports, "rules", { enumerable: true, get: function () { return rules_1.rules; } });
3
6
  const recommended_1 = require("./configs/recommended");
4
- module.exports = {
7
+ exports.recommended = recommended_1.default;
8
+ const legacy_1 = require("./configs/legacy");
9
+ exports.legacy = legacy_1.default;
10
+ const plugin = {
11
+ meta: {
12
+ name: '@testgorilla/tgo-linting',
13
+ version: '1.0.0',
14
+ },
5
15
  rules: rules_1.rules,
6
16
  configs: {
7
17
  recommended: recommended_1.default,
8
18
  },
9
19
  };
20
+ // Default export for ESM and CommonJS compatibility
21
+ exports.default = plugin;
10
22
  //# sourceMappingURL=index.js.map
package/src/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/tgo-linting/src/index.ts"],"names":[],"mappings":";AAAA,mCAA+B;AAC/B,uDAA+C;AAE/C,iBAAS;IACP,KAAK,EAAL,aAAK;IACL,OAAO,EAAE;QACP,WAAW,EAAX,qBAAW;KACZ;CACF,CAAA","sourcesContent":["import { rules } from './rules'\nimport recommended from './configs/recommended'\n\nexport = {\n rules,\n configs: {\n recommended,\n },\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/tgo-linting/src/index.ts"],"names":[],"mappings":";;;AAAA,mCAA+B;AAmBtB,sFAnBA,aAAK,OAmBA;AAlBd,uDAA+C;AAkB/B,sBAlBT,qBAAW,CAkBS;AAjB3B,6CAAqC;AAiBR,iBAjBtB,gBAAM,CAiBsB;AAfnC,MAAM,MAAM,GAAG;IACb,IAAI,EAAE;QACJ,IAAI,EAAE,0BAA0B;QAChC,OAAO,EAAE,OAAO;KACjB;IACD,KAAK,EAAL,aAAK;IACL,OAAO,EAAE;QACP,WAAW,EAAX,qBAAW;KACZ;CACF,CAAA;AAED,oDAAoD;AACpD,kBAAe,MAAM,CAAA","sourcesContent":["import { rules } from './rules'\nimport recommended from './configs/recommended'\nimport legacy from './configs/legacy'\n\nconst plugin = {\n meta: {\n name: '@testgorilla/tgo-linting',\n version: '1.0.0',\n },\n rules,\n configs: {\n recommended,\n },\n}\n\n// Default export for ESM and CommonJS compatibility\nexport default plugin\n\n// Named exports for specific use cases\nexport { rules, recommended, legacy }\n"]}