-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(no-use-context): removing imports should also remove the associat… (
#932)
- Loading branch information
Showing
11 changed files
with
54 additions
and
412 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
packages/plugins/eslint-plugin-react-x/src/utils/get-associated-tokens.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import type { RuleContext } from "@eslint-react/shared"; | ||
import type { TSESTree } from "@typescript-eslint/types"; | ||
|
||
export function getAssociatedTokens( | ||
context: RuleContext, | ||
node: TSESTree.Node, | ||
) { | ||
{ | ||
const tokenBefore = context.sourceCode.getTokenBefore(node); | ||
const tokenAfter = context.sourceCode.getTokenAfter(node); | ||
const tokens = []; | ||
|
||
// If this is not the only entry, then the line above this one | ||
// will become the last line, and should not have a trailing comma. | ||
if (tokenAfter?.value !== "," && tokenBefore?.value === ",") { | ||
tokens.push(tokenBefore); | ||
} | ||
|
||
// If this is not the last entry, then we need to remove the comma from this line. | ||
if (tokenAfter?.value === ",") { | ||
tokens.push(tokenAfter); | ||
} | ||
|
||
return tokens; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from "./create-rule"; | ||
export * from "./get-associated-tokens"; |
Oops, something went wrong.