Exclude our code from react ref lint-deps rules

This commit is contained in:
Jamie
2026-02-11 16:35:11 -08:00
committed by GitHub
parent 12e9013572
commit c2a51791d2
6 changed files with 25 additions and 1593 deletions

View File

@@ -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

View File

@@ -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;
}

View File

@@ -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"]
},
{

View File

@@ -52,6 +52,7 @@ export type RuleType = {
expression?: string;
reason: string;
regex: RegExp;
excludeOurCode?: boolean;
excludedModules?: Array<string>;
};

View File

@@ -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');
}