Skip to content

Commit

Permalink
Non-nullable validators
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaKGoldberg committed Jan 31, 2023
1 parent 2073b68 commit 3a7aed3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
Expand Up @@ -64,7 +64,7 @@ type ValidatorFunction = (
node: TSESTree.Identifier | TSESTree.PrivateIdentifier | TSESTree.Literal,
modifiers?: Set<Modifiers>,
) => void;
type ParsedOptions = Record<SelectorsString, null | ValidatorFunction>;
type ParsedOptions = Record<SelectorsString, ValidatorFunction>;
type Context = Readonly<TSESLint.RuleContext<MessageIds, Options>>;

export type {
Expand Down
5 changes: 1 addition & 4 deletions packages/eslint-plugin/src/rules/naming-convention.ts
Expand Up @@ -217,7 +217,7 @@ export default util.createRule<Options, MessageIds>({

const selectors: {
readonly [k in keyof TSESLint.RuleListener]: Readonly<{
validator: ValidatorFunction | null;
validator: ValidatorFunction;
handler: (
node: Parameters<NonNullable<TSESLint.RuleListener[k]>>[0],
validator: ValidatorFunction,
Expand Down Expand Up @@ -643,9 +643,6 @@ export default util.createRule<Options, MessageIds>({
return Object.fromEntries(
Object.entries(selectors)
.map(([selector, { validator, handler }]) => {
if (validator == null) {
return null;
}
return [
selector,
(node: Parameters<typeof handler>[0]): void => {
Expand Down

0 comments on commit 3a7aed3

Please sign in to comment.