@typescript-eslint/eslint-plugin 8.64.1-alpha.9 → 8.65.1-alpha.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.
@@ -1,5 +1,5 @@
1
1
  import type { TSESLint } from '@typescript-eslint/utils';
2
- export type MessageIds = 'noShadow' | 'noShadowGlobal';
2
+ export type MessageIds = 'noEnumShadow' | 'noShadow' | 'noShadowGlobal';
3
3
  export type Options = [
4
4
  {
5
5
  allow?: string[];
@@ -27,6 +27,7 @@ exports.default = (0, util_1.createRule)({
27
27
  extendsBaseRule: true,
28
28
  },
29
29
  messages: {
30
+ noEnumShadow: "Enum members are added to the enum scope, so references to '{{name}}' in enum member initializers resolve to this member instead of the declaration in the upper scope on line {{shadowedLine}} column {{shadowedColumn}}.",
30
31
  noShadow: "'{{name}}' is already declared in the upper scope on line {{shadowedLine}} column {{shadowedColumn}}.",
31
32
  noShadowGlobal: "'{{name}}' is already a global variable.",
32
33
  },
@@ -513,6 +514,7 @@ exports.default = (0, util_1.createRule)({
513
514
  isInitPatternNode(variable, shadowed)) &&
514
515
  !(options.hoist !== 'all' && isInTdz(variable, shadowed))) {
515
516
  const location = getDeclaredLocation(shadowed);
517
+ const isEnumDeclaration = shadowed.defs.some(def => def.type === scope_manager_1.DefinitionType.TSEnumName);
516
518
  context.report({
517
519
  node: variable.identifiers[0],
518
520
  ...(location.global
@@ -523,7 +525,7 @@ exports.default = (0, util_1.createRule)({
523
525
  },
524
526
  }
525
527
  : {
526
- messageId: 'noShadow',
528
+ messageId: isEnumDeclaration ? 'noEnumShadow' : 'noShadow',
527
529
  data: {
528
530
  name: variable.name,
529
531
  shadowedColumn: location.column,
@@ -27,7 +27,7 @@ exports.default = (0, util_1.createRule)({
27
27
  if (!isThisMemberExpression(node)) {
28
28
  return null;
29
29
  }
30
- if (node.property.type === utils_1.AST_NODE_TYPES.Identifier) {
30
+ if (!node.computed && node.property.type === utils_1.AST_NODE_TYPES.Identifier) {
31
31
  return node.property.name;
32
32
  }
33
33
  if (node.computed) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typescript-eslint/eslint-plugin",
3
- "version": "8.64.1-alpha.9",
3
+ "version": "8.65.1-alpha.0",
4
4
  "description": "TypeScript plugin for ESLint",
5
5
  "files": [
6
6
  "dist",
@@ -49,10 +49,10 @@
49
49
  "ignore": "^7.0.5",
50
50
  "natural-compare": "^1.4.0",
51
51
  "ts-api-utils": "^2.5.0",
52
- "@typescript-eslint/scope-manager": "8.64.1-alpha.9",
53
- "@typescript-eslint/visitor-keys": "8.64.1-alpha.9",
54
- "@typescript-eslint/type-utils": "8.64.1-alpha.9",
55
- "@typescript-eslint/utils": "8.64.1-alpha.9"
52
+ "@typescript-eslint/type-utils": "8.65.1-alpha.0",
53
+ "@typescript-eslint/scope-manager": "8.65.1-alpha.0",
54
+ "@typescript-eslint/utils": "8.65.1-alpha.0",
55
+ "@typescript-eslint/visitor-keys": "8.65.1-alpha.0"
56
56
  },
57
57
  "devDependencies": {
58
58
  "@types/json-schema": "^7.0.15",
@@ -76,13 +76,13 @@
76
76
  "typescript": ">=4.8.4 <6.1.0",
77
77
  "unist-util-visit": "^5.0.0",
78
78
  "vitest": "^4.0.18",
79
- "@typescript-eslint/rule-schema-to-typescript-types": "8.64.1-alpha.9",
80
- "@typescript-eslint/rule-tester": "8.64.1-alpha.9"
79
+ "@typescript-eslint/rule-schema-to-typescript-types": "8.65.1-alpha.0",
80
+ "@typescript-eslint/rule-tester": "8.65.1-alpha.0"
81
81
  },
82
82
  "peerDependencies": {
83
83
  "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0",
84
84
  "typescript": ">=4.8.4 <6.1.0",
85
- "@typescript-eslint/parser": "^8.64.1-alpha.9"
85
+ "@typescript-eslint/parser": "^8.65.1-alpha.0"
86
86
  },
87
87
  "funding": {
88
88
  "type": "opencollective",