mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-02-14 23:18:54 +00:00
Exclude our code from react ref lint-deps rules
This commit is contained in:
@@ -47,7 +47,7 @@ export function createEventHandler({
|
||||
// clipboardData at all, all other data is reset.
|
||||
event.clipboardData?.setData('text/plain', plaintext);
|
||||
|
||||
event.clipboardData?.setData('text/signal', container.innerHTML);
|
||||
event.clipboardData?.setData('text/signal', container.getHTML());
|
||||
|
||||
if (deleteSelection) {
|
||||
selection.deleteFromDocument();
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -25,6 +25,17 @@ const basePath = join(__dirname, '../../..');
|
||||
|
||||
const searchPattern = normalizePath(join(basePath, '**/*.{js,ts,tsx}'));
|
||||
|
||||
const THIRD_PARTY_PATHS = ['node_modules/', 'js/', 'components/'];
|
||||
|
||||
function pathStartsWithOneOf(
|
||||
filePath: string,
|
||||
pathPrefixes: ReadonlyArray<string>
|
||||
): boolean {
|
||||
return pathPrefixes.some(pathPrefix => {
|
||||
return filePath.startsWith(pathPrefix);
|
||||
});
|
||||
}
|
||||
|
||||
const excludedFilesRegexp = RegExp(
|
||||
[
|
||||
'^release/',
|
||||
@@ -399,8 +410,15 @@ async function main(argv: ReadonlyArray<string>): Promise<void> {
|
||||
const lines = (await fs.promises.readFile(file, ENCODING)).split(/\r?\n/);
|
||||
|
||||
rules.forEach((rule: RuleType) => {
|
||||
if (
|
||||
rule.excludeOurCode &&
|
||||
!pathStartsWithOneOf(relativePath, THIRD_PARTY_PATHS)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
const excludedModules = rule.excludedModules || [];
|
||||
if (excludedModules.some(module => relativePath.startsWith(module))) {
|
||||
if (pathStartsWithOneOf(relativePath, excludedModules)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
"name": "React-ref",
|
||||
"expression": "\\bref(\\s)*=\\b",
|
||||
"reason": "Potential XSS",
|
||||
"excludeOurCode": true,
|
||||
"excludedModules": [
|
||||
"node_modules/react-dom",
|
||||
"node_modules/tslint-microsoft-contrib",
|
||||
@@ -33,6 +34,7 @@
|
||||
"name": "React-createRef",
|
||||
"expression": "\\bcreateRef\\(",
|
||||
"reason": "Potential XSS",
|
||||
"excludeOurCode": true,
|
||||
"excludedModules": [
|
||||
"node_modules/react/",
|
||||
"node_modules/react-dom",
|
||||
@@ -44,6 +46,7 @@
|
||||
"name": "React-useRef",
|
||||
"expression": "\\buseRef(\\(|<)",
|
||||
"reason": "Potential XSS",
|
||||
"excludeOurCode": true,
|
||||
"excludedModules": ["node_modules/react/", "node_modules/react-dom"]
|
||||
},
|
||||
{
|
||||
|
||||
@@ -52,6 +52,7 @@ export type RuleType = {
|
||||
expression?: string;
|
||||
reason: string;
|
||||
regex: RegExp;
|
||||
excludeOurCode?: boolean;
|
||||
excludedModules?: Array<string>;
|
||||
};
|
||||
|
||||
|
||||
@@ -4,5 +4,5 @@ import '../sandboxedInit.dom.js';
|
||||
|
||||
const message = document.getElementById('message');
|
||||
if (message) {
|
||||
message.innerHTML = window.SignalContext.i18n('icu:optimizingApplication');
|
||||
message.innerText = window.SignalContext.i18n('icu:optimizingApplication');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user