Skip to content

Commit

Permalink
feat: add sort-tags rule
Browse files Browse the repository at this point in the history
  • Loading branch information
brettz9 committed Feb 7, 2022
1 parent 9d0a75d commit 38d51ff
Show file tree
Hide file tree
Showing 9 changed files with 1,268 additions and 7 deletions.
1 change: 1 addition & 0 deletions .README/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -589,5 +589,6 @@ selector).
{"gitdown": "include", "file": "./rules/require-throws.md"}
{"gitdown": "include", "file": "./rules/require-yields.md"}
{"gitdown": "include", "file": "./rules/require-yields-check.md"}
{"gitdown": "include", "file": "./rules/sort-tags.md"}
{"gitdown": "include", "file": "./rules/tag-lines.md"}
{"gitdown": "include", "file": "./rules/valid-types.md"}
198 changes: 198 additions & 0 deletions .README/rules/sort-tags.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
### `sort-tags`

Sorts tags by a specified sequence according to tag name.

(Default order originally inspired by [`@homer0/prettier-plugin-jsdoc`](https://github.com/homer0/packages/tree/main/packages/public/prettier-plugin-jsdoc).)

#### Options

##### `tagSequence`

An array of tag names indicating the preferred sequence for sorting tags.

Tag names earlier in the list will be arranged first. The relative position of
tags of the same name will not be changed.

Tags not in the list will be sorted alphabetically at the end (or in place of
the pseudo-tag `-other` placed within `tagSequence`) if `alphabetizeExtras` is
enabled and in their order of appearance otherwise (so if you want all your
tags alphabetized, supply an empty array with `alphabetizeExtras` enabled).

Defaults to the array below.

Please note that this order is still experimental, so if you want to retain
a fixed order that doesn't change into the future, supply your own
`tagSequence`.

```js
[
// Brief descriptions
'summary',
'typeSummary',

// Module/file-level
'module',
'exports',
'file',
'fileoverview',
'overview',

// Identifying (name, type)
'typedef',
'interface',
'record',
'template',
'name',
'kind',
'type',
'alias',
'external',
'host',
'callback',
'func',
'function',
'method',
'class',
'constructor',

// Relationships
'modifies',
'mixes',
'mixin',
'mixinClass',
'mixinFunction',
'namespace',
'borrows',
'constructs',
'lends',
'implements',
'requires',

// Long descriptions
'desc',
'description',
'classdesc',
'tutorial',
'copyright',
'license',

// Simple annotations
'const',
'constant',
'final',
'global',
'readonly',
'abstract',
'virtual',
'var',
'member',
'memberof',
'memberof!',
'inner',
'instance',
'inheritdoc',
'inheritDoc',
'override',
'hideconstructor',

// Core function/object info
'param',
'arg',
'argument',
'prop',
'property',
'return',
'returns',

// Important behavior details
'async',
'generator',
'default',
'defaultvalue',
'enum',
'augments',
'extends',
'throws',
'exception',
'yield',
'yields',
'event',
'fires',
'emits',
'listens',
'this',

// Access
'static',
'private',
'protected',
'public',
'access',
'package',

'-other',

// Supplementary descriptions
'see',
'example',

// METADATA

// Other Closure (undocumented) metadata
'closurePrimitive',
'customElement',
'expose',
'hidden',
'idGenerator',
'meaning',
'ngInject',
'owner',
'wizaction',

// Other Closure (documented) metadata
'define',
'dict',
'export',
'externs',
'implicitCast',
'noalias',
'nocollapse',
'nocompile',
'noinline',
'nosideeffects',
'polymer',
'polymerBehavior',
'preserve',
'struct',
'suppress',
'unrestricted',

// @homer0/prettier-plugin-jsdoc metadata
'category',

// Non-Closure metadata
'ignore',
'author',
'version',
'variation',
'since',
'deprecated',
'todo',
];
```

##### `alphabetizeExtras`

Defaults to `false`. Alphabetizes any items not within `tagSequence` after any
items within `tagSequence` (or in place of the special `-other` pseudo-tag)
are sorted.

|||
|---|---|
|Context|everywhere|
|Tags|any|
|Recommended|false|
|Settings||
|Options|`tagSequence`, `alphabetizeExtras`|

<!-- assertions sortTags -->

0 comments on commit 38d51ff

Please sign in to comment.