Skip to content

Commit

Permalink
chore(eslint-plugin): remove workaround for syntax errors
Browse files Browse the repository at this point in the history
  • Loading branch information
sosukesuzuki committed May 13, 2022
1 parent 7fdbf2d commit efc1b15
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
3 changes: 1 addition & 2 deletions packages/eslint-plugin/src/rules/ban-types.ts
Expand Up @@ -185,8 +185,7 @@ export default util.createRule<Options, MessageIds>({
customMessage,
},
fix: fixWith
? (fixer: TSESLint.RuleFixer): TSESLint.RuleFix =>
fixer.replaceText(typeNode, fixWith)
? (fixer): TSESLint.RuleFix => fixer.replaceText(typeNode, fixWith)
: null,
});
}
Expand Down
Expand Up @@ -84,7 +84,7 @@ export default createRule<Options, MessageIds>({
node,
messageId: 'preferRecord',
fix: safeFix
? (fixer: TSESLint.RuleFixer): TSESLint.RuleFix => {
? (fixer): TSESLint.RuleFix => {
const key = sourceCode.getText(keyType.typeAnnotation);
const value = sourceCode.getText(valueType.typeAnnotation);
const record = member.readonly
Expand Down
12 changes: 5 additions & 7 deletions packages/eslint-plugin/src/util/getESLintCoreRule.ts
Expand Up @@ -42,18 +42,16 @@ type RuleId = keyof RuleMap;

export const getESLintCoreRule: <R extends RuleId>(ruleId: R) => RuleMap[R] =
isESLintV8
? function <R extends RuleId>(ruleId: R): RuleMap[R] {
return ESLintUtils.nullThrows(
? <R extends RuleId>(ruleId: R): RuleMap[R] =>
ESLintUtils.nullThrows(
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
require('eslint/use-at-your-own-risk').builtinRules.get(
ruleId,
) as RuleMap[R],
`ESLint's core rule '${ruleId}' not found.`,
);
}
: function <R extends RuleId>(ruleId: R): RuleMap[R] {
return require(`eslint/lib/rules/${ruleId}`) as RuleMap[R];
};
)
: <R extends RuleId>(ruleId: R): RuleMap[R] =>
require(`eslint/lib/rules/${ruleId}`) as RuleMap[R];

export function maybeGetESLintCoreRule<R extends RuleId>(
ruleId: R,
Expand Down

0 comments on commit efc1b15

Please sign in to comment.