Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 38c159e

Browse filesBrowse files
nzakasfasttime
andauthored
docs: Provide example of reading package.json for plugins meta (#18530)
* docs: Provide example of reading package.json for plugins meta fixes #18462 * Update docs/src/extend/plugins.md Co-authored-by: Francesco Trotta <github@fasttime.org> --------- Co-authored-by: Francesco Trotta <github@fasttime.org>
1 parent c6de7bb commit 38c159e
Copy full SHA for 38c159e

File tree

Expand file treeCollapse file tree

1 file changed

+21
-1
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+21
-1
lines changed

‎docs/src/extend/plugins.md

Copy file name to clipboardExpand all lines: docs/src/extend/plugins.md
+21-1Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,27 @@ export default plugin;
6262
module.exports = plugin;
6363
```
6464

65-
The `meta.name` property should match the npm package name for your plugin and the `meta.version` property should match the npm package version for your plugin. The easiest way to accomplish this is by reading this information from your `package.json`.
65+
The `meta.name` property should match the npm package name for your plugin and the `meta.version` property should match the npm package version for your plugin. The easiest way to accomplish this is by reading this information from your `package.json`, as in this example:
66+
67+
```js
68+
import fs from "fs";
69+
70+
const pkg = JSON.parse(fs.readFileSync(new URL("./package.json", import.meta.url), "utf8"));
71+
72+
const plugin = {
73+
74+
// preferred location of name and version
75+
meta: {
76+
name: pkg.name,
77+
version: pkg.version
78+
},
79+
rules: {
80+
// add rules here
81+
}
82+
};
83+
84+
export default plugin;
85+
```
6686
6787
::: tip
6888
While there are no restrictions on plugin names, it helps others to find your plugin on [npm](https://npmjs.com) when you follow these naming conventions:

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.