Disallow redundant example patterns (#2787)

This commit is contained in:
Paul Melnikow
2019-01-16 19:47:10 -05:00
committed by GitHub
parent 7d4acba5c1
commit bcc9acd18f
6 changed files with 7 additions and 7 deletions

View File

@@ -106,7 +106,6 @@ function pullRequestClassGenerator(raw) {
return [
{
title: 'Bitbucket open pull requests',
pattern: ':user/:repo',
namedParams: {
user: 'atlassian',
repo: 'python-bitbucket',
@@ -120,7 +119,6 @@ function pullRequestClassGenerator(raw) {
repo: 'bar',
},
queryParams: { server: 'https://bitbucket.mydomain.net' },
pattern: ':user/:repo',
staticPreview: this.render({ prs: 42 }),
},
]

View File

@@ -41,7 +41,6 @@ module.exports = class Codetally extends BaseJsonService {
return [
{
title: 'Codetally',
pattern: ':owner/:repo',
namedParams: {
owner: 'triggerman722',
repo: 'colorstrap',

View File

@@ -18,7 +18,6 @@ module.exports = class Gitter extends BaseStaticService {
return [
{
title: 'Gitter',
pattern: ':user/:repo',
namedParams: {
user: 'nwjs',
repo: 'nw.js',

View File

@@ -201,7 +201,6 @@ module.exports = class Matrix extends BaseJsonService {
{
title: 'Matrix',
namedParams: { roomAlias: 'twim:matrix.org' },
pattern: ':roomAlias',
staticPreview: this.render({ members: 42 }),
documentation,
},
@@ -209,7 +208,6 @@ module.exports = class Matrix extends BaseJsonService {
title: 'Matrix',
namedParams: { roomAlias: 'twim:matrix.org' },
queryParams: { server_fqdn: 'matrix.org' },
pattern: ':roomAlias',
staticPreview: this.render({ members: 42 }),
documentation,
},

View File

@@ -66,6 +66,13 @@ function validateExample(example, index, ServiceClass) {
} at index ${index} also declares a dynamic previewUrl, which is not allowed`
)
}
if (pattern === ServiceClass.route.pattern) {
throw new Error(
`Example for ${
ServiceClass.name
} at index ${index} declares a redundant pattern which should be removed`
)
}
// Make sure we can build the full URL using these patterns.
try {

View File

@@ -122,7 +122,6 @@ class WordpressPluginTestedVersion extends BaseWordpressPlatform {
return [
{
title: 'Wordpress Plugin: Tested WP Version',
pattern: ':slug',
namedParams: { slug: 'bbpress' },
staticPreview: this.render({ version: '4.9.8', color: 'brightgreen' }),
documentation: `<p>There is an alias for this badge. <code>wordpress/v/:slug.svg</code></p>`,