@testgorilla/tgo-linting 4.0.0 → 5.0.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.
Files changed (2) hide show
  1. package/Readme.md +47 -64
  2. package/package.json +6 -6
package/Readme.md CHANGED
@@ -8,11 +8,34 @@ Linting rules and code quality standards for TestGorilla projects.
8
8
  npm install @testgorilla/tgo-linting @angular-eslint/template-parser --save-dev
9
9
  ```
10
10
 
11
+ ## Compatibility
12
+
13
+ | tgo-linting | ESLint | angular-eslint | Angular |
14
+ | ----------- | --------------------- | -------------- | ------------------------------------------------ |
15
+ | 5.x | `^9.0.0 \|\| ^10.0.0` | 21.x | any (angular-eslint 21 bundles its own compiler) |
16
+ | 4.x | `^8.57.0 \|\| ^9.0.0` | 20.x | any |
17
+
18
+ > **ESLint 9 consumers:** the bundled `eslint-plugin-rxjs-x@1.0.2` declares an
19
+ > `eslint: ^10` peer dependency (no release of that plugin supports ESLint 9 and 10
20
+ > simultaneously). Until your repo moves to ESLint 10, keep this override in your
21
+ > `package.json` so `npm install` resolves cleanly:
22
+ >
23
+ > ```json
24
+ > "overrides": {
25
+ > "eslint-plugin-rxjs-x": {
26
+ > "eslint": "$eslint"
27
+ > }
28
+ > }
29
+ > ```
30
+ >
31
+ > Consumers on ESLint 10 do not need the override.
32
+
11
33
  ## Usage
12
34
 
13
- This package supports both modern flat config (ESLint 9+) and legacy config formats (ESLint 8.x and below).
35
+ This package requires ESLint flat config (`eslint.config.js`/`.mjs`) and ESLint 9 or 10.
36
+ Support for legacy `.eslintrc.*` configs and ESLint 8 was removed in 5.0.0.
14
37
 
15
- ### Flat Config (ESLint 9+)
38
+ ### Flat Config
16
39
 
17
40
  **Recommended approach:**
18
41
 
@@ -44,51 +67,6 @@ export default [
44
67
  ];
45
68
  ```
46
69
 
47
- ### Legacy Config (ESLint 8.x and below)
48
-
49
- **Using the legacy preset:**
50
-
51
- ```javascript
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
- ```
70
-
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', // Example rule configuration
86
- },
87
- },
88
- ],
89
- };
90
- ```
91
-
92
70
  ## Important Notes
93
71
 
94
72
  - **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.
@@ -98,8 +76,8 @@ module.exports = {
98
76
 
99
77
  ### Available Rules
100
78
 
101
- | Rule | Description |
102
- |------|-------------|
79
+ | Rule | Description |
80
+ | ------------------------- | ----------------------------------------------------------------------------- |
103
81
  | `tgo/require-data-testid` | Ensures specific HTML elements have a `data-testid` attribute for E2E testing |
104
82
 
105
83
  ### Rule Documentation
@@ -113,10 +91,11 @@ Detailed documentation for each rule, including examples and configuration optio
113
91
  To add a new ESLint rule to this package:
114
92
 
115
93
  1. **Create the rule file** in `src/rules/`:
94
+
116
95
  ```typescript
117
96
  // src/rules/your-rule-name.ts
118
- import { Rule } from 'eslint'
119
-
97
+ import { Rule } from 'eslint';
98
+
120
99
  const rule: Rule.RuleModule = {
121
100
  meta: {
122
101
  type: 'problem', // or 'suggestion' or 'layout'
@@ -134,22 +113,23 @@ To add a new ESLint rule to this package:
134
113
  // Your rule implementation
135
114
  return {
136
115
  // AST node visitors
137
- }
116
+ };
138
117
  },
139
- }
140
-
141
- export default rule
118
+ };
119
+
120
+ export default rule;
142
121
  ```
143
122
 
144
123
  2. **Add tests** in `src/rules/your-rule-name.spec.ts`:
124
+
145
125
  ```typescript
146
- import { RuleTester } from '@typescript-eslint/rule-tester'
147
- import rule from './your-rule-name'
148
-
126
+ import { RuleTester } from '@typescript-eslint/rule-tester';
127
+ import rule from './your-rule-name';
128
+
149
129
  const ruleTester = new RuleTester({
150
130
  parser: '@angular-eslint/template-parser',
151
- })
152
-
131
+ });
132
+
153
133
  ruleTester.run('your-rule-name', rule, {
154
134
  valid: [
155
135
  // Test cases that should pass
@@ -157,20 +137,22 @@ To add a new ESLint rule to this package:
157
137
  invalid: [
158
138
  // Test cases that should fail
159
139
  ],
160
- })
140
+ });
161
141
  ```
162
142
 
163
143
  3. **Export the rule** in `src/rules/index.ts`:
144
+
164
145
  ```typescript
165
- import yourRuleName from './your-rule-name'
166
-
146
+ import yourRuleName from './your-rule-name';
147
+
167
148
  export const rules = {
168
149
  'require-data-testid': requireDataTestId,
169
150
  'your-rule-name': yourRuleName,
170
- }
151
+ };
171
152
  ```
172
153
 
173
154
  4. **Add to recommended config** (optional) in `src/configs/recommended.ts`:
155
+
174
156
  ```typescript
175
157
  rules: {
176
158
  'tgo/require-data-testid': 'warn',
@@ -179,6 +161,7 @@ To add a new ESLint rule to this package:
179
161
  ```
180
162
 
181
163
  5. **Document the rule** in `src/rules/your-rule-name.md`:
164
+
182
165
  - Describe what the rule does
183
166
  - Provide configuration options
184
167
  - Show correct and incorrect code examples
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testgorilla/tgo-linting",
3
- "version": "4.0.0",
3
+ "version": "5.0.0",
4
4
  "displayName": "TGO Linting",
5
5
  "description": "Linting rules and code quality standards for TestGorilla projects",
6
6
  "author": "TestGorilla",
@@ -24,13 +24,13 @@
24
24
  "registry": "https://registry.npmjs.org/"
25
25
  },
26
26
  "dependencies": {
27
- "@angular-eslint/eslint-plugin": "^20.7.0",
28
- "@angular-eslint/eslint-plugin-template": "^20.7.0",
29
- "@angular-eslint/template-parser": "^20.7.0",
27
+ "@angular-eslint/eslint-plugin": "^21.4.0",
28
+ "@angular-eslint/eslint-plugin-template": "^21.4.0",
29
+ "@angular-eslint/template-parser": "^21.4.0",
30
30
  "@typescript-eslint/utils": "^8.56.1",
31
31
  "eslint-config-prettier": "10.1.8",
32
32
  "eslint-import-resolver-typescript": "4.4.4",
33
- "eslint-plugin-import-x": "4.16.1",
33
+ "eslint-plugin-import-x": "4.16.2",
34
34
  "eslint-plugin-jsdoc": "62.7.1",
35
35
  "eslint-plugin-no-unsanitized": "4.1.5",
36
36
  "eslint-plugin-rxjs-x": "1.0.2",
@@ -38,7 +38,7 @@
38
38
  "typescript-eslint": "8.56.1"
39
39
  },
40
40
  "peerDependencies": {
41
- "eslint": "^8.57.0 || ^9.0.0",
41
+ "eslint": "^9.0.0 || ^10.0.0",
42
42
  "typescript": ">=4.8.4 <6.0.0",
43
43
  "tslib": "^2.0.0"
44
44
  },