@rushstack/eslint-config 3.6.9 → 3.7.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rushstack/eslint-config",
3
- "version": "3.6.9",
3
+ "version": "3.7.0",
4
4
  "description": "A TypeScript ESLint ruleset designed for large teams and projects",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -29,10 +29,10 @@
29
29
  "@typescript-eslint/typescript-estree": "~6.19.0",
30
30
  "eslint-plugin-promise": "~6.1.1",
31
31
  "eslint-plugin-react": "~7.33.2",
32
- "eslint-plugin-tsdoc": "~0.2.16",
33
- "@rushstack/eslint-patch": "1.10.2",
34
- "@rushstack/eslint-plugin-packlets": "0.9.1",
32
+ "eslint-plugin-tsdoc": "~0.3.0",
33
+ "@rushstack/eslint-patch": "1.10.3",
35
34
  "@rushstack/eslint-plugin": "0.15.1",
35
+ "@rushstack/eslint-plugin-packlets": "0.9.1",
36
36
  "@rushstack/eslint-plugin-security": "0.8.1"
37
37
  },
38
38
  "devDependencies": {
@@ -3,6 +3,161 @@
3
3
 
4
4
  const macros = require('./_macros');
5
5
 
6
+ const namingConventionRuleOptions = [
7
+ {
8
+ // We should be stricter about 'enumMember', but it often functions legitimately as an ad hoc namespace.
9
+ selectors: ['variable', 'enumMember', 'function'],
10
+
11
+ format: ['camelCase', 'UPPER_CASE', 'PascalCase'],
12
+ leadingUnderscore: 'allow',
13
+
14
+ filter: {
15
+ regex: [
16
+ // This is a special exception for naming patterns that use an underscore to separate two camel-cased
17
+ // parts. Example: "checkBox1_onChanged" or "_checkBox1_onChanged"
18
+ '^_?[a-z][a-z0-9]*([A-Z][a-z]?[a-z0-9]*)*_[a-z][a-z0-9]*([A-Z][a-z]?[a-z0-9]*)*$'
19
+ ]
20
+ .map((x) => `(${x})`)
21
+ .join('|'),
22
+ match: false
23
+ }
24
+ },
25
+
26
+ {
27
+ selectors: ['parameter'],
28
+
29
+ format: ['camelCase'],
30
+
31
+ filter: {
32
+ regex: [
33
+ // Silently accept names with a double-underscore prefix; we would like to be more strict about this,
34
+ // pending a fix for https://github.com/typescript-eslint/typescript-eslint/issues/2240
35
+ '^__'
36
+ ]
37
+ .map((x) => `(${x})`)
38
+ .join('|'),
39
+ match: false
40
+ }
41
+ },
42
+
43
+ // Genuine properties
44
+ {
45
+ selectors: ['parameterProperty', 'accessor'],
46
+ enforceLeadingUnderscoreWhenPrivate: true,
47
+
48
+ format: ['camelCase', 'UPPER_CASE'],
49
+
50
+ filter: {
51
+ regex: [
52
+ // Silently accept names with a double-underscore prefix; we would like to be more strict about this,
53
+ // pending a fix for https://github.com/typescript-eslint/typescript-eslint/issues/2240
54
+ '^__',
55
+ // Ignore quoted identifiers such as { "X+Y": 123 }. Currently @typescript-eslint/naming-convention
56
+ // cannot detect whether an identifier is quoted or not, so we simply assume that it is quoted
57
+ // if-and-only-if it contains characters that require quoting.
58
+ '[^a-zA-Z0-9_]',
59
+ // This is a special exception for naming patterns that use an underscore to separate two camel-cased
60
+ // parts. Example: "checkBox1_onChanged" or "_checkBox1_onChanged"
61
+ '^_?[a-z][a-z0-9]*([A-Z][a-z]?[a-z0-9]*)*_[a-z][a-z0-9]*([A-Z][a-z]?[a-z0-9]*)*$'
62
+ ]
63
+ .map((x) => `(${x})`)
64
+ .join('|'),
65
+ match: false
66
+ }
67
+ },
68
+
69
+ // Properties that incorrectly match other contexts
70
+ // See issue https://github.com/typescript-eslint/typescript-eslint/issues/2244
71
+ {
72
+ selectors: ['property'],
73
+ enforceLeadingUnderscoreWhenPrivate: true,
74
+
75
+ // The @typescript-eslint/naming-convention "property" selector matches cases like this:
76
+ //
77
+ // someLegacyApiWeCannotChange.invokeMethod({ SomeProperty: 123 });
78
+ //
79
+ // and this:
80
+ //
81
+ // const { CONSTANT1, CONSTANT2 } = someNamespace.constants;
82
+ //
83
+ // Thus for now "property" is more like a variable than a class member.
84
+ format: ['camelCase', 'UPPER_CASE', 'PascalCase'],
85
+ leadingUnderscore: 'allow',
86
+
87
+ filter: {
88
+ regex: [
89
+ // Silently accept names with a double-underscore prefix; we would like to be more strict about this,
90
+ // pending a fix for https://github.com/typescript-eslint/typescript-eslint/issues/2240
91
+ '^__',
92
+ // Ignore quoted identifiers such as { "X+Y": 123 }. Currently @typescript-eslint/naming-convention
93
+ // cannot detect whether an identifier is quoted or not, so we simply assume that it is quoted
94
+ // if-and-only-if it contains characters that require quoting.
95
+ '[^a-zA-Z0-9_]',
96
+ // This is a special exception for naming patterns that use an underscore to separate two camel-cased
97
+ // parts. Example: "checkBox1_onChanged" or "_checkBox1_onChanged"
98
+ '^_?[a-z][a-z0-9]*([A-Z][a-z]?[a-z0-9]*)*_[a-z][a-z0-9]*([A-Z][a-z]?[a-z0-9]*)*$'
99
+ ]
100
+ .map((x) => `(${x})`)
101
+ .join('|'),
102
+ match: false
103
+ }
104
+ },
105
+
106
+ {
107
+ selectors: ['method'],
108
+ enforceLeadingUnderscoreWhenPrivate: true,
109
+
110
+ // A PascalCase method can arise somewhat legitimately in this way:
111
+ //
112
+ // class MyClass {
113
+ // public static MyReactButton(props: IButtonProps): JSX.Element {
114
+ // . . .
115
+ // }
116
+ // }
117
+ format: ['camelCase', 'PascalCase'],
118
+ leadingUnderscore: 'allow',
119
+
120
+ filter: {
121
+ regex: [
122
+ // Silently accept names with a double-underscore prefix; we would like to be more strict about this,
123
+ // pending a fix for https://github.com/typescript-eslint/typescript-eslint/issues/2240
124
+ '^__',
125
+ // This is a special exception for naming patterns that use an underscore to separate two camel-cased
126
+ // parts. Example: "checkBox1_onChanged" or "_checkBox1_onChanged"
127
+ '^_?[a-z][a-z0-9]*([A-Z][a-z]?[a-z0-9]*)*_[a-z][a-z0-9]*([A-Z][a-z]?[a-z0-9]*)*$'
128
+ ]
129
+ .map((x) => `(${x})`)
130
+ .join('|'),
131
+ match: false
132
+ }
133
+ },
134
+
135
+ // Types should use PascalCase
136
+ {
137
+ // Group selector for: class, interface, typeAlias, enum, typeParameter
138
+ selectors: ['class', 'typeAlias', 'enum', 'typeParameter'],
139
+ format: ['PascalCase'],
140
+ leadingUnderscore: 'allow'
141
+ },
142
+
143
+ {
144
+ selectors: ['interface'],
145
+
146
+ // It is very common for a class to implement an interface of the same name.
147
+ // For example, the Widget class may implement the IWidget interface. The "I" prefix
148
+ // avoids the need to invent a separate name such as "AbstractWidget" or "WidgetInterface".
149
+ // In TypeScript it is also common to declare interfaces that are implemented by primitive
150
+ // objects, here the "I" prefix also helps by avoiding spurious conflicts with classes
151
+ // by the same name.
152
+ format: ['PascalCase'],
153
+
154
+ custom: {
155
+ regex: '^_?I[A-Z]',
156
+ match: true
157
+ }
158
+ }
159
+ ];
160
+
6
161
  // Rule severity guidelines
7
162
  // ------------------------
8
163
  //
@@ -207,160 +362,7 @@ function buildRules(profile) {
207
362
  // Docs: https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/naming-convention.md
208
363
  '@typescript-eslint/naming-convention': [
209
364
  'warn',
210
- ...macros.expandNamingConventionSelectors([
211
- {
212
- // We should be stricter about 'enumMember', but it often functions legitimately as an ad hoc namespace.
213
- selectors: ['variable', 'enumMember', 'function'],
214
-
215
- format: ['camelCase', 'UPPER_CASE', 'PascalCase'],
216
- leadingUnderscore: 'allow',
217
-
218
- filter: {
219
- regex: [
220
- // This is a special exception for naming patterns that use an underscore to separate two camel-cased
221
- // parts. Example: "checkBox1_onChanged" or "_checkBox1_onChanged"
222
- '^_?[a-z][a-z0-9]*([A-Z][a-z]?[a-z0-9]*)*_[a-z][a-z0-9]*([A-Z][a-z]?[a-z0-9]*)*$'
223
- ]
224
- .map((x) => `(${x})`)
225
- .join('|'),
226
- match: false
227
- }
228
- },
229
-
230
- {
231
- selectors: ['parameter'],
232
-
233
- format: ['camelCase'],
234
-
235
- filter: {
236
- regex: [
237
- // Silently accept names with a double-underscore prefix; we would like to be more strict about this,
238
- // pending a fix for https://github.com/typescript-eslint/typescript-eslint/issues/2240
239
- '^__'
240
- ]
241
- .map((x) => `(${x})`)
242
- .join('|'),
243
- match: false
244
- }
245
- },
246
-
247
- // Genuine properties
248
- {
249
- selectors: ['parameterProperty', 'accessor'],
250
- enforceLeadingUnderscoreWhenPrivate: true,
251
-
252
- format: ['camelCase', 'UPPER_CASE'],
253
-
254
- filter: {
255
- regex: [
256
- // Silently accept names with a double-underscore prefix; we would like to be more strict about this,
257
- // pending a fix for https://github.com/typescript-eslint/typescript-eslint/issues/2240
258
- '^__',
259
- // Ignore quoted identifiers such as { "X+Y": 123 }. Currently @typescript-eslint/naming-convention
260
- // cannot detect whether an identifier is quoted or not, so we simply assume that it is quoted
261
- // if-and-only-if it contains characters that require quoting.
262
- '[^a-zA-Z0-9_]',
263
- // This is a special exception for naming patterns that use an underscore to separate two camel-cased
264
- // parts. Example: "checkBox1_onChanged" or "_checkBox1_onChanged"
265
- '^_?[a-z][a-z0-9]*([A-Z][a-z]?[a-z0-9]*)*_[a-z][a-z0-9]*([A-Z][a-z]?[a-z0-9]*)*$'
266
- ]
267
- .map((x) => `(${x})`)
268
- .join('|'),
269
- match: false
270
- }
271
- },
272
-
273
- // Properties that incorrectly match other contexts
274
- // See issue https://github.com/typescript-eslint/typescript-eslint/issues/2244
275
- {
276
- selectors: ['property'],
277
- enforceLeadingUnderscoreWhenPrivate: true,
278
-
279
- // The @typescript-eslint/naming-convention "property" selector matches cases like this:
280
- //
281
- // someLegacyApiWeCannotChange.invokeMethod({ SomeProperty: 123 });
282
- //
283
- // and this:
284
- //
285
- // const { CONSTANT1, CONSTANT2 } = someNamespace.constants;
286
- //
287
- // Thus for now "property" is more like a variable than a class member.
288
- format: ['camelCase', 'UPPER_CASE', 'PascalCase'],
289
- leadingUnderscore: 'allow',
290
-
291
- filter: {
292
- regex: [
293
- // Silently accept names with a double-underscore prefix; we would like to be more strict about this,
294
- // pending a fix for https://github.com/typescript-eslint/typescript-eslint/issues/2240
295
- '^__',
296
- // Ignore quoted identifiers such as { "X+Y": 123 }. Currently @typescript-eslint/naming-convention
297
- // cannot detect whether an identifier is quoted or not, so we simply assume that it is quoted
298
- // if-and-only-if it contains characters that require quoting.
299
- '[^a-zA-Z0-9_]',
300
- // This is a special exception for naming patterns that use an underscore to separate two camel-cased
301
- // parts. Example: "checkBox1_onChanged" or "_checkBox1_onChanged"
302
- '^_?[a-z][a-z0-9]*([A-Z][a-z]?[a-z0-9]*)*_[a-z][a-z0-9]*([A-Z][a-z]?[a-z0-9]*)*$'
303
- ]
304
- .map((x) => `(${x})`)
305
- .join('|'),
306
- match: false
307
- }
308
- },
309
-
310
- {
311
- selectors: ['method'],
312
- enforceLeadingUnderscoreWhenPrivate: true,
313
-
314
- // A PascalCase method can arise somewhat legitimately in this way:
315
- //
316
- // class MyClass {
317
- // public static MyReactButton(props: IButtonProps): JSX.Element {
318
- // . . .
319
- // }
320
- // }
321
- format: ['camelCase', 'PascalCase'],
322
- leadingUnderscore: 'allow',
323
-
324
- filter: {
325
- regex: [
326
- // Silently accept names with a double-underscore prefix; we would like to be more strict about this,
327
- // pending a fix for https://github.com/typescript-eslint/typescript-eslint/issues/2240
328
- '^__',
329
- // This is a special exception for naming patterns that use an underscore to separate two camel-cased
330
- // parts. Example: "checkBox1_onChanged" or "_checkBox1_onChanged"
331
- '^_?[a-z][a-z0-9]*([A-Z][a-z]?[a-z0-9]*)*_[a-z][a-z0-9]*([A-Z][a-z]?[a-z0-9]*)*$'
332
- ]
333
- .map((x) => `(${x})`)
334
- .join('|'),
335
- match: false
336
- }
337
- },
338
-
339
- // Types should use PascalCase
340
- {
341
- // Group selector for: class, interface, typeAlias, enum, typeParameter
342
- selectors: ['class', 'typeAlias', 'enum', 'typeParameter'],
343
- format: ['PascalCase'],
344
- leadingUnderscore: 'allow'
345
- },
346
-
347
- {
348
- selectors: ['interface'],
349
-
350
- // It is very common for a class to implement an interface of the same name.
351
- // For example, the Widget class may implement the IWidget interface. The "I" prefix
352
- // avoids the need to invent a separate name such as "AbstractWidget" or "WidgetInterface".
353
- // In TypeScript it is also common to declare interfaces that are implemented by primitive
354
- // objects, here the "I" prefix also helps by avoiding spurious conflicts with classes
355
- // by the same name.
356
- format: ['PascalCase'],
357
-
358
- custom: {
359
- regex: '^_?I[A-Z]',
360
- match: true
361
- }
362
- }
363
- ])
365
+ ...macros.expandNamingConventionSelectors(namingConventionRuleOptions)
364
366
  ],
365
367
 
366
368
  // STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
@@ -834,4 +836,6 @@ function buildRules(profile) {
834
836
  ]
835
837
  };
836
838
  }
839
+
837
840
  exports.buildRules = buildRules;
841
+ exports.namingConventionRuleOptions = namingConventionRuleOptions;
@@ -86,7 +86,7 @@ function expandNamingConventionSelectors(inputBlocks) {
86
86
 
87
87
  const expandedBlock2 = {
88
88
  ...block,
89
- modifiers: ['private'],
89
+ modifiers: [...(block.modifiers ?? []), 'private'],
90
90
  leadingUnderscore: 'require'
91
91
  };
92
92
  delete expandedBlock2.enforceLeadingUnderscoreWhenPrivate;