@flint.fyi/ts 0.14.4 → 0.14.5

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 (57) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/lib/createTypeScriptFileFromProgram.js +4 -1
  3. package/lib/index.d.ts +3 -0
  4. package/lib/index.js +3 -0
  5. package/lib/plugin.d.ts +17 -1
  6. package/lib/plugin.js +8 -0
  7. package/lib/rules/chainedAssignments.js +2 -1
  8. package/lib/rules/chainedAssignments.test.js +24 -0
  9. package/lib/rules/debuggerStatements.test.js +4 -4
  10. package/lib/rules/emptyBlocks.d.ts +6 -0
  11. package/lib/rules/emptyBlocks.js +66 -0
  12. package/lib/rules/emptyBlocks.test.d.ts +1 -0
  13. package/lib/rules/emptyBlocks.test.js +135 -0
  14. package/lib/rules/octalNumbers.test.js +2 -2
  15. package/lib/rules/shadowedRestrictedNames.d.ts +6 -0
  16. package/lib/rules/shadowedRestrictedNames.js +95 -0
  17. package/lib/rules/shadowedRestrictedNames.test.d.ts +1 -0
  18. package/lib/rules/shadowedRestrictedNames.test.js +147 -0
  19. package/lib/rules/symbolDescriptions.test.js +4 -4
  20. package/lib/rules/unicodeBOMs.test.js +1 -0
  21. package/lib/rules/unnecessaryBlocks.d.ts +6 -0
  22. package/lib/rules/unnecessaryBlocks.js +75 -0
  23. package/lib/rules/unnecessaryBlocks.test.d.ts +1 -0
  24. package/lib/rules/unnecessaryBlocks.test.js +147 -0
  25. package/lib/rules/unnecessaryConcatenation.d.ts +6 -0
  26. package/lib/rules/unnecessaryConcatenation.js +38 -0
  27. package/lib/rules/unnecessaryConcatenation.test.d.ts +1 -0
  28. package/lib/rules/unnecessaryConcatenation.test.js +87 -0
  29. package/lib/rules/voidOperator.test.js +2 -2
  30. package/lib/utils/getDeclarationsIfGlobal.d.ts +2 -0
  31. package/lib/utils/getDeclarationsIfGlobal.js +7 -0
  32. package/lib/utils/isGlobalDeclaration.js +2 -3
  33. package/lib/utils/isGlobalDeclarationOfName.d.ts +1 -1
  34. package/lib/utils/isGlobalDeclarationOfName.js +4 -0
  35. package/package.json +3 -3
  36. package/src/createTypeScriptFileFromProgram.ts +5 -1
  37. package/src/index.ts +3 -0
  38. package/src/plugin.ts +8 -0
  39. package/src/rules/chainedAssignments.test.ts +24 -0
  40. package/src/rules/chainedAssignments.ts +4 -1
  41. package/src/rules/debuggerStatements.test.ts +4 -4
  42. package/src/rules/emptyBlocks.test.ts +136 -0
  43. package/src/rules/emptyBlocks.ts +73 -0
  44. package/src/rules/octalNumbers.test.ts +2 -2
  45. package/src/rules/shadowedRestrictedNames.test.ts +148 -0
  46. package/src/rules/shadowedRestrictedNames.ts +105 -0
  47. package/src/rules/symbolDescriptions.test.ts +4 -4
  48. package/src/rules/unicodeBOMs.test.ts +1 -0
  49. package/src/rules/unnecessaryBlocks.test.ts +148 -0
  50. package/src/rules/unnecessaryBlocks.ts +89 -0
  51. package/src/rules/unnecessaryConcatenation.test.ts +88 -0
  52. package/src/rules/unnecessaryConcatenation.ts +44 -0
  53. package/src/rules/voidOperator.test.ts +2 -2
  54. package/src/utils/getDeclarationsIfGlobal.ts +14 -0
  55. package/src/utils/isGlobalDeclaration.ts +3 -5
  56. package/src/utils/isGlobalDeclarationOfName.ts +6 -1
  57. package/tsconfig.tsbuildinfo +1 -1
@@ -0,0 +1,147 @@
1
+ import { ruleTester } from "./ruleTester.js";
2
+ import rule from "./shadowedRestrictedNames.js";
3
+ ruleTester.describe(rule, {
4
+ invalid: [
5
+ {
6
+ code: `
7
+ let undefined = 5;
8
+ `,
9
+ snapshot: `
10
+ let undefined = 5;
11
+ ~~~~~~~~~
12
+ This variable misleadingly shadows the global \`undefined\`.
13
+ `,
14
+ },
15
+ {
16
+ code: `
17
+ const NaN = 123;
18
+ `,
19
+ snapshot: `
20
+ const NaN = 123;
21
+ ~~~
22
+ This variable misleadingly shadows the global \`NaN\`.
23
+ `,
24
+ },
25
+ {
26
+ code: `
27
+ var Infinity = 100;
28
+ `,
29
+ snapshot: `
30
+ var Infinity = 100;
31
+ ~~~~~~~~
32
+ This variable misleadingly shadows the global \`Infinity\`.
33
+ `,
34
+ },
35
+ {
36
+ code: `
37
+ function test(arguments) {
38
+ return arguments.length;
39
+ }
40
+ `,
41
+ snapshot: `
42
+ function test(arguments) {
43
+ ~~~~~~~~~
44
+ This variable misleadingly shadows the global \`arguments\`.
45
+ return arguments.length;
46
+ }
47
+ `,
48
+ },
49
+ {
50
+ code: `
51
+ function eval() {
52
+ return 42;
53
+ }
54
+ `,
55
+ snapshot: `
56
+ function eval() {
57
+ ~~~~
58
+ This variable misleadingly shadows the global \`eval\`.
59
+ return 42;
60
+ }
61
+ `,
62
+ },
63
+ {
64
+ code: `
65
+ const arrowFunc = (undefined) => undefined;
66
+ `,
67
+ snapshot: `
68
+ const arrowFunc = (undefined) => undefined;
69
+ ~~~~~~~~~
70
+ This variable misleadingly shadows the global \`undefined\`.
71
+ `,
72
+ },
73
+ {
74
+ code: `
75
+ class NaN {
76
+ constructor() {}
77
+ }
78
+ `,
79
+ snapshot: `
80
+ class NaN {
81
+ ~~~
82
+ This variable misleadingly shadows the global \`NaN\`.
83
+ constructor() {}
84
+ }
85
+ `,
86
+ },
87
+ {
88
+ code: `
89
+ const obj = {
90
+ method(eval) {
91
+ return eval;
92
+ }
93
+ };
94
+ `,
95
+ snapshot: `
96
+ const obj = {
97
+ method(eval) {
98
+ ~~~~
99
+ This variable misleadingly shadows the global \`eval\`.
100
+ return eval;
101
+ }
102
+ };
103
+ `,
104
+ },
105
+ {
106
+ code: `
107
+ function test() {
108
+ const { undefined } = obj;
109
+ }
110
+ `,
111
+ snapshot: `
112
+ function test() {
113
+ const { undefined } = obj;
114
+ ~~~~~~~~~
115
+ This variable misleadingly shadows the global \`undefined\`.
116
+ }
117
+ `,
118
+ },
119
+ {
120
+ code: `
121
+ function test() {
122
+ const [NaN] = array;
123
+ }
124
+ `,
125
+ snapshot: `
126
+ function test() {
127
+ const [NaN] = array;
128
+ ~~~
129
+ This variable misleadingly shadows the global \`NaN\`.
130
+ }
131
+ `,
132
+ },
133
+ ],
134
+ valid: [
135
+ `let value = undefined;`,
136
+ `const result = NaN;`,
137
+ `const max = Infinity;`,
138
+ `function test() { return arguments; }`,
139
+ `const code = eval("1 + 1");`,
140
+ `let myValue = 5;`,
141
+ `function myFunction() {}`,
142
+ `class MyClass {}`,
143
+ `const obj = { undefined: 5 };`,
144
+ `const key = "undefined";`,
145
+ `obj.undefined = 5;`,
146
+ ],
147
+ });
@@ -43,8 +43,8 @@ function createSymbol() {
43
43
  snapshot: `
44
44
  function createSymbol() {
45
45
  return Symbol();
46
- ~~~~~~~~
47
- Symbols without descriptions are more difficult to debug or reason about.
46
+ ~~~~~~~~
47
+ Symbols without descriptions are more difficult to debug or reason about.
48
48
  }
49
49
  `,
50
50
  },
@@ -57,8 +57,8 @@ const obj = {
57
57
  snapshot: `
58
58
  const obj = {
59
59
  key: Symbol(),
60
- ~~~~~~~~
61
- Symbols without descriptions are more difficult to debug or reason about.
60
+ ~~~~~~~~
61
+ Symbols without descriptions are more difficult to debug or reason about.
62
62
  };
63
63
  `,
64
64
  },
@@ -1,3 +1,4 @@
1
+ // flint-disable-file invalidCodeLines -- This rule checks the first character of code files.
1
2
  import { ruleTester } from "./ruleTester.js";
2
3
  import rule from "./unicodeBOMs.js";
3
4
  ruleTester.describe(rule, {
@@ -0,0 +1,6 @@
1
+ declare const _default: import("@flint.fyi/core").Rule<{
2
+ readonly description: "Reports standalone block statements that don't create a meaningful scope.";
3
+ readonly id: "unnecessaryBlocks";
4
+ readonly preset: "stylistic";
5
+ }, import("../nodes.js").TSNodesByName, import("../language.js").TypeScriptServices, "unnecessaryBlock", undefined>;
6
+ export default _default;
@@ -0,0 +1,75 @@
1
+ import * as ts from "typescript";
2
+ import { typescriptLanguage } from "../language.js";
3
+ export default typescriptLanguage.createRule({
4
+ about: {
5
+ description: "Reports standalone block statements that don't create a meaningful scope.",
6
+ id: "unnecessaryBlocks",
7
+ preset: "stylistic",
8
+ },
9
+ messages: {
10
+ unnecessaryBlock: {
11
+ primary: "This standalone block statement is unnecessary and doesn't change any variable scopes.",
12
+ secondary: [
13
+ "Standalone block statements that aren't part of control flow (if/else, loops, switch) or don't create a meaningful lexical scope can be confusing and should be avoided.",
14
+ "In modern JavaScript and TypeScript, blocks primarily serve to create lexical scope for `let` and `const` variables, but this is often better achieved through other means.",
15
+ ],
16
+ suggestions: [
17
+ "Remove the block statement and move its contents to the parent scope.",
18
+ "If you need lexical scoping, consider using an IIFE (Immediately Invoked Function Expression) or extracting to a separate function.",
19
+ ],
20
+ },
21
+ },
22
+ setup(context) {
23
+ function isValidBlock(node) {
24
+ const parent = node.parent;
25
+ // Valid blocks: function bodies, arrow functions, class/interface bodies, etc.
26
+ if (ts.isFunctionDeclaration(parent) ||
27
+ ts.isFunctionExpression(parent) ||
28
+ ts.isArrowFunction(parent) ||
29
+ ts.isMethodDeclaration(parent) ||
30
+ ts.isConstructorDeclaration(parent) ||
31
+ ts.isGetAccessorDeclaration(parent) ||
32
+ ts.isSetAccessorDeclaration(parent) ||
33
+ ts.isModuleBlock(parent)) {
34
+ return true;
35
+ }
36
+ // Valid blocks: control flow statements
37
+ if (ts.isIfStatement(parent) ||
38
+ ts.isForStatement(parent) ||
39
+ ts.isForInStatement(parent) ||
40
+ ts.isForOfStatement(parent) ||
41
+ ts.isWhileStatement(parent) ||
42
+ ts.isDoStatement(parent) ||
43
+ ts.isWithStatement(parent) ||
44
+ ts.isTryStatement(parent) ||
45
+ ts.isCatchClause(parent)) {
46
+ return true;
47
+ }
48
+ // Valid block: switch case/default clause with block
49
+ // In ES6+, blocks in switch cases create scope for let/const
50
+ if (ts.isCaseClause(parent) || ts.isDefaultClause(parent)) {
51
+ return true;
52
+ }
53
+ // Valid block: labeled statement
54
+ if (ts.isLabeledStatement(parent)) {
55
+ return true;
56
+ }
57
+ return false;
58
+ }
59
+ return {
60
+ visitors: {
61
+ Block: (node) => {
62
+ if (!isValidBlock(node)) {
63
+ context.report({
64
+ message: "unnecessaryBlock",
65
+ range: {
66
+ begin: node.getStart(context.sourceFile),
67
+ end: node.getStart(context.sourceFile) + 1,
68
+ },
69
+ });
70
+ }
71
+ },
72
+ },
73
+ };
74
+ },
75
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,147 @@
1
+ import { ruleTester } from "./ruleTester.js";
2
+ import rule from "./unnecessaryBlocks.js";
3
+ ruleTester.describe(rule, {
4
+ invalid: [
5
+ {
6
+ code: `
7
+ {
8
+ const x = 1;
9
+ }
10
+ `,
11
+ snapshot: `
12
+ {
13
+ ~
14
+ This standalone block statement is unnecessary and doesn't change any variable scopes.
15
+ const x = 1;
16
+ }
17
+ `,
18
+ },
19
+ {
20
+ code: `
21
+ function test() {
22
+ {
23
+ const y = 2;
24
+ }
25
+ }
26
+ `,
27
+ snapshot: `
28
+ function test() {
29
+ {
30
+ ~
31
+ This standalone block statement is unnecessary and doesn't change any variable scopes.
32
+ const y = 2;
33
+ }
34
+ }
35
+ `,
36
+ },
37
+ {
38
+ code: `
39
+ if (condition) {
40
+ doSomething();
41
+ {
42
+ const nested = true;
43
+ }
44
+ }
45
+ `,
46
+ snapshot: `
47
+ if (condition) {
48
+ doSomething();
49
+ {
50
+ ~
51
+ This standalone block statement is unnecessary and doesn't change any variable scopes.
52
+ const nested = true;
53
+ }
54
+ }
55
+ `,
56
+ },
57
+ {
58
+ code: `
59
+ {
60
+ console.log("standalone");
61
+ }
62
+ `,
63
+ snapshot: `
64
+ {
65
+ ~
66
+ This standalone block statement is unnecessary and doesn't change any variable scopes.
67
+ console.log("standalone");
68
+ }
69
+ `,
70
+ },
71
+ {
72
+ code: `
73
+ function outer() {
74
+ {
75
+ console.log("inner");
76
+ }
77
+ {
78
+ console.log("another");
79
+ }
80
+ }
81
+ `,
82
+ snapshot: `
83
+ function outer() {
84
+ {
85
+ ~
86
+ This standalone block statement is unnecessary and doesn't change any variable scopes.
87
+ console.log("inner");
88
+ }
89
+ {
90
+ ~
91
+ This standalone block statement is unnecessary and doesn't change any variable scopes.
92
+ console.log("another");
93
+ }
94
+ }
95
+ `,
96
+ },
97
+ ],
98
+ valid: [
99
+ `if (condition) { doSomething(); }`,
100
+ `for (let i = 0; i < 10; i++) { console.log(i); }`,
101
+ `while (condition) { doWork(); }`,
102
+ `do { doWork(); } while (condition);`,
103
+ `function test() { return 42; }`,
104
+ `const arrow = () => { return 1; };`,
105
+ `
106
+ switch (value) {
107
+ case 1: {
108
+ const x = 1;
109
+ break;
110
+ }
111
+ case 2: {
112
+ const y = 2;
113
+ break;
114
+ }
115
+ }
116
+ `,
117
+ `
118
+ try {
119
+ doSomething();
120
+ } catch (error) {
121
+ handleError(error);
122
+ }
123
+ `,
124
+ `
125
+ class MyClass {
126
+ method() {
127
+ return 1;
128
+ }
129
+ }
130
+ `,
131
+ `
132
+ for (const item of items) {
133
+ processItem(item);
134
+ }
135
+ `,
136
+ `
137
+ for (const key in object) {
138
+ processKey(key);
139
+ }
140
+ `,
141
+ `
142
+ label: {
143
+ break label;
144
+ }
145
+ `,
146
+ ],
147
+ });
@@ -0,0 +1,6 @@
1
+ declare const _default: import("@flint.fyi/core").Rule<{
2
+ readonly description: "Reports string concatenation using the + operator when both operands are string literals.";
3
+ readonly id: "unnecessaryConcatenation";
4
+ readonly preset: "stylistic";
5
+ }, import("../nodes.js").TSNodesByName, import("../language.js").TypeScriptServices, "unnecessaryConcatenation", undefined>;
6
+ export default _default;
@@ -0,0 +1,38 @@
1
+ import * as ts from "typescript";
2
+ import { getTSNodeRange } from "../getTSNodeRange.js";
3
+ import { typescriptLanguage } from "../language.js";
4
+ export default typescriptLanguage.createRule({
5
+ about: {
6
+ description: "Reports string concatenation using the + operator when both operands are string literals.",
7
+ id: "unnecessaryConcatenation",
8
+ preset: "stylistic",
9
+ },
10
+ messages: {
11
+ unnecessaryConcatenation: {
12
+ primary: "This string concatenation can be streamlined into a single string literal.",
13
+ secondary: [
14
+ "Concatenating string literals with the + operator is unnecessary and reduces code readability.",
15
+ "String literals can be combined into a single literal, which is clearer and potentially more performant.",
16
+ ],
17
+ suggestions: [
18
+ "Combine the string literals into a single string literal.",
19
+ ],
20
+ },
21
+ },
22
+ setup(context) {
23
+ return {
24
+ visitors: {
25
+ BinaryExpression: (node) => {
26
+ if (node.operatorToken.kind === ts.SyntaxKind.PlusToken &&
27
+ ts.isStringLiteral(node.left) &&
28
+ ts.isStringLiteral(node.right)) {
29
+ context.report({
30
+ message: "unnecessaryConcatenation",
31
+ range: getTSNodeRange(node.operatorToken, context.sourceFile),
32
+ });
33
+ }
34
+ },
35
+ },
36
+ };
37
+ },
38
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,87 @@
1
+ import { ruleTester } from "./ruleTester.js";
2
+ import rule from "./unnecessaryConcatenation.js";
3
+ ruleTester.describe(rule, {
4
+ invalid: [
5
+ {
6
+ code: `
7
+ const message = "Hello" + "World";
8
+ `,
9
+ snapshot: `
10
+ const message = "Hello" + "World";
11
+ ~
12
+ This string concatenation can be streamlined into a single string literal.
13
+ `,
14
+ },
15
+ {
16
+ code: `
17
+ const path = 'foo' + 'bar';
18
+ `,
19
+ snapshot: `
20
+ const path = 'foo' + 'bar';
21
+ ~
22
+ This string concatenation can be streamlined into a single string literal.
23
+ `,
24
+ },
25
+ {
26
+ code: `
27
+ const result = "abc" + "def" + "ghi";
28
+ `,
29
+ snapshot: `
30
+ const result = "abc" + "def" + "ghi";
31
+ ~
32
+ This string concatenation can be streamlined into a single string literal.
33
+ `,
34
+ },
35
+ {
36
+ code: `
37
+ const text = "first" + "second";
38
+ `,
39
+ snapshot: `
40
+ const text = "first" + "second";
41
+ ~
42
+ This string concatenation can be streamlined into a single string literal.
43
+ `,
44
+ },
45
+ {
46
+ code: `
47
+ const mixed = 'single' + "double";
48
+ `,
49
+ snapshot: `
50
+ const mixed = 'single' + "double";
51
+ ~
52
+ This string concatenation can be streamlined into a single string literal.
53
+ `,
54
+ },
55
+ {
56
+ code: `
57
+ const withSpace = "Hello " + "World";
58
+ `,
59
+ snapshot: `
60
+ const withSpace = "Hello " + "World";
61
+ ~
62
+ This string concatenation can be streamlined into a single string literal.
63
+ `,
64
+ },
65
+ {
66
+ code: `
67
+ const longString = "This is a very long string that " +
68
+ "continues on the next line";
69
+ `,
70
+ snapshot: `
71
+ const longString = "This is a very long string that " +
72
+ ~
73
+ This string concatenation can be streamlined into a single string literal.
74
+ "continues on the next line";
75
+ `,
76
+ },
77
+ ],
78
+ valid: [
79
+ `const message = "Hello" + variable;`,
80
+ `const message = variable + "World";`,
81
+ `const result = variable1 + variable2;`,
82
+ `const template = \`Hello\${name}World\`;`,
83
+ `const number = 1 + 2;`,
84
+ `const mixed = "Hello" + getName() + "World";`,
85
+ `const value = "prefix" + getValue();`,
86
+ ],
87
+ });
@@ -71,8 +71,8 @@ function process() {
71
71
  snapshot: `
72
72
  function process() {
73
73
  void doSomething();
74
- ~~~~~~~~~~~~~~~~~~
75
- Prefer an explicit value over using the void operator to produce undefined.
74
+ ~~~~~~~~~~~~~~~~~~
75
+ Prefer an explicit value over using the void operator to produce undefined.
76
76
  }
77
77
  `,
78
78
  },
@@ -0,0 +1,2 @@
1
+ import * as ts from "typescript";
2
+ export declare function getDeclarationsIfGlobal(node: ts.Expression, typeChecker: ts.TypeChecker): ts.Declaration[] | undefined;
@@ -0,0 +1,7 @@
1
+ import { declarationsIncludeGlobal } from "./declarationsIncludeGlobal.js";
2
+ export function getDeclarationsIfGlobal(node, typeChecker) {
3
+ const declarations = typeChecker.getSymbolAtLocation(node)?.getDeclarations();
4
+ return !!declarations && declarationsIncludeGlobal(declarations)
5
+ ? declarations
6
+ : undefined;
7
+ }
@@ -1,5 +1,4 @@
1
- import { declarationsIncludeGlobal } from "./declarationsIncludeGlobal.js";
1
+ import { getDeclarationsIfGlobal } from "./getDeclarationsIfGlobal.js";
2
2
  export function isGlobalDeclaration(node, typeChecker) {
3
- const declarations = typeChecker.getSymbolAtLocation(node)?.getDeclarations();
4
- return !!declarations && declarationsIncludeGlobal(declarations);
3
+ return !!getDeclarationsIfGlobal(node, typeChecker);
5
4
  }
@@ -2,4 +2,4 @@ import * as ts from "typescript";
2
2
  /**
3
3
  * TODO: Use a scope analyzer (#400).
4
4
  */
5
- export declare function isGlobalDeclarationOfName(node: ts.Expression, name: string, typeChecker: ts.TypeChecker): boolean;
5
+ export declare function isGlobalDeclarationOfName(node: ts.Node, name: string, typeChecker: ts.TypeChecker): boolean;
@@ -16,6 +16,10 @@ export function isGlobalDeclarationOfName(node, name, typeChecker) {
16
16
  declaration.initializer.kind === ts.SyntaxKind.Identifier) {
17
17
  return isGlobalDeclarationOfName(declaration.initializer, name, typeChecker);
18
18
  }
19
+ // Special case: a property of an interface
20
+ if (ts.isPropertySignature(declaration)) {
21
+ return isGlobalDeclarationOfName(declaration.parent, name, typeChecker);
22
+ }
19
23
  return (isDeclarationOfName(declaration, name) &&
20
24
  declarationIncludesGlobal(declaration));
21
25
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flint.fyi/ts",
3
- "version": "0.14.4",
3
+ "version": "0.14.5",
4
4
  "description": "[Experimental] TypeScript language plugin for Flint.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -17,12 +17,12 @@
17
17
  "dependencies": {
18
18
  "@flint.fyi/core": "",
19
19
  "@flint.fyi/rule-tester": "",
20
- "@typescript-eslint/project-service": "^8.35.0",
20
+ "@typescript-eslint/project-service": "^8.46.2",
21
21
  "@typescript/vfs": "^1.6.1",
22
22
  "cached-factory": "^0.1.0",
23
23
  "debug-for-file": "^0.2.0",
24
24
  "ts-api-utils": "^2.1.0",
25
- "typescript": ">=5.8.0"
25
+ "typescript": ">=5.9.3"
26
26
  },
27
27
  "engines": {
28
28
  "node": ">=24.0.0"
@@ -53,6 +53,10 @@ export function createTypeScriptFileFromProgram(
53
53
  report: (report: RuleReport) => {
54
54
  reports.push({
55
55
  ...report,
56
+ fix:
57
+ report.fix && !Array.isArray(report.fix)
58
+ ? [report.fix]
59
+ : report.fix,
56
60
  message: rule.messages[report.message],
57
61
  range: normalizeRange(report.range, sourceFile),
58
62
  });
@@ -74,7 +78,7 @@ export function createTypeScriptFileFromProgram(
74
78
  node.forEachChild(visit);
75
79
  };
76
80
 
77
- sourceFile.forEachChild(visit);
81
+ visit(sourceFile);
78
82
 
79
83
  return reports;
80
84
  },
package/src/index.ts CHANGED
@@ -1,4 +1,7 @@
1
1
  export { getTSNodeRange } from "./getTSNodeRange.js";
2
2
  export * from "./language.js";
3
3
  export { ts } from "./plugin.js";
4
+ export { getDeclarationsIfGlobal } from "./utils/getDeclarationsIfGlobal.js";
4
5
  export { isGlobalDeclaration } from "./utils/isGlobalDeclaration.js";
6
+ export { isGlobalDeclarationOfName } from "./utils/isGlobalDeclarationOfName.js";
7
+ export { isGlobalVariable } from "./utils/isGlobalVariable.js";