@flint.fyi/ts 0.14.3 → 0.14.4

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 (101) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/lib/createTypeScriptFileFromProgram.js +1 -0
  3. package/lib/language.d.ts +1 -0
  4. package/lib/plugin.d.ts +44 -0
  5. package/lib/plugin.js +22 -0
  6. package/lib/rules/anyReturns.d.ts +6 -0
  7. package/lib/rules/anyReturns.js +187 -0
  8. package/lib/rules/anyReturns.test.d.ts +1 -0
  9. package/lib/rules/anyReturns.test.js +647 -0
  10. package/lib/rules/caseDuplicates.d.ts +6 -0
  11. package/lib/rules/caseDuplicates.js +49 -0
  12. package/lib/rules/caseDuplicates.test.d.ts +1 -0
  13. package/lib/rules/caseDuplicates.test.js +307 -0
  14. package/lib/rules/elseIfDuplicates.d.ts +6 -0
  15. package/lib/rules/elseIfDuplicates.js +53 -0
  16. package/lib/rules/elseIfDuplicates.test.d.ts +1 -0
  17. package/lib/rules/elseIfDuplicates.test.js +176 -0
  18. package/lib/rules/forDirections.d.ts +6 -0
  19. package/lib/rules/forDirections.js +124 -0
  20. package/lib/rules/forDirections.test.d.ts +1 -0
  21. package/lib/rules/forDirections.test.js +99 -0
  22. package/lib/rules/functionNewCalls.d.ts +6 -0
  23. package/lib/rules/functionNewCalls.js +60 -0
  24. package/lib/rules/functionNewCalls.test.d.ts +1 -0
  25. package/lib/rules/functionNewCalls.test.js +115 -0
  26. package/lib/rules/negativeZeroComparisons.js +4 -22
  27. package/lib/rules/nonOctalDecimalEscapes.d.ts +6 -0
  28. package/lib/rules/nonOctalDecimalEscapes.js +57 -0
  29. package/lib/rules/nonOctalDecimalEscapes.test.d.ts +1 -0
  30. package/lib/rules/nonOctalDecimalEscapes.test.js +69 -0
  31. package/lib/rules/numericLiteralParsing.d.ts +6 -0
  32. package/lib/rules/numericLiteralParsing.js +97 -0
  33. package/lib/rules/numericLiteralParsing.test.d.ts +1 -0
  34. package/lib/rules/numericLiteralParsing.test.js +99 -0
  35. package/lib/rules/selfAssignments.d.ts +6 -0
  36. package/lib/rules/selfAssignments.js +44 -0
  37. package/lib/rules/selfAssignments.test.d.ts +1 -0
  38. package/lib/rules/selfAssignments.test.js +66 -0
  39. package/lib/rules/selfComparisons.d.ts +6 -0
  40. package/lib/rules/selfComparisons.js +41 -0
  41. package/lib/rules/selfComparisons.test.d.ts +1 -0
  42. package/lib/rules/selfComparisons.test.js +297 -0
  43. package/lib/rules/sequences.d.ts +6 -0
  44. package/lib/rules/sequences.js +34 -0
  45. package/lib/rules/sequences.test.d.ts +1 -0
  46. package/lib/rules/sequences.test.js +48 -0
  47. package/lib/rules/typeofComparisons.d.ts +6 -0
  48. package/lib/rules/typeofComparisons.js +78 -0
  49. package/lib/rules/typeofComparisons.test.d.ts +1 -0
  50. package/lib/rules/typeofComparisons.test.js +85 -0
  51. package/lib/rules/utils/discriminateAnyType.d.ts +12 -0
  52. package/lib/rules/utils/discriminateAnyType.js +41 -0
  53. package/lib/rules/utils/getThisExpression.d.ts +2 -0
  54. package/lib/rules/utils/getThisExpression.js +23 -0
  55. package/lib/rules/utils/isUnsafeAssignment.d.ts +13 -0
  56. package/lib/rules/utils/isUnsafeAssignment.js +76 -0
  57. package/lib/rules/utils/operators.d.ts +4 -0
  58. package/lib/rules/utils/operators.js +36 -0
  59. package/lib/utils/declarationIncludesGlobal.d.ts +2 -0
  60. package/lib/utils/declarationIncludesGlobal.js +5 -0
  61. package/lib/utils/declarationsIncludeGlobal.js +2 -5
  62. package/lib/utils/hasSameTokens.d.ts +2 -0
  63. package/lib/utils/hasSameTokens.js +30 -0
  64. package/lib/utils/isGlobalDeclarationOfName.d.ts +5 -0
  65. package/lib/utils/isGlobalDeclarationOfName.js +31 -0
  66. package/package.json +1 -1
  67. package/src/createTypeScriptFileFromProgram.ts +1 -0
  68. package/src/language.ts +1 -0
  69. package/src/plugin.ts +22 -0
  70. package/src/rules/anyReturns.test.ts +649 -0
  71. package/src/rules/anyReturns.ts +263 -0
  72. package/src/rules/caseDuplicates.test.ts +308 -0
  73. package/src/rules/caseDuplicates.ts +57 -0
  74. package/src/rules/elseIfDuplicates.test.ts +177 -0
  75. package/src/rules/elseIfDuplicates.ts +69 -0
  76. package/src/rules/forDirections.test.ts +100 -0
  77. package/src/rules/forDirections.ts +163 -0
  78. package/src/rules/functionNewCalls.test.ts +116 -0
  79. package/src/rules/functionNewCalls.ts +75 -0
  80. package/src/rules/negativeZeroComparisons.ts +8 -27
  81. package/src/rules/nonOctalDecimalEscapes.test.ts +70 -0
  82. package/src/rules/nonOctalDecimalEscapes.ts +70 -0
  83. package/src/rules/numericLiteralParsing.test.ts +100 -0
  84. package/src/rules/numericLiteralParsing.ts +116 -0
  85. package/src/rules/selfAssignments.test.ts +67 -0
  86. package/src/rules/selfAssignments.ts +50 -0
  87. package/src/rules/selfComparisons.test.ts +298 -0
  88. package/src/rules/selfComparisons.ts +45 -0
  89. package/src/rules/sequences.test.ts +49 -0
  90. package/src/rules/sequences.ts +37 -0
  91. package/src/rules/typeofComparisons.test.ts +86 -0
  92. package/src/rules/typeofComparisons.ts +88 -0
  93. package/src/rules/utils/discriminateAnyType.ts +66 -0
  94. package/src/rules/utils/getThisExpression.ts +24 -0
  95. package/src/rules/utils/isUnsafeAssignment.ts +113 -0
  96. package/src/rules/utils/operators.ts +39 -0
  97. package/src/utils/declarationIncludesGlobal.ts +9 -0
  98. package/src/utils/declarationsIncludeGlobal.ts +3 -7
  99. package/src/utils/hasSameTokens.ts +45 -0
  100. package/src/utils/isGlobalDeclarationOfName.ts +51 -0
  101. package/tsconfig.tsbuildinfo +1 -1
@@ -1,30 +1,11 @@
1
1
  import * as ts from "typescript";
2
2
 
3
3
  import { typescriptLanguage } from "../language.js";
4
-
5
- const comparisonOperators = new Set([
6
- ts.SyntaxKind.EqualsEqualsEqualsToken,
7
- ts.SyntaxKind.EqualsEqualsToken,
8
- ts.SyntaxKind.ExclamationEqualsEqualsToken,
9
- ts.SyntaxKind.ExclamationEqualsToken,
10
- ts.SyntaxKind.GreaterThanEqualsToken,
11
- ts.SyntaxKind.GreaterThanToken,
12
- ts.SyntaxKind.LessThanEqualsToken,
13
- ts.SyntaxKind.LessThanToken,
14
- ]);
15
-
16
- function isEqualityOperator(operator: string) {
17
- return (
18
- operator === "===" ||
19
- operator === "==" ||
20
- operator === "!==" ||
21
- operator === "!="
22
- );
23
- }
24
-
25
- function isNegatedEqualityOperator(operator: string) {
26
- return operator === "!==" || operator === "!=";
27
- }
4
+ import {
5
+ isComparisonOperator,
6
+ isEqualityOperator,
7
+ isNegatedEqualityOperator,
8
+ } from "./utils/operators.js";
28
9
 
29
10
  function isNegativeZero(node: ts.Node): boolean {
30
11
  return (
@@ -68,7 +49,7 @@ export default typescriptLanguage.createRule({
68
49
  visitors: {
69
50
  BinaryExpression: (node) => {
70
51
  if (
71
- !comparisonOperators.has(node.operatorToken.kind) ||
52
+ !isComparisonOperator(node.operatorToken) ||
72
53
  (!isNegativeZero(node.left) && !isNegativeZero(node.right))
73
54
  ) {
74
55
  return;
@@ -86,14 +67,14 @@ export default typescriptLanguage.createRule({
86
67
  },
87
68
  message: "unexpectedNegativeZeroComparison",
88
69
  range,
89
- suggestions: isEqualityOperator(operator)
70
+ suggestions: isEqualityOperator(node.operatorToken)
90
71
  ? [
91
72
  {
92
73
  id: "useObjectIs",
93
74
  range,
94
75
  text: generateObjectIsText(
95
76
  node,
96
- isNegatedEqualityOperator(operator),
77
+ isNegatedEqualityOperator(node.operatorToken),
97
78
  ),
98
79
  },
99
80
  ]
@@ -0,0 +1,70 @@
1
+ import rule from "./nonOctalDecimalEscapes.js";
2
+ import { ruleTester } from "./ruleTester.js";
3
+
4
+ ruleTester.describe(rule, {
5
+ invalid: [
6
+ {
7
+ code: `
8
+ "\\8"
9
+ `,
10
+ snapshot: `
11
+ "\\8"
12
+ ~~
13
+ Non-octal decimal escape sequences (\\8 and \\9) should not be used in string literals.
14
+ `,
15
+ },
16
+ {
17
+ code: `
18
+ "\\9"
19
+ `,
20
+ snapshot: `
21
+ "\\9"
22
+ ~~
23
+ Non-octal decimal escape sequences (\\8 and \\9) should not be used in string literals.
24
+ `,
25
+ },
26
+ {
27
+ code: `
28
+ "w\\8less"
29
+ `,
30
+ snapshot: `
31
+ "w\\8less"
32
+ ~~
33
+ Non-octal decimal escape sequences (\\8 and \\9) should not be used in string literals.
34
+ `,
35
+ },
36
+ {
37
+ code: `
38
+ "December 1\\9"
39
+ `,
40
+ snapshot: `
41
+ "December 1\\9"
42
+ ~~
43
+ Non-octal decimal escape sequences (\\8 and \\9) should not be used in string literals.
44
+ `,
45
+ },
46
+ {
47
+ code: `
48
+ "Don't use \\8 and \\9 escapes."
49
+ `,
50
+ snapshot: `
51
+ "Don't use \\8 and \\9 escapes."
52
+ ~~
53
+ Non-octal decimal escape sequences (\\8 and \\9) should not be used in string literals.
54
+ ~~
55
+ Non-octal decimal escape sequences (\\8 and \\9) should not be used in string literals.
56
+ `,
57
+ },
58
+ {
59
+ code: `
60
+ "\\0\\8"
61
+ `,
62
+ snapshot: `
63
+ "\\0\\8"
64
+ ~~
65
+ Non-octal decimal escape sequences (\\8 and \\9) should not be used in string literals.
66
+ `,
67
+ },
68
+ ],
69
+ valid: ['"8"', '"9"', '"w8less"', '"December 19"', '"\\\\8"', '"\\0\\u0038"'],
70
+ });
@@ -0,0 +1,70 @@
1
+ import * as ts from "typescript";
2
+
3
+ import { typescriptLanguage } from "../language.js";
4
+
5
+ const nonOctalDecimalEscapePattern = /\\[89]/g;
6
+
7
+ export default typescriptLanguage.createRule({
8
+ about: {
9
+ description:
10
+ "Reports non-octal decimal escape sequences (\\8 and \\9) in string literals.",
11
+ id: "nonOctalDecimalEscapes",
12
+ preset: "logical",
13
+ },
14
+ messages: {
15
+ unexpectedEscape: {
16
+ primary:
17
+ "Non-octal decimal escape sequences (\\8 and \\9) should not be used in string literals.",
18
+ secondary: [
19
+ "Non-octal decimal escape sequences \\8 and \\9 are legacy features that are treated as identity escapes (the same as the literal digits).",
20
+ "They are optional in the ECMAScript specification and not supported in strict mode in all environments.",
21
+ "Use the literal digits directly instead.",
22
+ ],
23
+ suggestions: [
24
+ "Remove the backslash to use the literal digit.",
25
+ "If an escape sequence is needed, use a Unicode escape like \\u0038 or \\u0039.",
26
+ ],
27
+ },
28
+ },
29
+ setup(context) {
30
+ function checkNode(
31
+ node: ts.NoSubstitutionTemplateLiteral | ts.StringLiteral,
32
+ ) {
33
+ const text = node.getText(context.sourceFile);
34
+ const matches = [...text.matchAll(nonOctalDecimalEscapePattern)];
35
+
36
+ for (const match of matches) {
37
+ // Ignore escapes where the backslash itself is escaped (e.g. "\\\\8" -> literal "\\8").
38
+ // Count the number of consecutive backslashes immediately before the match.
39
+ const matchIndex = match.index;
40
+ let backslashesBefore = 0;
41
+ for (let i = matchIndex - 1; i >= 0 && text[i] === "\\"; i--) {
42
+ backslashesBefore++;
43
+ }
44
+
45
+ // If there is an odd number of backslashes before this one, the backslash is escaped
46
+ // and should not be treated as an escape sequence.
47
+ if (backslashesBefore % 2 === 1) {
48
+ continue;
49
+ }
50
+
51
+ const start = node.getStart(context.sourceFile) + matchIndex;
52
+
53
+ context.report({
54
+ message: "unexpectedEscape",
55
+ range: {
56
+ begin: start,
57
+ end: start + match[0].length,
58
+ },
59
+ });
60
+ }
61
+ }
62
+
63
+ return {
64
+ visitors: {
65
+ NoSubstitutionTemplateLiteral: checkNode,
66
+ StringLiteral: checkNode,
67
+ },
68
+ };
69
+ },
70
+ });
@@ -0,0 +1,100 @@
1
+ import rule from "./numericLiteralParsing.js";
2
+ import { ruleTester } from "./ruleTester.js";
3
+
4
+ ruleTester.describe(rule, {
5
+ invalid: [
6
+ {
7
+ code: `
8
+ const binary = parseInt("111110111", 2);
9
+ `,
10
+ snapshot: `
11
+ const binary = parseInt("111110111", 2);
12
+ ~~~~~~~~~~~~~~~~~~~~~~~~
13
+ Use 0b111110111 instead of parseInt with radix 2.
14
+ `,
15
+ },
16
+ {
17
+ code: `
18
+ const octal = parseInt("767", 8);
19
+ `,
20
+ snapshot: `
21
+ const octal = parseInt("767", 8);
22
+ ~~~~~~~~~~~~~~~~~~
23
+ Use 0o767 instead of parseInt with radix 8.
24
+ `,
25
+ },
26
+ {
27
+ code: `
28
+ const hex = parseInt("1F7", 16);
29
+ `,
30
+ snapshot: `
31
+ const hex = parseInt("1F7", 16);
32
+ ~~~~~~~~~~~~~~~~~~~
33
+ Use 0x1F7 instead of parseInt with radix 16.
34
+ `,
35
+ },
36
+ {
37
+ code: `
38
+ const value = Number.parseInt("111110111", 2);
39
+ `,
40
+ snapshot: `
41
+ const value = Number.parseInt("111110111", 2);
42
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
43
+ Use 0b111110111 instead of parseInt with radix 2.
44
+ `,
45
+ },
46
+ {
47
+ code: `
48
+ const result = Number.parseInt("767", 8);
49
+ `,
50
+ snapshot: `
51
+ const result = Number.parseInt("767", 8);
52
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
53
+ Use 0o767 instead of parseInt with radix 8.
54
+ `,
55
+ },
56
+ {
57
+ code: `
58
+ const num = Number.parseInt("1F7", 16);
59
+ `,
60
+ snapshot: `
61
+ const num = Number.parseInt("1F7", 16);
62
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
63
+ Use 0x1F7 instead of parseInt with radix 16.
64
+ `,
65
+ },
66
+ {
67
+ code: `
68
+ const value = parseInt(\`111110111\`, 2);
69
+ `,
70
+ snapshot: `
71
+ const value = parseInt(\`111110111\`, 2);
72
+ ~~~~~~~~~~~~~~~~~~~~~~~~
73
+ Use 0b111110111 instead of parseInt with radix 2.
74
+ `,
75
+ },
76
+ ],
77
+ valid: [
78
+ `const decimal = parseInt("123");`,
79
+ `const value = parseInt("123", 10);`,
80
+ `const ternary = parseInt("102", 3);`,
81
+ `const binary = 0b111110111;`,
82
+ `const octal = 0o767;`,
83
+ `const hex = 0x1F7;`,
84
+ `const dynamic = parseInt(value, 2);`,
85
+ `const variable = parseInt("111", radix);`,
86
+ `const single = parseInt("111");`,
87
+ `Number.parseInt("123");`,
88
+ `Number.parseInt("123", 10);`,
89
+ `
90
+ function parseInt(...values: unknown[]) {}
91
+ parseInt("1", 2);
92
+ export {};
93
+ `,
94
+ `
95
+ const Number = { parseInt(...values: unknown[]) {} };
96
+ Number.parseInt("1", 2);
97
+ export {};
98
+ `,
99
+ ],
100
+ });
@@ -0,0 +1,116 @@
1
+ import * as ts from "typescript";
2
+
3
+ import { getTSNodeRange } from "../getTSNodeRange.js";
4
+ import { typescriptLanguage } from "../language.js";
5
+ import { isGlobalDeclaration } from "../utils/isGlobalDeclaration.js";
6
+
7
+ function convertToLiteral(value: string, radix: number): string {
8
+ const parsed = Number.parseInt(value, radix);
9
+ if (Number.isNaN(parsed)) {
10
+ return value;
11
+ }
12
+
13
+ switch (radix) {
14
+ case 2:
15
+ return `0b${parsed.toString(2)}`;
16
+ case 8:
17
+ return `0o${parsed.toString(8)}`;
18
+ case 16:
19
+ return `0x${parsed.toString(16).toUpperCase()}`;
20
+ default:
21
+ return value;
22
+ }
23
+ }
24
+
25
+ function getRadixValue(node: ts.Expression): number | undefined {
26
+ if (!ts.isNumericLiteral(node)) {
27
+ return undefined;
28
+ }
29
+
30
+ const value = Number(node.text);
31
+ if (![2, 8, 16].includes(value)) {
32
+ return undefined;
33
+ }
34
+
35
+ return value;
36
+ }
37
+
38
+ // TODO: Use a util like getStaticValue
39
+ function getStringValue(node: ts.Expression): string | undefined {
40
+ return ts.isStringLiteral(node) || ts.isNoSubstitutionTemplateLiteral(node)
41
+ ? node.text
42
+ : undefined;
43
+ }
44
+
45
+ export default typescriptLanguage.createRule({
46
+ about: {
47
+ description:
48
+ "Reports parseInt calls with binary, hexadecimal, or octal strings that can be replaced with numeric literals.",
49
+ id: "numericLiteralParsing",
50
+ preset: "stylistic",
51
+ },
52
+ messages: {
53
+ preferLiteral: {
54
+ primary: "Use {{ literal }} instead of parseInt with radix {{ radix }}.",
55
+ secondary: [
56
+ "Binary, octal, and hexadecimal numeric literals are more readable and direct than using parseInt with a radix.",
57
+ "Numeric literals are supported natively and don't require function calls.",
58
+ ],
59
+ suggestions: ["Replace the parseInt call with the numeric literal."],
60
+ },
61
+ },
62
+ setup(context) {
63
+ function checkParseIntCall(node: ts.CallExpression) {
64
+ if (node.arguments.length !== 2) {
65
+ return;
66
+ }
67
+
68
+ const stringValue = getStringValue(node.arguments[0]);
69
+ if (!stringValue) {
70
+ return;
71
+ }
72
+
73
+ const radixValue = getRadixValue(node.arguments[1]);
74
+ if (!radixValue) {
75
+ return;
76
+ }
77
+
78
+ context.report({
79
+ data: {
80
+ literal: convertToLiteral(stringValue, radixValue),
81
+ radix: String(radixValue),
82
+ },
83
+ message: "preferLiteral",
84
+ range: getTSNodeRange(node, context.sourceFile),
85
+ });
86
+ }
87
+
88
+ return {
89
+ visitors: {
90
+ CallExpression: (node) => {
91
+ if (ts.isIdentifier(node.expression)) {
92
+ if (
93
+ node.expression.text === "parseInt" &&
94
+ isGlobalDeclaration(node.expression, context.typeChecker)
95
+ ) {
96
+ checkParseIntCall(node);
97
+ }
98
+ } else if (ts.isPropertyAccessExpression(node.expression)) {
99
+ if (
100
+ ts.isIdentifier(node.expression.expression) &&
101
+ node.expression.expression.text === "Number" &&
102
+ ts.isIdentifier(node.expression.name) &&
103
+ node.expression.name.text === "parseInt" &&
104
+ isGlobalDeclaration(
105
+ node.expression.expression,
106
+ context.typeChecker,
107
+ )
108
+ ) {
109
+ checkParseIntCall(node);
110
+ }
111
+ }
112
+ },
113
+ },
114
+ };
115
+ },
116
+ });
@@ -0,0 +1,67 @@
1
+ import { ruleTester } from "./ruleTester.js";
2
+ import rule from "./selfAssignments.js";
3
+
4
+ ruleTester.describe(rule, {
5
+ invalid: [
6
+ {
7
+ code: `
8
+ value = value;
9
+ `,
10
+ snapshot: `
11
+ value = value;
12
+ ~~~~~~~~~~~~~
13
+ This value is being assigned to itself, which does nothing.
14
+ `,
15
+ },
16
+ {
17
+ code: `
18
+ count &&= count;
19
+ `,
20
+ snapshot: `
21
+ count &&= count;
22
+ ~~~~~~~~~~~~~~~
23
+ This value is being assigned to itself, which does nothing.
24
+ `,
25
+ },
26
+ {
27
+ code: `
28
+ flag ||= flag;
29
+ `,
30
+ snapshot: `
31
+ flag ||= flag;
32
+ ~~~~~~~~~~~~~
33
+ This value is being assigned to itself, which does nothing.
34
+ `,
35
+ },
36
+ {
37
+ code: `
38
+ data ??= data;
39
+ `,
40
+ snapshot: `
41
+ data ??= data;
42
+ ~~~~~~~~~~~~~
43
+ This value is being assigned to itself, which does nothing.
44
+ `,
45
+ },
46
+ {
47
+ code: `
48
+ a.b ??= a.b;
49
+ `,
50
+ snapshot: `
51
+ a.b ??= a.b;
52
+ ~~~~~~~~~~~
53
+ This value is being assigned to itself, which does nothing.
54
+ `,
55
+ },
56
+ ],
57
+ valid: [
58
+ `value = other;`,
59
+ `first = second;`,
60
+ `let value = value;`,
61
+ `const data = data;`,
62
+ `value += value;`,
63
+ `count -= count;`,
64
+ `a ||= b;`,
65
+ `a.b ||= a.c;`,
66
+ ],
67
+ });
@@ -0,0 +1,50 @@
1
+ import * as ts from "typescript";
2
+
3
+ import { getTSNodeRange } from "../getTSNodeRange.js";
4
+ import { typescriptLanguage } from "../language.js";
5
+ import { hasSameTokens } from "../utils/hasSameTokens.js";
6
+
7
+ export default typescriptLanguage.createRule({
8
+ about: {
9
+ description:
10
+ "Reports self-assignments which have no effect and are likely errors.",
11
+ id: "selfAssignments",
12
+ preset: "logical",
13
+ },
14
+ messages: {
15
+ selfAssignment: {
16
+ primary: "This value is being assigned to itself, which does nothing.",
17
+ secondary: [
18
+ "Self-assignments have no effect and typically indicate an incomplete refactoring or copy-paste error.",
19
+ ],
20
+ suggestions: [
21
+ "Review the assignment and ensure you're assigning the correct value.",
22
+ ],
23
+ },
24
+ },
25
+ setup(context) {
26
+ return {
27
+ visitors: {
28
+ BinaryExpression: (node) => {
29
+ if (
30
+ node.operatorToken.kind !== ts.SyntaxKind.EqualsToken &&
31
+ node.operatorToken.kind !==
32
+ ts.SyntaxKind.AmpersandAmpersandEqualsToken &&
33
+ node.operatorToken.kind !== ts.SyntaxKind.BarBarEqualsToken &&
34
+ node.operatorToken.kind !==
35
+ ts.SyntaxKind.QuestionQuestionEqualsToken
36
+ ) {
37
+ return;
38
+ }
39
+
40
+ if (hasSameTokens(node.left, node.right, context.sourceFile)) {
41
+ context.report({
42
+ message: "selfAssignment",
43
+ range: getTSNodeRange(node, context.sourceFile),
44
+ });
45
+ }
46
+ },
47
+ },
48
+ };
49
+ },
50
+ });