Skip to content

Commit dbd3127

Browse files
committed
Docs: add document for version-specific URLs
1 parent 3f17cf4 commit dbd3127

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

docs/rules/require-meta-docs-url.md

+43
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,49 @@ module.exports = {
101101

102102
```
103103

104+
## Version specific URL
105+
106+
If you want to enforce version-specific URLs, it's feasible easily with `.eslintrc.js` and `npm version <type>` script.
107+
For example:
108+
109+
**.eslintrc.js**:
110+
111+
```js
112+
"use strict"
113+
114+
const version = require("./package.json").version
115+
116+
module.exports = {
117+
plugins: ["eslint-plugin"],
118+
// ... leaving out ...
119+
rules: {
120+
"eslint-plugin": ["error", {
121+
pattern: `path/to/v${version}/docs/rules/{{name}}.md`,
122+
}],
123+
}
124+
}
125+
```
126+
127+
**package.json**:
128+
129+
```json
130+
{
131+
"version": "1.0.0",
132+
"scripts": {
133+
"test": "... leaving out ...",
134+
"preversion": "npm test",
135+
"version": "eslint . --fix && git add ."
136+
},
137+
// ... leaving out ...
138+
}
139+
```
140+
141+
Then `npm version <type>` command will update every rule to the new version's URL.
142+
143+
> npm runs `preversion` script on the current version, runs `version` script on the new version, and commits and makes a tag.
144+
>
145+
> Further reading: https://docs.npmjs.com/cli/version
146+
104147
## When Not To Use It
105148

106149
If you do not plan to provide rule's documentation in website, you can turn off this rule.

0 commit comments

Comments
 (0)