diff --git a/lib/rules/array-foreach.js b/lib/rules/array-foreach.js index 2585e746..f7e7a55f 100644 --- a/lib/rules/array-foreach.js +++ b/lib/rules/array-foreach.js @@ -3,7 +3,7 @@ module.exports = { type: 'suggestion', docs: { description: 'enforce `for..of` loops over `Array.forEach`', - url: 'https://github.com/github/eslint-plugin-github/blob/main/docs/rules/array-foreach.md' + url: require('../url')(module) }, schema: [] }, diff --git a/lib/rules/async-currenttarget.js b/lib/rules/async-currenttarget.js index e5794e88..40c4f98f 100644 --- a/lib/rules/async-currenttarget.js +++ b/lib/rules/async-currenttarget.js @@ -3,7 +3,7 @@ module.exports = { type: 'problem', docs: { description: 'disallow `event.currentTarget` calls inside of async functions', - url: 'https://github.com/github/eslint-plugin-github/blob/main/docs/rules/async-currenttarget.md' + url: require('../url')(module) }, schema: [] }, diff --git a/lib/rules/async-preventdefault.js b/lib/rules/async-preventdefault.js index 808c65b7..fa05ccd9 100644 --- a/lib/rules/async-preventdefault.js +++ b/lib/rules/async-preventdefault.js @@ -3,7 +3,7 @@ module.exports = { type: 'problem', docs: { description: 'disallow `event.preventDefault` calls inside of async functions', - url: 'https://github.com/github/eslint-plugin-github/blob/main/docs/rules/async-preventDefault.md' + url: require('../url')(module) }, schema: [] }, diff --git a/lib/rules/authenticity-token.js b/lib/rules/authenticity-token.js index 3621fecf..43a0da44 100644 --- a/lib/rules/authenticity-token.js +++ b/lib/rules/authenticity-token.js @@ -3,7 +3,7 @@ module.exports = { type: 'problem', docs: { description: 'disallow usage of CSRF tokens in JavaScript', - url: 'https://github.com/github/eslint-plugin-github/blob/main/docs/rules/authenticity-token.md' + url: require('../url')(module) }, schema: [] }, diff --git a/lib/rules/get-attribute.js b/lib/rules/get-attribute.js index 26900203..c30594b1 100644 --- a/lib/rules/get-attribute.js +++ b/lib/rules/get-attribute.js @@ -23,7 +23,7 @@ module.exports = function(context) { type: 'problem', docs: { description: 'disallow wrong usage of attribute names', - url: 'https://github.com/github/eslint-plugin-github/blob/main/docs/rules/get-attribute.md' + url: require('../url')(module) }, fixable: 'code', schema: [] diff --git a/lib/rules/js-class-name.js b/lib/rules/js-class-name.js index 9494a212..78a3b273 100644 --- a/lib/rules/js-class-name.js +++ b/lib/rules/js-class-name.js @@ -3,7 +3,7 @@ module.exports = { type: 'suggestion', docs: { description: 'enforce a naming convention for js- prefixed classes', - url: 'https://github.com/github/eslint-plugin-github/blob/main/docs/rules/js-class-name.md' + url: require('../url')(module) }, schema: [] }, diff --git a/lib/rules/no-blur.js b/lib/rules/no-blur.js index c2c6ec14..ad336b05 100644 --- a/lib/rules/no-blur.js +++ b/lib/rules/no-blur.js @@ -4,7 +4,7 @@ module.exports = function(context) { type: 'problem', docs: { description: 'disallow usage of `Element.prototype.blur()`', - url: 'https://github.com/github/eslint-plugin-github/blob/main/docs/rules/no-blur.md' + url: require('../url')(module) }, schema: [] }, diff --git a/lib/rules/no-d-none.js b/lib/rules/no-d-none.js index e0bc39e8..7513f2e1 100644 --- a/lib/rules/no-d-none.js +++ b/lib/rules/no-d-none.js @@ -3,7 +3,7 @@ module.exports = { type: 'problem', docs: { description: 'disallow usage the `d-none` CSS class', - url: 'https://github.com/github/eslint-plugin-github/blob/main/docs/rules/no-d-none.md' + url: require('../url')(module) }, schema: [] }, diff --git a/lib/rules/no-dataset.js b/lib/rules/no-dataset.js index 16365b4f..5f7b5ede 100644 --- a/lib/rules/no-dataset.js +++ b/lib/rules/no-dataset.js @@ -3,7 +3,7 @@ module.exports = { type: 'problem', docs: { description: 'enforce usage of `Element.prototype.getAttribute` instead of `Element.prototype.datalist`', - url: 'https://github.com/github/eslint-plugin-github/blob/main/docs/rules/no-dataset.md' + url: require('../url')(module) }, schema: [] }, diff --git a/lib/rules/no-implicit-buggy-globals.js b/lib/rules/no-implicit-buggy-globals.js index fed703e1..39992213 100644 --- a/lib/rules/no-implicit-buggy-globals.js +++ b/lib/rules/no-implicit-buggy-globals.js @@ -3,7 +3,7 @@ module.exports = { type: 'problem', docs: { description: 'disallow implicit global variables', - url: 'https://github.com/github/eslint-plugin-github/blob/main/docs/rules/no-implicit-buggy-globals.md' + url: require('../url')(module) }, schema: [] }, diff --git a/lib/rules/no-innerText.js b/lib/rules/no-innerText.js index 7c73e8cb..b1396d77 100644 --- a/lib/rules/no-innerText.js +++ b/lib/rules/no-innerText.js @@ -3,7 +3,7 @@ module.exports = { type: 'problem', docs: { description: 'disallow `Element.prototype.innerText` in favor of `Element.prototype.textContent`', - url: 'https://github.com/github/eslint-plugin-github/blob/main/docs/rules/no-innerText.md' + url: require('../url')(module) }, fixable: 'code', schema: [] diff --git a/lib/rules/no-then.js b/lib/rules/no-then.js index eede41d3..f53517f4 100644 --- a/lib/rules/no-then.js +++ b/lib/rules/no-then.js @@ -3,7 +3,7 @@ module.exports = { type: 'suggestion', docs: { description: 'enforce using `async/await` syntax over Promises', - url: 'https://github.com/github/eslint-plugin-github/blob/main/docs/rules/no-then.md' + url: require('../url')(module) }, schema: [] }, diff --git a/lib/rules/no-useless-passive.js b/lib/rules/no-useless-passive.js index 6495e260..ab6a685f 100644 --- a/lib/rules/no-useless-passive.js +++ b/lib/rules/no-useless-passive.js @@ -7,7 +7,7 @@ module.exports = { type: 'suggestion', docs: { description: 'disallow marking a event handler as passive when it has no effect', - url: 'https://github.com/github/eslint-plugin-github/blob/main/docs/rules/no-useless-passive.md' + url: require('../url')(module) }, fixable: 'code', schema: [] diff --git a/lib/rules/prefer-observers.js b/lib/rules/prefer-observers.js index f7548da7..87280f34 100644 --- a/lib/rules/prefer-observers.js +++ b/lib/rules/prefer-observers.js @@ -7,7 +7,7 @@ module.exports = { type: 'suggestion', docs: { description: 'disallow poorly performing event listeners', - url: 'https://github.com/github/eslint-plugin-github/blob/main/docs/rules/prefer-observers.md' + url: require('../url')(module) }, schema: [] }, diff --git a/lib/rules/require-passive-events.js b/lib/rules/require-passive-events.js index d203e3c1..9b05a4f0 100644 --- a/lib/rules/require-passive-events.js +++ b/lib/rules/require-passive-events.js @@ -7,7 +7,7 @@ module.exports = { type: 'suggestion', docs: { description: 'enforce marking high frequency event handlers as passive', - url: 'https://github.com/github/eslint-plugin-github/blob/main/docs/rules/require-passive-events.md' + url: require('../url')(module) }, schema: [] }, diff --git a/lib/rules/unescaped-html-literal.js b/lib/rules/unescaped-html-literal.js index 5eb52654..51f59372 100644 --- a/lib/rules/unescaped-html-literal.js +++ b/lib/rules/unescaped-html-literal.js @@ -3,7 +3,7 @@ module.exports = { type: 'problem', docs: { description: 'disallow unesaped HTML literals', - url: 'https://github.com/github/eslint-plugin-github/blob/main/docs/rules/unescaped-html-literal.md' + url: require('../url')(module) }, schema: [] }, diff --git a/lib/url.js b/lib/url.js new file mode 100644 index 00000000..30e162e1 --- /dev/null +++ b/lib/url.js @@ -0,0 +1,9 @@ +const {homepage, version} = require('../package.json') +const path = require('path') +module.exports = ({id}) => { + const url = new URL(homepage) + const rule = path.basename(id, '.js') + url.hash = '' + url.pathname += `/blob/v${version}/docs/rules/${rule}.md` + return url.toString() +}