mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 14:03:30 +00:00 
			
		
		
		
	js: Fix no-useless-escape errors.
Generated manually, since ESLint doesn’t have a fixer for this. Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
		
				
					committed by
					
						
						Tim Abbott
					
				
			
			
				
	
			
			
			
						parent
						
							ac64d03988
						
					
				
				
					commit
					569b38fe34
				
			@@ -101,11 +101,6 @@
 | 
			
		||||
        ],
 | 
			
		||||
        "no-use-before-define": "error",
 | 
			
		||||
        "no-useless-constructor": "error",
 | 
			
		||||
        // The Zulip codebase complies partially with the "no-useless-escape"
 | 
			
		||||
        // rule; only regex expressions haven't been updated yet.
 | 
			
		||||
        // Updated regex expressions are currently being tested in casper
 | 
			
		||||
        // files and will decide about a potential future enforcement of this rule.
 | 
			
		||||
        "no-useless-escape": "off",
 | 
			
		||||
        "no-var": "error",
 | 
			
		||||
        "space-unary-ops": "error",
 | 
			
		||||
        "no-whitespace-before-property": "error",
 | 
			
		||||
 
 | 
			
		||||
@@ -238,7 +238,7 @@ casper.then(function () {
 | 
			
		||||
    casper.click('#create_alert_word_button');
 | 
			
		||||
    casper.test.info('Checking that a success message is displayed');
 | 
			
		||||
    casper.waitUntilVisible('#alert_word_status', function () {
 | 
			
		||||
        casper.test.assertSelectorHasText('.alert_word_status_text', 'Alert word \"some phrase\" added successfully!');
 | 
			
		||||
        casper.test.assertSelectorHasText('.alert_word_status_text', 'Alert word "some phrase" added successfully!');
 | 
			
		||||
        casper.test.info('Closing the status message');
 | 
			
		||||
        casper.click('.close-alert-word-status');
 | 
			
		||||
        casper.test.info('Checking the status message is hidden');
 | 
			
		||||
 
 | 
			
		||||
@@ -749,7 +749,7 @@ run_test('render item', () => {
 | 
			
		||||
                                  `tr[data-item='${INITIAL_RENDER_COUNT - 1}']`];
 | 
			
		||||
        const item = INITIAL_RENDER_COUNT - 1;
 | 
			
		||||
        const new_html = `<tr data-item=${item}>updated: ${item}</tr>\n`;
 | 
			
		||||
        const regex = new RegExp(`\\<tr data-item=${item}\\>.*?\<\\/tr\\>`);
 | 
			
		||||
        const regex = new RegExp(`\\<tr data-item=${item}\\>.*?<\\/tr\\>`);
 | 
			
		||||
        assert(expected_queries.includes(query));
 | 
			
		||||
        if (query.includes(`data-item='${INITIAL_RENDER_COUNT}'`)) {
 | 
			
		||||
            return; // This item is not rendered, so we find nothing
 | 
			
		||||
 
 | 
			
		||||
@@ -22,7 +22,7 @@ exports.has_alert_word = function (word) {
 | 
			
		||||
// escape_user_regex taken from jquery-ui/autocomplete.js,
 | 
			
		||||
// licensed under MIT license.
 | 
			
		||||
function escape_user_regex(value) {
 | 
			
		||||
    return value.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&");
 | 
			
		||||
    return value.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
exports.process_message = function (message) {
 | 
			
		||||
 
 | 
			
		||||
@@ -117,7 +117,7 @@ exports.adjust_mac_shortcuts = function (key_elem_class, require_cmd_style) {
 | 
			
		||||
 | 
			
		||||
    $(key_elem_class).each(function () {
 | 
			
		||||
        let key_text = $(this).text();
 | 
			
		||||
        const keys = key_text.match(/[^\s\+]+/g) || [];
 | 
			
		||||
        const keys = key_text.match(/[^\s+]+/g) || [];
 | 
			
		||||
 | 
			
		||||
        if (key_text.includes('Ctrl') && require_cmd_style) {
 | 
			
		||||
            $(this).addClass("mac-cmd-key");
 | 
			
		||||
 
 | 
			
		||||
@@ -311,7 +311,7 @@ exports.tokenize_compose_str = function (s) {
 | 
			
		||||
        case '_':
 | 
			
		||||
            if (i === 0) {
 | 
			
		||||
                return s;
 | 
			
		||||
            } else if (/[\s(){}\[\]]/.test(s[i - 1])) {
 | 
			
		||||
            } else if (/[\s(){}[\]]/.test(s[i - 1])) {
 | 
			
		||||
                return s.slice(i);
 | 
			
		||||
            }
 | 
			
		||||
            break;
 | 
			
		||||
@@ -709,7 +709,7 @@ exports.get_candidates = function (query) {
 | 
			
		||||
    if (this.options.completions.topic) {
 | 
			
		||||
        // Stream regex modified from marked.js
 | 
			
		||||
        // Matches '#**stream name** >' at the end of a split.
 | 
			
		||||
        const stream_regex =  /#\*\*([^\*>]+)\*\*\s?>$/;
 | 
			
		||||
        const stream_regex =  /#\*\*([^*>]+)\*\*\s?>$/;
 | 
			
		||||
        const should_jump_inside_typeahead = stream_regex.test(split[0]);
 | 
			
		||||
        if (should_jump_inside_typeahead) {
 | 
			
		||||
            this.completing = 'topic_jump';
 | 
			
		||||
@@ -719,7 +719,7 @@ exports.get_candidates = function (query) {
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Matches '#**stream name>some text' at the end of a split.
 | 
			
		||||
        const stream_topic_regex = /#\*\*([^\*>]+)>([^\*]*)$/;
 | 
			
		||||
        const stream_topic_regex = /#\*\*([^*>]+)>([^*]*)$/;
 | 
			
		||||
        const should_begin_typeahead = stream_topic_regex.test(split[0]);
 | 
			
		||||
        if (should_begin_typeahead) {
 | 
			
		||||
            this.completing = 'topic_list';
 | 
			
		||||
@@ -736,7 +736,7 @@ exports.get_candidates = function (query) {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    if (this.options.completions.timestamp) {
 | 
			
		||||
        const time_jump_regex = /<time(\:([^>]*?)>?)?$/;
 | 
			
		||||
        const time_jump_regex = /<time(:([^>]*?)>?)?$/;
 | 
			
		||||
        if (time_jump_regex.test(split[0])) {
 | 
			
		||||
            this.completing = 'time_jump';
 | 
			
		||||
            return [i18n.t('Mention a timezone-aware time')];
 | 
			
		||||
 
 | 
			
		||||
@@ -77,7 +77,7 @@ exports.contains_backend_only_syntax = function (content) {
 | 
			
		||||
    // then don't render it locally. It is workaround for the fact that
 | 
			
		||||
    // javascript regex doesn't support lookbehind.
 | 
			
		||||
    const false_filter_match = realm_filter_list.find((re) => {
 | 
			
		||||
        const pattern = /(?:[^\s'"\(,:<])/.source + re[0].source + /(?![\w])/.source;
 | 
			
		||||
        const pattern = /(?:[^\s'"(,:<])/.source + re[0].source + /(?![\w])/.source;
 | 
			
		||||
        const regex = new RegExp(pattern);
 | 
			
		||||
        return regex.test(content);
 | 
			
		||||
    });
 | 
			
		||||
@@ -487,7 +487,7 @@ exports.initialize = function (realm_filters, helper_config) {
 | 
			
		||||
    marked.InlineLexer.rules.zulip.strong = /^\*\*([\s\S]+?)\*\*(?!\*)/;
 | 
			
		||||
 | 
			
		||||
    // Make sure <del> syntax matches the backend processor
 | 
			
		||||
    marked.InlineLexer.rules.zulip.del = /^(?!<\~)\~\~([^~]+)\~\~(?!\~)/;
 | 
			
		||||
    marked.InlineLexer.rules.zulip.del = /^(?!<~)~~([^~]+)~~(?!~)/;
 | 
			
		||||
 | 
			
		||||
    // Disable _emphasis_ (keeping *emphasis*)
 | 
			
		||||
    // Text inside ** must start and end with a word character
 | 
			
		||||
 
 | 
			
		||||
@@ -60,7 +60,7 @@ function add_bot_row(info) {
 | 
			
		||||
 | 
			
		||||
function is_local_part(value, element) {
 | 
			
		||||
    // Adapted from Django's EmailValidator
 | 
			
		||||
    return this.optional(element) || /^[\-!#$%&'*+\/=?\^_`{}|~0-9A-Z]+(\.[\-!#$%&'*+\/=?\^_`{}|~0-9A-Z]+)*$/i.test(value);
 | 
			
		||||
    return this.optional(element) || /^[-!#$%&'*+/=?^_`{}|~0-9A-Z]+(\.[-!#$%&'*+/=?^_`{}|~0-9A-Z]+)*$/i.test(value);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
exports.type_id_to_string = function (type_id) {
 | 
			
		||||
 
 | 
			
		||||
@@ -14,7 +14,7 @@ exports.get_cleaned_pm_recipients = function (query_string) {
 | 
			
		||||
 | 
			
		||||
exports.build_highlight_regex = function (query) {
 | 
			
		||||
    // the regex below is based on bootstrap code
 | 
			
		||||
    query = query.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, '\\$&');
 | 
			
		||||
    query = query.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
 | 
			
		||||
    const regex = new RegExp('(' + query + ')', 'ig');
 | 
			
		||||
    return regex;
 | 
			
		||||
};
 | 
			
		||||
 
 | 
			
		||||
@@ -148,8 +148,7 @@ exports.strcmp = exports.make_strcmp();
 | 
			
		||||
 | 
			
		||||
exports.escape_regexp = function (string) {
 | 
			
		||||
    // code from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
 | 
			
		||||
    // Modified to escape the ^ to appease jslint. :/
 | 
			
		||||
    return string.replace(/([.*+?\^=!:${}()|\[\]\/\\])/g, "\\$1");
 | 
			
		||||
    return string.replace(/([.*+?^=!:${}()|[\]/\\])/g, "\\$1");
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
exports.array_compare = function util_array_compare(a, b) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user