mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-11-03 03:39:20 +08:00
We prefer single quotes by default, but still want to allow double
quotes in cases where that helps avoid quote-escaping, and also want
to allow template literals in cases where string interpolation is
used. For example:
const a = 'xxx'; // ok
const b = "xxx"; // not ok, should use single quotes
const c = "xxx'xxx"; // ok, double quotes avoid an escape sequence
const d = `xxx`; // not ok, frivolous use of template literal
const e = `xxx ${42}`; // ok
Per https://github.com/eslint/eslint/issues/12976, setting
the `allowTemplateLiterals` option for the `quotes` lint rule to
`false` gives us the desired behavior.
Note that the above lint rules are auto-fixed when running the linter;
there should be no need to manually make any changes to appease the
linter.
Per review feedback, this patch also removes the following escape
sequences for printable non-ASCII symbols:
- U+00D7 → ×
- U+2026 → …
- U+2019 → ’
Chromium CL temporarily updating test expectations:
https://chromium-review.googlesource.com/c/chromium/src/+/2083147
Cq-Depend: chromium:2083147
Bug: chromium:1057042
Change-Id: Id6bec3f96ca694d2fbc07dd8629fce305a58df8a
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2082372
Commit-Queue: Mathias Bynens <mathias@chromium.org>
Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org>
Auto-Submit: Mathias Bynens <mathias@chromium.org>
85 lines
1.9 KiB
JavaScript
85 lines
1.9 KiB
JavaScript
// Copyright 2017 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
import {Provider} from './FilteredListWidget.js';
|
|
import {QuickOpenImpl} from './QuickOpen.js';
|
|
|
|
export class HelpQuickOpen extends Provider {
|
|
constructor() {
|
|
super();
|
|
/** @type {!Array<{prefix: string, title: string}>} */
|
|
this._providers = [];
|
|
self.runtime.extensions(Provider).forEach(this._addProvider.bind(this));
|
|
}
|
|
|
|
/**
|
|
* @param {!Root.Runtime.Extension} extension
|
|
*/
|
|
_addProvider(extension) {
|
|
if (extension.title()) {
|
|
this._providers.push({prefix: extension.descriptor()['prefix'], title: extension.title()});
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @override
|
|
* @return {number}
|
|
*/
|
|
itemCount() {
|
|
return this._providers.length;
|
|
}
|
|
|
|
/**
|
|
* @override
|
|
* @param {number} itemIndex
|
|
* @return {string}
|
|
*/
|
|
itemKeyAt(itemIndex) {
|
|
return this._providers[itemIndex].prefix;
|
|
}
|
|
|
|
/**
|
|
* @override
|
|
* @param {number} itemIndex
|
|
* @param {string} query
|
|
* @return {number}
|
|
*/
|
|
itemScoreAt(itemIndex, query) {
|
|
return -this._providers[itemIndex].prefix.length;
|
|
}
|
|
|
|
/**
|
|
* @override
|
|
* @param {number} itemIndex
|
|
* @param {string} query
|
|
* @param {!Element} titleElement
|
|
* @param {!Element} subtitleElement
|
|
*/
|
|
renderItem(itemIndex, query, titleElement, subtitleElement) {
|
|
const provider = this._providers[itemIndex];
|
|
const prefixElement = titleElement.createChild('span', 'monospace');
|
|
prefixElement.textContent = (provider.prefix || '…') + ' ';
|
|
titleElement.createTextChild(provider.title);
|
|
}
|
|
|
|
/**
|
|
* @override
|
|
* @param {?number} itemIndex
|
|
* @param {string} promptValue
|
|
*/
|
|
selectItem(itemIndex, promptValue) {
|
|
if (itemIndex !== null) {
|
|
QuickOpenImpl.show(this._providers[itemIndex].prefix);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @override
|
|
* @return {boolean}
|
|
*/
|
|
renderAsTwoRows() {
|
|
return false;
|
|
}
|
|
}
|