Skip to content

Commit

Permalink
fix: don't do charnode twice
Browse files Browse the repository at this point in the history
  • Loading branch information
mshanemc committed Dec 5, 2022
1 parent 69fa0b7 commit 902dfe1
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/rules/noDuplicateShortCharacters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,12 @@ export const noDuplicateShortCharacters = ESLintUtils.RuleCreator.withoutDocs({
if (
flag.type === AST_NODE_TYPES.Property &&
flag.value.type === AST_NODE_TYPES.CallExpression &&
flag.value.arguments?.[0]?.type === AST_NODE_TYPES.ObjectExpression &&
flag.value.arguments?.[0]?.properties.some(
(p) => p.type === AST_NODE_TYPES.Property && flagPropertyIsNamed(p, 'char')
)
flag.value.arguments?.[0]?.type === AST_NODE_TYPES.ObjectExpression
) {
const charNode = flag.value.arguments[0].properties.find(
(p) => p.type === AST_NODE_TYPES.Property && flagPropertyIsNamed(p, 'char')
);
if (charNode.type === AST_NODE_TYPES.Property && charNode.value.type === AST_NODE_TYPES.Literal) {
if (charNode?.type === AST_NODE_TYPES.Property && charNode.value.type === AST_NODE_TYPES.Literal) {
const char = charNode.value.raw;
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const flagName = resolveFlagName(flag);
Expand Down

0 comments on commit 902dfe1

Please sign in to comment.