mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-02-15 07:28:59 +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.
|
// clipboardData at all, all other data is reset.
|
||||||
event.clipboardData?.setData('text/plain', plaintext);
|
event.clipboardData?.setData('text/plain', plaintext);
|
||||||
|
|
||||||
event.clipboardData?.setData('text/signal', container.innerHTML);
|
event.clipboardData?.setData('text/signal', container.getHTML());
|
||||||
|
|
||||||
if (deleteSelection) {
|
if (deleteSelection) {
|
||||||
selection.deleteFromDocument();
|
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 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(
|
const excludedFilesRegexp = RegExp(
|
||||||
[
|
[
|
||||||
'^release/',
|
'^release/',
|
||||||
@@ -399,8 +410,15 @@ async function main(argv: ReadonlyArray<string>): Promise<void> {
|
|||||||
const lines = (await fs.promises.readFile(file, ENCODING)).split(/\r?\n/);
|
const lines = (await fs.promises.readFile(file, ENCODING)).split(/\r?\n/);
|
||||||
|
|
||||||
rules.forEach((rule: RuleType) => {
|
rules.forEach((rule: RuleType) => {
|
||||||
|
if (
|
||||||
|
rule.excludeOurCode &&
|
||||||
|
!pathStartsWithOneOf(relativePath, THIRD_PARTY_PATHS)
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const excludedModules = rule.excludedModules || [];
|
const excludedModules = rule.excludedModules || [];
|
||||||
if (excludedModules.some(module => relativePath.startsWith(module))) {
|
if (pathStartsWithOneOf(relativePath, excludedModules)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
"name": "React-ref",
|
"name": "React-ref",
|
||||||
"expression": "\\bref(\\s)*=\\b",
|
"expression": "\\bref(\\s)*=\\b",
|
||||||
"reason": "Potential XSS",
|
"reason": "Potential XSS",
|
||||||
|
"excludeOurCode": true,
|
||||||
"excludedModules": [
|
"excludedModules": [
|
||||||
"node_modules/react-dom",
|
"node_modules/react-dom",
|
||||||
"node_modules/tslint-microsoft-contrib",
|
"node_modules/tslint-microsoft-contrib",
|
||||||
@@ -33,6 +34,7 @@
|
|||||||
"name": "React-createRef",
|
"name": "React-createRef",
|
||||||
"expression": "\\bcreateRef\\(",
|
"expression": "\\bcreateRef\\(",
|
||||||
"reason": "Potential XSS",
|
"reason": "Potential XSS",
|
||||||
|
"excludeOurCode": true,
|
||||||
"excludedModules": [
|
"excludedModules": [
|
||||||
"node_modules/react/",
|
"node_modules/react/",
|
||||||
"node_modules/react-dom",
|
"node_modules/react-dom",
|
||||||
@@ -44,6 +46,7 @@
|
|||||||
"name": "React-useRef",
|
"name": "React-useRef",
|
||||||
"expression": "\\buseRef(\\(|<)",
|
"expression": "\\buseRef(\\(|<)",
|
||||||
"reason": "Potential XSS",
|
"reason": "Potential XSS",
|
||||||
|
"excludeOurCode": true,
|
||||||
"excludedModules": ["node_modules/react/", "node_modules/react-dom"]
|
"excludedModules": ["node_modules/react/", "node_modules/react-dom"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ export type RuleType = {
|
|||||||
expression?: string;
|
expression?: string;
|
||||||
reason: string;
|
reason: string;
|
||||||
regex: RegExp;
|
regex: RegExp;
|
||||||
|
excludeOurCode?: boolean;
|
||||||
excludedModules?: Array<string>;
|
excludedModules?: Array<string>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -4,5 +4,5 @@ import '../sandboxedInit.dom.js';
|
|||||||
|
|
||||||
const message = document.getElementById('message');
|
const message = document.getElementById('message');
|
||||||
if (message) {
|
if (message) {
|
||||||
message.innerHTML = window.SignalContext.i18n('icu:optimizingApplication');
|
message.innerText = window.SignalContext.i18n('icu:optimizingApplication');
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user