Skip to content

Commit

Permalink
Document benefits from TypeScript annotation (#7423)
Browse files Browse the repository at this point in the history
See https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html

Co-authored-by: Marc G. <Mouvedia@users.noreply.github.com>
Co-authored-by: Richard Hallows <jeddy3@users.noreply.github.com>
  • Loading branch information
3 people committed Dec 24, 2023
1 parent 760a6f1 commit e222352
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 5 additions & 1 deletion docs/developer-guide/plugins.md
Expand Up @@ -34,7 +34,8 @@ const meta = {
url: "https://github.com/foo-org/stylelint-selector-no-foo/blob/main/README.md"
};

const ruleFunction = (primary, secondaryOptions) => {
/** @type {import('stylelint').Rule} */
const ruleFunction = (primary, secondaryOptions, context) => {
return (root, result) => {
const validOptions = validateOptions(result, ruleName, {
actual: primary,
Expand Down Expand Up @@ -66,6 +67,9 @@ ruleFunction.meta = meta;
export default createPlugin(ruleName, ruleFunction);
```

> [!NOTE]
> The [`@type` JSDoc annotation](https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html#type) enables Typescript to autocomplete and type-check.
The usage would be:

```json
Expand Down
4 changes: 4 additions & 0 deletions docs/user-guide/configure.md
Expand Up @@ -14,13 +14,17 @@ Stylelint expects a configuration object, and looks for one in a:
ES module example:

```js
/** @type {import('stylelint').Config} */
export default {
rules: {
"block-no-empty": true
}
};
```

> [!NOTE]
> The `@type` JSDoc annotation enables Typescript to autocomplete and type-check.
CommonJS example:

```js
Expand Down

0 comments on commit e222352

Please sign in to comment.