← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~cjwatson/launchpad/eslint-regexes into lp:launchpad

 

Colin Watson has proposed merging lp:~cjwatson/launchpad/eslint-regexes into lp:launchpad.

Commit message:
Remove useless escapes in JS regexes.  pocketlint wanted these, but eslint doesn't.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/eslint-regexes/+merge/335613
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/eslint-regexes into lp:launchpad.
=== modified file 'lib/lp/app/javascript/lp-names.js'
--- lib/lp/app/javascript/lp-names.js	2012-01-19 02:00:52 +0000
+++ lib/lp/app/javascript/lp-names.js	2018-01-02 04:26:57 +0000
@@ -41,13 +41,13 @@
 function launchpad_to_css(name) {
 
     // Ensure we're being asked to convert the valid LP name.
-    if (!name.match(/^[a-z0-9][a-z0-9\+\.\-]*$/)) {
+    if (!name.match(/^[a-z0-9][a-z0-9+.-]*$/)) {
         Y.error(
             'Passed value "' + name + '" is not a valid Launchpad name.');
         return;
     }
 
-    if (name.match(/^[a-z][a-z0-9\-]*$/)) {
+    if (name.match(/^[a-z][a-z0-9-]*$/)) {
         // This is an intersection between valid LP and CSS names.
         return name;
     } else {
@@ -88,17 +88,17 @@
  *   throughout the string.
  */
 function css_to_launchpad(name) {
-    if (!name.match(/^-?[_a-z][_a-z0-9\-]*$/)) {
+    if (!name.match(/^-?[_a-z][_a-z0-9-]*$/)) {
         Y.error(
             'Passed value "' + name + '" is not a valid CSS class name.');
     }
-    if (!name.match(/^((_[0-9yz])|[a-z])([a-z0-9\-]|(_[yz]))*$/)) {
+    if (!name.match(/^((_[0-9yz])|[a-z])([a-z0-9-]|(_[yz]))*$/)) {
         Y.error(
             'Passed value "' + name +
                 '" is not produced by launchpad_to_css.');
     }
 
-    if (name.match(/^[a-z][a-z0-9\-]*$/)) {
+    if (name.match(/^[a-z][a-z0-9-]*$/)) {
         // This is an intersection between valid LP and CSS names.
         return name;
     }

=== modified file 'lib/lp/app/javascript/tests/test_lp_client_integration.js'
--- lib/lp/app/javascript/tests/test_lp_client_integration.js	2012-10-26 10:00:20 +0000
+++ lib/lp/app/javascript/tests/test_lp_client_integration.js	2018-01-02 04:26:57 +0000
@@ -167,7 +167,7 @@
     var config = makeTestConfig({accept: Y.lp.client.XHTML});
     client.get(data.user.self_link, config);
     Y.Assert.isTrue(config.successful);
-    Y.Assert.isTrue(/<a href=\"\/\~/.test(config.result));
+    Y.Assert.isTrue(/<a href="\/~/.test(config.result));
   },
 
   test_get_html_representation_escaped: function() {
@@ -196,7 +196,7 @@
       client, data.user, data.user.self_link);
     user.lp_save(config);
     Y.Assert.isTrue(config.successful);
-    Y.Assert.isTrue(/<a href=\"\/\~/.test(config.result));
+    Y.Assert.isTrue(/<a href="\/~/.test(config.result));
   },
 
   test_patch_html_representation: function() {
@@ -205,7 +205,7 @@
     var config = makeTestConfig({accept: Y.lp.client.XHTML});
     client.patch(data.user.self_link, {}, config);
     Y.Assert.isTrue(config.successful);
-    Y.Assert.isTrue(/<a href=\"\/\~/.test(config.result));
+    Y.Assert.isTrue(/<a href="\/~/.test(config.result));
   },
 
   test_lp_save: function() {
@@ -308,7 +308,7 @@
     var team = config.result;
     Y.Assert.isInstanceOf(Y.lp.client.Entry, team);
     Y.Assert.areEqual('My lpclient team', team.get('display_name'));
-    Y.Assert.isTrue(/\~newlpclientteam$/.test(team.uri));
+    Y.Assert.isTrue(/~newlpclientteam$/.test(team.uri));
   },
 
   test_collection_paged_named_get: function() {

=== modified file 'lib/lp/registry/javascript/structural-subscription.js'
--- lib/lp/registry/javascript/structural-subscription.js	2017-07-21 17:35:14 +0000
+++ lib/lp/registry/javascript/structural-subscription.js	2018-01-02 04:26:57 +0000
@@ -988,7 +988,7 @@
     // As an extension, we also allow "-" (hyphen) in front of
     // any tag to indicate exclusion of a tag, and we accept
     // a space-separated list.
-    if (value.match(/^(\-?[a-z0-9][a-z0-9\+\.\-]*[ ]*)*$/) !== null) {
+    if (value.match(/^(-?[a-z0-9][a-z0-9+.-]*[ ]*)*$/) !== null) {
         return null;
     } else {
         return ('Tags can only contain lowercase ASCII letters, ' +


Follow ups