Skip to content

Commit aa36989

Browse files
authored
Enable no-jquery/no-parse-html-literal and fix violation (#31684)
Tested it, path segment creation works just like before.
1 parent a40192d commit aa36989

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

.eslintrc.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ rules:
568568
no-jquery/no-param: [2]
569569
no-jquery/no-parent: [0]
570570
no-jquery/no-parents: [2]
571-
no-jquery/no-parse-html-literal: [0]
571+
no-jquery/no-parse-html-literal: [2]
572572
no-jquery/no-parse-html: [2]
573573
no-jquery/no-parse-json: [2]
574574
no-jquery/no-parse-xml: [2]

web_src/js/features/repo-editor.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import $ from 'jquery';
22
import {htmlEscape} from 'escape-goat';
33
import {createCodeEditor} from './codeeditor.ts';
4-
import {hideElem, queryElems, showElem} from '../utils/dom.ts';
4+
import {hideElem, queryElems, showElem, createElementFromHTML} from '../utils/dom.ts';
55
import {initMarkupContent} from '../markup/content.ts';
66
import {attachRefIssueContextPopup} from './contextpopup.ts';
77
import {POST} from '../modules/fetch.ts';
@@ -61,7 +61,7 @@ export function initRepoEditor() {
6161
});
6262
}
6363

64-
const filenameInput = document.querySelector('#file-name');
64+
const filenameInput = document.querySelector<HTMLInputElement>('#file-name');
6565
function joinTreePath() {
6666
const parts = [];
6767
for (const el of document.querySelectorAll('.breadcrumb span.section')) {
@@ -80,8 +80,12 @@ export function initRepoEditor() {
8080
const value = parts[i];
8181
if (i < parts.length - 1) {
8282
if (value.length) {
83-
$(`<span class="section"><a href="#">${htmlEscape(value)}</a></span>`).insertBefore($(filenameInput));
84-
$('<div class="breadcrumb-divider">/</div>').insertBefore($(filenameInput));
83+
filenameInput.before(createElementFromHTML(
84+
`<span class="section"><a href="#">${htmlEscape(value)}</a></span>`,
85+
));
86+
filenameInput.before(createElementFromHTML(
87+
`<div class="breadcrumb-divider">/</div>`,
88+
));
8589
}
8690
} else {
8791
filenameInput.value = value;

0 commit comments

Comments
 (0)