Skip to content

Commit c26f311

Browse files
committed
Require plugin names to start with 'jquery.'. Fixes jquery-archive#22.
1 parent d04c68d commit c26f311

File tree

3 files changed

+14
-18
lines changed

3 files changed

+14
-18
lines changed

docs/package.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,11 @@ changes to the version.
3636

3737
The name is what your thing is called. Some tips:
3838

39-
* Don't put "js" or "jquery" in the name. It's assumed that it's js, since you're
40-
writing a package.json file, and it's assumed that it's a jQuery plugin, because
41-
you're registering it on the jQuery Plugins Site. Additionally, you will be listing
42-
`jquery` as a dependency, along with compatible versions (see 'Dependencies' below).
39+
* Don't put "js" in the name. It's assumed that it's js, since you're
40+
writing a package.json file.
41+
* Do put "jquery" in the name. This may seem like the opposite advice from the previous
42+
tip, but this is important for projects loading jQuery plugins and non-jQuery plugins
43+
through a module loader.
4344
* The name ends up being part of a URL. Any name with non-url-safe characters will
4445
be rejected. Also, it can't start with a dot or an underscore. The jQuery Plugins
4546
Site is UTF-8.
@@ -48,7 +49,7 @@ The name is what your thing is called. Some tips:
4849
to see if there's something by that name already, before you get too attached to it.
4950
* If you have a plugin with the same name as a plugin already in the jQuery Plugins
5051
Site, either consider renaming your plugin or namespace it. For example, jQuery UI
51-
plugins are listed with the "ui-" prefix (e.g. ui-dialog, ui-autocomplete).
52+
plugins are listed with the "jquery.ui." prefix (e.g. jquery.ui.dialog, jquery.ui.autocomplete).
5253

5354
## <a name="field-version">version</a>
5455

@@ -219,7 +220,7 @@ digits after the first "x" are ignored.
219220

220221
```json
221222
{
222-
"name": "color",
223+
"name": "jquery.color",
223224
"version": "2.0.0b1",
224225
"title": "jQuery.Color()",
225226
"author": {

src/service.js

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
var semver = require( "semver" ),
22
Step = require( "step" ),
3-
config = require( "./config" );
4-
5-
var suites = {
6-
"github/rdworth/temp-jqueryui": "ui-"
7-
};
3+
config = require( "./config" ),
4+
suites = require( "./suites" );
85

96
function extend( a, b ) {
107
for ( var prop in b ) {
@@ -57,13 +54,8 @@ extend( Repo.prototype, {
5754
errors.push( "Missing required field: name." );
5855
} else if ( typeof package.name !== "string" ) {
5956
errors.push( "Invalid data type for name; must be a string." );
60-
} else if ( package.name.charAt( 0 ) === "_" || package.name.charAt( 0 ) === "." ) {
61-
errors.push( "Name cannot start with an underscore or dot." );
62-
// don't allow semantic version for plugin name
63-
// this makes it easier for us to query against pages in the WP database
64-
// and semvers would be horrible plugin names anyway
65-
} else if ( semver.valid( package.name ) ) {
66-
errors.push( "Name cannot be a semantic version." );
57+
} else if ( !/^jquery\./.test( package.name ) ) {
58+
errors.push( "Name must start with 'jquery.'." );
6759
}
6860

6961
if ( !package.version ) {

src/suites.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"github/rdworth/temp-jqueryui": "jquery.ui."
3+
}

0 commit comments

Comments
 (0)