Skip to content

Commit a18bc22

Browse files
committed
feat: match-name rule; fixes gajus#509
1 parent 2dcd9ad commit a18bc22

File tree

9 files changed

+965
-102
lines changed

9 files changed

+965
-102
lines changed

.README/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,7 @@ selector).
557557
{"gitdown": "include", "file": "./rules/empty-tags.md"}
558558
{"gitdown": "include", "file": "./rules/implements-on-classes.md"}
559559
{"gitdown": "include", "file": "./rules/match-description.md"}
560+
{"gitdown": "include", "file": "./rules/match-name.md"}
560561
{"gitdown": "include", "file": "./rules/multiline-blocks.md"}
561562
{"gitdown": "include", "file": "./rules/newline-after-description.md"}
562563
{"gitdown": "include", "file": "./rules/no-bad-blocks.md"}

.README/rules/match-name.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
### `match-name`
2+
3+
Reports the name portion of a JSDoc tag if matching or not matching
4+
a given regular expression.
5+
6+
Note that some tags do not possess names and anything appearing to be a
7+
name will actually be part of the description (e.g., for
8+
`@returns {type} notAName`). If you are defining your own tags, see the
9+
`structuredTags` setting (if `name: false`, this rule will not apply to
10+
that tag).
11+
12+
#### Options
13+
14+
A single options object with the following properties:
15+
16+
##### `match`
17+
18+
`match` is a required option containing an array of objects which determine
19+
the conditions whereby a name is reported as being problematic.
20+
21+
These objects can have any combination of the following groups of optional
22+
properties, all of which act to confine one another:
23+
24+
- `tags` - This array should include tag names or `*` to indicate the
25+
match will apply for all tags (except as confined by any context
26+
properties). If `*` is not used, then these rules will only apply to
27+
the specified tags. If `tags` is omitted, then `*` is assumed.
28+
29+
- `allowName` - Indicates which names are allowed for the given tag (or `*`).
30+
Accepts a string regular expression (optionally wrapped between two
31+
`/` delimiters followed by optional flags) used to match the name.
32+
- `disallowName` - As with `allowName` but indicates names that are not
33+
allowed.
34+
- `replacement` - If `disallowName` is supplied and this value is present, it
35+
will replace the matched `disallowName` text.
36+
37+
- `context` - AST to confine the allowing or disallowing to jsdoc blocks
38+
associated with a particular context. See the
39+
["AST and Selectors"](#eslint-plugin-jsdoc-advanced-ast-and-selectors)
40+
section of our README for more on the expected format.
41+
- `comment` - As with `context` but AST for the JSDoc block comment and types
42+
43+
- `message` - An optional custom message to use when there is a match.
44+
45+
Note that `comment`, even if targeting a specific tag, is used to match the
46+
whole block. So if a `comment` finds its specific tag, it may still apply
47+
fixes found by the likes of `disallowName` even when a different tag has the
48+
disallowed name. An alternative is to ensure that `comment` finds the specific
49+
tag of the desired tag and/or name and no `disallowName` (or `allowName`) is
50+
supplied. In such a case, only one error will be reported, but no fixer will
51+
be applied, however.
52+
53+
|||
54+
|---|---|
55+
|Context|everywhere|
56+
|Tags|(The tags specifie by `tags`, including any tag if `*` is set)|
57+
|Recommended|false|
58+
|Settings|`structuredTags`|
59+
|Options|`match`|
60+
61+
<!-- assertions matchName -->

0 commit comments

Comments
 (0)