Skip to content
This repository has been archived by the owner on Oct 6, 2020. It is now read-only.

Commit

Permalink
feat: Improved selectors-format rule to forbid optional arguments
Browse files Browse the repository at this point in the history
resolves #65
  • Loading branch information
Aldredcz committed Apr 1, 2020
1 parent e2d805e commit da6ba32
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,12 @@ select(
~~~~~~~~~~~~~~ [Default arguments are forbidden.]
);
select(
[Store],
(a?: number) => false,
~~~~~~~~~~ [Optional arguments are forbidden.]
);
select(
[Store],
(abc, xyz) => false,
Expand Down
7 changes: 7 additions & 0 deletions src/rules/selectorsFormatRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,13 @@ class SelectorsFormatRule extends Lint.RuleWalker {
);
}

if (paramNode.questionToken) {
this.addFailureAtNode(
paramNode,
this.getFormattedError('Optional arguments are forbidden.'),
);
}

if (!paramNode.type) {
this.addFailureAtNode(
paramNode,
Expand Down
6 changes: 6 additions & 0 deletions test/rules/selectors-format/test.2.tsx.lint
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ select(
~~~~~~~~~~~~~~ [Default arguments are forbidden.]
);

select(
[Store],
(a?: number) => false,
~~~~~~~~~~ [Optional arguments are forbidden.]
);

select(
[Store],
(abc, xyz) => false,
Expand Down

0 comments on commit da6ba32

Please sign in to comment.