oxlint-plugin-effect 0.2.0 → 0.2.1
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/dist/_virtual/_rolldown/runtime.js +13 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/plugin.d.ts +5 -0
- package/dist/plugin.js +18 -0
- package/dist/presets/core.d.ts +43 -0
- package/dist/presets/core.js +43 -0
- package/dist/presets/effect-native.d.ts +28 -0
- package/dist/presets/effect-native.js +28 -0
- package/dist/presets/full.d.ts +60 -0
- package/dist/presets/full.js +60 -0
- package/dist/presets/functional.d.ts +21 -0
- package/dist/presets/functional.js +21 -0
- package/dist/presets/index.d.ts +13 -0
- package/dist/presets/index.js +18 -0
- package/dist/presets/strict.d.ts +69 -0
- package/dist/presets/strict.js +69 -0
- package/dist/presets/v3.d.ts +15 -0
- package/dist/presets/v3.js +15 -0
- package/dist/rules/_effect-context.d.ts +19 -0
- package/dist/rules/_effect-context.js +22 -0
- package/dist/rules/index.d.ts +66 -0
- package/dist/rules/index.js +124 -0
- package/dist/rules/no-arrow-ladder.d.ts +6 -0
- package/dist/rules/no-arrow-ladder.js +61 -0
- package/dist/rules/no-async-function.d.ts +6 -0
- package/dist/rules/no-async-function.js +46 -0
- package/dist/rules/no-catch-all-to-map-error.d.ts +6 -0
- package/dist/rules/no-catch-all-to-map-error.js +67 -0
- package/dist/rules/no-effect-as.d.ts +6 -0
- package/dist/rules/no-effect-as.js +16 -0
- package/dist/rules/no-effect-async.d.ts +6 -0
- package/dist/rules/no-effect-async.js +16 -0
- package/dist/rules/no-effect-bind.d.ts +6 -0
- package/dist/rules/no-effect-bind.js +16 -0
- package/dist/rules/no-effect-do.d.ts +6 -0
- package/dist/rules/no-effect-do.js +16 -0
- package/dist/rules/no-effect-fn-generator.d.ts +6 -0
- package/dist/rules/no-effect-fn-generator.js +30 -0
- package/dist/rules/no-effect-gen-adapter.d.ts +6 -0
- package/dist/rules/no-effect-gen-adapter.js +30 -0
- package/dist/rules/no-effect-map-flatten.d.ts +6 -0
- package/dist/rules/no-effect-map-flatten.js +53 -0
- package/dist/rules/no-effect-map-void.d.ts +6 -0
- package/dist/rules/no-effect-map-void.js +40 -0
- package/dist/rules/no-effect-never.d.ts +6 -0
- package/dist/rules/no-effect-never.js +16 -0
- package/dist/rules/no-effect-orElse-ladder.d.ts +6 -0
- package/dist/rules/no-effect-orElse-ladder.js +53 -0
- package/dist/rules/no-effect-succeed-string.d.ts +6 -0
- package/dist/rules/no-effect-succeed-string.js +30 -0
- package/dist/rules/no-effect-succeed-variable.d.ts +6 -0
- package/dist/rules/no-effect-succeed-variable.js +30 -0
- package/dist/rules/no-effect-succeed-void.d.ts +6 -0
- package/dist/rules/no-effect-succeed-void.js +33 -0
- package/dist/rules/no-effect-sync-console.d.ts +6 -0
- package/dist/rules/no-effect-sync-console.js +63 -0
- package/dist/rules/no-effect-sync-wrapper.d.ts +6 -0
- package/dist/rules/no-effect-sync-wrapper.js +37 -0
- package/dist/rules/no-effect-type-alias.d.ts +6 -0
- package/dist/rules/no-effect-type-alias.js +52 -0
- package/dist/rules/no-effect-wrapper-alias.d.ts +6 -0
- package/dist/rules/no-effect-wrapper-alias.js +69 -0
- package/dist/rules/no-extends-native-error.d.ts +6 -0
- package/dist/rules/no-extends-native-error.js +41 -0
- package/dist/rules/no-flatmap-ladder.d.ts +6 -0
- package/dist/rules/no-flatmap-ladder.js +48 -0
- package/dist/rules/no-fromnullable-coalesce.d.ts +6 -0
- package/dist/rules/no-fromnullable-coalesce.js +36 -0
- package/dist/rules/no-global-error-in-catch.d.ts +6 -0
- package/dist/rules/no-global-error-in-catch.js +75 -0
- package/dist/rules/no-global-error-in-failure.d.ts +6 -0
- package/dist/rules/no-global-error-in-failure.js +54 -0
- package/dist/rules/no-globals.d.ts +6 -0
- package/dist/rules/no-globals.js +164 -0
- package/dist/rules/no-if-statement.d.ts +6 -0
- package/dist/rules/no-if-statement.js +18 -0
- package/dist/rules/no-iife-wrapper.d.ts +6 -0
- package/dist/rules/no-iife-wrapper.js +37 -0
- package/dist/rules/no-inline-provide.d.ts +6 -0
- package/dist/rules/no-inline-provide.js +31 -0
- package/dist/rules/no-instanceof-schema.d.ts +6 -0
- package/dist/rules/no-instanceof-schema.js +35 -0
- package/dist/rules/no-manual-effect-channels.d.ts +6 -0
- package/dist/rules/no-manual-effect-channels.js +40 -0
- package/dist/rules/no-match-effect-branch.d.ts +6 -0
- package/dist/rules/no-match-effect-branch.js +64 -0
- package/dist/rules/no-match-void-branch.d.ts +6 -0
- package/dist/rules/no-match-void-branch.js +50 -0
- package/dist/rules/no-multiple-effect-provide.d.ts +6 -0
- package/dist/rules/no-multiple-effect-provide.js +45 -0
- package/dist/rules/no-nested-effect-call.d.ts +6 -0
- package/dist/rules/no-nested-effect-call.js +97 -0
- package/dist/rules/no-nested-effect-gen.d.ts +6 -0
- package/dist/rules/no-nested-effect-gen.js +46 -0
- package/dist/rules/no-nested-pipe.d.ts +6 -0
- package/dist/rules/no-nested-pipe.js +38 -0
- package/dist/rules/no-new-error.d.ts +6 -0
- package/dist/rules/no-new-error.js +39 -0
- package/dist/rules/no-new-promise.d.ts +6 -0
- package/dist/rules/no-new-promise.js +38 -0
- package/dist/rules/no-node-builtin-import.d.ts +6 -0
- package/dist/rules/no-node-builtin-import.js +61 -0
- package/dist/rules/no-option-as.d.ts +6 -0
- package/dist/rules/no-option-as.js +16 -0
- package/dist/rules/no-option-boolean-normalization.d.ts +6 -0
- package/dist/rules/no-option-boolean-normalization.js +50 -0
- package/dist/rules/no-positional-log-error.d.ts +6 -0
- package/dist/rules/no-positional-log-error.js +52 -0
- package/dist/rules/no-redundant-schema-tag-identifier.d.ts +6 -0
- package/dist/rules/no-redundant-schema-tag-identifier.js +46 -0
- package/dist/rules/no-return-in-arrow.d.ts +6 -0
- package/dist/rules/no-return-in-arrow.js +41 -0
- package/dist/rules/no-return-nullish.d.ts +6 -0
- package/dist/rules/no-return-nullish.js +47 -0
- package/dist/rules/no-run-in-effect-gen.d.ts +6 -0
- package/dist/rules/no-run-in-effect-gen.js +48 -0
- package/dist/rules/no-runtime-run-fork.d.ts +6 -0
- package/dist/rules/no-runtime-run-fork.js +19 -0
- package/dist/rules/no-schema-struct-with-tag.d.ts +6 -0
- package/dist/rules/no-schema-struct-with-tag.js +48 -0
- package/dist/rules/no-schema-union-of-literals.d.ts +6 -0
- package/dist/rules/no-schema-union-of-literals.js +35 -0
- package/dist/rules/no-string-sentinel-const.d.ts +6 -0
- package/dist/rules/no-string-sentinel-const.js +38 -0
- package/dist/rules/no-switch-statement.d.ts +6 -0
- package/dist/rules/no-switch-statement.js +16 -0
- package/dist/rules/no-ternary.d.ts +6 -0
- package/dist/rules/no-ternary.js +30 -0
- package/dist/rules/no-throw-statement.d.ts +6 -0
- package/dist/rules/no-throw-statement.js +34 -0
- package/dist/rules/no-try-catch.d.ts +6 -0
- package/dist/rules/no-try-catch.js +34 -0
- package/dist/rules/no-unnecessary-arrow-block.d.ts +6 -0
- package/dist/rules/no-unnecessary-arrow-block.js +34 -0
- package/dist/rules/no-unnecessary-effect-gen.d.ts +6 -0
- package/dist/rules/no-unnecessary-effect-gen.js +35 -0
- package/dist/rules/no-unnecessary-pipe-chain.d.ts +6 -0
- package/dist/rules/no-unnecessary-pipe-chain.js +36 -0
- package/dist/rules/no-unnecessary-pipe.d.ts +6 -0
- package/dist/rules/no-unnecessary-pipe.js +29 -0
- package/dist/vendor/effect-oxlint/AST.d.ts +199 -0
- package/dist/vendor/effect-oxlint/AST.js +214 -0
- package/dist/vendor/effect-oxlint/Comment.d.ts +55 -0
- package/dist/vendor/effect-oxlint/Comment.js +67 -0
- package/dist/vendor/effect-oxlint/Diagnostic.d.ts +86 -0
- package/dist/vendor/effect-oxlint/Diagnostic.js +115 -0
- package/dist/vendor/effect-oxlint/Plugin.d.ts +38 -0
- package/dist/vendor/effect-oxlint/Plugin.js +45 -0
- package/dist/vendor/effect-oxlint/Rule.d.ts +218 -0
- package/dist/vendor/effect-oxlint/Rule.js +309 -0
- package/dist/vendor/effect-oxlint/RuleContext.d.ts +77 -0
- package/dist/vendor/effect-oxlint/RuleContext.js +74 -0
- package/dist/vendor/effect-oxlint/Scope.d.ts +100 -0
- package/dist/vendor/effect-oxlint/Scope.js +110 -0
- package/dist/vendor/effect-oxlint/SourceCode.d.ts +180 -0
- package/dist/vendor/effect-oxlint/SourceCode.js +203 -0
- package/dist/vendor/effect-oxlint/Testing.d.ts +510 -0
- package/dist/vendor/effect-oxlint/Testing.js +963 -0
- package/dist/vendor/effect-oxlint/Token.d.ts +98 -0
- package/dist/vendor/effect-oxlint/Token.js +103 -0
- package/dist/vendor/effect-oxlint/Visitor.d.ts +166 -0
- package/dist/vendor/effect-oxlint/Visitor.js +138 -0
- package/dist/vendor/effect-oxlint/index.d.ts +13 -0
- package/dist/vendor/effect-oxlint/index.js +12 -0
- package/package.json +24 -5
- package/.effect-lsp.json +0 -60
- package/.oxlintrc.json +0 -33
- package/CHANGELOG.md +0 -55
- package/scripts/add-rule.ts +0 -87
- package/scripts/codegen.ts +0 -108
- package/src/index.ts +0 -9
- package/src/plugin.ts +0 -16
- package/src/presets/core.ts +0 -47
- package/src/presets/effect-native.ts +0 -34
- package/src/presets/full.ts +0 -70
- package/src/presets/functional.ts +0 -18
- package/src/presets/index.ts +0 -5
- package/src/presets/strict.ts +0 -77
- package/src/rules/_effect-context.ts +0 -28
- package/src/rules/index.ts +0 -72
- package/src/rules/no-arrow-ladder.ts +0 -70
- package/src/rules/no-async-function.ts +0 -47
- package/src/rules/no-catch-all-to-map-error.ts +0 -90
- package/src/rules/no-effect-as.ts +0 -14
- package/src/rules/no-effect-async.ts +0 -14
- package/src/rules/no-effect-bind.ts +0 -13
- package/src/rules/no-effect-do.ts +0 -14
- package/src/rules/no-effect-fn-generator.ts +0 -58
- package/src/rules/no-effect-gen-adapter.ts +0 -51
- package/src/rules/no-effect-map-flatten.ts +0 -82
- package/src/rules/no-effect-map-void.ts +0 -80
- package/src/rules/no-effect-never.ts +0 -14
- package/src/rules/no-effect-orElse-ladder.ts +0 -79
- package/src/rules/no-effect-succeed-string.ts +0 -52
- package/src/rules/no-effect-succeed-variable.ts +0 -50
- package/src/rules/no-effect-succeed-void.ts +0 -63
- package/src/rules/no-effect-sync-console.ts +0 -91
- package/src/rules/no-effect-sync-wrapper.ts +0 -67
- package/src/rules/no-effect-type-alias.ts +0 -71
- package/src/rules/no-effect-wrapper-alias.ts +0 -95
- package/src/rules/no-extends-native-error.ts +0 -54
- package/src/rules/no-flatmap-ladder.ts +0 -77
- package/src/rules/no-fromnullable-coalesce.ts +0 -62
- package/src/rules/no-global-error-in-catch.ts +0 -104
- package/src/rules/no-global-error-in-failure.ts +0 -83
- package/src/rules/no-globals.ts +0 -178
- package/src/rules/no-if-statement.ts +0 -16
- package/src/rules/no-iife-wrapper.ts +0 -51
- package/src/rules/no-inline-provide.ts +0 -41
- package/src/rules/no-instanceof-schema.ts +0 -42
- package/src/rules/no-manual-effect-channels.ts +0 -58
- package/src/rules/no-match-effect-branch.ts +0 -82
- package/src/rules/no-match-void-branch.ts +0 -72
- package/src/rules/no-multiple-effect-provide.ts +0 -75
- package/src/rules/no-nested-effect-call.ts +0 -57
- package/src/rules/no-nested-effect-gen.ts +0 -43
- package/src/rules/no-nested-pipe.ts +0 -73
- package/src/rules/no-new-error.ts +0 -53
- package/src/rules/no-new-promise.ts +0 -50
- package/src/rules/no-node-builtin-import.ts +0 -68
- package/src/rules/no-option-as.ts +0 -13
- package/src/rules/no-option-boolean-normalization.ts +0 -88
- package/src/rules/no-positional-log-error.ts +0 -76
- package/src/rules/no-redundant-schema-tag-identifier.ts +0 -62
- package/src/rules/no-return-in-arrow.ts +0 -76
- package/src/rules/no-return-nullish.ts +0 -80
- package/src/rules/no-run-in-effect-gen.ts +0 -66
- package/src/rules/no-runtime-run-fork.ts +0 -14
- package/src/rules/no-schema-struct-with-tag.ts +0 -64
- package/src/rules/no-schema-union-of-literals.ts +0 -48
- package/src/rules/no-string-sentinel-const.ts +0 -49
- package/src/rules/no-switch-statement.ts +0 -13
- package/src/rules/no-ternary.ts +0 -30
- package/src/rules/no-throw-statement.ts +0 -39
- package/src/rules/no-try-catch.ts +0 -39
- package/src/rules/no-unnecessary-arrow-block.ts +0 -51
- package/src/rules/no-unnecessary-effect-gen.ts +0 -83
- package/src/rules/no-unnecessary-pipe-chain.ts +0 -47
- package/src/rules/no-unnecessary-pipe.ts +0 -45
- package/src/vendor/effect-oxlint/AST.ts +0 -516
- package/src/vendor/effect-oxlint/Comment.ts +0 -86
- package/src/vendor/effect-oxlint/Diagnostic.ts +0 -199
- package/src/vendor/effect-oxlint/Plugin.ts +0 -71
- package/src/vendor/effect-oxlint/Rule.ts +0 -548
- package/src/vendor/effect-oxlint/RuleContext.ts +0 -144
- package/src/vendor/effect-oxlint/Scope.ts +0 -177
- package/src/vendor/effect-oxlint/SourceCode.ts +0 -377
- package/src/vendor/effect-oxlint/Testing.ts +0 -1227
- package/src/vendor/effect-oxlint/Token.ts +0 -131
- package/src/vendor/effect-oxlint/Visitor.ts +0 -287
- package/src/vendor/effect-oxlint/index.ts +0 -88
- package/tests/ban-rules.test.ts +0 -68
- package/tests/context-rules.test.ts +0 -263
- package/tests/pattern-rules.test.ts +0 -247
- package/tsconfig.json +0 -15
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { RuleContext } from "./RuleContext.js";
|
|
2
|
+
import * as Option from "effect/Option";
|
|
3
|
+
import * as Effect from "effect/Effect";
|
|
4
|
+
import { Comment, ESTree, LineColumn, Range, Scope, Token, Variable } from "@oxlint/plugins";
|
|
5
|
+
|
|
6
|
+
//#region src/vendor/effect-oxlint/SourceCode.d.ts
|
|
7
|
+
declare namespace SourceCode_d_exports {
|
|
8
|
+
export { commentsExistBetween, getAllComments, getAncestors, getCommentsAfter, getCommentsBefore, getCommentsInside, getDeclaredVariables, getFirstToken, getFirstTokenBetween, getIndexFromLoc, getJSDocComment, getLastToken, getLines, getLocFromIndex, getNodeByRangeIndex, getRange, getScope, getText, getTokenAfter, getTokenBefore, getTokenByRangeStart, getTokens, getTokensBetween, isGlobalReference, isSpaceBetween, markVariableAsUsed };
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Get the source text for a node, optionally with surrounding characters.
|
|
12
|
+
*
|
|
13
|
+
* When called with no arguments, returns the entire source text.
|
|
14
|
+
* Pass an `Option<ESTree.Node>` to get text for a specific node.
|
|
15
|
+
*
|
|
16
|
+
* @since 0.2.0
|
|
17
|
+
*/
|
|
18
|
+
declare const getText: {
|
|
19
|
+
(): Effect.Effect<string, never, RuleContext>;
|
|
20
|
+
(node: Option.Option<ESTree.Node>, beforeCount?: number, afterCount?: number): Effect.Effect<string, never, RuleContext>;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Get the ancestor nodes of the given node, from innermost to outermost.
|
|
24
|
+
*
|
|
25
|
+
* Note: oxlint types `getAncestors` as returning `Node[]` where `Node`
|
|
26
|
+
* is the base `Span` interface. At runtime these are full `ESTree.Node`
|
|
27
|
+
* values — the cast bridges this upstream type gap at the FFI boundary.
|
|
28
|
+
*
|
|
29
|
+
* @since 0.2.0
|
|
30
|
+
*/
|
|
31
|
+
declare const getAncestors: (node: ESTree.Node) => Effect.Effect<ReadonlyArray<ESTree.Node>, never, RuleContext>;
|
|
32
|
+
/**
|
|
33
|
+
* Get the AST node that contains the given source offset.
|
|
34
|
+
*
|
|
35
|
+
* Returns `Option.none()` when no node spans that offset.
|
|
36
|
+
*
|
|
37
|
+
* @since 0.2.0
|
|
38
|
+
*/
|
|
39
|
+
declare const getNodeByRangeIndex: (offset: number) => Effect.Effect<Option.Option<ESTree.Node>, never, RuleContext>;
|
|
40
|
+
/**
|
|
41
|
+
* Convert a source offset (0-based) to a `{ line, column }` location.
|
|
42
|
+
*
|
|
43
|
+
* @since 0.2.0
|
|
44
|
+
*/
|
|
45
|
+
declare const getLocFromIndex: (offset: number) => Effect.Effect<LineColumn, never, RuleContext>;
|
|
46
|
+
/**
|
|
47
|
+
* Convert a `{ line, column }` location to a source offset (0-based).
|
|
48
|
+
*
|
|
49
|
+
* @since 0.2.0
|
|
50
|
+
*/
|
|
51
|
+
declare const getIndexFromLoc: (loc: LineColumn) => Effect.Effect<number, never, RuleContext>;
|
|
52
|
+
/**
|
|
53
|
+
* Get the range `[start, end]` for a node or token.
|
|
54
|
+
*
|
|
55
|
+
* @since 0.2.0
|
|
56
|
+
*/
|
|
57
|
+
declare const getRange: (nodeOrToken: ESTree.Node | Token | Comment) => Effect.Effect<Range, never, RuleContext>;
|
|
58
|
+
/**
|
|
59
|
+
* Get the first token of a node.
|
|
60
|
+
*
|
|
61
|
+
* @since 0.2.0
|
|
62
|
+
*/
|
|
63
|
+
declare const getFirstToken: (node: ESTree.Node) => Effect.Effect<Option.Option<Token>, never, RuleContext>;
|
|
64
|
+
/**
|
|
65
|
+
* Get the last token of a node.
|
|
66
|
+
*
|
|
67
|
+
* @since 0.2.0
|
|
68
|
+
*/
|
|
69
|
+
declare const getLastToken: (node: ESTree.Node) => Effect.Effect<Option.Option<Token>, never, RuleContext>;
|
|
70
|
+
/**
|
|
71
|
+
* Get all tokens for a node.
|
|
72
|
+
*
|
|
73
|
+
* @since 0.2.0
|
|
74
|
+
*/
|
|
75
|
+
declare const getTokens: (node: ESTree.Node) => Effect.Effect<ReadonlyArray<Token>, never, RuleContext>;
|
|
76
|
+
/**
|
|
77
|
+
* Get the token before a node or token.
|
|
78
|
+
*
|
|
79
|
+
* @since 0.2.0
|
|
80
|
+
*/
|
|
81
|
+
declare const getTokenBefore: (nodeOrToken: ESTree.Node | Token | Comment) => Effect.Effect<Option.Option<Token>, never, RuleContext>;
|
|
82
|
+
/**
|
|
83
|
+
* Get the token after a node or token.
|
|
84
|
+
*
|
|
85
|
+
* @since 0.2.0
|
|
86
|
+
*/
|
|
87
|
+
declare const getTokenAfter: (nodeOrToken: ESTree.Node | Token | Comment) => Effect.Effect<Option.Option<Token>, never, RuleContext>;
|
|
88
|
+
/**
|
|
89
|
+
* Get all tokens between two nodes/tokens.
|
|
90
|
+
*
|
|
91
|
+
* @since 0.2.0
|
|
92
|
+
*/
|
|
93
|
+
declare const getTokensBetween: (left: ESTree.Node | Token | Comment, right: ESTree.Node | Token | Comment) => Effect.Effect<ReadonlyArray<Token>, never, RuleContext>;
|
|
94
|
+
/**
|
|
95
|
+
* Get the first token between two nodes/tokens.
|
|
96
|
+
*
|
|
97
|
+
* @since 0.2.0
|
|
98
|
+
*/
|
|
99
|
+
declare const getFirstTokenBetween: (left: ESTree.Node | Token | Comment, right: ESTree.Node | Token | Comment) => Effect.Effect<Option.Option<Token>, never, RuleContext>;
|
|
100
|
+
/**
|
|
101
|
+
* Find a token by its range start offset.
|
|
102
|
+
*
|
|
103
|
+
* @since 0.2.0
|
|
104
|
+
*/
|
|
105
|
+
declare const getTokenByRangeStart: (offset: number) => Effect.Effect<Option.Option<Token>, never, RuleContext>;
|
|
106
|
+
/**
|
|
107
|
+
* Get all comments in the file.
|
|
108
|
+
*
|
|
109
|
+
* @since 0.2.0
|
|
110
|
+
*/
|
|
111
|
+
declare const getAllComments: () => Effect.Effect<ReadonlyArray<Comment>, never, RuleContext>;
|
|
112
|
+
/**
|
|
113
|
+
* Get comments before a node or token.
|
|
114
|
+
*
|
|
115
|
+
* @since 0.2.0
|
|
116
|
+
*/
|
|
117
|
+
declare const getCommentsBefore: (nodeOrToken: ESTree.Node | Token | Comment) => Effect.Effect<ReadonlyArray<Comment>, never, RuleContext>;
|
|
118
|
+
/**
|
|
119
|
+
* Get comments after a node or token.
|
|
120
|
+
*
|
|
121
|
+
* @since 0.2.0
|
|
122
|
+
*/
|
|
123
|
+
declare const getCommentsAfter: (nodeOrToken: ESTree.Node | Token | Comment) => Effect.Effect<ReadonlyArray<Comment>, never, RuleContext>;
|
|
124
|
+
/**
|
|
125
|
+
* Get comments inside a node.
|
|
126
|
+
*
|
|
127
|
+
* @since 0.2.0
|
|
128
|
+
*/
|
|
129
|
+
declare const getCommentsInside: (node: ESTree.Node) => Effect.Effect<ReadonlyArray<Comment>, never, RuleContext>;
|
|
130
|
+
/**
|
|
131
|
+
* Check whether comments exist between two nodes/tokens.
|
|
132
|
+
*
|
|
133
|
+
* @since 0.2.0
|
|
134
|
+
*/
|
|
135
|
+
declare const commentsExistBetween: (left: ESTree.Node | Token | Comment, right: ESTree.Node | Token | Comment) => Effect.Effect<boolean, never, RuleContext>;
|
|
136
|
+
/**
|
|
137
|
+
* Get the JSDoc comment for a node.
|
|
138
|
+
*
|
|
139
|
+
* @deprecated Upstream deprecation. Use `getCommentsBefore` instead.
|
|
140
|
+
* @since 0.2.0
|
|
141
|
+
*/
|
|
142
|
+
declare const getJSDocComment: (node: ESTree.Node) => Effect.Effect<Option.Option<Comment>, never, RuleContext>;
|
|
143
|
+
/**
|
|
144
|
+
* Get the scope for a node.
|
|
145
|
+
*
|
|
146
|
+
* @since 0.2.0
|
|
147
|
+
*/
|
|
148
|
+
declare const getScope: (node: ESTree.Node) => Effect.Effect<Scope, never, RuleContext>;
|
|
149
|
+
/**
|
|
150
|
+
* Get declared variables for a node.
|
|
151
|
+
*
|
|
152
|
+
* @since 0.2.0
|
|
153
|
+
*/
|
|
154
|
+
declare const getDeclaredVariables: (node: ESTree.Node) => Effect.Effect<ReadonlyArray<Variable>, never, RuleContext>;
|
|
155
|
+
/**
|
|
156
|
+
* Check whether a node is a global reference.
|
|
157
|
+
*
|
|
158
|
+
* @since 0.2.0
|
|
159
|
+
*/
|
|
160
|
+
declare const isGlobalReference: (node: ESTree.Node) => Effect.Effect<boolean, never, RuleContext>;
|
|
161
|
+
/**
|
|
162
|
+
* Mark a variable as used in the scope of the given node.
|
|
163
|
+
*
|
|
164
|
+
* @since 0.2.0
|
|
165
|
+
*/
|
|
166
|
+
declare const markVariableAsUsed: (name: string, refNode?: ESTree.Node) => Effect.Effect<boolean, never, RuleContext>;
|
|
167
|
+
/**
|
|
168
|
+
* Check whether there is a space between two nodes/tokens.
|
|
169
|
+
*
|
|
170
|
+
* @since 0.2.0
|
|
171
|
+
*/
|
|
172
|
+
declare const isSpaceBetween: (first: ESTree.Node | Token | Comment, second: ESTree.Node | Token | Comment) => Effect.Effect<boolean, never, RuleContext>;
|
|
173
|
+
/**
|
|
174
|
+
* Get all source lines.
|
|
175
|
+
*
|
|
176
|
+
* @since 0.2.0
|
|
177
|
+
*/
|
|
178
|
+
declare const getLines: () => Effect.Effect<ReadonlyArray<string>, never, RuleContext>;
|
|
179
|
+
//#endregion
|
|
180
|
+
export { SourceCode_d_exports, commentsExistBetween, getAllComments, getAncestors, getCommentsAfter, getCommentsBefore, getCommentsInside, getDeclaredVariables, getFirstToken, getFirstTokenBetween, getIndexFromLoc, getJSDocComment, getLastToken, getLines, getLocFromIndex, getNodeByRangeIndex, getRange, getScope, getText, getTokenAfter, getTokenBefore, getTokenByRangeStart, getTokens, getTokensBetween, isGlobalReference, isSpaceBetween, markVariableAsUsed };
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { __exportAll } from "../../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { RuleContext } from "./RuleContext.js";
|
|
3
|
+
import * as Option from "effect/Option";
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
//#region src/vendor/effect-oxlint/SourceCode.ts
|
|
6
|
+
var SourceCode_exports = /* @__PURE__ */ __exportAll({
|
|
7
|
+
commentsExistBetween: () => commentsExistBetween,
|
|
8
|
+
getAllComments: () => getAllComments,
|
|
9
|
+
getAncestors: () => getAncestors,
|
|
10
|
+
getCommentsAfter: () => getCommentsAfter,
|
|
11
|
+
getCommentsBefore: () => getCommentsBefore,
|
|
12
|
+
getCommentsInside: () => getCommentsInside,
|
|
13
|
+
getDeclaredVariables: () => getDeclaredVariables,
|
|
14
|
+
getFirstToken: () => getFirstToken,
|
|
15
|
+
getFirstTokenBetween: () => getFirstTokenBetween,
|
|
16
|
+
getIndexFromLoc: () => getIndexFromLoc,
|
|
17
|
+
getJSDocComment: () => getJSDocComment,
|
|
18
|
+
getLastToken: () => getLastToken,
|
|
19
|
+
getLines: () => getLines,
|
|
20
|
+
getLocFromIndex: () => getLocFromIndex,
|
|
21
|
+
getNodeByRangeIndex: () => getNodeByRangeIndex,
|
|
22
|
+
getRange: () => getRange,
|
|
23
|
+
getScope: () => getScope,
|
|
24
|
+
getText: () => getText,
|
|
25
|
+
getTokenAfter: () => getTokenAfter,
|
|
26
|
+
getTokenBefore: () => getTokenBefore,
|
|
27
|
+
getTokenByRangeStart: () => getTokenByRangeStart,
|
|
28
|
+
getTokens: () => getTokens,
|
|
29
|
+
getTokensBetween: () => getTokensBetween,
|
|
30
|
+
isGlobalReference: () => isGlobalReference,
|
|
31
|
+
isSpaceBetween: () => isSpaceBetween,
|
|
32
|
+
markVariableAsUsed: () => markVariableAsUsed
|
|
33
|
+
});
|
|
34
|
+
/** @internal */
|
|
35
|
+
const withSourceCode = (fn) => Effect.service(RuleContext).pipe(Effect.map((ctx) => fn(ctx.sourceCode)));
|
|
36
|
+
/**
|
|
37
|
+
* Get the source text for a node, optionally with surrounding characters.
|
|
38
|
+
*
|
|
39
|
+
* When called with no arguments, returns the entire source text.
|
|
40
|
+
* Pass an `Option<ESTree.Node>` to get text for a specific node.
|
|
41
|
+
*
|
|
42
|
+
* @since 0.2.0
|
|
43
|
+
*/
|
|
44
|
+
const getText = (node, beforeCount, afterCount) => withSourceCode((sc) => sc.getText(node === void 0 ? null : Option.getOrElse(node, () => null), beforeCount, afterCount));
|
|
45
|
+
/**
|
|
46
|
+
* Get the ancestor nodes of the given node, from innermost to outermost.
|
|
47
|
+
*
|
|
48
|
+
* Note: oxlint types `getAncestors` as returning `Node[]` where `Node`
|
|
49
|
+
* is the base `Span` interface. At runtime these are full `ESTree.Node`
|
|
50
|
+
* values — the cast bridges this upstream type gap at the FFI boundary.
|
|
51
|
+
*
|
|
52
|
+
* @since 0.2.0
|
|
53
|
+
*/
|
|
54
|
+
const getAncestors = (node) => withSourceCode((sc) => sc.getAncestors(node));
|
|
55
|
+
/**
|
|
56
|
+
* Get the AST node that contains the given source offset.
|
|
57
|
+
*
|
|
58
|
+
* Returns `Option.none()` when no node spans that offset.
|
|
59
|
+
*
|
|
60
|
+
* @since 0.2.0
|
|
61
|
+
*/
|
|
62
|
+
const getNodeByRangeIndex = (offset) => withSourceCode((sc) => Option.fromNullishOr(sc.getNodeByRangeIndex(offset)));
|
|
63
|
+
/**
|
|
64
|
+
* Convert a source offset (0-based) to a `{ line, column }` location.
|
|
65
|
+
*
|
|
66
|
+
* @since 0.2.0
|
|
67
|
+
*/
|
|
68
|
+
const getLocFromIndex = (offset) => withSourceCode((sc) => sc.getLocFromIndex(offset));
|
|
69
|
+
/**
|
|
70
|
+
* Convert a `{ line, column }` location to a source offset (0-based).
|
|
71
|
+
*
|
|
72
|
+
* @since 0.2.0
|
|
73
|
+
*/
|
|
74
|
+
const getIndexFromLoc = (loc) => withSourceCode((sc) => sc.getIndexFromLoc(loc));
|
|
75
|
+
/**
|
|
76
|
+
* Get the range `[start, end]` for a node or token.
|
|
77
|
+
*
|
|
78
|
+
* @since 0.2.0
|
|
79
|
+
*/
|
|
80
|
+
const getRange = (nodeOrToken) => withSourceCode((sc) => sc.getRange(nodeOrToken));
|
|
81
|
+
/**
|
|
82
|
+
* Get the first token of a node.
|
|
83
|
+
*
|
|
84
|
+
* @since 0.2.0
|
|
85
|
+
*/
|
|
86
|
+
const getFirstToken = (node) => withSourceCode((sc) => Option.fromNullishOr(sc.getFirstToken(node)));
|
|
87
|
+
/**
|
|
88
|
+
* Get the last token of a node.
|
|
89
|
+
*
|
|
90
|
+
* @since 0.2.0
|
|
91
|
+
*/
|
|
92
|
+
const getLastToken = (node) => withSourceCode((sc) => Option.fromNullishOr(sc.getLastToken(node)));
|
|
93
|
+
/**
|
|
94
|
+
* Get all tokens for a node.
|
|
95
|
+
*
|
|
96
|
+
* @since 0.2.0
|
|
97
|
+
*/
|
|
98
|
+
const getTokens = (node) => withSourceCode((sc) => sc.getTokens(node));
|
|
99
|
+
/**
|
|
100
|
+
* Get the token before a node or token.
|
|
101
|
+
*
|
|
102
|
+
* @since 0.2.0
|
|
103
|
+
*/
|
|
104
|
+
const getTokenBefore = (nodeOrToken) => withSourceCode((sc) => Option.fromNullishOr(sc.getTokenBefore(nodeOrToken)));
|
|
105
|
+
/**
|
|
106
|
+
* Get the token after a node or token.
|
|
107
|
+
*
|
|
108
|
+
* @since 0.2.0
|
|
109
|
+
*/
|
|
110
|
+
const getTokenAfter = (nodeOrToken) => withSourceCode((sc) => Option.fromNullishOr(sc.getTokenAfter(nodeOrToken)));
|
|
111
|
+
/**
|
|
112
|
+
* Get all tokens between two nodes/tokens.
|
|
113
|
+
*
|
|
114
|
+
* @since 0.2.0
|
|
115
|
+
*/
|
|
116
|
+
const getTokensBetween = (left, right) => withSourceCode((sc) => sc.getTokensBetween(left, right));
|
|
117
|
+
/**
|
|
118
|
+
* Get the first token between two nodes/tokens.
|
|
119
|
+
*
|
|
120
|
+
* @since 0.2.0
|
|
121
|
+
*/
|
|
122
|
+
const getFirstTokenBetween = (left, right) => withSourceCode((sc) => Option.fromNullishOr(sc.getFirstTokenBetween(left, right)));
|
|
123
|
+
/**
|
|
124
|
+
* Find a token by its range start offset.
|
|
125
|
+
*
|
|
126
|
+
* @since 0.2.0
|
|
127
|
+
*/
|
|
128
|
+
const getTokenByRangeStart = (offset) => withSourceCode((sc) => Option.fromNullishOr(sc.getTokenByRangeStart(offset)));
|
|
129
|
+
/**
|
|
130
|
+
* Get all comments in the file.
|
|
131
|
+
*
|
|
132
|
+
* @since 0.2.0
|
|
133
|
+
*/
|
|
134
|
+
const getAllComments = () => withSourceCode((sc) => sc.getAllComments());
|
|
135
|
+
/**
|
|
136
|
+
* Get comments before a node or token.
|
|
137
|
+
*
|
|
138
|
+
* @since 0.2.0
|
|
139
|
+
*/
|
|
140
|
+
const getCommentsBefore = (nodeOrToken) => withSourceCode((sc) => sc.getCommentsBefore(nodeOrToken));
|
|
141
|
+
/**
|
|
142
|
+
* Get comments after a node or token.
|
|
143
|
+
*
|
|
144
|
+
* @since 0.2.0
|
|
145
|
+
*/
|
|
146
|
+
const getCommentsAfter = (nodeOrToken) => withSourceCode((sc) => sc.getCommentsAfter(nodeOrToken));
|
|
147
|
+
/**
|
|
148
|
+
* Get comments inside a node.
|
|
149
|
+
*
|
|
150
|
+
* @since 0.2.0
|
|
151
|
+
*/
|
|
152
|
+
const getCommentsInside = (node) => withSourceCode((sc) => sc.getCommentsInside(node));
|
|
153
|
+
/**
|
|
154
|
+
* Check whether comments exist between two nodes/tokens.
|
|
155
|
+
*
|
|
156
|
+
* @since 0.2.0
|
|
157
|
+
*/
|
|
158
|
+
const commentsExistBetween = (left, right) => withSourceCode((sc) => sc.commentsExistBetween(left, right));
|
|
159
|
+
/**
|
|
160
|
+
* Get the JSDoc comment for a node.
|
|
161
|
+
*
|
|
162
|
+
* @deprecated Upstream deprecation. Use `getCommentsBefore` instead.
|
|
163
|
+
* @since 0.2.0
|
|
164
|
+
*/
|
|
165
|
+
const getJSDocComment = (node) => withSourceCode((sc) => Option.fromNullishOr(sc.getJSDocComment(node)));
|
|
166
|
+
/**
|
|
167
|
+
* Get the scope for a node.
|
|
168
|
+
*
|
|
169
|
+
* @since 0.2.0
|
|
170
|
+
*/
|
|
171
|
+
const getScope = (node) => withSourceCode((sc) => sc.getScope(node));
|
|
172
|
+
/**
|
|
173
|
+
* Get declared variables for a node.
|
|
174
|
+
*
|
|
175
|
+
* @since 0.2.0
|
|
176
|
+
*/
|
|
177
|
+
const getDeclaredVariables = (node) => withSourceCode((sc) => sc.getDeclaredVariables(node));
|
|
178
|
+
/**
|
|
179
|
+
* Check whether a node is a global reference.
|
|
180
|
+
*
|
|
181
|
+
* @since 0.2.0
|
|
182
|
+
*/
|
|
183
|
+
const isGlobalReference = (node) => withSourceCode((sc) => sc.isGlobalReference(node));
|
|
184
|
+
/**
|
|
185
|
+
* Mark a variable as used in the scope of the given node.
|
|
186
|
+
*
|
|
187
|
+
* @since 0.2.0
|
|
188
|
+
*/
|
|
189
|
+
const markVariableAsUsed = (name, refNode) => withSourceCode((sc) => sc.markVariableAsUsed(name, refNode));
|
|
190
|
+
/**
|
|
191
|
+
* Check whether there is a space between two nodes/tokens.
|
|
192
|
+
*
|
|
193
|
+
* @since 0.2.0
|
|
194
|
+
*/
|
|
195
|
+
const isSpaceBetween = (first, second) => withSourceCode((sc) => sc.isSpaceBetween(first, second));
|
|
196
|
+
/**
|
|
197
|
+
* Get all source lines.
|
|
198
|
+
*
|
|
199
|
+
* @since 0.2.0
|
|
200
|
+
*/
|
|
201
|
+
const getLines = () => withSourceCode((sc) => sc.getLines());
|
|
202
|
+
//#endregion
|
|
203
|
+
export { SourceCode_exports, commentsExistBetween, getAllComments, getAncestors, getCommentsAfter, getCommentsBefore, getCommentsInside, getDeclaredVariables, getFirstToken, getFirstTokenBetween, getIndexFromLoc, getJSDocComment, getLastToken, getLines, getLocFromIndex, getNodeByRangeIndex, getRange, getScope, getText, getTokenAfter, getTokenBefore, getTokenByRangeStart, getTokens, getTokensBetween, isGlobalReference, isSpaceBetween, markVariableAsUsed };
|